/* =========================================================================
   WordRush — visual system
   Dark: night-sky indigo with coral→pink glow. Light: lilac & peach daylight.
   Tiles are always warm cream "game pieces" so the board reads the same in both.
   ========================================================================= */
:root {
  /* light (default tokens) */
  --bg: #f3effb;
  --bg-blob-1: rgba(255, 140, 105, .30);
  --bg-blob-2: rgba(139, 108, 255, .26);
  --bg-blob-3: rgba(25, 195, 166, .16);
  --surface: rgba(255, 255, 255, .72);
  --surface-solid: #ffffff;
  --surface-2: rgba(84, 66, 160, .07);
  --surface-3: rgba(84, 66, 160, .12);
  --line: rgba(84, 66, 160, .12);
  --ink: #221a46;
  --muted: #6f6894;
  --faint: #a7a1c4;

  --grad: linear-gradient(135deg, #ff8a4c 0%, #ff4d7a 100%);
  --grad-cool: linear-gradient(135deg, #7c5cff 0%, #19c3a6 100%);
  --accent: #ff5f6d;
  --accent-ink: #fff;
  --accent-glow: rgba(255, 85, 110, .38);
  --good: #12a88f;
  --bad: #e5484d;
  --dup: #e09a12;
  --gold: #f5b82e;

  --tile-top: #fffaf1;
  --tile-bot: #f6e6c8;
  --tile-edge: #dcc394;
  --tile-ink: #2a1f4a;
  --board-bg: rgba(84, 66, 160, .10);
  --seg-on: #ffffff;

  --shadow-sm: 0 1px 2px rgba(34, 26, 70, .06), 0 2px 8px rgba(34, 26, 70, .05);
  --shadow: 0 1px 2px rgba(34, 26, 70, .05), 0 10px 30px -8px rgba(34, 26, 70, .16);
  --radius: 22px;
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110e29;
    --bg-blob-1: rgba(255, 95, 109, .26);
    --bg-blob-2: rgba(124, 92, 255, .34);
    --bg-blob-3: rgba(25, 195, 166, .16);
    --surface: rgba(255, 255, 255, .055);
    --surface-solid: #1c1740;
    --surface-2: rgba(255, 255, 255, .065);
    --surface-3: rgba(255, 255, 255, .12);
    --line: rgba(255, 255, 255, .10);
    --ink: #f4f1ff;
    --muted: #a9a3d1;
    --faint: #6d679a;
    --good: #2fd3b4;
    --board-bg: rgba(10, 8, 28, .48);
    --seg-on: rgba(255, 255, 255, .16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 16px 42px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #110e29;
  --bg-blob-1: rgba(255, 95, 109, .26);
  --bg-blob-2: rgba(124, 92, 255, .34);
  --bg-blob-3: rgba(25, 195, 166, .16);
  --surface: rgba(255, 255, 255, .055);
  --surface-solid: #1c1740;
  --surface-2: rgba(255, 255, 255, .065);
  --surface-3: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .10);
  --ink: #f4f1ff;
  --muted: #a9a3d1;
  --faint: #6d679a;
  --good: #2fd3b4;
  --board-bg: rgba(10, 8, 28, .48);
  --seg-on: rgba(255, 255, 255, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 16px 42px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.35;
  background-color: var(--bg);
  background-image:
    radial-gradient(60vmax 50vmax at 110% -10%, var(--bg-blob-1), transparent 60%),
    radial-gradient(70vmax 60vmax at -20% 30%, var(--bg-blob-2), transparent 60%),
    radial-gradient(50vmax 40vmax at 80% 110%, var(--bg-blob-3), transparent 60%);
  background-attachment: fixed;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .01em; }
h2 { font-size: 1.12rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; display: block; margin-inline: auto; }
.error { color: var(--bad); min-height: 1em; margin: 0; }
svg { display: block; }

#app {
  max-width: 520px; margin: 0 auto; min-height: 100vh;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(env(safe-area-inset-bottom, 0px) + var(--nav-h) + 28px);
}
body.no-nav #app { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); }
.screen { display: flex; flex-direction: column; gap: 14px; animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- brand / wordmark ---------- */
.brand { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 0 6px; text-align: center; }
.wordmark { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.wm-row { display: flex; gap: 7px; }
.wm-row i {
  font-style: normal; width: 50px; height: 54px; display: grid; place-items: center; border-radius: 14px;
  font-size: 1.85rem; font-weight: 700; color: var(--tile-ink);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bot));
  box-shadow: 0 5px 0 var(--tile-edge), 0 12px 22px -8px rgba(20, 10, 60, .5);
  animation: drop .55s cubic-bezier(.3, 1.4, .5, 1) backwards;
}
.wm-row i:nth-child(odd) { transform: rotate(-3deg); }
.wm-row i:nth-child(even) { transform: rotate(2.5deg) translateY(2px); }
.wm-row.rush i { background: var(--grad); color: #fff; box-shadow: 0 4px 0 #c8335a, 0 12px 26px -8px var(--accent-glow); }
.wm-row i:nth-child(1) { animation-delay: .02s; } .wm-row i:nth-child(2) { animation-delay: .07s; }
.wm-row i:nth-child(3) { animation-delay: .12s; } .wm-row i:nth-child(4) { animation-delay: .17s; }
.wm-row.rush i:nth-child(1) { animation-delay: .24s; } .wm-row.rush i:nth-child(2) { animation-delay: .29s; }
.wm-row.rush i:nth-child(3) { animation-delay: .34s; } .wm-row.rush i:nth-child(4) { animation-delay: .39s; }
@keyframes drop { from { opacity: 0; transform: translateY(-24px) rotate(-12deg); } }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: .95rem; max-width: 30ch; }
.net {
  position: absolute; top: 0; right: 0; display: flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 600;
  color: var(--muted); padding: 5px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.net .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.net.on .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 28%, transparent); animation: beat 2.4s infinite; }
@keyframes beat { 50% { box-shadow: 0 0 0 6px transparent; } }
.page-title { font-size: 1.75rem; padding: 6px 2px 2px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.hero-card {
  position: relative; overflow: hidden;
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: 0 0 32px -12px var(--accent-glow), var(--shadow);
}
.hero-card::before {
  content: ''; position: absolute; inset: -40% -30% auto auto; width: 70%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 65%); pointer-events: none; opacity: .55;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin-bottom: -4px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 15px; padding: 12px 16px;
  font-weight: 600; cursor: pointer; white-space: nowrap; position: relative;
  transition: transform .12s cubic-bezier(.3, 1.5, .5, 1), filter .15s, background .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--grad); border: 0; color: var(--accent-ink); border-radius: 99px;
  box-shadow: 0 4px 0 #c8335a, 0 12px 28px -6px var(--accent-glow);
  text-shadow: 0 1px 0 rgba(150, 20, 60, .25);
}
.btn.primary:hover { filter: brightness(1.06) saturate(1.05); background: var(--grad); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #c8335a, 0 6px 14px -8px var(--accent-glow); }
.btn.ghost { background: transparent; border-radius: 99px; }
.btn.big { padding: 17px 20px; font-size: 1.2rem; border-radius: 99px; }
.btn.small { padding: 8px 16px; font-size: .88rem; border-radius: 99px; }
.btn.primary.small { box-shadow: 0 3px 0 #c8335a; }
.play-btn { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; overflow: hidden; }
.play-btn svg { width: 22px; height: 22px; fill: currentColor; }
.play-btn::after {
  content: ''; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.35) 50%, transparent 65%);
  transform: translateX(-100%); animation: shine 4.5s ease-in-out 1.2s infinite;
}
@keyframes shine { 0%, 70% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); width: 42px; height: 42px; border-radius: 50%;
  font-size: 1.1rem; cursor: pointer; flex: none; display: grid; place-items: center; backdrop-filter: blur(10px);
  transition: transform .12s, background .15s;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .4; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 8px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- inputs ---------- */
input {
  width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: var(--faint); }
input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); background: var(--surface); }
#join-code { text-transform: uppercase; letter-spacing: .22em; font-weight: 700; text-align: center; }
#join-code::placeholder { text-transform: none; letter-spacing: normal; font-weight: 500; }
.join { display: flex; gap: 8px; }
.join.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.mp-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
@media (max-width: 380px) { .mp-actions { grid-template-columns: 1fr; } }

/* ---------- segmented ---------- */
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button {
  flex: 1; border: 0; background: none; padding: 10px 8px; border-radius: 12px; font-weight: 600; cursor: pointer; color: var(--muted);
  transition: background .2s, color .2s, box-shadow .2s;
}
.seg button:hover:not(:disabled):not(.on) { color: var(--ink); }
.seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg button:disabled { cursor: default; }
.seg.small button { padding: 7px 6px; font-size: .9rem; }
.seg small { font-weight: 500; opacity: .75; }

.pill { align-self: center; font-size: .75rem; font-weight: 600; padding: 4px 11px; border-radius: 99px; background: var(--grad-cool); color: #fff; }
.badge {
  position: absolute; top: 8px; right: calc(50% - 22px); min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--grad); color: #fff; font-size: .68rem; font-weight: 700; font-style: normal; display: grid; place-items: center;
  padding: 0 5px; box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; min-height: 54px; transition: background .15s; }
.list li:hover { background: var(--surface-2); }
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.list li .sub { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
.list li.empty { color: var(--muted); justify-content: center; text-align: center; font-size: .92rem; font-weight: 500; }
.list li.empty:hover { background: none; }
.list .num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
.ranked { counter-reset: rank; }
.ranked li::before {
  counter-increment: rank; content: counter(rank); width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  border-radius: 50%; font-size: .82rem; font-weight: 700; color: var(--muted); background: var(--surface-2);
}
.ranked li:nth-child(1)::before { background: linear-gradient(135deg, #ffd66b, #f5a524); color: #6b4300; box-shadow: 0 3px 10px -2px rgba(245, 165, 36, .45); }
.ranked li:nth-child(2)::before { background: linear-gradient(135deg, #eef0f7, #b9bfd3); color: #3c4260; }
.ranked li:nth-child(3)::before { background: linear-gradient(135deg, #f3c39b, #c98552); color: #5a2e0e; }
.ranked li:nth-child(1) .num { color: var(--accent); }
.ranked li.empty::before { display: none; }
.ranked li.me { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.avatar {
  width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none;
  background: var(--faint); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15), 0 4px 10px -4px rgba(0, 0, 0, .3);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}
.profile { display: flex; align-items: center; gap: 12px; }
.profile .avatar { width: 50px; height: 50px; border-radius: 16px; font-size: 1.3rem; }
.tag {
  font-size: .68rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--muted);
  margin-left: 5px; vertical-align: 2px; text-transform: lowercase;
}

/* ---------- settings ---------- */
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; cursor: pointer; font-weight: 600; }
.toggle input { position: absolute; opacity: 0; width: 0; }
.toggle i { width: 50px; height: 30px; border-radius: 15px; background: var(--surface-3); position: relative; transition: background .25s; flex: none; }
.toggle i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .25s cubic-bezier(.3, 1.5, .5, 1);
}
.toggle input:checked + i { background: var(--grad); }
.toggle input:checked + i::after { transform: translateX(20px); }
.toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle input:disabled + i { opacity: .4; }

/* ---------- lobby ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; }
.bar h1 { font-size: 1.3rem; }
.code-card { flex-direction: column; align-items: center; gap: 14px; padding: 24px 18px; }
.code-card .code {
  font-size: 2.15rem; font-weight: 700; letter-spacing: .34em; padding: 12px 14px 12px 26px; border-radius: 16px;
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bot)); color: var(--tile-ink);
  box-shadow: 0 5px 0 var(--tile-edge), 0 14px 28px -10px rgba(20, 10, 60, .55), inset 0 1px 0 rgba(255, 255, 255, .9);
}

/* ---------- game ---------- */
.game { gap: 12px; }
.hud { display: flex; align-items: stretch; gap: 8px; }
.hud .icon-btn { align-self: center; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 7px 10px; text-align: center;
  backdrop-filter: blur(12px); display: flex; flex-direction: column; justify-content: center;
}
.stat:has(#g-score) {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  box-shadow: 0 0 24px -10px var(--accent-glow);
}
.stat small { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.stat b { font-size: 1.45rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
#g-score { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.timer { position: relative; flex: 0 0 76px; padding: 0; height: 76px; border-radius: 50%; align-items: center; }
.timer svg { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4.5; }
.timer .track { stroke: var(--surface-3); }
.timer .prog { stroke: var(--good); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .3s; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--good) 60%, transparent)); }
.timer .prog.low { stroke: var(--bad); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--bad) 60%, transparent)); }
.timer b { position: relative; font-size: 1.05rem; }
#g-time.low { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.opponents { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.opponents li {
  display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  padding: 4px 12px 4px 4px; font-size: .86rem; font-weight: 600; white-space: nowrap; backdrop-filter: blur(10px);
}
.opponents .avatar { width: 24px; height: 24px; border-radius: 50%; font-size: .72rem; box-shadow: none; }
.opponents b { font-variant-numeric: tabular-nums; color: var(--accent); }

.current-wrap { position: relative; height: 48px; display: grid; place-items: center; }
.current {
  font-size: 1.9rem; font-weight: 700; letter-spacing: .14em; color: var(--ink); opacity: .55; transition: color .12s, opacity .12s, transform .12s;
}
.current:empty { opacity: 0; }
.current.valid {
  color: var(--good); opacity: 1; transform: scale(1.04);
  text-shadow: 0 0 18px color-mix(in srgb, var(--good) 55%, transparent);
}
.feedback {
  position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.15rem; letter-spacing: .06em;
  opacity: 0; pointer-events: none;
}
.feedback.show { animation: fb .9s ease forwards; }
.feedback.good { color: var(--good); } .feedback.bad { color: var(--bad); } .feedback.dup { color: var(--dup); }
@keyframes fb { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: 1; transform: scale(1.12); } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

.board-wrap { position: relative; }
.board {
  position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; padding: 12px;
  background: var(--board-bg); border: 1px solid var(--line); border-radius: 26px; touch-action: none; user-select: none; -webkit-user-select: none;
  aspect-ratio: 1; width: 100%; max-width: min(100%, 58vh); margin: 0 auto;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, .12);
  transition: box-shadow .2s;
}
.tile {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 16px; position: relative; z-index: 1;
  background: linear-gradient(180deg, var(--tile-top) 0%, var(--tile-bot) 100%); color: var(--tile-ink);
  box-shadow: 0 5px 0 var(--tile-edge), 0 9px 14px -6px rgba(20, 10, 60, .45), inset 0 1px 0 rgba(255, 255, 255, .9);
  font-size: clamp(1.45rem, 8.2vw, 2.45rem); font-weight: 700; line-height: 1; padding-bottom: 3px;
  transition: transform .1s cubic-bezier(.3, 1.6, .5, 1), box-shadow .1s, background .1s, color .1s;
  animation: deal .45s cubic-bezier(.3, 1.4, .5, 1) backwards; animation-delay: calc(var(--i) * 16ms);
}
@keyframes deal { from { opacity: 0; transform: scale(.4) rotate(-8deg); } }
.board.waiting .tile { filter: blur(7px) saturate(.6); }
.tile.sel {
  background: var(--grad); color: #fff; transform: translateY(3px) scale(.96);
  box-shadow: 0 2px 0 #c8335a, 0 0 24px 0 var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 1px 0 rgba(150, 20, 60, .3);
}
.tile.head { transform: translateY(1px) scale(1.04); }
.trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.trail polyline { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; opacity: .72; filter: drop-shadow(0 0 8px var(--accent)); }
.board.good { animation: flash-good .4s; } .board.bad { animation: shake .32s; } .board.dup { animation: flash-dup .4s; }
@keyframes flash-good { 40% { box-shadow: inset 0 2px 12px rgba(0,0,0,.12), 0 0 0 3px var(--good), 0 0 30px -4px var(--good); } }
@keyframes flash-dup { 40% { box-shadow: inset 0 2px 12px rgba(0,0,0,.12), 0 0 0 3px var(--dup); } }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
.score-pop {
  position: absolute; z-index: 4; transform: translate(-50%, 0); pointer-events: none; font-weight: 700; font-size: 1.5rem; color: #fff;
  padding: 2px 10px; border-radius: 99px; background: var(--good); box-shadow: 0 6px 16px -4px rgba(0, 0, 0, .35);
  animation: float-up 1s cubic-bezier(.2, .8, .3, 1) forwards;
}
.score-pop.big { background: linear-gradient(135deg, #ffd66b, #f5a524); color: #5a3500; font-size: 1.8rem; }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -60px) scale(1); } }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; z-index: 3; }
.overlay span { font-size: .9rem; text-transform: uppercase; letter-spacing: .2em; color: var(--ink); font-weight: 600; opacity: .8; }
.overlay b {
  font-size: 5.5rem; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px var(--accent-glow)); animation: count 1s ease infinite;
}
@keyframes count { 0% { transform: scale(1.25); opacity: .3; } 25% { transform: scale(1); opacity: 1; } }
.found { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; max-height: 22vh; overflow-y: auto; }
.found li {
  display: flex; gap: 6px; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 13px; font-weight: 600; font-size: .88rem; letter-spacing: .04em; animation: rise .25s;
}
.found b { color: var(--good); font-size: .78rem; }

/* ---------- results ---------- */
.result-hero { text-align: center; padding: 14px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.result-hero p { margin: 0; }
.eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); font-weight: 600; }
.score-medal {
  width: 168px; height: 168px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, var(--surface-solid), transparent 75%), var(--surface);
  border: 1px solid var(--line); position: relative; margin: 6px 0;
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 8%, transparent), 0 0 60px -10px var(--accent-glow);
  animation: medal .6s cubic-bezier(.3, 1.5, .5, 1);
}
.score-medal::before {
  content: ''; position: absolute; inset: -4px; border-radius: 50%; padding: 4px;
  background: conic-gradient(from 200deg, #ff8a4c, #ff4d7a, #7c5cff, #19c3a6, #ff8a4c);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes medal { from { transform: scale(.5); opacity: 0; } }
.big-score {
  font-size: 4.3rem; font-weight: 700; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.score-medal small { font-size: .72rem; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips span {
  background: color-mix(in srgb, var(--good) 12%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--good) 28%, var(--line));
  border-radius: 99px; padding: 6px 13px; font-weight: 600; font-size: .88rem; letter-spacing: .03em;
}
.chips span sup { color: var(--good); margin-left: 4px; font-size: .72rem; }
.muted-chips span { color: var(--muted); font-weight: 500; background: var(--surface-2); border-color: var(--line); }
.chips .gone { opacity: .45; text-decoration: line-through; text-decoration-color: var(--faint); }
.banner {
  flex-direction: row; align-items: center; justify-content: space-between; font-weight: 600;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent), var(--shadow);
}
.actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; padding-top: 4px; }
.standing-words { display: block; font-size: .76rem; color: var(--muted); white-space: normal; font-weight: 500; letter-spacing: .03em; margin-top: 2px; }

/* ---------- bottom nav ---------- */
.tabs {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); transform: translateX(-50%); z-index: 10;
  width: min(calc(100% - 24px), 480px); display: flex; justify-content: space-around; padding: 6px;
  background: color-mix(in srgb, var(--surface-solid) 82%, transparent); border: 1px solid var(--line); border-radius: 28px;
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 16px 40px -12px rgba(20, 10, 60, .45);
}
body.no-nav .tabs { display: none; }
.tabs button {
  flex: 1; height: calc(var(--nav-h) - 14px); border: 0; background: none; cursor: pointer; color: var(--muted); border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
  transition: color .2s, background .2s;
}
.tabs button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s cubic-bezier(.3, 1.6, .5, 1); }
.tabs button svg .fill { fill: currentColor; }
.tabs button small { font-size: .7rem; font-weight: 600; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tabs button.on svg { transform: translateY(-1px) scale(1.08); }

/* ---------- dialogs & toasts ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 26px; background: var(--surface-solid); color: var(--ink); padding: 22px;
  width: min(92vw, 460px); box-shadow: 0 30px 80px -20px rgba(10, 5, 40, .6);
}
dialog[open] { animation: pop-in .3s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes pop-in { from { opacity: 0; transform: scale(.92) translateY(10px); } }
dialog::backdrop { background: rgba(12, 8, 40, .5); backdrop-filter: blur(4px); }
dialog h2 { font-size: 1.35rem; }
dialog h3 { margin-top: 16px; }
dialog form { margin-top: 16px; display: flex; }
dialog form .btn { flex: 1; }
#dlg-howto ol { padding: 0; margin: 14px 0 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
#dlg-howto li { counter-increment: step; display: flex; gap: 12px; line-height: 1.45; }
#dlg-howto li::before {
  content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bot)); color: var(--tile-ink); font-weight: 700;
  box-shadow: 0 3px 0 var(--tile-edge);
}
.sheet { display: none; flex-direction: column; gap: 14px; }
.sheet[open] { display: flex; }
.sheet form { margin: 0; }
.score-table { width: 100%; border-collapse: separate; border-spacing: 0 4px; margin-top: 8px; }
.score-table td { padding: 7px 10px; background: var(--surface-2); }
.score-table td:first-child { border-radius: 10px 0 0 10px; }
.score-table td:last-child { text-align: right; font-weight: 700; color: var(--good); border-radius: 0 10px 10px 0; }

.toasts {
  position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px;
}
.toast {
  pointer-events: auto; background: color-mix(in srgb, var(--surface-solid) 92%, transparent); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; padding: 10px 12px 10px 16px; font-weight: 600;
  box-shadow: 0 16px 40px -12px rgba(10, 5, 40, .5); backdrop-filter: blur(16px);
  display: flex; gap: 10px; align-items: center; max-width: 480px; animation: toast-in .35s cubic-bezier(.3, 1.4, .5, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.95); } }
.toast .btn { padding: 7px 11px; font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Google sign-in (Google brand guidelines: white button, coloured G) ---------- */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  padding: 12px 16px; border-radius: 15px; border: 1px solid #dadce0; background: #fff; color: #1f1f1f;
  font: 600 1rem var(--font); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background .15s, box-shadow .15s, transform .12s;
}
.google-btn:hover { background: #f8f9fa; box-shadow: 0 2px 10px rgba(60, 64, 67, .2); }
.google-btn:active { transform: scale(.98); }
.google-btn:disabled { opacity: .5; cursor: not-allowed; }
.google-btn svg { width: 20px; height: 20px; flex: none; }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
