:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2b2d42;
  --muted: #6b6f80;
  --primary: #4361ee;
  --primary-ink: #ffffff;
  --right: #2a9d63;
  --right-bg: #e3f7ec;
  --wrong: #e5484d;
  --wrong-bg: #fdeaea;
  --info-bg: #e8eeff;
  --border: #d9d4c7;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
  font-size: 18px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--primary);
  color: var(--primary-ink);
}
.topbar h1 { margin: 0; font-size: 1.5rem; flex: 1; text-align: center; }
.scoreboard { font-weight: 700; white-space: nowrap; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.screen { text-align: center; }
[hidden] { display: none !important; }

/* ---------- home ---------- */
.tagline { font-size: 1.6rem; font-weight: 800; margin: 8px 0 20px; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 24px 16px;
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  font: inherit; color: inherit; cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-4px); border-color: var(--primary); outline: none; }
.mode-emoji { font-size: 3.5rem; }
.mode-title { font-size: 1.35rem; font-weight: 800; }
.mode-desc { color: var(--muted); }

.settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; margin-top: 28px; }
.settings select, .settings input { font: inherit; }
.settings select { padding: 6px 10px; border-radius: 10px; border: 2px solid var(--border); }
.settings input[type=checkbox] { width: 20px; height: 20px; vertical-align: middle; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 800;
  padding: 12px 24px;
  border-radius: 999px;
  border: 3px solid var(--primary);
  background: var(--card); color: var(--primary);
  cursor: pointer;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.small { padding: 6px 14px; font-size: .9rem; border-color: var(--primary-ink); background: transparent; color: var(--primary-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible { outline: 4px solid #ffd166; outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 16px; min-height: 56px; }

/* ---------- prompt ---------- */
.prompt { margin-bottom: 16px; }
.prompt.pop { animation: pop .5s ease; }
.picture { font-size: 8rem; line-height: 1.1; }
.picture img { max-width: 220px; max-height: 220px; border-radius: var(--radius); }
.instruction { font-size: 1.25rem; font-weight: 700; margin: 8px 0; }
.warn { color: var(--wrong); }
.small-note { color: var(--muted); margin: 6px 0 0; font-size: .95rem; }

.listen-row { display: flex; justify-content: center; align-items: center; gap: 16px; }
.speaker {
  font-size: 4rem; width: 130px; height: 130px;
  border-radius: 50%; border: 4px solid var(--primary);
  background: var(--card); cursor: pointer;
}
.speaker:active { transform: scale(.95); }

/* ---------- letter boxes ---------- */
.boxes { position: relative; display: inline-flex; gap: 10px; padding: 4px; }
.box {
  width: 3.4rem; height: 4.2rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; font-weight: 800;
  background: var(--card);
  border: 3px dashed var(--border);
  border-radius: 12px;
}
.box.cursor { border-style: solid; border-color: var(--primary); }
.box.ghost { color: #c4c0b4; }
.box.right { border: 3px solid var(--right); background: var(--right-bg); color: var(--right); }
.box.wrong { border: 3px solid var(--wrong); background: var(--wrong-bg); color: var(--wrong); }
.box-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; font-size: 16px; caret-color: transparent; cursor: text;
}
.shake { animation: shake .45s; }

/* ---------- read mode ---------- */
.read-word {
  display: inline-block;
  font-size: 4rem; font-weight: 800; letter-spacing: .08em;
  padding: 8px 32px;
  background: var(--card); border: 3px solid var(--border); border-radius: var(--radius);
}
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; max-width: 420px; margin: 0 auto; }
.choice {
  background: var(--card); border: 3px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; font: inherit;
  transition: transform .15s, border-color .15s;
}
.choice:hover:not(:disabled) { transform: scale(1.04); border-color: var(--primary); }
.choice.wrong { border-color: var(--wrong); background: var(--wrong-bg); opacity: .5; }
.choice.right { border-color: var(--right); background: var(--right-bg); animation: pop .5s ease; }
.choice:disabled { cursor: default; }
.choice-pic { font-size: 4.5rem; line-height: 1.2; }
.choice-pic img { max-width: 100%; max-height: 110px; }
.mic.listening { background: var(--wrong); border-color: var(--wrong); color: #fff; animation: pulse 1s infinite; }

/* ---------- read-aloud buttons ---------- */
.replay {
  font-size: 1.1rem; line-height: 1;
  margin-left: 8px; padding: 4px 8px;
  border: 2px solid currentColor; border-radius: 999px;
  background: transparent; color: inherit; cursor: pointer;
  vertical-align: middle; opacity: .75;
}
.replay:hover, .replay:focus-visible { opacity: 1; }

/* ---------- feedback ---------- */
.feedback { min-height: 2.5em; margin-top: 16px; padding: 0; font-size: 1.2rem; font-weight: 700; border-radius: 14px; }
.feedback.yay  { padding: 12px 16px; background: var(--right-bg); color: var(--right); }
.feedback.oops { padding: 12px 16px; background: var(--wrong-bg); color: #b4232a; }
.feedback.info { padding: 12px 16px; background: var(--info-bg); color: var(--primary); }

/* ---------- done ---------- */
.trophy { font-size: 6rem; animation: pop .6s ease; }
.done-text { font-size: 1.3rem; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes pulse { 50% { opacity: .7; } }

@media (max-width: 480px) {
  .topbar h1 { font-size: 1.15rem; }
  .box { width: 2.8rem; height: 3.6rem; font-size: 2rem; }
  .picture { font-size: 6rem; }
  .read-word { font-size: 3rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
