/* ============================================================
   WORDL — world-class dark glass theme
   ============================================================ */
:root {
  color-scheme: dark;
  --bg-0: #070a14;
  --bg-1: #0b1020;
  --ink: #eef1ff;
  --ink-dim: #aab3d6;
  --ink-faint: #8b94ba;

  --glass: rgba(255, 255, 255, 0.045);
  --glass-strong: rgba(255, 255, 255, 0.08);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-bright: rgba(255, 255, 255, 0.18);

  --violet: #7c5cff;
  --cyan: #22d3ee;
  --magenta: #f472b6;
  --gold: #fbbf24;

  --correct: #2fd472;
  --correct-2: #1fa85a;
  --present: #f5b93e;
  --present-2: #d99a1c;
  --absent: #39415f;
  --absent-2: #262d47;

  --tile-bg: rgba(255, 255, 255, 0.03);
  --tile-stroke: rgba(255, 255, 255, 0.10);
  --key-bg: rgba(255, 255, 255, 0.07);
  --key-stroke: rgba(255, 255, 255, 0.06);

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --panel-pad: clamp(24px, 5vw, 36px);

  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;

  --tile-gap: clamp(5px, 1.3vw, 8px);
  --board-w: min(92vw, 420px);
  --tile: max(52px, min(calc((var(--board-w) - 4 * var(--tile-gap)) / 5), calc((100dvh - 380px) / 6)));
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scrollbar-gutter: stable both-edges; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: radial-gradient(1200px 800px at 70% -10%, #141a35 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* ---------- Ambient background ---------- */
.bg-aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; filter: saturate(1.2); }
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .5; mix-blend-mode: screen;
  will-change: transform;
}
.blob-1 { width: 58vmax; height: 58vmax; left: -20vmax; top: -22vmax;
  background: radial-gradient(circle at 30% 30%, rgba(124,92,255,.6), transparent 65%);
  animation: drift1 26s ease-in-out infinite alternate; }
.blob-2 { width: 46vmax; height: 46vmax; right: -18vmax; top: 10vmax;
  background: radial-gradient(circle at 60% 40%, rgba(34,211,238,.3), transparent 65%);
  animation: drift2 32s ease-in-out infinite alternate; }
.blob-3 { width: 46vmax; height: 46vmax; left: 20vw; bottom: -24vmax;
  background: radial-gradient(circle at 50% 50%, rgba(244,114,182,.35), transparent 65%);
  animation: drift3 38s ease-in-out infinite alternate; }

@keyframes drift1 { to { transform: translate(9vmax, 7vmax) rotate(40deg) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-8vmax, -6vmax) rotate(-30deg) scale(1.1); } }
@keyframes drift3 { to { transform: translate(6vmax, -9vmax) rotate(25deg) scale(1.2); } }

.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.016) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, black 20%, transparent 75%);
}

#confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ---------- Top bar ---------- */
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: clamp(12px, 2.4vw, 20px) clamp(14px, 3vw, 28px);
  position: relative; z-index: 5;
}
.brand {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(26px, 5vw, 34px); letter-spacing: .14em;
  display: flex; align-items: center; gap: 2px; user-select: none;
}
.brand-mark {
  width: 1.35em; height: 1.35em; border-radius: .32em;
  display: grid; place-items: center; margin-right: .18em;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  box-shadow: 0 6px 24px rgba(124,92,255,.45), inset 0 1px 0 rgba(255,255,255,.35);
  font-size: .78em; letter-spacing: 0; color: #fff;
}
.brand-text {
  background: linear-gradient(92deg, #fff 20%, #b9c4ff 60%, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; justify-self: end; }
.topbar-left { justify-self: start; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--stroke);
  color: #b8c0dd; display: grid; place-items: center;
  transition: all .2s ease; backdrop-filter: blur(8px);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--ink); border-color: var(--stroke-bright); background: var(--glass-strong); transform: translateY(-1px); }
#btn-sound .ico-off { display: none; }
#btn-sound.muted .ico-on { display: none; }
#btn-sound.muted .ico-off { display: block; }

.pill-btn {
  font-family: var(--font-display); font-weight: 600; font-size: 13.5px;
  padding: 11px 16px; border-radius: 12px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--stroke); color: #b8c0dd;
  transition: all .2s ease; backdrop-filter: blur(8px); letter-spacing: .02em;
}
.pill-btn:hover { color: var(--ink); border-color: var(--stroke-bright); background: var(--glass-strong); transform: translateY(-1px); }
.pill-glow {
  background: linear-gradient(135deg, rgba(124,92,255,.28), rgba(34,211,238,.22));
  border-color: rgba(124,92,255,.5); color: #dfe6ff;
  box-shadow: 0 0 0 0 rgba(124,92,255,0);
}
.pill-glow:hover {
  border-color: var(--violet); color: #fff;
  box-shadow: 0 6px 24px rgba(124,92,255,.35), inset 0 1px 0 rgba(255,255,255,.2);
}

/* ---------- Stage / board ---------- */
.stage { flex: 1; display: grid; place-items: center; padding: 8px 16px 4px; position: relative; z-index: 2; }
.game-wrap { display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3vh, 26px); width: calc(var(--tile) * 5 + var(--tile-gap) * 4); }

.board {
  display: grid; grid-template-columns: repeat(5, var(--tile)); grid-template-rows: repeat(6, var(--tile)); gap: var(--tile-gap);
  width: calc(var(--tile) * 5 + var(--tile-gap) * 4);
}

.tile { position: relative; perspective: 750px; border-radius: var(--radius-sm); width: var(--tile); height: var(--tile); }
.tile-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.34,.9,.4,1); will-change: transform; }
.tile.flipped .tile-inner { transform: rotateX(-180deg); }

.tile-face {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: calc(var(--tile) * .42);
  text-transform: uppercase; color: var(--ink);
  border-radius: var(--radius-sm);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: opacity .05s linear;
}
.tile-face.front {
  background: var(--tile-bg);
  border: 2px solid var(--tile-stroke);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.tile-face.back { transform: rotateX(180deg); border: 2px solid transparent; }

/* letter pop-in when typed */
.tile.filled .tile-face.front { animation: letterPop .18s cubic-bezier(.34,1.56,.64,1); }
@keyframes letterPop { 0% { transform: scale(.72); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }

/* flip reveal — canonical 3D card flip on .tile-inner (preserve-3d).
   Belt-and-suspenders: once settled, force the front face off so exactly one
   face is ever visible even if a renderer's backface culling misbehaves. */
.tile.settled .tile-face.front { opacity: 0; }

/* color states (on back face) */
.tile.correct .tile-face.back {
  background: linear-gradient(160deg, var(--correct), var(--correct-2));
  border-color: rgba(255,255,255,.25);
  box-shadow: 0 8px 24px rgba(47,212,114,.35), inset 0 1px 0 rgba(255,255,255,.3);
}
.tile.present .tile-face.back {
  background: linear-gradient(160deg, var(--present), var(--present-2));
  border-color: rgba(255,255,255,.25);
  box-shadow: 0 8px 24px rgba(245,185,62,.3), inset 0 1px 0 rgba(255,255,255,.3);
}
.tile.absent .tile-face.back {
  background: linear-gradient(160deg, var(--absent), var(--absent-2));
  border-color: rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

/* row shake */
.tile.shake { animation: tileShake .45s ease both; }
@keyframes tileShake {
  0%,100% { transform: translateX(0); }
  15% { transform: translateX(-7px); } 30% { transform: translateX(6px); }
  45% { transform: translateX(-5px); } 60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

/* win bounce — celebratory hop on the tile (inner stays flipped to back face) */
.tile.win-bounce { animation: tileWin .6s cubic-bezier(.34,1.56,.64,1); }
@keyframes tileWin {
  0%   { transform: translateY(0); }
  35%  { transform: translateY(calc(var(--tile) * -0.28)) scale(1.06); }
  70%  { transform: translateY(2px) scale(.98); }
  100% { transform: translateY(0) scale(1); }
}

/* ---------- Keyboard ---------- */
.keyboard {
  width: min(94vw, 560px);
  display: grid; grid-template-columns: repeat(20, 1fr); gap: 7px 6px; user-select: none;
}
.key {
  height: clamp(50px, 9vh, 62px);
  border-radius: var(--radius-sm); cursor: pointer;
  background: var(--key-bg); border: 1px solid var(--key-stroke);
  color: var(--ink); font-family: var(--font-display); font-weight: 600;
  font-size: clamp(13px, 2.4vw, 15px); text-transform: uppercase;
  display: grid; place-items: center; position: relative;
  transition: background .25s ease, color .25s ease, transform .08s ease, border-color .25s ease;
  backdrop-filter: blur(6px);
}
.key:hover { background: var(--glass-strong); }
.key.pressed { transform: scale(.9); filter: brightness(1.6); }

.key.st-correct { background: linear-gradient(160deg, var(--correct), var(--correct-2)); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(47,212,114,.3); }
.key.st-present { background: linear-gradient(160deg, var(--present), var(--present-2)); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(245,185,62,.25); }
.key.st-absent  { background: rgba(38,45,71,.9); border-color: transparent; color: var(--ink-faint); }

/* ---------- Footer ---------- */
.foot {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  color: var(--ink-faint); font-size: 12.5px; letter-spacing: .03em; z-index: 2;
}
.foot-date { color: var(--ink-dim); font-weight: 600; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; top: max(78px, env(safe-area-inset-top) + 70px); left: 50%;
  transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: rgba(13,17,32,.92); border: 1px solid var(--stroke-bright);
  color: var(--ink); font-weight: 600; font-size: 14px;
  padding: 12px 20px; border-radius: 14px; backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.03) inset;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  max-width: min(88vw, 420px); text-align: center;
}
.toast.out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.94); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.95); } }

/* ---------- Modals ---------- */
.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-root[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(4,6,14,.7);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal { position: relative; width: auto; max-width: 94vw; max-height: 88dvh; overflow-y: auto; scrollbar-width: thin; }
.panel-wide { width: min(94vw, 560px); }

.modal-panel {
  width: min(94vw, 460px);
  background: linear-gradient(165deg, rgba(24,30,54,.92), rgba(11,15,30,.94));
  border: 1px solid var(--stroke-bright);
  border-radius: var(--radius-lg); padding: var(--panel-pad);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08);
  animation: modalIn .38s cubic-bezier(.34,1.4,.64,1);
  position: relative;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(22px) scale(.96); } to { opacity: 1; transform: none; } }

.modal-x {
  position: absolute; top: var(--panel-pad); right: var(--panel-pad); width: 34px; height: 34px; margin-top: -6px;
  border-radius: 10px; border: 1px solid var(--stroke); background: var(--glass);
  color: var(--ink-dim); font-size: 20px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: all .2s ease;
}
.modal-x:hover { color: #fff; border-color: var(--stroke-bright); background: var(--glass-strong); }

.modal-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(21px, 4.5vw, 26px); letter-spacing: .01em; margin-bottom: 8px;
}
.modal-sub { color: var(--ink-dim); font-size: 14.5px; line-height: 1.55; margin-bottom: 20px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-dim); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.field input {
  width: 100%; padding: 14px 16px; border-radius: var(--radius-md);
  background: rgba(255,255,255,.05); border: 1px solid var(--stroke);
  color: var(--ink); font-family: var(--font-display); font-weight: 600; font-size: 17px;
  letter-spacing: .04em; outline: none; transition: all .2s ease;
}
.field input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124,92,255,.22); background: rgba(255,255,255,.07); }
.field input::placeholder { color: var(--ink-faint); font-weight: 400; }

.btn-primary {
  width: 100%; padding: 15px; border-radius: var(--radius-md); cursor: pointer;
  border: none; font-family: var(--font-display); font-weight: 700; font-size: 15.5px; letter-spacing: .03em;
  color: #fff; background: linear-gradient(135deg, var(--violet), #4f8cff 60%, var(--cyan));
  background-size: 180% 180%;
  box-shadow: 0 10px 30px rgba(124,92,255,.4), inset 0 1px 0 rgba(255,255,255,.3);
  transition: all .25s ease;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(124,92,255,.5), inset 0 1px 0 rgba(255,255,255,.3); background-position: 100% 50%; }
.btn-primary:active { transform: translateY(0) scale(.98); }

.btn-ghost {
  width: 100%; padding: 14px; border-radius: var(--radius-md); cursor: pointer;
  background: transparent; border: 1px solid var(--stroke); color: var(--ink-dim);
  font-family: var(--font-display); font-weight: 600; font-size: 14.5px; transition: all .2s ease;
}
.btn-ghost:hover { color: #fff; border-color: var(--stroke-bright); background: var(--glass); }

.modal-fineprint { margin-top: 14px; font-size: 12px; color: var(--ink-faint); text-align: center; }

/* stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 26px; }
.stat-cell {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius-md);
  padding: 16px 8px; text-align: center;
}
.stat-num { font-family: var(--font-display); font-weight: 800; font-size: clamp(22px, 5vw, 30px); line-height: 1.1; }
.stat-lbl { font-size: 11px; color: var(--ink-dim); letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }

.dist-wrap h3 { font-family: var(--font-display); font-size: 15px; font-weight: 700; margin-bottom: 12px; color: var(--ink-dim); letter-spacing: .04em; }
.dist-bars { display: flex; flex-direction: column; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 12px; }
.dist-bar {
  min-height: 30px; border-radius: 9px; padding: 4px 12px;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  background: linear-gradient(160deg, var(--correct), var(--correct-2)); color: #fff;
  border: 1px solid rgba(255,255,255,.2); white-space: nowrap; overflow: hidden;
}
.dist-bar.zero { background: var(--absent); border-color: var(--stroke); color: var(--ink-faint); }

/* leaderboard */
.board-rank-list { display: flex; flex-direction: column; gap: 8px; max-height: min(52dvh, 460px); overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.board-tabs { display: inline-flex; gap: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--stroke); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.board-tab { border: none; background: transparent; color: var(--ink-dim); font-family: var(--font-display); font-weight: 600; font-size: 13px; padding: 8px 16px; border-radius: 9px; cursor: pointer; transition: all .2s ease; letter-spacing: .02em; }
.board-tab:hover { color: var(--ink); }
.board-tab.active { background: linear-gradient(135deg, rgba(124,92,255,.85), rgba(79,140,255,.85)); color: #fff; box-shadow: 0 4px 14px rgba(124,92,255,.35); }
.rank-row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius-md);
  padding: 12px 16px; transition: all .2s ease;
}
.rank-row:hover { background: var(--glass-strong); border-color: var(--stroke-bright); transform: translateX(3px); }
.rank-row.me { border-color: rgba(124,92,255,.7); background: linear-gradient(90deg, rgba(124,92,255,.2), rgba(124,92,255,.05) 60%, transparent); box-shadow: 0 0 28px rgba(124,92,255,.22), inset 0 0 0 1px rgba(124,92,255,.25); }
.rank-num { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--ink-dim); text-align: center; display: grid; place-items: center; }
/* CSS medal badges — consistent across all platforms (no emoji) */
.medal {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; font-weight: 800; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 3px 10px rgba(0,0,0,.3);
}
.medal.m1 { background: radial-gradient(circle at 35% 30%, #ffe27a, #f4b400 60%, #c8860a); color: #6b4e00; }
.medal.m2 { background: radial-gradient(circle at 35% 30%, #eef2ff, #b9c2d8 60%, #8b95ad); color: #454e63; }
.medal.m3 { background: radial-gradient(circle at 35% 30%, #f4bd8a, #cf7f3e 60%, #9c5a22); color: #4a2c0d; }
.you-tag { opacity: .7; font-size: 12px; color: var(--ink-dim); font-weight: 600; }
.rank-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: #cdd6ff; }
.board-empty { text-align: center; color: var(--ink-faint); padding: 34px 0; font-size: 14.5px; line-height: 1.6; }

/* help */
.help-line { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; color: var(--ink-dim); font-size: 14.5px; line-height: 1.5; }
.tile-demo {
  width: 40px; height: 40px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; color: #fff;
}
.t-correct { background: linear-gradient(160deg, var(--correct), var(--correct-2)); }
.t-present { background: linear-gradient(160deg, var(--present), var(--present-2)); }
.t-absent { background: linear-gradient(160deg, var(--absent), var(--absent-2)); color: var(--ink-dim); }
.help-fine { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--stroke); color: var(--ink-faint); font-size: 13px; line-height: 1.6; }

/* result */
.result-hero { text-align: center; margin-bottom: 20px; }
.result-badge {
  width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, rgba(124,92,255,.5), rgba(34,211,238,.25));
  border: 1px solid rgba(124,92,255,.6);
  box-shadow: 0 0 50px rgba(124,92,255,.4), inset 0 1px 0 rgba(255,255,255,.3);
  animation: badgePop .6s cubic-bezier(.34,1.56,.64,1) both;
}
.result-badge svg { width: 40px; height: 40px; }
.result-badge.streak { background: radial-gradient(circle at 35% 30%, rgba(245,185,62,.5), rgba(244,114,182,.3)); border-color: rgba(245,185,62,.6); box-shadow: 0 0 50px rgba(245,185,62,.35), inset 0 1px 0 rgba(255,255,255,.3); }
.result-badge.lose { background: radial-gradient(circle at 35% 30%, rgba(93,102,140,.4), rgba(38,45,71,.5)); border-color: rgba(154,163,199,.4); box-shadow: 0 0 40px rgba(93,102,140,.25), inset 0 1px 0 rgba(255,255,255,.15); color: var(--ink-dim); }
@keyframes badgePop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.result-word-row { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; }
.result-label { font-size: 13px; color: var(--ink-dim); letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.result-tiles { display: flex; gap: 5px; }
.rt {
  width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 19px; color: #fff; text-transform: uppercase;
}
.rt-correct { background: linear-gradient(160deg, var(--correct), var(--correct-2)); }
.rt-present { background: linear-gradient(160deg, var(--present), var(--present-2)); }
.rt-absent { background: linear-gradient(160deg, var(--absent), var(--absent-2)); color: var(--ink-dim); }

.result-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Light theme ---------- */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg-0: #eef0f8;
    --bg-1: #ffffff;
    --ink: #1a2033;
    --ink-dim: #4a5472;
    --ink-faint: #6f7a99;

    --glass: rgba(10, 14, 30, 0.04);
    --glass-strong: rgba(10, 14, 30, 0.07);
    --stroke: rgba(10, 14, 30, 0.09);
    --stroke-bright: rgba(10, 14, 30, 0.16);

    --absent: #d6dbe8;
    --absent-2: #c3c9d9;

    --tile-bg: rgba(255, 255, 255, 0.7);
    --tile-stroke: rgba(10, 14, 30, 0.14);
    --key-bg: rgba(255, 255, 255, 0.85);
    --key-stroke: rgba(10, 14, 30, 0.09);
  }

  body {
    background: radial-gradient(1200px 800px at 70% -10%, #dfe4f4 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  }

  /* aurora blobs: soft tints instead of glow, so they don't wash out */
  .blob { opacity: .28; mix-blend-mode: multiply; }
  .blob-1 { background: radial-gradient(circle at 30% 30%, rgba(124,92,255,.45), transparent 65%); }
  .blob-2 { background: radial-gradient(circle at 60% 40%, rgba(34,211,238,.35), transparent 65%); }
  .blob-3 { background: radial-gradient(circle at 50% 50%, rgba(244,114,182,.32), transparent 65%); }

  .bg-grid {
    background-image:
      linear-gradient(rgba(10,14,30,.05) 1px, transparent 1px),
      linear-gradient(90deg, rgba(10,14,30,.05) 1px, transparent 1px);
  }

  /* brand: white text is invisible on light → darker gradient */
  .brand-text {
    background: linear-gradient(92deg, var(--ink) 20%, #4a5472 60%, var(--violet));
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }

  .icon-btn, .pill-btn { color: var(--ink-dim); }
  .icon-btn:hover, .pill-btn:hover { color: var(--ink); }
  .pill-glow { color: var(--ink); border-color: rgba(124,92,255,.55); background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(34,211,238,.14)); }

  .board-tabs { background: rgba(10,14,30,.05); }

  .key.st-absent { background: var(--absent); color: var(--ink-dim); }
  .key.st-correct, .key.st-present { color: #fff; }

  .dist-bar.zero { color: var(--ink-faint); }

  .tile-face.front {
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
  }
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 480px) {
  :root { --board-w: min(94vw, 360px); }
  .topbar { grid-template-columns: auto auto auto; gap: 8px; padding: 12px 12px; }
  .brand { font-size: 21px; letter-spacing: .1em; justify-self: center; }
  .pill-btn { padding: 9px 10px; font-size: 11.5px; }
  .icon-btn { width: 36px; height: 36px; }
  .key { border-radius: 8px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  .tile-inner { transition-duration: .01s; }
  .tile.filled .tile-face.front, .tile.shake, .tile.win-bounce { animation: none; }
  * { scroll-behavior: auto; }
}
