/* 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 { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px 10px; 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 { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.home-head h1 { margin: 12px 0 0; font-size: 30px; color: var(--gold); }
.home-head p { margin: 2px 0 18px; }
.lang-switch { display: inline-flex; gap: 4px; margin-top: 10px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.lang-switch button { min-width: 44px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; letter-spacing: .04em; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--panel2); color: var(--gold); }
.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; }
.access-card { background: var(--panel); border: 1px solid var(--gold-d); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 12px; margin-bottom: 14px; }
.access-card h2 { margin: 0; font-size: 20px; color: var(--gold); }
.access-card p { margin: 0; font-size: 15px; color: var(--text); }
.access-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.access-actions .btn { flex: 1 1 140px; }
.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; flex: 0 0 46px; }
.lesson-item .num { width: 46px; height: 64px; flex: 0 0 46px; display: grid; place-items: center; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line); font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--gold); }
.lesson-item.locked { opacity: .62; cursor: default; background: rgba(29, 31, 42, .55); border-style: dashed; }
.lesson-item.locked .num { color: var(--muted); background: transparent; }
.lesson-title { font-family: var(--serif); font-size: 19px; }
.status { font-size: 13px; color: var(--gold); margin-top: 2px; } .status.done { color: var(--good); } .status.locked { color: var(--muted); }
.next-unlock { margin: 12px 2px 0; text-align: center; }
.home-foot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 12px; 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 (illustration only; no tappable regions) */
.cardfig { position: relative; align-self: center; width: min(100%, calc(56dvh * .596)); user-select: none; }
.cardfig.small { width: min(62%, calc(32dvh * .596)); }
.cardfig img { display: block; width: 100%; border-radius: 8px; }

/* 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); }

/* drag ghost used by spread_slot; .btn.ghost is an outline button and must stay in flow */
.dragging { opacity: .35; }
.ghost:not(.btn) { 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); }
.end-notice { margin: 4px 0; padding: 12px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--gold); font-size: 15px; width: 100%; display: grid; gap: 10px; }
.end-notice p { margin: 0; }
.end-error { width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--bad-bg); border: 1px solid var(--bad); color: var(--text); display: grid; gap: 10px; text-align: center; }
.credit { font-size: 12px; color: var(--muted); }
