/* ================= Well Played ================= */
:root {
  --bg: #f5f0e8; --bg-2: #ede5d8;
  --surface: #fffcf7; --surface-2: #f8f2e9; --surface-3: #f1e9dd;
  --ink: #2a2733; --ink-2: #5b5665; --muted: #8b8593;
  --line: #e7ded1; --line-2: #d7ccbc;
  --accent: #6c5dd3; --accent-2: #8b7ee6; --accent-soft: #ece9fb; --on-accent: #fff;
  --correct: #6aa37a; --present: #dfae46; --absent: #9e978f; --on-tile: #fff;
  --key: #e8e0d3; --key-ink: #2a2733;
  --danger: #c8553d;
  --a-language: #5f9e6e; --a-focus: #d99a2b; --a-logic: #5a7fd4; --a-perception: #2f9d97;
  --a-memory: #df6f53; --a-association: #9d63c0; --a-calm: #5c9fd6; --a-spatial: #8c963a;
  --g0: #e6c25e; --g1: #95c28f; --g2: #93b6e3; --g3: #bb98da;
  --shadow-sm: 0 1px 2px rgb(42 39 51 / .06);
  --shadow: 0 1px 2px rgb(42 39 51 / .05), 0 10px 30px -12px rgb(42 39 51 / .18);
  --shadow-lg: 0 30px 80px -20px rgb(42 39 51 / .35);
  --radius: 20px; --radius-sm: 12px;
  --font: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Fraunces', ui-serif, Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15141a; --bg-2: #1b1a22;
    --surface: #1f1d26; --surface-2: #26242f; --surface-3: #2d2b37;
    --ink: #f1eef6; --ink-2: #c5c0cf; --muted: #8f899a;
    --line: #302d3a; --line-2: #3d3a48;
    --accent: #9a8cf2; --accent-2: #b2a7f7; --accent-soft: #2c2845; --on-accent: #17151f;
    --correct: #5f9b6d; --present: #c99a36; --absent: #4a4753; --on-tile: #fff;
    --key: #3a3746; --key-ink: #f1eef6;
    --a-language: #73b483; --a-focus: #e6ab45; --a-logic: #7b9be6; --a-perception: #47b8b1;
    --a-memory: #ee8a70; --a-association: #b688d6; --a-calm: #79b3e6; --a-spatial: #aab560;
    --g0: #c7a647; --g1: #6fa36a; --g2: #6f93c4; --g3: #9a78bd;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 30px -14px rgb(0 0 0 / .6);
    --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15141a; --bg-2: #1b1a22;
  --surface: #1f1d26; --surface-2: #26242f; --surface-3: #2d2b37;
  --ink: #f1eef6; --ink-2: #c5c0cf; --muted: #8f899a;
  --line: #302d3a; --line-2: #3d3a48;
  --accent: #9a8cf2; --accent-2: #b2a7f7; --accent-soft: #2c2845; --on-accent: #17151f;
  --correct: #5f9b6d; --present: #c99a36; --absent: #4a4753; --on-tile: #fff;
  --key: #3a3746; --key-ink: #f1eef6;
  --a-language: #73b483; --a-focus: #e6ab45; --a-logic: #7b9be6; --a-perception: #47b8b1;
  --a-memory: #ee8a70; --a-association: #b688d6; --a-calm: #79b3e6; --a-spatial: #aab560;
  --g0: #c7a647; --g1: #6fa36a; --g2: #6f93c4; --g3: #9a78bd;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 30px -14px rgb(0 0 0 / .6);
  --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / .7);
  color-scheme: dark;
}
:root[data-cb] { --correct: #e8833a; --present: #4fa3e0; }

/* Area accents */
.area-language { --area: var(--a-language); }
.area-focus { --area: var(--a-focus); }
.area-logic { --area: var(--a-logic); }
.area-perception { --area: var(--a-perception); }
.area-memory { --area: var(--a-memory); }
.area-association { --area: var(--a-association); }
.area-listening { --area: var(--a-calm); }
.area-spatial { --area: var(--a-spatial); }

/* ================= Base ================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
/* Fast tapping should never zoom or select text: taps are taps. Pinch-zoom still works. */
button, a, .key, .tile, .echo-pad, .groups-tile, .swap-tile, .code-key { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
svg { display: block; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.bloom { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bloom i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.bloom i:nth-child(1) { width: 46vmax; height: 46vmax; left: -14vmax; top: -16vmax; background: color-mix(in srgb, var(--a-language) 32%, transparent); }
.bloom i:nth-child(2) { width: 40vmax; height: 40vmax; right: -14vmax; top: 10vh; background: color-mix(in srgb, var(--a-association) 26%, transparent); }
.bloom i:nth-child(3) { width: 38vmax; height: 38vmax; left: 30vw; bottom: -22vmax; background: color-mix(in srgb, var(--a-focus) 24%, transparent); }
body.in-game .bloom { opacity: .55; }

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 0; border-radius: 999px; padding: .78rem 1.35rem; font-weight: 700; font-size: .98rem;
  cursor: pointer; transition: transform .15s var(--ease), background .2s, box-shadow .2s, opacity .2s;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: var(--bg); box-shadow: var(--shadow); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 88%, var(--accent)); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 45%, transparent); padding: .55rem 1rem; font-size: .88rem; }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--ink-2); transition: background .2s, color .2s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.pulse { animation: pulse 1.8s ease-in-out 3; color: var(--accent); }
.link-btn { border: 0; background: none; padding: .3rem .1rem; color: var(--muted); font-size: .85rem; font-weight: 600; cursor: pointer; }
.link-btn:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.link { color: var(--ink-2); font-size: .9rem; font-weight: 600; }
.link:hover { color: var(--ink); }
.pill-btn {
  display: inline-flex; align-items: center; gap: .4rem; border: 0; cursor: pointer;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); border-radius: 999px;
  padding: .45rem .9rem; font-weight: 600; font-size: .88rem; color: var(--ink-2);
}
.pill-btn svg { width: 16px; height: 16px; }
.pill-btn:hover { color: var(--ink); background: var(--surface-2); }

/* ================= Header ================= */
.top {
  max-width: 1120px; margin: 0 auto; padding: 18px 20px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 13px); gap: 3px; transform: rotate(-6deg); transition: transform .4s var(--ease); }
.brand:hover .brand-mark { transform: rotate(4deg); }
.brand-mark i { width: 13px; height: 13px; border-radius: 4px; background: var(--correct); }
.brand-mark i:nth-child(2) { background: var(--present); }
.brand-mark i:nth-child(3) { background: var(--a-association); }
.brand-mark i:nth-child(4) { background: var(--a-calm); }
.brand-name { font-family: var(--display); font-weight: 600; font-size: 1.45rem; letter-spacing: -.01em; }
.brand-name em { font-style: italic; color: var(--accent); }
.top-actions { display: flex; gap: 2px; }

/* ================= Hub ================= */
.hub { max-width: 1120px; margin: 0 auto; padding: 8px 20px 60px; }
.hero {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center;
  background: linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 80%, var(--accent-soft)) 100%);
  border: 1px solid var(--line); border-radius: 28px; padding: 34px 38px; margin: 14px 0 26px;
  box-shadow: var(--shadow); overflow: hidden; animation: rise .6s var(--ease) both;
}
.hero::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--present) 30%, transparent), transparent 70%); pointer-events: none;
}
.eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hero h1 { font-family: var(--display); font-weight: 600; font-size: clamp(2.1rem, 5vw, 3.2rem); letter-spacing: -.02em; margin: .3rem 0 .5rem; }
.hero h1 .dot { color: var(--correct); }
.lede { font-size: 1.08rem; color: var(--ink-2); max-width: 46ch; }
.theme-chip { display: inline-flex; align-items: center; gap: .45rem; margin-top: .9rem; padding: .35rem .8rem .35rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--ink-2); font-size: .9rem; }
.theme-chip svg { width: 16px; height: 16px; color: var(--accent); }
.hero-cta { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 20px; margin-top: 1.4rem; }
.hero-meta { color: var(--muted); font-size: .9rem; }
.hero-meta b { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.hero-side { display: flex; flex-direction: column; align-items: center; gap: 14px; position: relative; z-index: 1; }
.ring { position: relative; width: 132px; height: 132px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--surface-3); }
.ring-fg { stroke: var(--correct); stroke-linecap: round; transition: stroke-dashoffset 1.2s var(--ease); animation: ring-in 1.2s var(--ease) both; }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1; }
.ring-label b { font-family: var(--display); font-size: 2.3rem; font-weight: 600; }
.ring-label span { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.streak { display: flex; align-items: center; gap: .35rem; padding: .4rem .85rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .88rem; box-shadow: inset 0 0 0 1px var(--line); }
.streak svg { width: 17px; height: 17px; }
.streak b { color: var(--ink); font-size: 1rem; }
.streak.on svg { color: #e8743b; fill: color-mix(in srgb, #e8743b 30%, transparent); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
  animation: rise .55s var(--ease) both; animation-delay: calc(var(--i) * 45ms + 80ms); overflow: hidden;
}
.card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--area); opacity: .85;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--area) 40%, var(--line)); }
.card-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none;
  color: var(--area); background: color-mix(in srgb, var(--area) 14%, transparent);
}
.card-icon svg { width: 26px; height: 26px; }
.card-body { flex: 1; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card h3 { font-family: var(--display); font-weight: 600; font-size: 1.35rem; }
.card p { color: var(--ink-2); font-size: .93rem; }
.chip { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: .2rem .55rem; border-radius: 999px; color: var(--area); background: color-mix(in srgb, var(--area) 12%, transparent); white-space: nowrap; }
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.status { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; font-size: .88rem; padding: .38rem .85rem; border-radius: 999px; background: var(--ink); color: var(--bg); }
.status svg { width: 15px; height: 15px; }
.status.prog { background: color-mix(in srgb, var(--present) 22%, transparent); color: var(--ink); }
.status.done { background: color-mix(in srgb, var(--correct) 18%, transparent); color: color-mix(in srgb, var(--correct) 70%, var(--ink)); }
.status.done.soft { background: var(--surface-3); color: var(--ink-2); }
.card.is-done .card-icon { background: color-mix(in srgb, var(--area) 22%, transparent); }

.hub-lower { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 26px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.panel h2 { font-family: var(--display); font-weight: 600; font-size: 1.2rem; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; align-items: end; margin-bottom: 12px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar-track { width: 100%; max-width: 38px; height: 92px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.bar-track i { display: block; width: 100%; background: var(--area); border-radius: 10px; min-height: 0; transition: height .9s var(--ease); animation: grow .9s var(--ease) both; transform-origin: bottom; }
.bar-col b { font-size: .9rem; }
.bar-col span { font-size: .68rem; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.tip { display: flex; gap: 16px; align-items: flex-start; background: linear-gradient(160deg, var(--surface), color-mix(in srgb, var(--surface) 75%, var(--a-calm) 12%)); }
.tip-icon { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--present) 22%, transparent); color: color-mix(in srgb, var(--present) 70%, var(--ink)); }
.tip-icon svg { width: 22px; height: 22px; }
.tip h2 { margin-bottom: 6px; }
.tip p { color: var(--ink-2); }

/* ================= Game screen ================= */
.game-screen { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; }
.game-top {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
}
.game-title { text-align: center; min-width: 0; }
.game-title h1 { font-family: var(--display); font-weight: 600; font-size: 1.45rem; display: inline-flex; align-items: center; gap: .45rem; }
.mini-icon { width: 24px; height: 24px; color: var(--area); display: inline-block; }
.mini-icon svg { width: 100%; height: 100%; }
.game-sub { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.game-actions { display: flex; align-items: center; gap: 0; }
.mode-btn { border: 0; cursor: pointer; margin-left: 4px; padding: .4rem .8rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: color-mix(in srgb, var(--area) 14%, transparent); color: color-mix(in srgb, var(--area) 75%, var(--ink)); }
.mode-btn:hover { background: color-mix(in srgb, var(--area) 22%, transparent); }
.game-stage { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.play-area { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; padding: 8px 0 14px; }

/* ================= Tiles & board ================= */
.board { --gap: 6px; display: grid; gap: var(--gap); --tile: min(62px, calc((100vw - 60px) / var(--cols) - var(--gap)), calc((100dvh - 360px) / 6 - var(--gap))); }
.board-row { display: grid; grid-template-columns: repeat(var(--cols), var(--tile)); gap: var(--gap); }
.tile {
  width: var(--tile, 58px); height: var(--tile, 58px); display: grid; place-items: center;
  border-radius: 10px; border: 2px solid var(--line-2); background: var(--surface);
  font-weight: 800; font-size: calc(var(--tile, 58px) * .5); text-transform: uppercase; line-height: 1;
  user-select: none; transition: border-color .15s, background .15s;
}
.board-row.active .tile:not(.filled) { border-color: color-mix(in srgb, var(--line-2) 70%, var(--ink) 12%); }
.tile.filled { border-color: color-mix(in srgb, var(--ink) 45%, transparent); }
.tile[data-state] { border-color: transparent; color: var(--on-tile); }
.tile[data-state="correct"] { background: var(--correct); }
.tile[data-state="present"] { background: var(--present); }
.tile[data-state="absent"] { background: var(--absent); }
.tile.pop { animation: pop .12s ease-out; }
.tile.flip { animation: flip .5s ease-in-out; }
.tile.bounce { animation: bounce .6s var(--ease); }
.board-row.shake, .ladder-row.shake, .groups-grid.shake, .echo-grid.shake { animation: shake .42s ease; }

.boards { display: flex; gap: 14px; justify-content: center; }
.boards-2 .board { --gap: 4px; --tile: min(44px, calc((100vw - 64px) / 10 - 4px), calc((100dvh - 350px) / 7 - 4px)); }
.boards-2 .board.solved { opacity: .8; }
.board.solved .tile:not([data-state]) { border-style: dashed; opacity: .35; }
.boards-2 .board .tile { border-radius: 8px; }

/* ================= Keyboard ================= */
.keyboard { display: flex; flex-direction: column; gap: 7px; width: 100%; max-width: 520px; margin: 0 auto; user-select: none; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  flex: 1; max-width: 46px; height: 56px; border: 0; border-radius: 9px; cursor: pointer; padding: 0;
  background: var(--key); color: var(--key-ink); font-weight: 700; font-size: 1.05rem; text-transform: uppercase;
  display: grid; place-items: center; transition: background .25s, transform .08s, color .2s;
  box-shadow: 0 1.5px 0 color-mix(in srgb, var(--ink) 12%, transparent);
}
.key:active { transform: translateY(1px) scale(.96); }
.key.wide { flex: 1.55; max-width: 72px; font-size: .78rem; letter-spacing: .02em; }
.key svg { width: 22px; height: 22px; }
.key[data-state="correct"] { background: var(--correct); color: var(--on-tile); }
.key[data-state="present"] { background: var(--present); color: var(--on-tile); }
.key[data-state="absent"] { background: var(--absent); color: var(--on-tile); opacity: .75; }
.key.split { background: linear-gradient(90deg, var(--ka) 50%, var(--kb) 50%); }
.key.quad {
  background:
    linear-gradient(90deg, var(--ka) 50%, var(--kb) 50%) top / 100% 50% no-repeat,
    linear-gradient(90deg, var(--kc) 50%, var(--kd) 50%) bottom / 100% 50% no-repeat;
}
.key.quad.lit { color: var(--on-tile); text-shadow: 0 1px 2px rgb(0 0 0 / .35); }
.key.split.lit { color: var(--on-tile); text-shadow: 0 1px 2px rgb(0 0 0 / .25); }
.key.split.dead { opacity: .6; color: var(--on-tile); }
.kb-row:nth-child(2) { padding: 0 4.5%; }
.kb-sums .kb-row:nth-child(2) { padding: 0; }
.kb-sums .key:not(.wide) { max-width: 52px; font-size: 1.15rem; }

/* ================= Sums ================= */
.board.sums { --tile: min(54px, calc((100vw - 60px) / 8 - var(--gap)), calc((100dvh - 330px) / 6 - var(--gap))); }
.board.sums .tile { border-radius: 9px; }

/* ================= Ladder ================= */
.play-area.ladder { justify-content: flex-start; padding-top: 0; }
.ladder-info { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); padding: 4px 14px 10px; }
.ladder-info b { color: var(--ink); font-size: 1.05rem; }
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line-2); }
.ladder-scroll { flex: 1; width: 100%; overflow-y: auto; min-height: 0; scroll-behavior: smooth; mask-image: linear-gradient(transparent, #000 14px, #000 calc(100% - 14px), transparent); }
.ladder-chain { display: flex; flex-direction: column; align-items: center; padding: 14px 0 20px; --tile: min(54px, calc((100vw - 80px) / 4 - 8px)); }
.ladder-row { display: grid; grid-template-columns: repeat(4, var(--tile)); gap: 7px; animation: rise .3s var(--ease) both; }
.ladder-row .tile[data-state="plain"] { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.ladder-row .tile.changed { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.ladder-row.start .tile[data-state="plain"] { background: var(--surface-3); }
.ladder-row .tile[data-state="goal"] { background: color-mix(in srgb, var(--correct) 16%, var(--surface)); color: color-mix(in srgb, var(--correct) 75%, var(--ink)); border: 2px dashed color-mix(in srgb, var(--correct) 55%, transparent); }
.ladder-row.reached .tile { animation: bounce .6s var(--ease) both; }
.ladder-row.input .tile.ghost { color: color-mix(in srgb, var(--ink) 18%, transparent); border-style: dashed; }
.ladder-link { width: 2px; height: 14px; background: var(--line-2); margin: 3px 0; border-radius: 2px; }
.ladder-link.dashed { height: 22px; background: repeating-linear-gradient(var(--line-2) 0 4px, transparent 4px 8px); }
.ladder-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 2px 0 6px; }
.ladder-actions { display: flex; gap: 8px; justify-content: center; padding-bottom: 10px; }
.demo-ladder { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0; font-weight: 800; letter-spacing: .06em; }
.demo-ladder span { background: var(--surface-3); padding: .25rem .5rem; border-radius: 8px; }
.demo-ladder i { color: var(--muted); font-style: normal; }

/* ================= Hue ================= */
.play-area.hue { justify-content: flex-start; gap: 12px; width: 100%; max-width: 460px; margin: 0 auto; }
.hue-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.hue-swatch { position: relative; height: clamp(110px, 22dvh, 180px); border-radius: 22px; box-shadow: var(--shadow), inset 0 0 0 1px rgb(255 255 255 / .12); transition: background .15s; }
.hue-swatch span { position: absolute; left: 12px; bottom: 10px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: rgb(0 0 0 / .28); padding: .2rem .55rem; border-radius: 999px; backdrop-filter: blur(4px); }
.hue-name { font-family: var(--display); font-size: 1.2rem; font-weight: 600; color: var(--ink-2); }
.hue-history { width: 100%; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; flex: 1; }
.hue-row { display: grid; grid-template-columns: 38px 1fr 92px; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px 6px 6px; }
.hue-row.enter { animation: rise .35s var(--ease) both; }
.hue-chip { width: 38px; height: 38px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); }
.hue-fb, .demo-fb { display: flex; gap: 6px; }
.fb { display: inline-flex; align-items: center; gap: 4px; min-width: 52px; justify-content: center; padding: .3rem .5rem; border-radius: 9px; font-weight: 800; color: var(--on-tile); background: var(--absent); }
.fb small { font-size: .65rem; opacity: .85; font-weight: 700; }
.fb[data-state="correct"] { background: var(--correct); }
.fb[data-state="present"] { background: var(--present); }
.demo-fb { margin: 10px 0; }
.hue-pct { text-align: right; }
.hue-pct b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.hue-pct .bar { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 3px; }
.hue-pct .bar i { display: block; height: 100%; background: var(--ink-2); border-radius: 3px; }
.hue-controls { width: 100%; max-width: 460px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px 18px; box-shadow: var(--shadow); }
.hue-sliders { display: grid; gap: 12px; }
.hue-sliders.locked { opacity: .5; }
.hue-slider { display: grid; grid-template-columns: 86px 1fr; align-items: center; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.hue-slider input { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; border-radius: 999px; background: var(--track, var(--surface-3)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); cursor: pointer; margin: 0; }
.hue-slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 3px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / .3), inset 0 0 0 2px rgb(0 0 0 / .1); }
.hue-slider input::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / .3); }
.hue-submit-row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.hue-count { color: var(--muted); font-size: .88rem; font-weight: 600; }

/* ================= Echo ================= */
.play-area.echo { gap: 18px; }
.echo-top { display: flex; align-items: center; justify-content: space-between; width: min(92vw, 380px); }
.echo-level { font-size: .95rem; color: var(--muted); font-weight: 600; }
.echo-level b { font-family: var(--display); font-size: 1.6rem; color: var(--ink); margin-left: 4px; }
.echo-hearts { display: flex; gap: 4px; }
.heart svg { width: 22px; height: 22px; color: var(--a-memory); fill: var(--a-memory); transition: all .3s; }
.heart.lost svg { fill: transparent; color: var(--line-2); transform: scale(.85); }
.echo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(92vw, 380px, 52dvh); aspect-ratio: 1; }
.echo-pad {
  --c: var(--a-memory); border: 0; border-radius: 22px; cursor: pointer; touch-action: manipulation;
  background: color-mix(in srgb, var(--c) 22%, var(--surface)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 30%, transparent), var(--shadow-sm);
  transition: background .12s, transform .12s, box-shadow .12s;
}
.echo-pad:nth-child(1) { --c: #e57a6a; } .echo-pad:nth-child(2) { --c: #e9a24c; } .echo-pad:nth-child(3) { --c: #d9c34f; }
.echo-pad:nth-child(4) { --c: #79b86c; } .echo-pad:nth-child(5) { --c: #4fb3a6; } .echo-pad:nth-child(6) { --c: #5aa2db; }
.echo-pad:nth-child(7) { --c: #7d82e0; } .echo-pad:nth-child(8) { --c: #a874d4; } .echo-pad:nth-child(9) { --c: #d672a8; }
.echo-pad.lit { background: var(--c); transform: scale(1.04); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent), 0 10px 30px -6px var(--c); }
.echo-pad.wrong { background: var(--danger); }
.echo-grid.watching .echo-pad { cursor: default; }
.echo-grid.cleared .echo-pad { animation: pop .3s ease; }
.echo-grid.over .echo-pad { opacity: .55; cursor: default; }
.echo-status { min-height: 1.6em; font-weight: 700; color: var(--muted); font-size: 1.05rem; }
.echo-status.go { color: var(--ink); }
.echo-status.good { color: var(--correct); }
.echo-status.bad { color: var(--danger); }
.echo-start { min-height: 48px; }

/* ================= Groups ================= */
.play-area.groups { gap: 10px; width: 100%; max-width: 560px; margin: 0 auto; }
.groups-hint { color: var(--muted); font-size: .92rem; }
.groups-solved, .groups-grid { width: 100%; display: grid; gap: 8px; }
.groups-grid { grid-template-columns: repeat(4, 1fr); }
.groups-tile {
  aspect-ratio: 1.25; border: 0; border-radius: 12px; cursor: pointer; padding: 4px;
  background: var(--surface-3); color: var(--ink); font-weight: 800; font-size: clamp(.72rem, 3.3vw, .98rem); letter-spacing: .02em;
  transition: background .18s, transform .15s, color .18s; word-break: break-word; line-height: 1.1;
  box-shadow: inset 0 0 0 1px var(--line);
}
.groups-tile.sm { font-size: clamp(.62rem, 2.8vw, .86rem); }
.groups-tile.xs { font-size: clamp(.55rem, 2.4vw, .74rem); }
.groups-tile:hover { background: color-mix(in srgb, var(--surface-3) 80%, var(--ink) 8%); }
.groups-tile.sel { background: var(--ink-2); color: var(--bg); transform: scale(.97); }
.groups-tile.hop { animation: hop .45s var(--ease); }
.groups-bar { border-radius: 12px; padding: 12px 14px; text-align: center; color: #2a2733; min-height: 64px; display: flex; flex-direction: column; justify-content: center; }
.groups-bar.enter { animation: pop-in .45s var(--ease) both; }
.groups-bar b { display: block; font-size: .95rem; letter-spacing: .04em; text-transform: uppercase; }
.groups-bar span { font-size: .88rem; }
.lv0 { background: var(--g0); } .lv1 { background: var(--g1); } .lv2 { background: var(--g2); } .lv3 { background: var(--g3); }
.groups-mistakes { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.groups-dots { display: flex; gap: 6px; }
.groups-dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--ink-2); transition: all .3s; }
.groups-dots i.used { background: var(--line-2); transform: scale(.7); }
.groups-controls { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
.groups-controls .btn { padding: .65rem 1.1rem; }
.demo-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.demo-bars .groups-bar { min-height: 40px; padding: 8px 4px; }
.demo-bars b { font-size: .7rem; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: .42rem 1rem; border-radius: 999px; font-weight: 600; font-size: .88rem; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg.locked { opacity: .5; pointer-events: none; }

/* ================= Modal ================= */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgb(20 18 26 / 0); transition: background .22s; }
.modal.open { background: rgb(20 18 26 / .45); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: min(100%, 440px); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--surface); border-radius: 26px; padding: 28px 26px 24px; box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(.97); opacity: 0; transition: transform .28s var(--ease), opacity .22s;
}
.modal-card.wide { width: min(100%, 560px); }
.modal.open .modal-card { transform: none; opacity: 1; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal-title { font-family: var(--display); font-weight: 600; font-size: 1.5rem; margin: 0 36px 14px 0; }
.howto p { color: var(--ink-2); margin: 10px 0; }
.howto b { color: var(--ink); }
.demo-row { display: flex; gap: 5px; --tile: 40px; margin: 12px 0 4px; }
.demo-row .tile { font-size: 1.15rem; border-radius: 8px; }
.demo-row.sums { --tile: 36px; }
.demo-row.sums .tile { border-color: color-mix(in srgb, var(--ink) 45%, transparent); }
.chip-c { padding: .05rem .45rem; border-radius: 6px; color: #fff; font-weight: 700; }
.chip-c.correct { background: var(--correct); } .chip-c.present { background: var(--present); }

/* Result */
.result { text-align: center; display: flex; flex-direction: column; align-items: center; }
.result-badge { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: var(--area); background: color-mix(in srgb, var(--area) 15%, transparent); margin-bottom: 12px; animation: pop-in .5s var(--ease) both; }
.result-badge svg { width: 34px; height: 34px; }
.result-title { font-family: var(--display); font-weight: 600; font-size: 2rem; letter-spacing: -.01em; }
.result-sub { color: var(--ink-2); margin-top: 4px; }
.result-pill { margin-top: 12px; padding: .35rem .9rem; border-radius: 999px; font-weight: 800; background: var(--surface-3); }
.result-pill.won { background: color-mix(in srgb, var(--correct) 18%, transparent); color: color-mix(in srgb, var(--correct) 70%, var(--ink)); }
.result-note { margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); color: var(--ink-2); font-size: .92rem; text-align: left; border-left: 3px solid var(--area); }
.result-actions { display: flex; gap: 10px; margin-top: 20px; width: 100%; }
.result-actions .btn { flex: 1; }
.next-up { margin-top: 14px; width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); text-align: left; transition: background .2s, transform .2s; }
.next-up:hover { background: var(--surface-3); transform: translateY(-1px); }
.next-up .card-icon { width: 40px; height: 40px; border-radius: 12px; }
.next-up .card-icon svg { width: 22px; height: 22px; }
.next-up small { display: block; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.next-up b { font-size: 1.05rem; }
.next-up .arrow { margin-left: auto; font-size: 1.2rem; color: var(--muted); }
.result > .muted { margin-top: 14px; }
.result .muted b { font-variant-numeric: tabular-nums; color: var(--ink-2); }

.stat-block { width: 100%; margin-top: 18px; }
.stat-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat b { font-family: var(--display); font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.stat span { font-size: .72rem; color: var(--muted); }
.dist { margin-top: 14px; text-align: left; }
.dist h4 { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.dist-row { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; margin: 4px 0; font-size: .85rem; font-weight: 700; }
.dist-row > span { text-align: right; color: var(--ink-2); }
.dist-bar i { display: block; background: var(--absent); color: #fff; font-style: normal; text-align: right; padding: 1px 8px; border-radius: 6px; font-size: .78rem; min-width: 24px; animation: grow-x .7s var(--ease) both; transform-origin: left; }
.dist-row.hi .dist-bar i { background: var(--correct); }

/* Settings */
.settings { display: flex; flex-direction: column; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.setting b { display: block; }
.setting small { display: block; color: var(--muted); font-size: .82rem; }
.switch { -webkit-appearance: none; appearance: none; flex: none; width: 48px; height: 28px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .22s var(--ease); }
.switch:checked { background: var(--correct); }
.switch:checked::after { transform: translateX(20px); }

/* ================= Stats page ================= */
.stats-page { max-width: 1120px; margin: 0 auto; padding: 10px 20px 60px; }
.page-title { font-family: var(--display); font-weight: 600; font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 14px 0 20px; letter-spacing: -.02em; }
.section-title { font-family: var(--display); font-weight: 600; font-size: 1.4rem; margin: 30px 0 14px; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-sm); animation: rise .5s var(--ease) both; }
.stat-tile span { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.stat-tile span svg { width: 18px; height: 18px; }
.stat-tile b { font-family: var(--display); font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stat-tile small { color: var(--muted); font-size: .85rem; }
.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.cal-h { font-size: .7rem; color: var(--muted); text-align: center; font-weight: 700; }
.cal-d { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: .75rem; color: var(--muted); background: color-mix(in srgb, var(--correct) calc(var(--lv) * 100%), var(--surface-2)); }
.cal-d.on { color: #fff; font-weight: 700; }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--ink-2); }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 96px 1fr 28px; gap: 10px; align-items: center; font-size: .88rem; }
.hbar span { color: var(--ink-2); font-weight: 600; }
.hbar b { text-align: right; }
.hbar-track { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: var(--area); border-radius: 6px; animation: grow-x .9s var(--ease) both; transform-origin: left; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.stat-card-head { display: flex; align-items: center; gap: 10px; }
.stat-card-head .card-icon { width: 38px; height: 38px; border-radius: 11px; }
.stat-card-head .card-icon svg { width: 20px; height: 20px; }
.stat-card-head h3 { font-family: var(--display); font-weight: 600; font-size: 1.2rem; flex: 1; }
.stat-card .stat-block { margin-top: 14px; }

/* ================= Toasts & confetti ================= */
#toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); font-weight: 700; font-size: .92rem; padding: .65rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow-lg); animation: toast-in .25s var(--ease); white-space: nowrap; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .3s; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 70; }

/* ================= Animations ================= */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-16px); } 55% { transform: translateY(2px); } 75% { transform: translateY(-5px); } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
@keyframes hop { 40% { transform: translateY(-8px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.96); } }
@keyframes pulse { 50% { transform: scale(1.15); } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes ring-in { from { stroke-dashoffset: 290; } }

:root[data-rm] *, :root[data-rm] *::before, :root[data-rm] *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .05s !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .05s !important; } }

/* ================= Responsive ================= */
@media (max-width: 820px) {
  .hub-lower, .stats-row { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .top, .hub, .stats-page { padding-left: 16px; padding-right: 16px; }
  .hero { grid-template-columns: 1fr; padding: 24px 22px; gap: 18px; border-radius: 24px; }
  .hero-side { flex-direction: row; justify-content: flex-start; order: -1; gap: 16px; }
  .ring { width: 92px; height: 92px; }
  .ring-label b { font-size: 1.7rem; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card { padding: 16px; gap: 10px; }
  .card p { display: none; }
  .card .chip { display: none; }
  .card h3 { font-size: 1.2rem; }
  .card-icon { width: 42px; height: 42px; }
  .card-foot { flex-direction: column; align-items: flex-start; gap: 6px; }
  .game-stage { padding: 0 6px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .kb-row { gap: 5px; }
  .key { height: 54px; }
  .game-title h1 { font-size: 1.25rem; }
  .mode-btn { padding: .35rem .6rem; }
  .hue-slider { grid-template-columns: 74px 1fr; font-size: .8rem; }
  .hue-row { grid-template-columns: 34px 1fr 64px; gap: 8px; }
  .fb { min-width: 0; padding: .3rem .4rem; }
}
@media (max-width: 360px) {
  .cards { grid-template-columns: 1fr; }
}

/* ================= Quad ================= */
.boards-4 { display: grid; grid-template-columns: auto auto; gap: 12px 16px; }
.boards-4 .board { --gap: 3px; --tile: min(38px, calc((100vw - 56px) / 10 - 3px), calc((100dvh - 320px) / 18 - 3px)); }
.boards-4 .board .tile { border-radius: 6px; border-width: 1.5px; }
.boards-4 .board.solved { opacity: .75; }

/* ================= Swap ================= */
.play-area.swap { gap: 16px; }
.swap-count { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-weight: 600; }
.swap-count b { font-family: var(--display); font-size: 2rem; color: var(--ink); transition: color .3s; }
.swap-count.low b { color: var(--danger); }
.swap-grid { --tile: min(64px, calc((100vw - 64px) / 5 - 8px), calc((100dvh - 330px) / 5 - 8px)); display: grid; grid-template-columns: repeat(5, var(--tile)); gap: 8px; }
.swap-hole { width: var(--tile); height: var(--tile); }
.swap-tile { cursor: pointer; padding: 0; font-family: var(--font); color: var(--on-tile); border: 0; box-shadow: 0 2px 0 rgb(0 0 0 / .12); transition: transform .15s var(--ease), box-shadow .15s, background .25s; }
.swap-tile[data-state="absent"] { background: var(--absent); }
.swap-tile:disabled { cursor: default; }
.swap-tile.sel { transform: translateY(-4px) scale(1.06); box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--accent), 0 10px 20px -6px rgb(0 0 0 / .35); }
.swap-tile.swapping { animation: pop .28s ease; }
.swap-tile.revealed { background: var(--absent) !important; }
.swap-hint { color: var(--muted); font-size: .88rem; text-align: center; max-width: 34ch; }

/* ================= Code ================= */
.play-area.code { gap: 14px; }
.code-board { display: flex; flex-direction: column; gap: 8px; --cell: min(54px, calc((100vw - 90px) / 5 - 8px), calc((100dvh - 380px) / 6 - 8px)); }
.code-row { display: flex; align-items: center; gap: 8px; }
.code-row.shake { animation: shake .42s ease; }
.code-num { width: 18px; font-size: .75rem; font-weight: 700; color: var(--muted); text-align: right; }
.code-row.active .code-num { color: var(--ink); }
.code-cell, .demo-code .code-cell { width: var(--cell, 46px); height: var(--cell, 46px); border-radius: 50%; display: grid; place-items: center; border: 2px dashed var(--line-2); background: var(--surface); transition: background .2s, border-color .2s; }
.code-row.active .code-cell:not(.filled) { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.code-cell.filled { border-style: solid; border-color: transparent; background: transparent; }
.code-cell[data-state] { border-radius: 14px; }
.code-cell[data-state="correct"] { background: var(--correct); }
.code-cell[data-state="present"] { background: var(--present); }
.code-cell[data-state="absent"] { background: var(--surface-3); }
.code-cell.flip { animation: flip .5s ease-in-out; }
.peg { width: 78%; height: 78%; border-radius: 50%; display: grid; place-items: center; background: var(--peg); color: rgb(255 255 255 / .9); font-size: calc(var(--cell, 46px) * .32); box-shadow: inset 0 -3px 0 rgb(0 0 0 / .15), inset 0 2px 0 rgb(255 255 255 / .25); text-shadow: 0 1px 1px rgb(0 0 0 / .25); line-height: 1; }
.code-controls { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: 6px; }
.code-palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; width: min(100%, 460px); }
.code-key { border: 0; background: var(--key); border-radius: 12px; aspect-ratio: 1; display: grid; place-items: center; cursor: pointer; --cell: 46px; transition: transform .1s; }
.code-key:active { transform: scale(.92); }
.code-actions { display: flex; gap: 10px; }
.code-actions .btn { min-width: 120px; }
.code-answer { display: flex; align-items: center; gap: 6px; --cell: 40px; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.code-answer span:first-child { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-right: 4px; }
.code-answer .peg { width: 32px; height: 32px; }
.demo-code { display: flex; gap: 6px; --cell: 44px; margin: 10px 0; }

/* ================= Tune ================= */
.play-area.tune { gap: 18px; width: 100%; max-width: 520px; margin: 0 auto; justify-content: flex-start; padding-top: 18px; }
.tune-dots { display: flex; gap: 6px; }
.tune-dots i { width: 34px; height: 6px; border-radius: 3px; background: var(--surface-3); transition: background .3s; }
.tune-dots i.now { background: color-mix(in srgb, var(--area) 45%, var(--surface-3)); }
.tune-dots i.skip { background: var(--absent); }
.tune-dots i.wrong { background: var(--danger); }
.tune-dots i.right { background: var(--correct); }
.tune-stage { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); }
.tune-play { width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; background: var(--area); box-shadow: 0 10px 24px -8px var(--area); transition: transform .15s var(--ease); }
.tune-play svg { width: 30px; height: 30px; margin-left: 4px; fill: currentColor; }
.tune-play.playing svg { margin-left: 0; }
.tune-play:active { transform: scale(.94); }
.tune-play.playing { animation: pulse 1.2s ease-in-out infinite; }
.tune-play-label { margin-bottom: 10px; }
.tune-play-label b { display: block; font-size: 1.05rem; }
.tune-play-label span { font-size: .85rem; color: var(--muted); }
.tune-strip { display: flex; align-items: flex-end; gap: 3px; height: 54px; }
.tune-strip i { flex: var(--w, 1) 1 0; min-width: 3px; height: calc(18% + var(--y, 0) * 82%); border-radius: 3px; background: var(--surface-3); transition: background .2s, transform .12s; }
.tune-strip i.rest { background: transparent; }
.tune-strip i.on { background: color-mix(in srgb, var(--area) 45%, var(--surface-3)); }
.tune-strip i.on.hit { background: var(--area); transform: scaleY(1.12); transform-origin: bottom; }
.tune-strip i:not(.on):not(.rest) { height: 18%; }
.tune-history { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.tune-guess { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; animation: rise .3s var(--ease) both; }
.tune-guess span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; color: #fff; background: var(--absent); flex: none; }
.tune-guess.wrong span { background: var(--danger); }
.tune-guess.right span { background: var(--correct); }
.tune-guess.skip { color: var(--muted); }
.tune-controls { width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.tune-search { position: relative; }
.tune-input { width: 100%; font: inherit; font-size: 1rem; padding: .85rem 1.1rem; border-radius: 16px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); outline: none; }
.tune-input:focus { border-color: var(--area); box-shadow: 0 0 0 4px color-mix(in srgb, var(--area) 18%, transparent); }
.tune-suggest { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 5; }
.tune-suggest:empty { display: none; }
.tune-opt { border: 0; background: transparent; text-align: left; padding: 10px 14px; cursor: pointer; display: flex; flex-direction: column; }
.tune-opt span { font-size: .8rem; color: var(--muted); }
.tune-opt.active, .tune-opt:hover { background: var(--surface-2); }
.tune-buttons { display: flex; gap: 10px; }
.tune-buttons .btn { flex: 1; }

/* ================= Streaks ================= */
.streak-chip { display: inline-flex; align-items: center; gap: 4px; border: 0; cursor: pointer; padding: .35rem .7rem; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 800; font-size: 1rem; }
.streak-chip svg { width: 20px; height: 20px; }
.streak-chip:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.streak-chip.warm { color: color-mix(in srgb, #e8743b 60%, var(--muted)); }
.streak-chip.lit { color: #e8743b; }
.streak-chip.lit svg, .streak.lit svg, .big-flame.lit svg { fill: color-mix(in srgb, #f39a3d 55%, transparent); }
button.streak { border: 0; font: inherit; cursor: pointer; }
.streak.lit { background: color-mix(in srgb, #e8743b 14%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, #e8743b 35%, transparent); }
.freeze-count { margin-left: 4px; color: #5aa9e6; font-weight: 700; }
.week-strip { display: flex; gap: 6px; justify-content: center; }
.wk { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .68rem; font-weight: 700; color: var(--muted); }
.wk i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-style: normal; font-size: .8rem; color: var(--muted); }
.wk i svg { width: 15px; height: 15px; }
.wk.done i { background: #e8743b; color: #fff; }
.wk.done i svg { fill: rgb(255 255 255 / .5); }
.wk.rest i { background: color-mix(in srgb, var(--a-association) 22%, var(--surface)); color: var(--a-association); }
.wk.frozen i { background: color-mix(in srgb, #5aa9e6 22%, var(--surface)); color: #3b8fd0; }
.wk.today i { box-shadow: inset 0 0 0 2px #e8743b; }
.wk.future i { opacity: .45; }
.ring.done .ring-fg { stroke: #e8743b; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 16px; margin: 12px 0 0; font-size: .95rem; animation: rise .5s var(--ease) both; }
.banner svg { width: 22px; height: 22px; flex: none; }
.banner.risk { background: color-mix(in srgb, #e8743b 13%, var(--surface)); color: color-mix(in srgb, #c25a26 80%, var(--ink)); }
.banner.repair { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--ink); }
.streak-sheet, .celebrate { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.streak-sheet h2 { font-family: var(--display); font-weight: 600; font-size: 1.8rem; }
.big-flame { width: 84px; height: 84px; color: var(--muted); }
.big-flame svg { width: 100%; height: 100%; }
.big-flame.lit { color: #e8743b; filter: drop-shadow(0 8px 18px rgb(232 116 59 / .45)); }
.big-flame.pop { animation: flame-pop .8s var(--ease) both; }
.streak-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; margin: 6px 0; }
.sfact { background: var(--surface-2); border-radius: 14px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; }
.sfact span { font-size: 1rem; }
.sfact b { font-family: var(--display); font-size: 1.4rem; }
.sfact small { font-size: .68rem; color: var(--muted); }
.repair-note { background: var(--accent-soft); padding: 10px 14px; border-radius: 12px; font-size: .9rem; }
.celebrate-num { font-family: var(--display); font-size: 4.5rem; font-weight: 700; line-height: .9; color: #e8743b; animation: pop-in .6s var(--ease) .2s both; }
.celebrate h2 { font-family: var(--display); font-weight: 600; font-size: 1.6rem; margin-top: -4px; }
.celebrate-line { color: var(--ink-2); font-weight: 600; }
.xp-pill, .result-pill.xp { background: color-mix(in srgb, var(--present) 25%, transparent) !important; color: color-mix(in srgb, var(--present) 60%, var(--ink)) !important; font-weight: 800; padding: .35rem .9rem; border-radius: 999px; }
.btn.wide { width: 100%; margin-top: 6px; }
.result-pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.result-pills .result-pill { margin-top: 0; }
.setting.stack { flex-direction: column; align-items: flex-start; gap: 10px; }
@keyframes flame-pop { 0% { transform: scale(.3) rotate(-12deg); opacity: 0; } 60% { transform: scale(1.15) rotate(4deg); opacity: 1; } 100% { transform: none; } }

/* ================= Ranked ================= */
.ranked-promo { display: flex; align-items: center; gap: 16px; margin: 0 0 18px; transition: transform .2s var(--ease), box-shadow .2s; background: linear-gradient(120deg, var(--surface), color-mix(in srgb, var(--surface) 82%, var(--present))); }
.ranked-promo:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.ranked-promo h2 { margin-bottom: 4px; }
.ranked-promo p { color: var(--ink-2); font-size: .93rem; }
.ranked-promo .arrow { margin-left: auto; font-size: 1.3rem; color: var(--muted); }
.ranked-promo .tip-icon { background: color-mix(in srgb, var(--present) 25%, transparent); }
.card-links { display: inline-flex; gap: 10px; }
.race-timer { display: block; font-variant-numeric: tabular-nums; font-weight: 800; font-size: .95rem; color: var(--area); letter-spacing: .02em; }
.race-timer.stopped { color: var(--ink); }
.game-screen { position: relative; }
.race-hidden { filter: blur(14px); opacity: .25; pointer-events: none; user-select: none; }
.race-gate { position: absolute; inset: 64px 0 0; display: grid; place-items: center; padding: 16px; z-index: 5; }
.race-card { width: min(100%, 400px); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 26px 22px; box-shadow: var(--shadow-lg); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; animation: pop-in .35s var(--ease) both; }
.race-card.done { box-shadow: var(--shadow); }
.race-card h2 { font-family: var(--display); font-weight: 600; font-size: 1.5rem; }
.race-card p { color: var(--ink-2); font-size: .93rem; }
.race-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: .3rem .7rem; border-radius: 999px; background: color-mix(in srgb, var(--present) 25%, transparent); color: color-mix(in srgb, var(--present) 55%, var(--ink)); }
.race-badge svg { width: 14px; height: 14px; }
.race-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.race-facts > div { background: var(--surface-2); border-radius: 12px; padding: 8px; }
.race-facts small { display: block; font-size: .72rem; color: var(--muted); }
.race-facts b { font-variant-numeric: tabular-nums; }
.race-count { font-family: var(--display); font-size: 7rem; font-weight: 700; color: var(--area); text-shadow: 0 10px 40px color-mix(in srgb, var(--area) 50%, transparent); }
.race-count.tick { animation: count-tick .65s var(--ease); }
.race-big { font-family: var(--display); font-size: 3.2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; margin: 6px 0 2px; }
.world-line { margin-top: 12px; }
@keyframes count-tick { 0% { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(.9); opacity: .9; } }
.ranked-head .lede { margin: -8px 0 20px; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: grid; grid-template-columns: auto 1fr 90px 90px 120px; align-items: center; gap: 14px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; transition: transform .2s var(--ease), border-color .2s; }
.rank-row:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--area) 40%, var(--line)); }
.rank-row .card-icon { width: 40px; height: 40px; border-radius: 12px; }
.rank-row .card-icon svg { width: 22px; height: 22px; }
.rank-name b { display: block; font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.rank-name small, .rank-stat small { color: var(--muted); font-size: .75rem; }
.rank-stat b { display: block; font-variant-numeric: tabular-nums; }
.rank-row .status { justify-self: end; }
.world { margin-top: 18px; }
.world-off p { color: var(--ink-2); margin-bottom: 6px; }
.stat-tiles { grid-template-columns: repeat(3, 1fr); }
.cal-d.covered { font-size: .9rem; }
@media (max-width: 600px) {
  .rank-row { grid-template-columns: auto 1fr auto; }
  .rank-row .rank-stat { display: none; }
  .streak-facts { grid-template-columns: repeat(2, 1fr); }
  .hero-side { flex-wrap: wrap; }
  .card-links { gap: 8px; }
}
@media (max-width: 820px) { .stat-tiles { grid-template-columns: repeat(2, 1fr); } }

/* ================= Online: boards, friends, sign-up ================= */
.text-input { width: 100%; font: inherit; font-size: 1rem; padding: .8rem 1rem; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); outline: none; }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.signup { display: flex; flex-direction: column; gap: 12px; }
.form-err { color: var(--danger); font-size: .88rem; min-height: 1.2em; margin: -4px 0; }
.lb-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: none; }
.lb-tabs button { border: 0; cursor: pointer; padding: .4rem .85rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: .85rem; white-space: nowrap; }
.lb-tabs button.on { background: var(--ink); color: var(--bg); }
.lboard { display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: grid; grid-template-columns: 36px 1fr auto 56px; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; }
.lb-row:nth-child(even) { background: var(--surface-2); }
.lb-row.you { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.lb-rank { font-weight: 800; text-align: center; color: var(--muted); }
.lb-row.top1 .lb-rank, .lb-row.top2 .lb-rank, .lb-row.top3 .lb-rank { font-size: 1.2rem; }
.lb-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.lb-row b { font-variant-numeric: tabular-nums; }
.lb-row small { color: var(--muted); text-align: right; }
.lb-gap { text-align: center; color: var(--muted); }
.me-card { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.me-card h2 { margin: 2px 0 0; font-size: 1.5rem; }
.code-box { background: var(--surface-2); border-radius: 14px; padding: 8px 16px; }
.code-box b { display: block; font-size: 1.4rem; letter-spacing: .18em; font-variant-numeric: tabular-nums; }
.me-card .btn { margin-left: auto; }
.add-friend { display: flex; gap: 8px; margin-bottom: 12px; }
.add-friend .text-input { text-transform: uppercase; letter-spacing: .12em; }
.friend-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.friend { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 10px; align-items: center; padding: 8px; border-radius: 14px; background: var(--surface-2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--a-association)); }
.friend-name b { display: block; }
.friend-name small { color: var(--muted); font-size: .8rem; }
.friend-streak { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-weight: 800; }
.friend-streak svg { width: 20px; height: 20px; }
.friend-streak.lit { color: #e8743b; }
.friend-streak.lit svg { fill: color-mix(in srgb, #f39a3d 55%, transparent); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.promo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.promo-row .ranked-promo { margin: 0; }
.checkin-promo { background: linear-gradient(120deg, var(--surface), color-mix(in srgb, var(--surface) 84%, var(--a-memory))); }
.checkin-promo .tip-icon { background: color-mix(in srgb, var(--a-memory) 20%, transparent); color: var(--a-memory); }
.checkin-page { max-width: 760px; margin: 0 auto; padding: 8px 16px 60px; }
@media (max-width: 820px) { .promo-row { grid-template-columns: 1fr; } }
.top.has-back { gap: 4px; justify-content: flex-start; }
.top.has-back .top-actions { margin-left: auto; }
.top.has-back > .icon-btn { margin-left: -8px; }
@media (max-width: 600px) {
  .toast { white-space: normal; text-align: center; max-width: calc(100vw - 32px); }
  .top.has-back .brand-name { font-size: 1.2rem; }
  .top-actions .icon-btn { width: 38px; }
}

/* ================= Side menu (drawer + rail) ================= */
.top { gap: 6px; justify-content: flex-start; }
.top .top-actions { margin-left: auto; }
.menu-btn { margin-left: -8px; color: var(--ink); }
.shell { display: flex; min-height: 100dvh; }
.shell-main { flex: 1; min-width: 0; }
.nav-panel { display: flex; flex-direction: column; gap: 6px; box-sizing: border-box; }
.nav-panel.rail { display: none; }
.nav-top { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.drawer-card .nav-top { flex-direction: row; align-items: center; }
.nav-top > .brand { height: 44px; padding: 0 6px; }
.nav-profile { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 14px; border: 0; background: transparent; text-align: left; cursor: pointer; flex: 1; min-width: 0; color: var(--ink); }
.nav-profile:hover { background: var(--surface-2); }
.nav-profile .avatar { flex: none; width: 42px; height: 42px; }
.avatar.ghost { background: var(--surface-3); color: var(--ink-2); }
.avatar.ghost svg { width: 20px; height: 20px; }
.nav-profile .nav-label { display: flex; flex-direction: column; min-width: 0; }
.nav-profile small { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-items { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 12px; border: 0; background: transparent; color: var(--ink-2); font-weight: 600; font-size: .98rem; text-align: left; cursor: pointer; white-space: nowrap; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--ink); }
.nav-item.active .nav-ico { color: var(--accent); }
.nav-ico { width: 22px; height: 22px; flex: none; color: var(--muted); }
.nav-ico svg { width: 100%; height: 100%; }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { font-size: .75rem; font-weight: 800; color: var(--muted); padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.nav-badge.hot { color: color-mix(in srgb, var(--a-memory) 75%, var(--ink)); background: color-mix(in srgb, var(--a-memory) 18%, transparent); }
.nav-chev { width: 16px; height: 16px; color: var(--muted); transition: transform .2s var(--ease); }
.nav-chev svg { width: 100%; height: 100%; }
.nav-item[aria-expanded="true"] .nav-chev { transform: rotate(90deg); }
.nav-sub { display: none; flex-direction: column; padding: 2px 0 6px 46px; }
.nav-sub.open { display: flex; }
.nav-game { display: flex; align-items: center; gap: 10px; min-height: 36px; padding-right: 12px; border-radius: 10px; color: var(--ink-2); font-size: .95rem; }
.nav-game:hover, .nav-game.active { color: var(--ink); }
.nav-game i { width: 8px; height: 8px; border-radius: 50%; background: var(--area); flex: none; }
.nav-game span { flex: 1; }
.nav-game small { font-weight: 800; font-size: .8rem; }
.nav-game small.done { color: var(--correct); }
.nav-game small.prog { color: var(--present); }
.nav-foot { display: flex; flex-direction: column; gap: 8px; padding: 12px 8px 4px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.nav-foot b { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nav-collapse { display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; cursor: pointer; }
.nav-collapse svg { width: 18px; height: 18px; transition: transform .2s; }

/* Drawer (phones and narrow windows) */
.modal.drawer { place-items: stretch; justify-items: start; padding: 0; }
.drawer-card { width: min(86vw, 320px); height: 100%; background: var(--surface); border-radius: 0 24px 24px 0; padding: 14px 12px max(14px, env(safe-area-inset-bottom)); padding-top: max(14px, env(safe-area-inset-top)); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; transform: translateX(-104%); transition: transform .28s var(--ease); box-sizing: border-box; }
.modal.drawer.open .drawer-card { transform: none; }
.drawer-card .nav-panel { height: 100%; }

/* Rail (wide screens) */
@media (min-width: 1024px) {
  .menu-btn { display: none; }
  .nav-panel.rail { display: flex; position: sticky; top: 0; height: 100dvh; width: 272px; flex: none; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); transition: width .22s var(--ease); overflow: hidden; }
  .nav-panel.rail.collapsed { width: 76px; }
  .nav-panel.rail.collapsed .nav-label, .nav-panel.rail.collapsed .nav-badge, .nav-panel.rail.collapsed .nav-chev, .nav-panel.rail.collapsed .nav-sub { display: none; }
  .nav-panel.rail.collapsed .nav-item, .nav-panel.rail.collapsed .nav-profile, .nav-panel.rail.collapsed .nav-top > .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .nav-panel.rail.collapsed .nav-collapse svg { transform: rotate(180deg); }
  .shell .top .brand { display: none; }
}

/* ================= Home (cleaner layout) ================= */
.hub2 { display: flex; flex-direction: column; gap: 18px; padding-top: 4px; }
.hub-intro h1 { font-family: var(--display); font-weight: 600; font-size: clamp(1.9rem, 4.5vw, 2.6rem); letter-spacing: -.02em; margin-top: 4px; }
.hub-top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
.today-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.today-head > span { color: var(--ink-2); font-size: .92rem; }
.today-head > span > b { color: var(--ink); }
.xp-link { padding: 0; font-size: inherit; color: var(--ink-2); }
.segments { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; }
.segments i { height: 8px; border-radius: 4px; background: var(--surface-3); transition: background .3s; }
.segments i.done { background: var(--correct); }
.segments i.prog { background: var(--present); }
.week-btn { border: 0; background: transparent; padding: 0; cursor: pointer; }
.week-btn .week-strip { justify-content: space-between; }
.up-next { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; background: color-mix(in srgb, var(--surface) 82%, var(--area, var(--present)) 10%); border: 1px solid color-mix(in srgb, var(--area, var(--present)) 28%, var(--line)); transition: transform .2s var(--ease); }
.up-next:hover { transform: translateY(-2px); }
.up-next .card-icon { width: 50px; height: 50px; }
.up-next.done { --area: var(--present); }
.up-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.up-text small { font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.up-text b { font-size: 1.2rem; }
.up-go { flex: none; padding: .55rem 1.1rem; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 800; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.sec-head h2 { font-family: var(--display); font-weight: 600; font-size: 1.3rem; }
.sec-head b { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.game-list { display: flex; flex-direction: column; }
.game-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); animation: rise .4s var(--ease) both; animation-delay: calc(var(--i) * 25ms); }
.game-row .card-icon { width: 40px; height: 40px; border-radius: 12px; }
.game-row .card-icon svg { width: 22px; height: 22px; }
.gr-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.gr-text b { font-size: 1.02rem; }
.gr-text small { font-size: .78rem; color: var(--muted); }
.gr-pill { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 800; padding: .38rem .85rem; border-radius: 999px; background: var(--ink); color: var(--bg); }
.gr-pill svg { width: 14px; height: 14px; }
.gr-pill.prog { background: color-mix(in srgb, var(--present) 22%, transparent); color: color-mix(in srgb, var(--present) 60%, var(--ink)); }
.gr-pill.done { background: color-mix(in srgb, var(--correct) 18%, transparent); color: color-mix(in srgb, var(--correct) 65%, var(--ink)); }
.gr-pill.done.soft { background: var(--surface-3); color: var(--ink-2); }
.hub-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: .93rem; }
.hub-note .tip-icon { width: 34px; height: 34px; border-radius: 10px; }
.hub-note .tip-icon svg { width: 18px; height: 18px; }
.hub-note b { color: var(--ink); }
@media (min-width: 720px) {
  .game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
  .game-row { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); transition: transform .2s var(--ease), border-color .2s; }
  .game-row:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--area) 40%, var(--line)); }
  .game-row .gr-text { flex: none; }
}
@media (max-width: 720px) {
  .hub-top { grid-template-columns: 1fr; }
}

/* ================= Avatars & profiles ================= */
.av { display: inline-block; flex: none; border-radius: 50%; line-height: 0; }
.av svg { width: 100%; height: 100%; display: block; }
.nav-profile .av { width: 42px; height: 42px; }
.nav-profile.active { background: var(--accent-soft); }
.lb-row { color: inherit; text-decoration: none; }
.lb-row:hover { background: var(--surface-3); }
.lb-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lb-name > span { overflow: hidden; text-overflow: ellipsis; }
.friend { grid-template-columns: 40px 1fr auto auto; }
.friend-av { line-height: 0; }
.friend-name { color: inherit; }

.profile-hero { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin: 14px 0 22px; }
.profile-av { position: relative; border: 0; background: transparent; padding: 0; cursor: pointer; line-height: 0; border-radius: 50%; }
span.profile-av { cursor: default; }
.profile-av .av { filter: drop-shadow(0 12px 28px rgb(0 0 0 / .35)); }
.profile-edit { position: absolute; right: 2px; bottom: 2px; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; box-shadow: var(--shadow); }
.profile-edit svg { width: 18px; height: 18px; }
.profile-id h1 { font-family: var(--display); font-weight: 600; font-size: clamp(1.9rem, 4vw, 2.5rem); letter-spacing: -.01em; }
.profile-title { color: var(--accent); font-weight: 700; margin: 2px 0 12px; }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.ach { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); opacity: .78; }
.ach.earned { opacity: 1; border-color: color-mix(in srgb, var(--present) 40%, var(--line)); background: linear-gradient(140deg, var(--surface), color-mix(in srgb, var(--surface) 86%, var(--present))); }
.ach-ico { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.ach.earned .ach-ico { background: color-mix(in srgb, var(--present) 25%, transparent); color: color-mix(in srgb, var(--present) 60%, var(--ink)); }
.ach-ico svg { width: 20px; height: 20px; }
.ach-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.ach-body small { color: var(--muted); font-size: .82rem; }
.ach-reward { color: var(--accent) !important; font-weight: 600; }
.ach-bar { position: relative; height: 16px; border-radius: 8px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.ach-bar i { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 8px; }
.ach-bar span { position: relative; font-size: .7rem; font-weight: 800; padding-left: 8px; line-height: 16px; }
.best-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.best { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.best small { display: block; color: var(--muted); font-size: .78rem; }
.best b { font-family: var(--display); font-size: 1.4rem; font-variant-numeric: tabular-nums; }

/* Avatar editor */
.editor { display: flex; flex-direction: column; gap: 14px; }
.ed-head { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ed-preview { line-height: 0; }
.ed-title { color: var(--accent); font-weight: 700; }
.ed-tabs { align-self: center; flex-wrap: wrap; justify-content: center; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 44vh; overflow-y: auto; padding: 4px; }
.ed-grid.ed-titles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.ed-opt { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 14px; border: 2px solid transparent; background: var(--surface-2); cursor: pointer; color: var(--ink-2); }
.ed-opt small { font-size: .75rem; font-weight: 600; }
.ed-opt.chosen { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.ed-opt.locked .av, .ed-opt.locked .ed-title-opt { filter: grayscale(1) brightness(.6); opacity: .55; }
/* Locked frames and colours stay visible (dimmed) so players can see what they're working toward. */
.ed-frames .ed-opt.locked .av, .ed-colors .ed-opt.locked .av { filter: saturate(.75) brightness(.8); opacity: .7; }
.ed-lock { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; }
.ed-lock svg { width: 13px; height: 13px; }
.ed-title-opt { font-weight: 700; padding: 8px 4px; }
