/* ════════════════════════════════════════════════════════════════════
   Bhuchi Arcade — web hub.
   Glassmorphism pass: frosted surfaces over a slow-drifting aurora,
   with motion that reacts to input rather than decorating idly.

   PERFORMANCE NOTE (deliberate, please keep):
   `backdrop-filter` is genuinely expensive — the compositor re-samples
   everything behind the element every frame. It is therefore used only on
   the handful of LARGE, mostly-static surfaces (header, rail, hero,
   sheets, player bar). The 31 game cards use a layered translucent
   gradient that *reads* as glass but costs nothing, because 31
   simultaneously-blurring surfaces drops mid-range phones to single-digit
   frame rates. Same look, a fraction of the cost.

   Breakpoints — mobile-first:
     base      phone      : 2-col grid, pill category row
     >=480px   big phone  : slightly roomier
     >=700px   tablet     : 3-col, search + sort side by side
     >=1080px  desktop    : glass rail + 4-col + side panel by the game
     >=1500px  wide       : 5-col
     >=1900px  ultrawide  : 6-col, capped content width
   Plus landscape-phone and reduced-motion variants.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #08060F;
  --text: #F5F3FF;
  --muted: #9A95BE;
  --accent: #8B5CFF;
  --success: #00E6A0;
  --danger: #FF2E6A;

  /* Glass tokens — one place to retune the whole material */
  --glass-bg: rgba(255, 255, 255, 0.055);
  --glass-bg-strong: rgba(23, 20, 46, 0.72);
  --glass-brd: rgba(255, 255, 255, 0.11);
  --glass-brd-lit: rgba(255, 255, 255, 0.20);
  --glass-blur: blur(22px) saturate(150%);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.42);

  --radius: 20px;
  --radius-sm: 14px;
  --tap: 48px;
  --ease: cubic-bezier(.22, 1, .36, 1);       /* soft overshoot-free ease-out */
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
body { position: relative; overflow-x: hidden; }

/* ─────────── Animated aurora backdrop ───────────
   Three big blurred blobs on GPU-only transforms. Fixed + -1 z-index so
   nothing above it repaints when they move. */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .55;
  pointer-events: none;
  will-change: transform;
}
body::before {
  width: 60vmax; height: 60vmax;
  top: -22vmax; left: -18vmax;
  background: radial-gradient(circle, #6C3BFF 0%, rgba(108,59,255,0) 70%);
  animation: drift-a 26s ease-in-out infinite alternate;
}
body::after {
  width: 52vmax; height: 52vmax;
  bottom: -20vmax; right: -16vmax;
  background: radial-gradient(circle, #FF3D9A 0%, rgba(255,61,154,0) 70%);
  animation: drift-b 32s ease-in-out infinite alternate;
}
/* A third, deeper glow anchored behind the content column */
.screen::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: auto 0 -30vmax 0;
  height: 60vmax;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0,230,160,.13) 0%, rgba(0,230,160,0) 70%);
  pointer-events: none;
  animation: pulse-glow 14s ease-in-out infinite;
}
@keyframes drift-a {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(14vmax, 10vmax, 0) scale(1.18); }
}
@keyframes drift-b {
  from { transform: translate3d(0,0,0) scale(1.1); }
  to   { transform: translate3d(-12vmax, -8vmax, 0) scale(1); }
}
@keyframes pulse-glow {
  0%, 100% { opacity: .5; }
  50%      { opacity: 1; }
}

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
[hidden] { display: none !important; }
.screen { min-height: 100%; display: flex; flex-direction: column; }

/* ─────────── Reusable glass surface ─────────── */
.hub-header, .rail, .hero, .sheet, .player-bar, .side-panel, .search-wrap, .coach-card {
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
/* Without backdrop-filter support, fall back to a solid-ish panel so text
   never sits on a transparent wash it can't be read against. */
@supports not (backdrop-filter: blur(2px)) {
  .hub-header, .rail, .hero, .sheet, .player-bar, .side-panel, .search-wrap, .coach-card {
    background-color: rgba(16, 13, 34, .93) !important;
  }
}

/* ─────────── Header ─────────── */
.hub-header {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(12,9,24,.80), rgba(12,9,24,.55));
  border-bottom: 1px solid var(--glass-brd);
  padding-top: env(safe-area-inset-top);
}
.hub-header-inner {
  max-width: 1600px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px clamp(14px, 4vw, 28px);
}
.wordmark {
  margin: 0; font-weight: 900; letter-spacing: -.03em;
  font-size: clamp(1.15rem, 1rem + 1.2vw, 1.6rem);
  animation: fade-down .5s var(--ease) both;
}
.wordmark span {
  background: linear-gradient(90deg, #B98CFF, #FF4FA3, #B98CFF);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sheen 6s linear infinite;
}
@keyframes sheen { to { background-position: -200% 0; } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-8px); } }

.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg);
  font-size: 1.05rem; line-height: 1;
  transition: background .2s var(--ease), transform .2s var(--ease-spring), border-color .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.13); border-color: var(--glass-brd-lit); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.9); }

/* ─────────── Layout ─────────── */
.hub-body {
  flex: 1; width: 100%; max-width: 1600px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr;
  padding: 0 0 calc(32px + env(safe-area-inset-bottom));
}
.hub-main { padding: clamp(14px, 3vw, 26px); min-width: 0; }
.rail { display: none; }

/* ─────────── Hero ─────────── */
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
  padding: clamp(16px, 3vw, 22px);
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(185,140,255,.16), rgba(255,79,163,.07));
  border: 1px solid var(--glass-brd-lit);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255,255,255,.14);
  animation: rise-in .55s var(--ease) both;
}
/* slow light sweep across the glass */
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.13) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sweep 7s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sweep { 0%, 62% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }

.hero-avatar {
  width: clamp(48px, 12vw, 62px); aspect-ratio: 1; flex: none;
  display: grid; place-items: center; font-size: clamp(1.4rem, 5vw, 1.9rem);
  border-radius: 999px;
  background: linear-gradient(145deg, #B98CFF, #5A1FE0);
  box-shadow: 0 0 24px rgba(139,92,255,.6), inset 0 1px 0 rgba(255,255,255,.4);
  animation: bob 4.5s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-5px); } }
.hero-copy { min-width: 0; }
.hero-name { margin: 0; font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hero-line { margin: 4px 0 0; font-weight: 650; font-size: clamp(.95rem, .85rem + .5vw, 1.15rem); }
.hero-meta { margin: 6px 0 0; font-size: .74rem; color: var(--muted); }

/* ─────────── Controls ─────────── */
.controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search-wrap {
  display: flex; align-items: center; gap: 9px;
  min-height: var(--tap); padding: 0 14px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.search-wrap:focus-within {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  background: rgba(255,255,255,.08);
}
.search-icon { font-size: .9rem; opacity: .75; }
#search { flex: 1; min-width: 0; background: none; border: 0; color: var(--text); font-size: 1rem; padding: 12px 0; }
#search::placeholder { color: var(--muted); }
#search:focus { outline: none; }
#search::-webkit-search-cancel-button { display: none; }
.search-clear { border: 0; background: none; color: var(--muted); min-width: 34px; min-height: 34px; border-radius: 999px; transition: color .2s, transform .2s; }
.search-clear:hover { color: var(--text); transform: rotate(90deg); }

.sorts { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  /* Finger-sized by default; only shrinks for a mouse (see below). Relying
     solely on `pointer: coarse` would leave touch laptops and any device
     that reports a fine pointer with a 36px target. */
  min-height: 44px; padding: 0 16px;
  border-radius: 999px; font-size: .78rem;
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg); color: var(--muted);
  transition: all .22s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--glass-brd-lit); }
.chip.is-active {
  color: #fff; font-weight: 700;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #FF4FA3));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 45%, transparent);
}

.pill-cats { display: flex; gap: 9px; overflow-x: auto; padding: 2px 0 6px; margin-bottom: 16px; scrollbar-width: none; }
.pill-cats::-webkit-scrollbar { display: none; }
.cat-pill {
  flex: none; display: flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px;
  border-radius: 999px; white-space: nowrap; font-size: .85rem;
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg); color: var(--muted);
  transition: all .25s var(--ease);
}
.cat-pill:hover { transform: translateY(-2px); border-color: var(--glass-brd-lit); }
.cat-pill:active { transform: scale(.96); }
.cat-pill .dot {
  width: 22px; aspect-ratio: 1; border-radius: 999px;
  display: grid; place-items: center; font-size: .72rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.cat-pill[aria-selected="true"] { color: var(--text); font-weight: 700; }

/* ─────────── Sections ─────────── */
.section-label { margin: 0; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.continue { margin-bottom: 20px; animation: rise-in .5s .05s var(--ease) both; }
.continue-row { display: flex; gap: 11px; overflow-x: auto; padding: 11px 2px 6px; scrollbar-width: none; }
.continue-row::-webkit-scrollbar { display: none; }
.cont-card {
  flex: none; display: flex; align-items: center; gap: 11px;
  min-height: var(--tap); padding: 11px 16px;
  border-radius: var(--radius-sm); text-align: left;
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
}
.cont-card:hover { transform: translateY(-3px); border-color: var(--glass-brd-lit); box-shadow: 0 10px 26px rgba(0,0,0,.4); }
.cont-card:active { transform: scale(.97); }
.cont-emoji { font-size: 1.35rem; }
.cont-name { font-size: .84rem; font-weight: 700; }
.cont-best { font-size: .7rem; color: var(--muted); }

.grid-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.count { font-size: .72rem; color: var(--muted); }

/* ─────────── Game grid ─────────── */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: clamp(10px, 2vw, 16px); }

.card-game {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 7px;
  padding: clamp(13px, 2.4vw, 17px);
  min-height: clamp(132px, 26vw, 168px);
  text-align: left;
  border-radius: var(--radius);
  /* Fake-glass: layered translucency instead of backdrop-filter (see note) */
  background:
    linear-gradient(160deg, rgba(255,255,255,.085) 0%, rgba(255,255,255,.02) 42%, rgba(255,255,255,.045) 100%),
    rgba(18, 15, 38, .55);
  border: 1px solid var(--glass-brd);
  box-shadow: 0 4px 18px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.10);
  transition: transform .28s var(--ease), box-shadow .28s var(--ease), border-color .28s;
  animation: card-in .42s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }

/* moving highlight on hover */
.card-game::before {
  content: ""; position: absolute; inset: -1px; z-index: -1;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.16) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform .7s var(--ease);
}
.card-game:hover::before { transform: translateX(100%); }
.card-game:hover { transform: translateY(-5px); border-color: var(--glass-brd-lit); box-shadow: 0 16px 38px rgba(0,0,0,.5); }
.card-game:active { transform: translateY(-1px) scale(.985); }

.card-emoji { font-size: clamp(1.5rem, 5vw, 1.9rem); transition: transform .3s var(--ease-spring); }
.card-game:hover .card-emoji { transform: scale(1.16) rotate(-6deg); }
.card-title { font-size: clamp(.85rem, .78rem + .3vw, .96rem); font-weight: 700; }
.card-desc { font-size: clamp(.7rem, .66rem + .2vw, .78rem); color: var(--muted); line-height: 1.4; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 4px; }
.badge {
  font-size: .64rem; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: rgba(255,255,255,.09); color: var(--muted);
  border: 1px solid rgba(255,255,255,.07);
}
.badge.best { color: #0B0A14; border: 0; box-shadow: 0 2px 10px rgba(0,0,0,.35); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); animation: rise-in .4s var(--ease) both; }
.empty-icon { font-size: 2.2rem; animation: bob 3s ease-in-out infinite; }
.empty-title { margin: 12px 0 4px; font-weight: 700; color: var(--text); }
.empty-sub { margin: 0; font-size: .84rem; }

/* ─────────── Player ─────────── */
.player-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px clamp(12px, 3vw, 20px);
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--glass-brd);
  background: linear-gradient(180deg, rgba(12,9,24,.82), rgba(12,9,24,.55));
  animation: fade-down .4s var(--ease) both;
}
.player-title { display: flex; align-items: center; gap: 9px; font-weight: 700; min-width: 0; }
.player-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-score { margin-left: auto; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.stage-wrap { flex: 1; display: flex; gap: clamp(12px, 2.5vw, 24px); justify-content: center; align-items: stretch; padding: clamp(10px, 2.5vw, 22px); min-height: 0; }
.stage {
  position: relative; flex: 1;
  max-width: min(100%, calc((100dvh - 150px) * 4 / 7));
  aspect-ratio: 4 / 7; margin: 0 auto;
  border-radius: 22px; overflow: hidden;
  background: #0F1120;
  border: 1px solid var(--glass-brd-lit);
  /* glow frame — the game itself stays perfectly crisp, never blurred */
  box-shadow: 0 24px 60px rgba(0,0,0,.6), 0 0 60px -12px color-mix(in srgb, var(--accent) 55%, transparent);
  animation: stage-in .45s var(--ease) both;
}
@keyframes stage-in { from { opacity: 0; transform: scale(.97); } }
#frame { width: 100%; height: 100%; border: 0; display: block; }
.frame-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .85rem; background: #0F1120; }
.frame-loading::after { content: ""; margin-left: 8px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.side-panel { display: none; }

.dpad { display: none; padding: 0 14px calc(14px + env(safe-area-inset-bottom)); justify-content: center; }
.dpad-btn {
  width: 60px; height: 60px; border-radius: 18px;
  border: 1px solid var(--glass-brd); background: var(--glass-bg);
  font-size: 1rem; display: grid; place-items: center;
  transition: background .15s, transform .15s;
}
.dpad-btn:active { background: color-mix(in srgb, var(--accent) 40%, transparent); transform: scale(.92); }

/* ─────────── Overlays ─────────── */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: clamp(14px, 4vw, 24px);
  background: rgba(4, 2, 10, .68);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fade .22s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 430px;
  border-radius: 26px; padding: clamp(18px, 4vw, 24px);
  background: linear-gradient(150deg, rgba(255,255,255,.10), rgba(255,255,255,.03)), var(--glass-bg-strong);
  border: 1px solid var(--glass-brd-lit);
  box-shadow: 0 30px 70px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.18);
  animation: sheet-in .34s var(--ease-spring) both;
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(20px) scale(.95); } }
.sheet-tall { max-width: 540px; max-height: min(88dvh, 780px); display: flex; flex-direction: column; padding: 0; }
.sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--glass-brd); }
.sheet-bar h2 { margin: 0; font-size: 1.15rem; }
.sheet-scroll { overflow-y: auto; padding: 4px 20px 24px; -webkit-overflow-scrolling: touch; }

.sheet-head { text-align: center; margin-bottom: 18px; }
.sheet-icon { font-size: 2.1rem; animation: pop .45s var(--ease-spring) both; }
@keyframes pop { from { opacity: 0; transform: scale(.5); } }
.sheet-head h2 { margin: 8px 0 2px; font-size: 1.32rem; }
.sheet-sub { margin: 0; font-size: .8rem; color: var(--muted); }
.sheet-best { margin: 9px 0 0; font-size: .72rem; color: var(--muted); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }

.btn {
  position: relative; overflow: hidden;
  min-height: 52px; padding: 0 20px; width: 100%;
  border-radius: 16px; font-size: .95rem; font-weight: 650;
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg); color: var(--text);
  transition: transform .18s var(--ease-spring), filter .2s, box-shadow .25s, border-color .2s;
}
.btn:hover { filter: brightness(1.2); border-color: var(--glass-brd-lit); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #FF4FA3));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 26px color-mix(in srgb, var(--accent) 50%, transparent);
}
.btn.primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.28) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform .6s var(--ease);
}
.btn.primary:hover::after { transform: translateX(100%); }
.btn.danger { background: rgba(255,46,106,.15); border-color: rgba(255,46,106,.5); color: #FF88AC; }

.toggles { border-radius: var(--radius-sm); overflow: hidden; background: rgba(255,255,255,.045); border: 1px solid var(--glass-brd); margin-bottom: 16px; }
.toggle-row { width: 100%; min-height: 56px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; background: none; text-align: left; transition: background .2s; }
.toggle-row:hover { background: rgba(255,255,255,.04); }
.toggles .toggle-row + .toggle-row { border-top: 1px solid var(--glass-brd); }
.toggle-row span strong { display: block; font-size: .92rem; font-weight: 650; }
.toggle-row span small { display: block; font-size: .74rem; color: var(--muted); margin-top: 2px; }
.switch { flex: none; width: 48px; height: 28px; border-radius: 999px; background: #241C4A; position: relative; transition: background .25s var(--ease); box-shadow: inset 0 1px 3px rgba(0,0,0,.5); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 999px; background: #F5F3FF; transition: transform .28s var(--ease-spring); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
[aria-checked="true"] .switch { background: linear-gradient(135deg, var(--accent), #FF4FA3); }
[aria-checked="true"] .switch::after { transform: translateX(20px); }

.howto { font-size: .8rem; color: var(--muted); background: rgba(255,255,255,.045); border: 1px solid var(--glass-brd); border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 16px; }
.howto:empty { display: none; }
.howto b { display: block; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 5px; color: var(--text); }

.confirm-title { margin: 0 0 6px; text-align: center; font-weight: 650; }
.confirm-sub { margin: 0 0 20px; text-align: center; font-size: .8rem; color: var(--muted); }

.score-block { text-align: center; margin-bottom: 20px; }
.score-main { font-size: clamp(2.6rem, 12vw, 3.2rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #fff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: pop .5s var(--ease-spring) both; }
.score-best { margin-top: 8px; font-size: .78rem; color: var(--muted); }

.group-label { margin: 24px 0 8px; font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.card { background: rgba(255,255,255,.045); border: 1px solid var(--glass-brd); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 9px; }
.card-title { display: block; font-size: .92rem; margin-bottom: 6px; }
.card-body { margin: 0 0 6px; font-size: .78rem; color: var(--muted); line-height: 1.55; }
.toggle-row.card { padding: 14px 16px; }
.linkcard { padding: 0; }
.linkrow { width: 100%; min-height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border: 0; background: none; text-align: left; font-size: .9rem; transition: background .2s, padding-left .2s; }
.linkrow:hover { background: rgba(255,255,255,.05); padding-left: 20px; }
.linkrow + .linkrow { border-top: 1px solid var(--glass-brd); }
.linkrow span { color: var(--muted); }

.accents { display: flex; gap: 14px; flex-wrap: wrap; }
.accent-dot { width: 46px; aspect-ratio: 1; border-radius: 999px; border: 3px solid transparent; padding: 0; display: grid; place-items: center; background: none; transition: transform .25s var(--ease-spring), border-color .2s; }
.accent-dot:hover { transform: scale(1.12); }
.accent-dot i { display: block; width: 34px; height: 34px; border-radius: 999px; box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.accent-dot[aria-checked="true"] { border-color: #F5F3FF; transform: scale(1.08); }

.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 90;
  background: var(--glass-bg-strong); color: var(--text);
  border: 1px solid var(--glass-brd-lit);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  padding: 13px 20px; border-radius: 999px; font-size: .84rem;
  box-shadow: var(--glass-shadow); max-width: 90vw; text-align: center;
  animation: toast-in .4s var(--ease-spring) both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 24px); } }

/* ─────────── Tutorial ─────────── */
.tut-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tut-head span { font-size: 1.4rem; }
.tut-head h2 { margin: 0; font-size: 1.08rem; }
.sheet-foot { border-top: 1px solid var(--glass-brd); padding: 14px 20px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.foot-actions { display: flex; gap: 10px; }
.foot-actions .btn { flex: 1; }
.skip-row { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); cursor: pointer; min-height: 34px; }
.skip-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.tut-goal { font-size: .95rem; line-height: 1.6; margin: 16px 0 4px; }
.tut-section { margin-top: 22px; }
.tut-section h3 { margin: 0 0 8px; font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ctrl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 0; border-bottom: 1px solid var(--glass-brd); }
.ctrl-row:last-child { border-bottom: 0; }
.ctrl-chip { font-size: .74rem; padding: 6px 11px; border-radius: 9px; white-space: nowrap; background: rgba(255,255,255,.08); border: 1px solid var(--glass-brd); }
.ctrl-chip.kbd { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.ctrl-act { font-size: .84rem; color: var(--muted); flex: 1; min-width: 140px; }
.tut-list { margin: 0; padding-left: 18px; }
.tut-list li { font-size: .84rem; color: var(--muted); line-height: 1.65; margin-bottom: 5px; }
.tut-tip { margin-top: 20px; padding: 15px 17px; border-radius: var(--radius-sm); font-size: .84rem; line-height: 1.6;
  background: color-mix(in srgb, var(--accent) 14%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent); }
.tut-tip b { display: block; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 5px; color: var(--accent); }

/* ─────────── Coach marks ─────────── */
.coach { position: fixed; inset: 0; z-index: 80; animation: fade .25s var(--ease); }
.coach-hole {
  position: absolute; border-radius: 14px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(3,2,8,.82), 0 0 28px color-mix(in srgb, var(--accent) 75%, transparent);
  transition: all .34s var(--ease);
  pointer-events: none;
  animation: halo 2s ease-in-out infinite;
}
@keyframes halo {
  50% { box-shadow: 0 0 0 9999px rgba(3,2,8,.82), 0 0 44px color-mix(in srgb, var(--accent) 95%, transparent); }
}
.coach-card {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: min(380px, calc(100vw - 32px));
  background: linear-gradient(150deg, rgba(255,255,255,.10), rgba(255,255,255,.03)), var(--glass-bg-strong);
  border: 1px solid var(--glass-brd-lit);
  border-radius: 20px; padding: 19px;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
  animation: sheet-in .3s var(--ease-spring) both;
}
.coach-step { margin: 0 0 6px; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.coach-card h3 { margin: 0 0 6px; font-size: 1rem; }
.coach-card p:not(.coach-step) { margin: 0; font-size: .86rem; color: var(--muted); line-height: 1.55; }
.coach-actions { display: flex; gap: 10px; margin-top: 16px; }
.coach-actions .btn { flex: 1; min-height: 46px; }

/* ─────────── Phone cost reduction ───────────
   Phones are where a GPU actually struggles, and it's also where the effect
   is least visible (small surfaces, less parallax behind them). So on narrow
   screens: soften the aurora, drop one blob entirely, and take
   backdrop-filter off the small always-on-screen surfaces — the layered
   translucency underneath already reads as glass. Header and sheets keep
   it, because those genuinely overlap moving content. */
@media (max-width: 700px) {
  body::before { filter: blur(64px); width: 70vmax; height: 70vmax; }
  body::after  { display: none; }
  .screen::before { display: none; }
  .search-wrap, .hero {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background-color: rgba(20, 16, 42, .55);
  }
}

/* Touch devices get larger hit areas than a mouse needs. The sort chips
   read fine at 36px with a cursor, but that's under the ~44px minimum for
   a fingertip, so they grow only where it matters. */
@media (pointer: coarse) {
  .search-clear { min-width: 44px; min-height: 44px; }
  .accent-dot { width: 48px; }
}
/* Roomy desktop + a real mouse: chips can tighten up again. */
@media (min-width: 1080px) and (pointer: fine) {
  .chip { min-height: 36px; padding-inline: 14px; }
}

/* ═══════════ BIG PHONE ═══════════ */
@media (min-width: 480px) {
  .grid { gap: 14px; }
  .continue-row { gap: 12px; }
}

/* ═══════════ TABLET ═══════════ */
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .controls { flex-direction: row; align-items: center; justify-content: space-between; }
  .search-wrap { flex: 1; max-width: 440px; }
}

/* ═══════════ DESKTOP ═══════════ */
@media (min-width: 1080px) {
  .hub-body { grid-template-columns: 248px minmax(0,1fr); gap: 26px; padding-inline: clamp(20px, 3vw, 34px); }
  .hub-main { padding: 26px 0; }

  .rail {
    display: flex; flex-direction: column; gap: 10px;
    position: sticky; top: 96px; align-self: start;
    padding: 18px; border-radius: var(--radius);
    background: var(--glass-bg); border: 1px solid var(--glass-brd);
    box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255,255,255,.10);
    animation: rise-in .5s var(--ease) both;
  }
  .rail-cats { display: flex; flex-direction: column; gap: 7px; }
  .rail-cats .cat-pill { width: 100%; justify-content: flex-start; }
  .rail-cats .cat-pill:hover { transform: translateX(4px); }
  .rail-stat { background: rgba(255,255,255,.05); border: 1px solid var(--glass-brd); border-radius: var(--radius-sm); padding: 14px 16px; }
  .rail-stat-num { font-size: 1.6rem; font-weight: 900; background: linear-gradient(135deg,#fff,var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .rail-stat-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

  .pill-cats { display: none; }
  .grid { grid-template-columns: repeat(4, minmax(0,1fr)); }

  .stage-wrap { align-items: flex-start; }
  .stage { flex: 0 1 auto; max-width: min(470px, calc((100dvh - 165px) * 4 / 7)); }
  .side-panel {
    display: block; width: 280px; flex: none; align-self: flex-start;
    background: var(--glass-bg); border: 1px solid var(--glass-brd);
    border-radius: var(--radius); padding: 22px;
    box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255,255,255,.10);
    animation: rise-in .5s .08s var(--ease) both;
  }
  .side-title { margin: 0 0 14px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
  .keylist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
  .keylist li { display: flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
  .keylist span { margin-left: auto; color: var(--text); }
  kbd { font-family: inherit; font-size: .68rem; min-width: 25px; text-align: center; padding: 4px 7px; border-radius: 7px;
    background: rgba(255,255,255,.09); border: 1px solid var(--glass-brd); box-shadow: 0 2px 0 rgba(0,0,0,.4); }
  .side-note { font-size: .72rem; color: var(--muted); margin: 18px 0 0; line-height: 1.55; }
  .side-best { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--glass-brd); display: flex; align-items: baseline; justify-content: space-between; }
  .side-best-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
  .side-best-val { font-size: 1.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }
}

@media (min-width: 1500px) { .grid { grid-template-columns: repeat(5, minmax(0,1fr)); } }
@media (min-width: 1900px) { .grid { grid-template-columns: repeat(6, minmax(0,1fr)); } }

/* D-pad only where it earns its space: small touch screens */
@media (max-width: 1079px) and (pointer: coarse) {
  .dpad.is-on { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(2, 60px); gap: 9px; }
  .dpad-btn.up { grid-column: 2; grid-row: 1; }
  .dpad-btn.left { grid-column: 1; grid-row: 2; }
  .dpad-btn.down { grid-column: 2; grid-row: 2; }
  .dpad-btn.right { grid-column: 3; grid-row: 2; }
}

/* Landscape phones: the stage would be unusably short with full chrome */
@media (max-height: 560px) and (orientation: landscape) {
  .stage-wrap { padding: 8px; }
  .stage { max-width: calc((100dvh - 74px) * 4 / 7); }
  .player-bar { padding-block: 6px; }
  .hero { display: none; }             /* reclaim vertical space on the hub */
  .dpad { padding-bottom: 6px; }
}

/* Very small phones (≤340px): drop to a single column so cards stay legible */
@media (max-width: 340px) {
  .grid { grid-template-columns: 1fr; }
  .hero-avatar { display: none; }
}

/* Motion off — kill every animation and transition, keep all layout */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
