:root{
  --bg: #0b1020;
  --bg2:#0f1733;
  --card:#121a3a;
  --card2:#0f1633;
  --text:#e9ecff;
  --muted:#b7c0ff;
  --line: rgba(255,255,255,.12);
  --shadow: 0 10px 24px rgba(0,0,0,.35);
  --r: 16px;
  --pad: 14px;
  --max: 520px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: radial-gradient(1200px 600px at 50% 0%, rgba(130,160,255,.20), transparent 55%),
              linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 縦固定の“雰囲気”を作る（OS強制は不可なので、UIで横を避ける） */
.page{
  min-height: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

a{ color: inherit; text-decoration: none; }
button{ font: inherit; color: inherit; }

.topbar{
  position: sticky; top:0; z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(11,16,32,.55);
  border-bottom: 1px solid var(--line);
}
.topbar__inner{
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px 14px;
}
.brand{ display:flex; gap:10px; align-items:center; }
.brand__logo{
  width: 36px; height: 36px;
  border-radius: 12px;
  background: rgba(255,255,255,.10);
  display:flex; align-items:center; justify-content:center;
  box-shadow: var(--shadow);
}
.brand__title{ font-weight: 800; letter-spacing: .02em; }
.brand__sub{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.container{
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px;
  display:flex;
  flex-direction: column;
  gap: 12px;
}

.card{
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.hero{ padding: 14px; }
.hero__title{ margin: 0 0 6px; font-size: 18px; }
.hero__desc{ margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }

.chips{ display:flex; gap:8px; flex-wrap:wrap; }
.chip{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.10);
}

.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 480px){
  .grid{ grid-template-columns: 1fr 1fr; }
}

.gamecard{ padding: 14px; display:flex; flex-direction:column; gap:10px; }
.gamecard__top{ display:flex; justify-content:space-between; align-items:center; }
.gamecard__title{ font-weight: 800; }
.gamecard__desc{ font-size: 13px; color: var(--muted); line-height: 1.5; }
.gamecard__min{ font-size: 12px; color: var(--muted); }

.pill{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(120,170,255,.18);
  border: 1px solid rgba(120,170,255,.35);
}
.pill--muted{
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--muted);
}

.footer{ opacity: .9; }
.footer__inner{
  text-align:center;
  padding: 10px 0 24px;
  color: var(--muted);
  font-size: 12px;
}

/* ゲームページ共通 */
.game-wrap{ display:flex; flex-direction:column; gap: 12px; }
.game-header{ padding: 12px 14px; display:flex; gap:10px; align-items:center; justify-content:space-between; }
.game-header__left{ display:flex; flex-direction:column; gap:2px; }
.game-title{ font-weight: 900; }
.game-sub{ font-size: 12px; color: var(--muted); }
.game-actions{ display:flex; gap:8px; align-items:center; }
.btn{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active{ transform: translateY(1px); }

.game-stage{
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.notice{
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.kbd{
  display:inline-block;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.07);
  font-size: 12px;
  color: var(--text);
}

/* 2048風（Merge Grid） */
.board{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  padding: 10px;
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  touch-action: none; /* スワイプ制御 */
}

.cell{
  border-radius: 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: .02em;
  user-select: none;
}

.hud{
  display:flex;
  gap: 10px;
}
.hud .stat{
  flex:1;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
}
.stat__label{ font-size: 12px; color: var(--muted); }
.stat__value{ font-weight: 900; font-size: 18px; margin-top: 2px; }

.toast{
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: min(var(--max), calc(100vw - 28px));
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,14,28,.72);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display:none;
}
.toast--show{ display:block; }
.toast__title{ font-weight: 900; }
.toast__desc{ font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.5; }

/* ===== Block Fit Mini ===== */
.bf-board{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
}

.bf-cell{
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bf-cell.is-filled{
  background: rgba(255,255,255,.38);
  border-color: rgba(255,255,255,.22);
}
.bf-cell:active{ transform: translateY(1px); }

.bf-tray{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-items: stretch;
}

.bf-piece{
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  padding: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display:flex;
  flex-direction: column;
  gap: 8px;
  min-height: 96px;
}
.bf-piece.is-selected{
  border-color: rgba(120,170,255,.55);
  background: rgba(120,170,255,.12);
}
.bf-piece.is-used{
  opacity: .55;
  cursor: default;
  justify-content: center;
  text-align:center;
  color: var(--muted);
  font-size: 12px;
}
.bf-piece:disabled{ opacity: .65; cursor: default; }

.bf-preview{
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  aspect-ratio: 1 / 1;
}
.bf-dot{
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
}
.bf-dot.is-on{
  background: rgba(255,255,255,.38);
  border-color: rgba(255,255,255,.22);
}

.bf-piece__hint{
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

