/* Calm dark theme, phone first. No animation beyond tiny colour fades. */
:root {
  --bg: #14151d; --panel: #1d1f2a; --panel2: #262938; --line: #33374a;
  --text: #ebe7dc; --muted: #9a9cab; --gold: #d4b26a; --gold-d: #a88a4c;
  --good: #5fae7b; --good-bg: #1d3327; --bad: #d36b62; --bad-bg: #3a2124;
  --radius: 14px; --tap: 52px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
button { font: inherit; color: inherit; }
a { color: var(--gold); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.screen { max-width: 520px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 18px calc(110px + env(safe-area-inset-bottom)); min-height: 100dvh; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); text-decoration: none; color: var(--text); font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1710; }
.btn.ghost { background: transparent; color: var(--gold); border-color: var(--gold-d); }
.btn.good { background: var(--good); border-color: var(--good); color: #0e1a12; }
.btn.bad { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.wide { width: 100%; } .btn.half { flex: 1; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 12px; cursor: pointer; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }

/* ---------- home ---------- */
.home-head h1 { margin: 12px 0 0; font-size: 30px; color: var(--gold); }
.home-head p { margin: 2px 0 18px; }
.review-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.review-card h2 { margin: 0; font-size: 22px; } .review-card p { margin: 4px 0 0; font-size: 15px; }
.section-h { font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-family: inherit; margin: 26px 0 10px; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lesson-item { display: flex; gap: 14px; align-items: center; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); min-height: 84px; }
.lesson-item img { width: 46px; border-radius: 4px; }
.lesson-title { font-family: var(--serif); font-size: 19px; }
.status { font-size: 13px; color: var(--gold); margin-top: 2px; } .status.done { color: var(--good); }
.home-foot { text-align: center; margin-top: 30px; }

/* ---------- lesson chrome ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin: -6px -6px 10px; }
.progress { flex: 1; height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--gold); transition: width .3s; }
.actionbar, .sheet { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; display: flex; gap: 10px; }
.actionbar:empty { display: none; }
.actionbar { background: linear-gradient(transparent, var(--bg) 30%); }
.sheet { flex-direction: column; background: var(--panel); border-top: 2px solid var(--line); border-radius: 18px 18px 0 0; gap: 8px; max-height: 60dvh; overflow-y: auto; z-index: 5; }
.sheet[hidden] { display: none; }
.sheet.ok { border-top-color: var(--good); } .sheet.bad { border-top-color: var(--bad); }
.verdict { font-weight: 700; font-size: 19px; } .sheet.ok .verdict { color: var(--good); } .sheet.bad .verdict { color: var(--bad); }
.answer-line { margin: 0; } .explain p { margin: 0 0 6px; color: #d8d4c8; }

/* ---------- steps ---------- */
.step { display: flex; flex-direction: column; gap: 14px; }
.prompt { font-size: 22px; margin: 4px 0 0; }
.kicker { margin: 0; color: var(--gold); font-size: 14px; letter-spacing: .06em; text-transform: uppercase; }
.hint { margin: -6px 0 0; color: var(--muted); font-size: 15px; }
.teach-title { font-size: 26px; margin: 4px 0 0; color: var(--gold); }
.teach-text p { margin: 0 0 12px; } .teach-text ul, .teach-text ol { margin: 0 0 12px; padding-left: 22px; } .teach-text li { margin-bottom: 6px; }
.teach-text strong { color: var(--gold); font-weight: 600; }
.statement { margin: 0; font-family: var(--serif); font-size: 22px; padding: 18px; background: var(--panel); border-left: 3px solid var(--gold); border-radius: 6px; }

.options, .grid { display: grid; gap: 10px; } .grid { grid-template-columns: 1fr 1fr; }
.option { min-height: var(--tap); padding: 12px 16px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.grid .option { font-size: 15px; }
.option.selected { border-color: var(--gold); background: #2c2a24; }
.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.missed { border-color: var(--good); border-style: dashed; }
.option:disabled { cursor: default; } .option:disabled:not(.correct):not(.wrong):not(.missed) { opacity: .55; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .option.big { text-align: center; font-size: 20px; min-height: 70px; font-weight: 600; }

/* card figure */
.cardfig { position: relative; align-self: center; width: min(100%, calc(56dvh * .596)); user-select: none; touch-action: none; }
.cardfig.small { width: min(62%, calc(32dvh * .596)); }
.cardfig img { display: block; width: 100%; border-radius: 8px; }
.cardfig.tappable { cursor: crosshair; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.region { fill: rgba(95, 174, 123, .18); stroke: var(--good); stroke-width: 2.5; }
.region.hint { fill: rgba(212, 178, 106, .15); stroke: var(--gold); }
.markers { position: absolute; inset: 0; }
.dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 3px solid #fff; }
.dot.correct { background: var(--good); } .dot.wrong { background: var(--bad); }

/* spell */
.slots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.slot { width: 34px; height: 46px; border: 0; border-bottom: 2px solid var(--gold-d); background: var(--panel); border-radius: 6px 6px 0 0; font-size: 22px; font-weight: 700; }
.slot.correct { color: var(--good); border-color: var(--good); } .slot.wrong { color: var(--bad); border-color: var(--bad); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.tile { width: 52px; height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-size: 22px; font-weight: 700; cursor: pointer; }
.tile:disabled { opacity: .2; }

/* number lock */
.lock { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 16px; }
.lock-btn { width: 96px; height: 60px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel2); font-size: 22px; color: var(--gold); cursor: pointer; }
.lock-value { width: 130px; height: 120px; display: grid; place-items: center; font: 700 64px var(--serif); background: var(--panel); border: 2px solid var(--gold-d); border-radius: 16px; }
.lock-value.correct { border-color: var(--good); color: var(--good); } .lock-value.wrong { border-color: var(--bad); color: var(--bad); }

/* label drag */
.tray { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 48px; }
.pill { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--gold-d); background: var(--panel2); font-size: 15px; cursor: grab; touch-action: none; white-space: nowrap; }
.pill.selected { background: var(--gold); color: #1a1710; }
.pill.on-card { position: absolute; transform: translate(-50%, -50%); min-height: 32px; padding: 0 10px; font-size: 13px; background: rgba(20, 21, 29, .88); }
.pill.correct { border-color: var(--good); color: #c9f0d6; background: rgba(29, 51, 39, .92); } .pill.wrong { border-color: var(--bad); color: #ffd6d2; background: rgba(58, 33, 36, .92); }
.pill.dragging { opacity: .35; }
.ghost { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -50%); opacity: .95; }

/* spread */
.hand { align-self: center; border: 0; background: none; padding: 0; width: 80px; cursor: grab; touch-action: none; }
.hand img { width: 100%; border-radius: 5px; display: block; } .hand.used { opacity: .3; }
.spread { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); }
.spread.n2 { grid-template-columns: repeat(2, 1fr); width: 70%; align-self: center; }
.spread.n3 { grid-template-columns: repeat(3, 1fr); }
.spread-slot { aspect-ratio: .6; border: 2px dashed var(--line); background: var(--panel); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; padding: 6px 4px; cursor: pointer; }
.spread-slot img { width: 80%; border-radius: 4px; }
.spread-slot .pos { font-size: 13px; color: var(--muted); }
.spread-slot.filled { border-style: solid; border-color: var(--gold-d); }
.spread-slot.correct { border-color: var(--good); border-style: solid; background: var(--good-bg); } .spread-slot.wrong { border-color: var(--bad); background: var(--bad-bg); }

/* match pairs */
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.col { display: grid; gap: 10px; align-content: start; }
.option.match { font-size: 15px; min-height: 64px; }
.option.flash-wrong { border-color: var(--bad); background: var(--bad-bg); }

/* review */
.recall-answer { font: 600 21px var(--serif); color: var(--gold); padding: 16px; background: var(--panel); border-radius: 12px; border: 1px solid var(--gold-d); }

/* end */
.end { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.end h1 { color: var(--gold); margin: 30px 0 0; }
.end-card { width: 120px; border-radius: 6px; }
.score { font-size: 20px; margin: 0; } .score strong { font: 700 34px var(--serif); color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 15px; }
.missed { text-align: left; width: 100%; background: var(--panel); border-radius: 12px; padding: 10px 14px; }
.missed summary { cursor: pointer; color: var(--muted); }
.credit { font-size: 12px; color: var(--muted); }
