/* app.css - VocabApp: a calm, macOS-like app with card-game accents on the game screens.
   Drafted with help from Claude (AI); reviewed and modified by the team. */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f9f9fb;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --accent: #1f7a57;
  --accent-hover: #186347;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ea;
  --gold: #c99a2e;
  --gold-soft: #f7ecd2;
  --good: #2e8b57;
  --mid: #d39a2f;
  --bad: #d2453a;
  --ivory: #f7f1e1;
  --ink: #1d2433;
  --rule: #b8322a;
  --felt: #1e5143;
  --felt-deep: #153b30;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.06);
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 14px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121314;
  --surface: #1c1d1f;
  --surface-2: #232427;
  --text: #f2f2f4;
  --muted: #9a9aa1;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #3fb37e;
  --accent-hover: #4cc58d;
  --accent-ink: #08170f;
  --accent-soft: rgba(63, 179, 126, 0.15);
  --gold-soft: rgba(201, 154, 46, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-pop: 0 30px 70px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
kbd {
  font-family: var(--sans); font-size: 0.72rem; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 0.05rem 0.4rem; background: var(--surface-2);
}
.icon { display: inline-flex; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; justify-content: center; }
.lead { color: var(--muted); font-size: 1.02rem; margin-top: 0.35rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--surface); padding: 0.5rem 1rem; border-radius: 8px; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.gap { gap: 0.6rem; }
.row.end { justify-content: flex-end; margin-top: 1.5rem; }

/* ---------- Buttons, fields, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 0.6rem 1rem; border-radius: 10px; font-weight: 550; font-size: 0.93rem;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { padding: 0.42rem 0.8rem; font-size: 0.85rem; border-radius: 9px; }
.btn.big { padding: 0.85rem 1.5rem; font-size: 1.02rem; border-radius: 12px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.again { color: var(--bad); }
.btn kbd { margin-left: 0.3rem; }
.icon-btn { border: 0; background: transparent; padding: 0.45rem; border-radius: 9px; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: var(--line); color: var(--text); }
.field {
  width: 100%; padding: 0.7rem 0.9rem; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 1rem;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.label { display: block; font-size: 0.85rem; font-weight: 550; margin-bottom: 0.35rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px;
  padding: 0.35rem 0.8rem; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.35rem;
}
.chip small { color: var(--muted); }
.chip.toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tag { font-size: 0.72rem; color: var(--muted); background: var(--line); border-radius: 6px; padding: 0.05rem 0.45rem; white-space: nowrap; }
.level { font-size: 0.7rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 0.05rem 0.4rem; margin-left: 0.4rem; }
.badge { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; font-weight: 600; color: var(--muted);
  background: var(--line); padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.badge.ok { color: var(--accent); background: var(--accent-soft); }
.coin-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.notice { display: flex; gap: 0.6rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.8rem 1rem; margin: 1rem 0; }
.notice.warn { background: var(--gold-soft); border-color: transparent; color: var(--text); }
.switch { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent-soft); }
.bar { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar.gold i { background: var(--gold); }
.bar.good i { background: var(--good); }
.bar.mid i { background: var(--mid); }
.bar.bad i { background: var(--bad); }

/* ---------- Top bar (translucent, like macOS) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 58px; padding: 0 max(1.2rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--text); font-weight: 700; font-size: 1.02rem; text-decoration: none !important; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 1rem;
}
.brand-mark.big { width: 56px; height: 56px; border-radius: 16px; font-size: 1.8rem; margin: 0 auto 1.2rem; }
.nav { display: flex; gap: 0.2rem; }
.nav a { color: var(--muted); padding: 0.4rem 0.75rem; border-radius: 8px; font-size: 0.92rem; font-weight: 550; text-decoration: none; }
.nav a:hover { color: var(--text); background: var(--line); }
.nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.top-right { display: flex; align-items: center; gap: 0.5rem; }
.search-btn {
  display: inline-flex; align-items: center; gap: 0.45rem; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); border-radius: 9px; padding: 0.38rem 0.5rem 0.38rem 0.65rem; font-size: 0.88rem;
}
.search-btn:hover { border-color: var(--line-strong); color: var(--text); }
.coins-top { color: var(--text); padding: 0.3rem 0.55rem; border-radius: 9px; text-decoration: none !important; }
.coins-top:hover { background: var(--line); }
.avatar-btn { position: relative; text-decoration: none !important; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #5fae8a, #1f7a57); color: #fff; font-weight: 700; font-size: 0.9rem;
}
.avatar.sm { width: 26px; height: 26px; font-size: 0.78rem; }
.avatar.bot { background: linear-gradient(135deg, #8b93a7, #5b6478); }
.guest-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid var(--bg); }

/* ---------- Pages ---------- */
.main { outline: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.2rem; box-shadow: var(--shadow); }
.panel.center { display: grid; gap: 0.9rem; justify-items: center; text-align: center; padding: 2rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; }
.back { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.8rem; }
.wallet { display: grid; justify-items: end; font-size: 1.3rem; }

/* ---------- Welcome ---------- */
.welcome { min-height: calc(100vh - 58px); display: grid; place-items: center; padding: 2rem 1.2rem; }
.welcome-card { max-width: 460px; width: 100%; text-align: center; display: grid; gap: 0.9rem; }
.welcome-card h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.welcome-card .label { text-align: left; margin-top: 0.8rem; }
.welcome-card .row { flex-wrap: nowrap; }

/* ---------- Home ---------- */
.hello { text-align: center; padding: 1.5rem 0 2rem; }
.hello h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.hero-search {
  margin: 1.4rem auto 0; width: min(620px, 100%); display: flex; align-items: center; gap: 0.7rem;
  padding: 0.95rem 1.1rem; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 1.05rem; box-shadow: var(--shadow); text-align: left; transition: box-shadow 0.2s, transform 0.2s;
}
.hero-search:hover { box-shadow: var(--shadow-pop); transform: translateY(-1px); }
.hero-search span { flex: 1; }
.dash { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; grid-auto-flow: row dense; }
.wide-2 { grid-column: span 2; }
.today { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.8rem; }
.big-line { font-weight: 650; font-size: 1.05rem; }
.ring { position: relative; width: 88px; height: 88px; flex: none; }
.ring svg { display: block; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; }
.ring-num small { font-size: 0.7rem; color: var(--muted); font-weight: 500; }
.ring-num { grid-auto-flow: column; align-content: center; justify-content: center; }
.streak { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.streak.on { color: #e0742b; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.stats > div { display: grid; }
.stats b { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.stats span { font-size: 0.78rem; color: var(--muted); }
.stats.big { grid-template-columns: repeat(4, 1fr); margin: 1.2rem 0; }
.unlock { display: grid; gap: 0.45rem; }
.unlock-top { display: flex; justify-content: space-between; font-size: 0.88rem; }
.acc-list { list-style: none; padding: 0; margin: 0.9rem 0; display: grid; gap: 0.55rem; }
.acc-list li { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 3rem; align-items: center; gap: 0.7rem; font-size: 0.9rem; }
.acc-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.weak-words { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.4rem 0 0.9rem; }
.recent { list-style: none; margin: 0 0 0.8rem; padding: 0; display: grid; gap: 0.5rem; }
.recent li { display: grid; grid-template-columns: 1fr auto auto; gap: 0.2rem 0.7rem; font-size: 0.88rem; align-items: center; }
.recent .muted { grid-column: 1 / -1; margin-top: -0.3rem; font-size: 0.75rem; }
.rg-place { font-weight: 600; }
.rg-coins { color: var(--gold); font-weight: 650; }
.rank-pill { font-size: 0.78rem; font-weight: 650; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 0.15rem 0.6rem; }
.mini-board { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.15rem; }
.mini-board li { display: grid; grid-template-columns: 1.6rem 1fr auto; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 8px; font-size: 0.9rem; }
.mini-board li.me { background: var(--accent-soft); font-weight: 600; }
.mb-rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.mb-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.tile {
  display: grid; gap: 0.4rem; padding: 1.4rem; border-radius: 18px; color: #fff; text-decoration: none !important;
  box-shadow: var(--shadow); position: relative; overflow: hidden; min-height: 170px; transition: transform 0.15s, box-shadow 0.2s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.tile.play { background: radial-gradient(circle at 85% 10%, #2f7a60 0%, var(--felt) 45%, var(--felt-deep) 100%); }
.tile.learn { background: linear-gradient(140deg, #2d3d6b, #1d2a4f); }
.tile h2 { font-size: 1.3rem; }
.tile p { color: rgba(255, 255, 255, 0.78); max-width: 36ch; }
.tile-icon { width: 46px; height: 46px; border-radius: 12px; background: rgba(255, 255, 255, 0.14); display: grid; place-items: center; margin-bottom: 0.3rem; }
.tile-go { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 650; margin-top: 0.4rem; }
.lib-strip { display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 0.4rem; scroll-snap-type: x proximity; }
.lib-mini {
  flex: none; width: 180px; scroll-snap-align: start; display: grid; gap: 0.2rem; padding: 0.8rem 0.9rem;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration: none !important;
}
.lib-mini.locked { color: var(--muted); }
.lm-name { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.lm-price { display: inline-flex; gap: 0.3rem; align-items: center; font-size: 0.8rem; color: var(--gold); font-weight: 600; }

/* ---------- Library, learn ---------- */
.lib-group { margin-bottom: 1.8rem; }
.group-title { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin-bottom: 0.7rem; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.9rem; }
.lib-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.05rem; display: grid; gap: 0.55rem; box-shadow: var(--shadow); text-align: left; }
.lib-card.locked { background: var(--surface-2); box-shadow: none; }
.lib-card.pick { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.lib-card.pick.picked { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; }
.lc-price { font-size: 1.15rem; }

/* Index cards (game and learning) */
.index-card {
  position: relative; background: var(--ivory); color: var(--ink); border-radius: 14px; border: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), 0 12px 28px rgba(0, 0, 0, 0.18); text-align: left;
  background-image: linear-gradient(var(--ivory), var(--ivory)), repeating-linear-gradient(to bottom, transparent 0 25px, rgba(52, 86, 160, 0.16) 25px 26px);
  background-size: 100% 44px, 100% 100%; background-repeat: no-repeat, repeat; background-position: 0 0, 0 44px;
}
.index-card::before { content: ""; position: absolute; left: 0; right: 0; top: 42px; height: 2px; background: var(--rule); opacity: 0.8; }
.ic-subject { display: block; font-size: 0.75rem; color: #5b6272; padding: 13px 18px 0; height: 42px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Flashcards */
.fc-stage { display: grid; gap: 1rem; margin-top: 1.2rem; }
.fc-progress { display: grid; grid-template-columns: auto 1fr auto; gap: 0.8rem; align-items: center; font-size: 0.88rem; }
.fc { border: 0; background: none; padding: 0; perspective: 1400px; height: 300px; width: 100%; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.2, 1); transform-style: preserve-3d; }
.fc.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; }
.fc-face.back { transform: rotateY(180deg); }
.fc-word { font-family: var(--serif); font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 600; padding: 2.6rem 24px 0; }
.fc-pos { font-family: var(--serif); font-style: italic; color: #5b6272; padding: 0.2rem 24px; }
.fc-hint { margin-top: auto; padding: 0 24px 18px; color: #7a7f8a; }
.fc-def { font-size: 1.15rem; line-height: 26px; padding: 13px 24px 0; }
.fc-ex { font-family: var(--serif); font-style: italic; color: #5b6272; padding: 12px 24px 0; line-height: 26px; }
.fc-actions { display: flex; gap: 0.7rem; justify-content: center; }

/* Practice quiz + game questions */
.quiz-box { display: grid; gap: 1rem; margin-top: 1.4rem; }
.quiz-top { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--muted); }
.question-card { min-height: 170px; padding-bottom: 1.2rem; width: 100%; }
.qc-def { font-size: 1.15rem; line-height: 26px; padding: 14px 22px 0; }
.qc-letter { padding: 10px 22px 0; color: var(--rule); font-weight: 600; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; width: 100%; }
.option {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 12px; padding: 0.9rem 1rem;
  font-family: var(--serif); font-weight: 600; font-size: 1.05rem; text-align: left; transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.option:hover:enabled { border-color: var(--accent); transform: translateY(-1px); }
.option:disabled { cursor: default; }
.option.picked { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { background: var(--good); border-color: var(--good); color: #fff; }
.option.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
.option.removed { opacity: 0.3; text-decoration: line-through; }
.hints { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.result { display: grid; gap: 0.6rem; justify-items: center; text-align: center; }
.result-line { font-weight: 650; font-size: 1.08rem; text-align: center; }
.result-line.good, .result.good .result-line { color: var(--good); }
.result-line.bad, .result.bad .result-line { color: var(--bad); }
.timer { width: 100%; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.timer i { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left; transition: transform 0.1s linear; }
.timer.hurry i { background: var(--bad); }

/* ---------- Play setup ---------- */
.step { display: flex; align-items: center; gap: 0.55rem; margin: 1.6rem 0 0.8rem; font-size: 1.05rem; }
.step span { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 0.8rem; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; }
.choice {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 0.2rem 0.8rem; align-items: center; text-align: left;
  padding: 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.choice:hover { border-color: var(--line-strong); }
.choice.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice-icon { grid-row: span 2; width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.choice-name { font-weight: 650; }
.choice-text { grid-column: 2; font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.start-row { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; margin-top: 2rem; }
.join { display: flex; align-items: center; gap: 0.5rem; }
.code-field { width: 110px; text-transform: uppercase; letter-spacing: 0.25em; font-weight: 700; text-align: center; }

/* ---------- Game table ---------- */
.page.game { max-width: 980px; padding-top: 1.2rem; }
.table-wrap { display: grid; gap: 0.8rem; }
.table-top { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.table-top > div { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.mode-pill { font-weight: 700; }
.code-pill { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; background: var(--gold-soft); color: var(--gold); border-radius: 999px; padding: 0.15rem 0.6rem; }
.scoreboard { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
.seat { position: relative; display: flex; align-items: center; gap: 0.45rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.45rem 0.6rem; min-width: 0; box-shadow: var(--shadow); }
.seat.me { border-color: var(--accent); }
.seat.thrower { box-shadow: 0 0 0 2px var(--gold); }
.seat.left { opacity: 0.45; }
.seat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.86rem; font-weight: 550; }
.seat-score { font-weight: 750; font-variant-numeric: tabular-nums; }
.st { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; flex: none; }
.st.done { background: var(--good); color: #fff; }
.st.wait { color: var(--muted); }
.seat-time { position: absolute; right: 8px; bottom: -9px; font-size: 0.7rem; font-weight: 700; background: var(--surface); border-radius: 6px; padding: 0 0.3rem; }
.seat-time.good { color: var(--good); } .seat-time.bad { color: var(--bad); }
.float { position: absolute; right: 8px; top: -12px; font-weight: 800; color: var(--gold); animation: floatUp 1.6s ease-out forwards; }
.felt {
  border-radius: 22px; padding: clamp(1rem, 3vw, 2rem); min-height: 440px; display: grid; align-items: center;
  background: radial-gradient(ellipse at 50% 30%, #2a6b57 0%, var(--felt) 50%, var(--felt-deep) 100%);
  color: #f1ead6; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), var(--shadow);
}
.felt .lead, .felt .muted { color: rgba(241, 234, 214, 0.75); }
.felt .option { background: #fbf7ec; color: var(--ink); border-color: transparent; box-shadow: 0 3px 0 #e2d8bd; }
.felt .option.correct { background: var(--good); color: #fff; box-shadow: 0 3px 0 #1d6340; }
.felt .option.wrong { background: var(--bad); color: #fff; box-shadow: 0 3px 0 #8b2a1d; }
.felt .option.picked { background: #fff1c8; box-shadow: 0 0 0 3px var(--gold); }
.felt .timer { background: rgba(0, 0, 0, 0.3); }
.felt .timer i { background: #e4b547; }
.felt .result-line.good { color: #8ee0b2; } .felt .result-line.bad { color: #ffb0a5; }
.felt .btn:not(.primary) { background: rgba(255, 255, 255, 0.08); color: #f1ead6; border-color: rgba(255, 255, 255, 0.2); }
.center-col { display: grid; gap: 1rem; justify-items: center; width: min(640px, 100%); margin: 0 auto; }
.game-log { text-align: center; color: var(--muted); font-size: 0.85rem; }
.land { animation: land 0.45s cubic-bezier(0.2, 0.8, 0.2, 1.1); }
.pile { position: relative; width: 120px; height: 160px; }
.pile i { position: absolute; inset: 0; border-radius: 12px; background:
  repeating-linear-gradient(45deg, transparent 0 7px, rgba(212, 169, 60, 0.28) 7px 8px),
  repeating-linear-gradient(-45deg, transparent 0 7px, rgba(212, 169, 60, 0.28) 7px 8px), #22305a;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), inset 0 0 0 3px #f7f1e1, inset 0 0 0 5px #22305a; }
.pile i:nth-child(1) { transform: rotate(-7deg) translate(-6px, 3px); }
.pile i:nth-child(2) { transform: rotate(4deg) translate(5px, 1px); }
.hand { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; }
.hand-card { width: 170px; min-height: 210px; padding-bottom: 12px; cursor: pointer; transform: rotate(var(--tilt)); transition: transform 0.15s; display: flex; flex-direction: column; }
.hand-card:hover { transform: translateY(-8px) rotate(0); }
.hc-word { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; padding: 12px 16px 0; }
.hc-def { font-size: 0.8rem; line-height: 26px; padding: 0 16px; color: #2e3546; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.lobby { display: grid; gap: 1.2rem; justify-items: center; width: min(680px, 100%); margin: 0 auto; }
.lobby-code { display: grid; justify-items: center; gap: 0.3rem; }
.lobby-code strong { font-family: var(--serif); font-size: 3rem; letter-spacing: 0.2em; color: #fbf7ec; }
.seats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; width: 100%; }
.seat-card { display: grid; justify-items: center; gap: 0.35rem; padding: 0.9rem 0.5rem; border-radius: 14px; background: rgba(0, 0, 0, 0.18); text-align: center; font-size: 0.88rem; overflow-wrap: anywhere; }
.seat-card.empty { border: 1.5px dashed rgba(255, 255, 255, 0.2); background: transparent; color: rgba(241, 234, 214, 0.55); align-content: center; }
.lobby-settings { display: grid; gap: 0.9rem; justify-items: center; }
.felt .chip { background: rgba(0, 0, 0, 0.2); color: #f1ead6; border-color: transparent; }
.felt .chip.toggle.on { background: #fbf7ec; color: var(--ink); }
.segmented { display: inline-flex; background: var(--line); border-radius: 11px; padding: 3px; gap: 2px; margin-bottom: 1rem; flex-wrap: wrap; }
.segmented a, .segmented button { border: 0; background: transparent; padding: 0.45rem 0.95rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 0.9rem; text-decoration: none !important; }
.segmented .on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.felt .segmented { background: rgba(0, 0, 0, 0.22); margin: 0; }
.felt .segmented button { color: rgba(241, 234, 214, 0.75); }
.felt .segmented .on { background: #fbf7ec; color: var(--ink); }
.match { display: grid; gap: 0.8rem; width: 100%; }
.match-head { display: flex; justify-content: space-between; gap: 0.6rem; font-weight: 600; flex-wrap: wrap; }
.match-cols { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr); gap: 0.8rem; align-items: start; }
.match-words, .match-defs { display: grid; gap: 0.45rem; }
.mw, .md { border: 0; border-radius: 10px; background: #fbf7ec; color: var(--ink); text-align: left; padding: 0.6rem 0.8rem; box-shadow: 0 2px 0 #e2d8bd; transition: transform 0.1s; }
.mw { font-family: var(--serif); font-weight: 700; }
.md { font-size: 0.85rem; line-height: 1.35; }
.mw.on { background: #e4b547; box-shadow: 0 2px 0 #b5862a; transform: translateX(4px); }
.md:hover { transform: translateY(-1px); }
.shake { animation: shake 0.4s; background: #ffb0a5 !important; }
.results { text-align: center; }
.big-title { font-size: clamp(1.8rem, 5vw, 2.6rem); font-family: var(--serif); color: #fbf7ec; }
.podium { list-style: none; padding: 0; margin: 0; width: 100%; display: grid; gap: 0.5rem; }
.podium li { display: grid; grid-template-columns: 2rem 1fr auto auto; gap: 0.8rem; align-items: center; background: #fbf7ec; color: var(--ink); border-radius: 12px; padding: 0.65rem 1rem; text-align: left; }
.podium li:first-child { box-shadow: 0 0 0 3px #e4b547; }
.podium li.me .pd-name { font-weight: 700; }
.pd-place { font-family: var(--serif); font-weight: 800; color: var(--rule); font-size: 1.2rem; }
.pd-detail { color: #6b6f7a; }
.pd-score { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.waiting { gap: 1rem; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }

/* ---------- Leaderboard ---------- */
.board { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; }
.board li { display: grid; grid-template-columns: 2.6rem 1fr auto; align-items: center; gap: 0.6rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 1rem; }
.board li.me { border-color: var(--accent); background: var(--accent-soft); }
.b-rank { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.b-name { font-weight: 600; }
.b-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.b-val small { font-weight: 500; color: var(--muted); }
.medal { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 0.85rem; }
.top1 .medal { background: #d4a93c; } .top2 .medal { background: #9aa3b0; } .top3 .medal { background: #b8763f; }

/* ---------- Account ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.4rem; align-items: start; }
.form { display: grid; gap: 0.9rem; }
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }

/* ---------- Word card (Spotlight + favourites) ---------- */
.word-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: grid; gap: 0.7rem; align-content: start; }
.wc-head { display: flex; justify-content: space-between; gap: 0.8rem; align-items: flex-start; }
.wc-word { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; }
.wc-meta { color: var(--muted); font-style: italic; font-family: var(--serif); display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.wc-meta .tag, .wc-meta .level { font-style: normal; font-family: var(--sans); }
.wc-defs { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.4rem; }
.wc-examples { display: grid; gap: 0.3rem; border-left: 3px solid var(--accent-soft); padding-left: 0.8rem; }
.wc-examples p { font-family: var(--serif); font-style: italic; color: var(--muted); }
.fav-btn.on { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.wc-lock { display: grid; gap: 0.6rem; justify-items: start; color: var(--muted); }

/* ---------- Spotlight ---------- */
.spot-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.18); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fadeIn 0.14s ease; }
.spotlight {
  position: fixed; z-index: 41; left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(780px, calc(100vw - 2rem)); max-height: 72vh; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-pop); overflow: hidden;
  animation: popIn 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.spot-backdrop.closing { animation: fadeOut 0.14s ease forwards; }
.spotlight.closing { animation: popOut 0.14s ease forwards; }
.spot-bar { display: flex; align-items: center; gap: 0.7rem; padding: 0.95rem 1.1rem; color: var(--muted); }
.spot-input { flex: 1; border: 0; background: transparent; font-size: 1.35rem; outline: none; color: var(--text); min-width: 0; }
.spot-input::-webkit-search-cancel-button { display: none; }
.spot-esc { cursor: pointer; }
.spot-body { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr); border-top: 1px solid var(--line); min-height: 0; flex: 1; }
.spot-body:has(.spot-empty) { display: block; }
.spot-empty { padding: 1.6rem 1.2rem; display: grid; gap: 0.3rem; }
.spot-list { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; max-height: 58vh; border-right: 1px solid var(--line); }
.spot-group { font-size: 0.72rem; font-weight: 700; color: var(--muted); padding: 0.6rem 0.6rem 0.25rem; }
.spot-row { display: flex; align-items: center; gap: 0.45rem; padding: 0.5rem 0.6rem; border-radius: 9px; cursor: pointer; color: var(--muted); }
.spot-row.active { background: var(--accent); color: var(--accent-ink); }
.spot-row.active .spot-pos, .spot-row.active .tag { color: inherit; background: rgba(255, 255, 255, 0.18); }
.spot-word { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-row.active .spot-word { color: inherit; }
.spot-pos { font-size: 0.78rem; font-style: italic; }
.spot-row .tag { margin-left: auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.fav-dot { color: var(--gold); display: inline-flex; }
.spot-row.active .fav-dot { color: inherit; }
.spot-toggle-row { padding: 0.5rem 0.6rem; }
.spot-preview { overflow-y: auto; max-height: 58vh; padding: 0.8rem; }
.spot-preview .word-card { border: 0; padding: 0.4rem 0.5rem; background: transparent; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 160%);
  background: var(--text); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 12px; font-weight: 550; font-size: 0.92rem;
  box-shadow: var(--shadow-pop); z-index: 60; max-width: min(92vw, 480px); transition: transform 0.25s ease, opacity 0.25s; opacity: 0; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--bad); color: #fff; }

/* ---------- Motion ---------- */
@keyframes popIn { from { opacity: 0; transform: translateX(-50%) scale(0.96); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes popOut { to { opacity: 0; transform: translateX(-50%) scale(0.97); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes land { from { transform: translateY(-60px) rotate(-6deg) scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes floatUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Tablets and phones ---------- */
@media (max-width: 900px) {
  .dash { grid-template-columns: 1fr 1fr; }
  .wide-2 { grid-column: span 2; }
  .choice-grid { grid-template-columns: 1fr; }
  .nav a { padding: 0.4rem 0.5rem; }
  .search-label, .search-btn kbd { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  .topbar { height: auto; min-height: 54px; flex-wrap: wrap; padding: 0.5rem 0.9rem; gap: 0.4rem 0.8rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; padding-bottom: 0.3rem; }
  .brand-name { display: none; }
  .page { padding: 1.2rem 0.9rem 3rem; }
  .dash, .tiles, .two-col { grid-template-columns: 1fr; }
  .wide-2 { grid-column: auto; }
  .hello { padding: 0.6rem 0 1.4rem; }
  .acc-list li { grid-template-columns: minmax(90px, 40%) 1fr 2.6rem; }
  .stats.big { grid-template-columns: 1fr 1fr; }
  .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .felt { min-height: 0; border-radius: 16px; padding: 1rem 0.8rem 1.2rem; }
  .options { gap: 0.5rem; }
  .option { padding: 0.75rem 0.8rem; font-size: 0.98rem; }
  .qc-def { font-size: 1.02rem; line-height: 25px; padding: 12px 16px 0; }
  .seats-grid { grid-template-columns: 1fr 1fr; }
  .lobby-code strong { font-size: 2.3rem; }
  .match-cols { grid-template-columns: 1fr; }
  .match-words { display: flex; flex-wrap: wrap; gap: 0.4rem; position: sticky; top: 0; z-index: 2; padding: 0.4rem 0; background: var(--felt); }
  .hand-card { width: 46%; min-height: 180px; transform: none; }
  .fc { height: 280px; }
  .spotlight { top: 0.6rem; max-height: calc(100dvh - 1.2rem); width: calc(100vw - 1.2rem); border-radius: 16px; }
  .spot-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; }
  .spot-list { max-height: 34dvh; border-right: 0; border-bottom: 1px solid var(--line); }
  .spot-preview { max-height: none; }
  .spot-input { font-size: 1.15rem; }
  .welcome-card .row { flex-wrap: wrap; }
  .welcome-card .row .btn { width: 100%; }
  .hero-search kbd { display: none; }
}

/* Text on ivory cards inside the felt keeps dark ink. */
.felt .podium .muted, .felt .podium .pd-detail, .felt .index-card .muted { color: #6b6f7a; }
