/* Same palette and type as the games hub (games/shared/base.css). */
:root {
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #f0e9db;
  --line: #ded4c1;
  --text: #2a2420;
  --muted: #6f665c;
  --accent: #8b1e2d;
  --gold: #b8892f;
  --focus: #2f6fdd;
  --error: #a32d2d;
  --sky: #dfeaf0;
  --water: #7fa9bf;
  --window: #f6e7b8;
  --good: #0F6E56;
  --on-accent: #fffdf8;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --surface: #1a1d28;
    --surface-2: #222634;
    --line: #313649;
    --text: #ebe6dc;
    --muted: #a3a1a8;
    --accent: #ff8fa3;
    --focus: #8ab4ff;
    --error: #f09595;
    --sky: #1b2233;
    --water: #24435a;
    --window: #e9c46a;
    --good: #5DCAA5;
    --on-accent: #12141c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font-body); }
h1, h2 { font-family: var(--font-display); font-weight: 600; margin: 0; }
h1 { font-size: clamp(30px, 5vw, 44px); }
h2 { font-size: 22px; }
.muted { color: var(--muted); }
button, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 16px; }
.error { color: var(--error); font-size: 14px; min-height: 1.4em; margin: 0; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.badge, .pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill { color: var(--gold); }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); display: grid; gap: 10px; text-align: center; }
.login form { display: grid; gap: 14px; text-align: left; margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login img { margin: 0 auto; }

/* Home */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 18px var(--font-display); color: var(--text); text-decoration: none; }
.account { display: flex; align-items: center; gap: 8px; }
.home { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 18px; }
.hello p { margin: 6px 0 0; }
.town { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.town svg { display: block; width: 100%; height: auto; }
.town .sky { fill: var(--sky); }
.town .sun { fill: var(--gold); opacity: .55; }
.town .water { fill: var(--water); }
.town .quay { fill: var(--line); }
.town .window { fill: var(--window); opacity: .85; }
.town .door { fill: var(--bg); opacity: .9; }
.town .label { fill: #fffdf8; font: 600 13px var(--font-body); }
.town .house { cursor: pointer; transition: transform .2s; transform-box: fill-box; transform-origin: bottom; }
.town .house:hover, .town .house:focus-visible { transform: translateY(-6px); outline: none; }
.quest-items { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.quest-items li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.buildings { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.building { display: grid; gap: 6px; align-content: start; }
.building .badge { justify-self: start; }
.building p { margin: 0; }
#bibliotheek { border-top: 4px solid #0F6E56; }
#gemeentehuis { border-top: 4px solid #534AB7; }
.big { font: 600 26px var(--font-display); margin-top: 6px !important; }
.games { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.games li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--accent-color); font-size: 14px; }
.bars { display: grid; gap: 8px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 14px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--gold); } to { box-shadow: 0 0 0 0 transparent; } }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(380px, calc(100% - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { display: grid; gap: 12px; }
@media (max-width: 560px) {
  .topbar { gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  .brand { font-size: 0; gap: 0; }
  .account { gap: 6px; min-width: 0; }
  .account button, .account .btn { padding: 6px 10px; font-size: 14px; }
  .account .pill { white-space: normal; text-align: center; line-height: 1.3; }
  button, .btn { min-height: 44px; }
  .card { padding: 16px; }
  /* Scroll the town sideways so the labels stay readable. */
  .town { overflow-x: auto; overscroll-behavior-x: contain; }
  .town svg { min-width: 760px; }
  .town .label { font-size: 16px; paint-order: stroke; stroke: rgb(0 0 0 / .45); stroke-width: 3px; stroke-linejoin: round; }
}
@media (max-width: 400px) {
  #open-settings { font-size: 0; min-width: 44px; }
  #open-settings::before { content: "\2699\FE0E"; font-size: 20px; line-height: 1; }
}

/* Shared bits for the study pages */
a { color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; color: var(--text); text-decoration: none; font-size: 15px; width: fit-content; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.pill.xp { color: var(--accent); }
kbd { font: 600 11px var(--font-body); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .6; margin-left: 4px; }
.building.link { color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.building.link:hover { border-color: var(--muted); transform: translateY(-2px); }
.building .btn, .building button { justify-self: start; margin-top: 6px; }
.locked { opacity: .75; }
.town .house.lit .window { fill: var(--window); opacity: 1; }
.town .house:not(.lit) .window { opacity: .35; }
.quest-items a { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.quest-items li.done .dot { background: #1D9E75; border-color: #1D9E75; }
.quest-items li.done a > span:nth-child(2) { text-decoration: line-through; color: var(--muted); }
.quest.complete { border-color: #1D9E75; }
.games a, .games div { display: grid; gap: 2px; color: inherit; text-decoration: none; }
.games li:has(a):hover { background: var(--line); }

/* Cards */
.study { max-width: 720px; margin: 0 auto; padding: 20px 16px 64px; display: grid; gap: 16px; }
.decks { display: flex; gap: 8px; flex-wrap: wrap; }
.decks a { font-size: 14px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; }
.decks a[aria-current="page"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.flashcard { display: grid; gap: 14px; text-align: center; padding: 24px; min-height: 360px; align-content: start; }
.flashcard.is-new::before { content: "nieuw"; justify-self: center; font-size: 12px; font-weight: 600; color: var(--gold); }
.picture { margin: 0; }
.picture img { width: 100%; max-width: 420px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.front { font: 600 clamp(26px, 5vw, 36px)/1.25 var(--font-display); }
.flashcard[data-deck="grammar"] .front, .flashcard[data-deck="cloze"] .front { font-size: clamp(20px, 4vw, 26px); }
.back { font-size: 20px; }
.answer { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.example { margin: 0; font-size: 16px; }
.example .source { font-size: 12px; }
.note { margin: 0; font-size: 14px; }
.audio { justify-self: center; }
.actions { margin-top: 6px; }
.wide { width: 100%; padding: 12px; }
.ratings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ratings button { padding: 12px 6px; border-radius: 10px; }
.ratings .again { border-color: var(--error); color: var(--error); }
.ratings .good { border-color: #1D9E75; color: var(--good); }
.done { display: grid; gap: 10px; justify-items: start; }
.attribution { font-size: 12px; text-align: center; }
.front, .back, .example, .note, .quiz h2, .option, .review-list { overflow-wrap: anywhere; }

/* Exams */
.quiz { display: grid; gap: 12px; }
.quiz h2 { font-size: 24px; }
.theme { margin: 0; font-size: 13px; }
.options { display: grid; gap: 8px; }
.option { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 16px; cursor: pointer; background: var(--surface); }
.option:has(input:checked) { border-color: var(--accent); }
.option input { accent-color: var(--accent); }
.option .letter { font-weight: 700; color: var(--muted); }
.option.right { border-color: #1D9E75; background: color-mix(in srgb, #1D9E75 12%, var(--surface)); }
.option.wrong { border-color: var(--error); background: color-mix(in srgb, var(--error) 10%, var(--surface)); }
.feedback { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); }
.feedback.is-right strong { color: var(--good); }
.feedback.is-wrong strong { color: var(--error); }
.review-list { display: grid; gap: 12px; padding-left: 20px; }
.review-list li p { margin: 4px 0 0; }
.review-list li.is-right::marker { color: #1D9E75; }
.review-list li.is-wrong::marker { color: var(--error); }
@media (max-width: 560px) {
  .ratings kbd, .wide kbd { display: none; }
  .ratings button { font-size: 14px; padding: 12px 2px; }
  .pill.xp { display: none; }
  .study { padding-top: 12px; gap: 12px; }
  .decks { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .decks a { flex: none; padding: 11px 14px; }
  .flashcard { padding: 16px; gap: 12px; }
  .picture img { max-height: 26vh; }
  .quiz h2 { font-size: 20px; }
  .front, .back, .example, .quiz h2, .option { hyphens: auto; }
}
@media (max-width: 359px) {
  .ratings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Card page: deck picker, state, audio controls, interval labels */
.deck-picker { display: grid; gap: 4px; }
.deck-picker select, .speed select, dialog select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 16px; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.card-meta .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.state[data-state="new"] { color: var(--gold); }
.state[data-state="learning"], .state[data-state="relearning"] { color: var(--error); }
.state[data-state="review"] { color: var(--good); }
.flashcard.is-new::before { content: none; }
.audio-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.audio-row .speed, .audio-row .auto { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.audio-row .speed select { padding: 6px 8px; font-size: 15px; }
.ratings button { display: grid; justify-items: center; gap: 2px; line-height: 1.2; }
.ratings small { font-size: 12px; color: var(--muted); font-weight: 400; }
.help summary { cursor: pointer; font-weight: 600; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 12px 0 8px; font-size: 14px; }
.help dt { font-weight: 600; }
.help dd { margin: 0; color: var(--muted); }
.help p { margin: 0; font-size: 13px; }
@media (max-width: 560px) {
  .help dl { grid-template-columns: 1fr; }
  .help dd { margin-bottom: 6px; }
}
.study { grid-template-columns: minmax(0, 1fr); }
.deck-picker select { width: 100%; min-width: 0; text-overflow: ellipsis; }
.attribution { overflow-wrap: anywhere; }
.install { display: grid; gap: 8px; border-color: var(--gold); }
.install p { margin: 0; }
.study-options { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
.study-options select { width: 100%; min-width: 0; }
@media (max-width: 560px) {
  .study-options { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
.back[lang="nl"] { font: 600 clamp(24px, 4.5vw, 32px)/1.25 var(--font-display); }
