:root,
:root[data-theme="dark"] {
  --bg: #14161a; --fg: #e9e6df; --muted: #8b8f98;
  --panel: #1e2128; --panel-hover: #272b34; --line: #2f3440;
  --right: #3fa860; --wrong: #c8524c; --accent: #d8b26a;
}
:root[data-theme="light"] {
  --bg: #f6f4ef; --fg: #23262c; --muted: #6d727b;
  --panel: #ffffff; --panel-hover: #edeae3; --line: #d8d3c8;
  --right: #2f8b4e; --wrong: #b2413b; --accent: #8a6a26;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 3rem 0 4rem;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s;
}

main { width: min(38rem, 94vw); text-align: center; }
.screen { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.screen[hidden] { display: none; }
.round-body { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; width: 100%; }

h1 {
  margin: 0;
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Polytonic Greek needs breathings, accents and iota subscript composed
   correctly; the generic serif fallbacks do not manage it reliably. */
.greek {
  font-family: "Palatino Linotype", Palatino, "Gentium Plus",
               "New Athena Unicode", "Times New Roman", serif;
}

.play {
  width: 11rem;
  height: 11rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 1.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.play:hover { background: var(--accent); color: var(--bg); }
.play:active { transform: scale(0.97); }
.play:disabled { opacity: 0.4; cursor: default; }
.play:disabled:hover { background: transparent; color: var(--accent); }
.play.secondary {
  width: auto; height: auto; border-radius: 2rem;
  padding: 0.7rem 2rem; font-size: 1rem;
}

.progress-line { margin: 0; color: var(--muted); font-size: 0.95rem; }
.counter { margin: 0; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.1em; }
.bar { width: 100%; height: 9px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

.lessons { list-style: none; margin: 0; padding: 0; width: 100%; text-align: left; }
.lesson-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
  margin-bottom: 0.5rem;
  cursor: pointer;
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}
.lesson-row:hover { background: var(--panel-hover); }
.lesson-row.locked { opacity: 0.8; }
.lesson-row.untrainable { opacity: 0.7; cursor: default; }
.lesson-row.complete .lesson-num { color: var(--right); }
.lesson-num { color: var(--fg); font-variant-numeric: tabular-nums; }
.lesson-state { color: var(--fg); font-size: 0.8rem; white-space: nowrap; }

.lesson-icons { display: flex; gap: 0.35rem; }
.icon-btn {
  border: 1px solid transparent;
  border-radius: 0.35rem;
  background: none;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--line); }

/* Proof sheets: read-only views of a lesson's curated material. */
.proof-body { display: flex; flex-direction: column; gap: 1.5rem; width: 100%; }
.proof-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.proof-item:last-child { border-bottom: 0; }
.proof-title { font-size: 1.15rem; }
.proof-source { margin: 0; color: var(--muted); font-size: 0.75rem; }

.proof-word { align-items: start; text-align: left; gap: 0.25rem; padding-bottom: 0.9rem; }
.proof-headword { font-size: 1.6rem; line-height: 1.2; }
.proof-short { font-size: 1.05rem; color: var(--fg); }
.proof-meta { display: flex; gap: 0.4rem; }
.proof-full { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }

.badge {
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  padding: 0.05rem 0.4rem;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge.koine { color: var(--accent); border-color: var(--accent); }

.prompt-greek { font-size: clamp(2.6rem, 12vw, 4.5rem); line-height: 1.15; user-select: none; }
.prompt-english { font-size: 1.35rem; line-height: 1.3; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; width: 100%; }
.option {
  padding: 1rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
  color: var(--fg);
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.option:hover:not(:disabled) { background: var(--panel-hover); }
.option:disabled { cursor: default; }
.option.right { border-color: var(--right); color: var(--right); }
.option.wrong { border-color: var(--wrong); color: var(--wrong); }
.option.right::after { content: " ✓"; }
.option.wrong::after { content: " ✗"; }

.reveal { color: var(--muted); font-size: 0.95rem; min-height: 2.4em; margin: 0; }

.grid { border-collapse: separate; border-spacing: 0.3rem; margin: 0 auto; }
.grid th {
  color: var(--muted); font-weight: 400; font-size: 0.85rem;
  padding: 0.2rem 0.4rem; white-space: nowrap;
}
.grid td {
  border: 1px dashed var(--line);
  border-radius: 0.4rem;
  height: 3rem;
  min-width: 6.5rem;
  padding: 0.2rem 0.4rem;
  text-align: center;
  font-size: 1.1rem;
}
.grid td.over { border-color: var(--accent); background: var(--panel-hover); }
.grid td.filled { border-style: solid; background: var(--panel); cursor: pointer; }
.grid td.wrong { border-color: var(--wrong); border-style: solid; }

.tray { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; width: 100%; }
.chip {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--fg);
  font-size: 1.05rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.chip.selected { border-color: var(--accent); color: var(--accent); }
.chip.dragging { opacity: 0.4; }
.chip.placed { visibility: hidden; }

.footnote { color: var(--muted); font-size: 0.85rem; margin: 0; min-height: 1.2em; }

.score { margin: 0; font-size: 2rem; }
.missed { margin: 0; color: var(--muted); font-size: 0.95rem; min-height: 1.2em; }

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(135deg, #f6f4ef 0 50%, #14161a 50% 100%);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); }
:root[data-theme="light"] .theme-toggle { transform: rotate(180deg); }

/* Fixed so it stays reachable, with its own ground so long scrolling content
   (the proof sheets) passes behind it rather than colliding with it.
   Link row above, progress bar flush with the bottom edge. */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
}
.links { display: flex; justify-content: center; gap: 1.5rem; padding: 0.9rem 0; }
.link { border: 0; background: none; color: var(--muted); font-size: 0.8rem; cursor: pointer; }
.link:hover { color: var(--fg); }

@media (max-width: 420px) {
  .options { grid-template-columns: 1fr; }
  .grid td { min-width: 4.5rem; font-size: 1rem; }
  .grid { border-spacing: 0.2rem; }
}
