/* Spelling Bee Practice — shared styles. Themes: body[data-theme="y3"] (honey) and body[data-theme="y8"] (night). */
:root {
  --bg: #FFF8E7; --bg2: #FFEFC2; --card: #FFFFFF; --ink: #2B2118; --muted: #7A6A58; --line: #F0DFB8;
  --accent: #FFB703; --accent-ink: #2B2118; --accent2: #FB8500; --good: #2A9D8F; --bad: #E63946;
  --b1: #FFD166; --b2: #F4A261; --b3: #90BE6D; --b4: #A0C4FF;
  --radius: 22px; --shadow: 0 10px 30px rgba(80, 50, 0, .12);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Fredoka', 'Nunito', system-ui, sans-serif;
}
body[data-theme="y8"] {
  --bg: #0F1C2E; --bg2: #16283F; --card: #1B2F4A; --ink: #F1F5FB; --muted: #9DB0C8; --line: #2A4364;
  --accent: #2EC4B6; --accent-ink: #062A27; --accent2: #FFC93C; --good: #2EC4B6; --bad: #FF6B6B;
  --b1: #2EC4B6; --b2: #FFC93C; --b3: #9B8CFF; --b4: #FF8FA3;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; font-family: var(--font); color: var(--ink);
  background: radial-gradient(circle at 15% 0%, var(--bg2), transparent 55%), var(--bg);
  font-size: clamp(16px, 1.1vw + 12px, 26px); line-height: 1.45;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--accent2); outline-offset: 3px; }
h1, h2 { font-family: var(--display); margin: 0; line-height: 1.1; }
.muted { color: var(--muted); }
.center { text-align: center; }
b.best { color: var(--accent2); }
body[data-theme="y3"] b.best { color: #C2410C; }

/* ---------- shared controls ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.tb-title { flex: 1; font-family: var(--display); font-weight: 600; font-size: 1.15em; text-align: center; }
.tb-extra { min-width: 110px; display: flex; justify-content: flex-end; }
.ghost { background: transparent; border: 2px solid var(--line); border-radius: 999px; padding: .45em 1em; font-weight: 700; }
.ghost.danger { color: var(--bad); margin-top: 24px; }
.pill { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: .5em 1.1em; font-weight: 700; min-height: 48px; box-shadow: var(--shadow); }
.pill.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mini { background: transparent; font-size: .9em; padding: 0 .3em; vertical-align: middle; }
.primary { display: block; width: 100%; margin-top: 18px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 1.1em; border-radius: 18px; padding: .8em 1em; min-height: 60px; box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000); transition: transform .08s; }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.primary:disabled { opacity: .45; }
.score-box { background: var(--card); border-radius: 999px; padding: .3em .9em; font-weight: 800; box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0; }
.chip { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: .4em 1em; font-weight: 700; min-height: 46px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pop { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- home ---------- */
.home { max-width: 1000px; margin: 0 auto; padding: 32px 16px 48px; text-align: center; position: relative; }
.switch { position: absolute; top: 16px; right: 16px; color: var(--muted); font-weight: 700; font-size: .85em; }
.mascot { font-size: clamp(56px, 8vw, 110px); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-6deg); } }
.home h1 { font-size: clamp(34px, 5vw, 72px); }
.sub { color: var(--muted); font-weight: 700; margin: 6px 0 20px; }
.meter { height: 16px; max-width: 520px; margin: 0 auto; background: var(--line); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; transition: width .6s; }
.meter-label { margin: 8px 0 0; color: var(--muted); }
.menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 8px; }
.big { text-align: left; border-radius: var(--radius); padding: 22px; min-height: 150px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); color: #1D1A16; transition: transform .12s; }
.big:active { transform: scale(.97); }
.big span { font-size: 1.8em; }
.big b { font-family: var(--display); font-size: 1.5em; }
.big small { font-size: .85em; opacity: .8; }
.b1 { background: var(--b1); } .b2 { background: var(--b2); } .b3 { background: var(--b3); } .b4 { background: var(--b4); }

/* ---------- learn ---------- */
.learn { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px; }
.nav { width: 64px; height: 64px; border-radius: 50%; background: var(--card); font-size: 2.2em; line-height: 1; box-shadow: var(--shadow); }
.learn-card, .qcard { background: var(--card); border-radius: var(--radius); padding: clamp(20px, 3vw, 44px); box-shadow: var(--shadow); }
.lc-count { color: var(--muted); font-weight: 700; font-size: .85em; }
.lc-word { font-size: clamp(40px, 6.5vw, 96px); margin: 6px 0 2px; color: var(--accent2); letter-spacing: .01em; overflow-wrap: anywhere; }
body[data-theme="y3"] .lc-word { color: #C2410C; }
.lc-say { font-size: 1.2em; font-weight: 700; }
.lc-type { display: inline-block; font-size: .7em; color: var(--muted); border: 2px solid var(--line); border-radius: 999px; padding: 0 .7em; margin-left: 6px; vertical-align: middle; }
.lc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; justify-content: center; }
.learn-card .lc-actions { justify-content: flex-start; }
dl { margin: 0; display: grid; gap: 4px; }
dt { font-weight: 800; color: var(--muted); text-transform: uppercase; font-size: .72em; letter-spacing: .08em; margin-top: 12px; }
dd { margin: 0; font-size: 1.05em; }
.sentence { font-style: italic; }

/* ---------- quiz & bee ---------- */
.qwrap, .bwrap, .results { max-width: 900px; margin: 0 auto; padding: 8px 16px 48px; }
.qmeta { display: flex; justify-content: space-between; color: var(--muted); font-weight: 700; font-size: .85em; }
.clock, .timer-num { font-variant-numeric: tabular-nums; }
.timer { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 18px; }
.timer span { display: block; height: 100%; width: 100%; background: var(--good); border-radius: 999px; }
.timer span.low { background: var(--bad); }
.qlabel { font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .78em; margin: 10px 0; }
.qmain { font-family: var(--display); font-size: clamp(36px, 5.5vw, 80px); font-weight: 600; text-align: center; margin: 10px 0 20px; overflow-wrap: anywhere; }
.qmain.small { font-family: var(--font); font-size: clamp(20px, 2.2vw, 34px); font-weight: 700; line-height: 1.35; }
.listen { display: block; margin: 8px auto 10px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 1.2em; border-radius: 999px; padding: .7em 1.6em; min-height: 64px; box-shadow: var(--shadow); }
.listen.huge { font-size: 1.5em; padding: .9em 2em; }
.hint { text-align: center; color: var(--muted); margin-bottom: 14px; }
.opts { display: grid; gap: 12px; }
.opts.grid { grid-template-columns: repeat(2, 1fr); }
.opt { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--bg); border: 3px solid var(--line); border-radius: 18px; padding: .75em 1em; min-height: 70px; font-weight: 700; font-size: 1.05em; transition: transform .08s, border-color .15s; overflow-wrap: anywhere; }
.opts.grid .opt { font-size: 1.25em; justify-content: flex-start; }
.opt:not(:disabled):active { transform: scale(.98); }
.opt kbd { flex: none; display: grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 10px; background: var(--card); font-family: var(--font); font-size: .7em; color: var(--muted); border: 2px solid var(--line); }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 22%, var(--bg)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, var(--bg)); animation: shake .35s; }
.opt:disabled:not(.right):not(.wrong) { opacity: .55; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.fb { min-height: 1.6em; margin-top: 14px; text-align: center; font-size: 1.1em; }
.good { color: var(--good); } .bad { color: var(--bad); }
.streak { font-weight: 800; }
.reveal { margin-top: 12px; padding: 14px 18px; border-radius: 16px; background: var(--bg); display: grid; gap: 6px; }
.rv-word { font-family: var(--display); font-size: 1.3em; }
.spelled { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 18px 0 8px; }
.spelled span { display: grid; place-items: center; min-width: 1.5em; height: 1.8em; padding: 0 .15em; background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-weight: 700; font-size: clamp(24px, 3.6vw, 52px); border-radius: 12px; animation: pop .4s backwards; }
.b-result > .muted { text-align: center; }
.judge { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.judge button, .j-syn { border-radius: 16px; padding: .7em; min-height: 64px; font-weight: 800; font-size: 1.05em; border: 3px solid var(--line); background: var(--bg); }
.j-yes.on { background: var(--good); border-color: var(--good); color: #fff; }
.j-no.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.stage2 { margin-top: 18px; padding: 14px 18px; border-radius: 16px; background: var(--bg); display: grid; gap: 8px; }
.j-syn { width: 100%; }
.j-syn.on { background: var(--accent2); border-color: var(--accent2); color: #1D1A16; }

/* ---------- results & progress ---------- */
.results .qcard { text-align: center; }
.results h2 { font-size: clamp(28px, 3.5vw, 48px); margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0; }
.stats div { background: var(--bg); border-radius: 18px; padding: 14px 8px; display: grid; }
.progress .stats div { background: var(--card); box-shadow: var(--shadow); }
.stats b { font-family: var(--display); font-size: clamp(26px, 3.5vw, 48px); }
.stats span { color: var(--muted); font-weight: 700; font-size: .8em; }
.row { display: flex; gap: 12px; align-items: center; }
.row .primary { flex: 1; margin-top: 0; }
.row .ghost { min-height: 60px; padding: 0 1.4em; }
.progress { max-width: 1100px; margin: 0 auto; padding: 8px 16px 48px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { position: relative; text-align: left; background: var(--card); border-radius: 16px; padding: 12px 14px; display: grid; gap: 2px; box-shadow: var(--shadow); border: 3px solid transparent; }
.tile b { overflow-wrap: anywhere; }
.t-n { font-size: .7em; color: var(--muted); font-weight: 800; }
.dots { color: var(--accent2); letter-spacing: .15em; }
.t-miss { font-size: .7em; color: var(--bad); font-weight: 700; }
.tile.lvl3 { border-color: var(--good); }
.tile.lvl3::after { content: '⭐'; position: absolute; top: 8px; right: 10px; }

/* ---------- example sentences ---------- */
.ex { display: grid; gap: 6px; }
.ex-nav { display: flex; align-items: center; gap: 8px; font-style: normal; }
.ex-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); font-size: 1.3em; line-height: 1; padding: 0; }
.ex-btn:disabled { opacity: .3; }
.ex-count { font-size: .75em; font-weight: 800; color: var(--muted); }
.sentence-list { margin: 0; padding-left: 1.3em; font-style: italic; display: grid; gap: 4px; }

/* ---------- home footer, settings, install ---------- */
.home-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 24px; }
.settings { max-width: 800px; margin: 0 auto; padding: 8px 16px 48px; display: grid; gap: 18px; }
.voices { display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; padding: 2px; }
.voice { text-align: left; display: grid; background: var(--bg); border: 3px solid var(--line); border-radius: 14px; padding: .55em .9em; min-height: 56px; }
.voice span { font-size: .78em; color: var(--muted); }
.voice.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg)); }
.rate-row { display: flex; align-items: center; gap: 12px; font-size: 1.4em; }
.rate-row input { flex: 1; accent-color: var(--accent2); height: 36px; }
.settings .row { margin-top: 18px; }
.tips p { margin: 8px 0; }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; font-size: 1.1em; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- landing page ---------- */
.landing { max-width: 900px; margin: 0 auto; padding: 48px 16px; text-align: center; }
.landing h1 { font-size: clamp(36px, 5vw, 64px); }
.years { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }
.year { display: block; text-decoration: none; border-radius: var(--radius); padding: 32px 22px; box-shadow: var(--shadow); color: #1D1A16; }
.year b { display: block; font-family: var(--display); font-size: 2em; }
.year.y3 { background: #FFD166; }
.year.y8 { background: #2EC4B6; color: #062A27; }

/* ---------- small screens (phones, portrait tablets) ---------- */
@media (max-width: 640px) {
  .menu, .years { grid-template-columns: 1fr; }
  .big { min-height: 0; }
  .learn { grid-template-columns: 1fr 1fr; }
  .learn-card { grid-column: 1 / -1; grid-row: 1; }
  .nav { justify-self: center; }
  .opts.grid { grid-template-columns: 1fr; }
  .tb-extra { min-width: 0; }
  .switch { position: static; display: inline-block; margin-bottom: 8px; }
  .spelled { gap: 3px; }
  .spelled span { font-size: 18px; min-width: 1.25em; border-radius: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
