/* Stavestorm. Mørk spilverden, guld som accent. Én bevidst mørk visning. */
:root {
  --bg: #0f151d;
  --bg-2: #0b1016;
  --panel: #18212c;
  --panel-2: #1f2a37;
  --line: #2c3a4b;
  --fg: #eef2f6;
  --muted: #9aabbd;
  --gold: #ffc83d;
  --gold-ink: #2a1d00;
  --good: #5fdc8f;
  --bad: #ff6b6b;
  --display: "Bungee", "Arial Black", Impact, system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", Verdana, system-ui, sans-serif;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 17px; line-height: 1.5;
  -webkit-user-select: none; user-select: none; touch-action: manipulation; overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; letter-spacing: .01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.eyebrow { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.ic { width: 18px; height: 18px; flex: none; }

#app { height: 100%; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.screen { height: 100%; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--display); color: var(--gold); background: var(--bg); font-size: 22px; }

/* ---------- Start ---------- */
#home { overflow-y: auto; }
.home-wrap { max-width: 760px; margin: 0 auto; padding-inline: 20px; padding-block: 36px 40px; display: grid; gap: 26px; }
.logo { font-size: clamp(46px, 11vw, 92px); color: var(--gold); line-height: 1; text-shadow: 0 5px 0 #8a5f00; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.stat .ic { width: 22px; height: 22px; }
.stat small { color: var(--muted); font-weight: 400; }
.home-actions { display: grid; gap: 12px; }
.big { font-family: var(--display); font-size: clamp(22px, 4.6vw, 30px); padding: 22px 24px; border-radius: 16px; border: 0; background: var(--gold); color: var(--gold-ink); box-shadow: 0 6px 0 #a87600; transition: transform .08s; }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #a87600; }
.big.alt { background: #5cc8ff; color: #062033; box-shadow: 0 6px 0 #2a7aa6; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 4px; text-align: left; padding: 16px; border-radius: var(--r); background: var(--panel); border: 2px solid var(--line); }
.tile:active { border-color: var(--gold); }
.t-title { font-family: var(--display); font-size: 18px; }
.t-sub { color: var(--muted); font-size: 15px; }
.voice-warn { background: #3a2a10; border: 1px solid #7a5a1a; padding: 12px 14px; border-radius: 12px; font-size: 15px; }
.parent-link { justify-self: start; background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px 0; font-size: 15px; }

/* ---------- Spil ---------- */
#play { display: grid; grid-template-rows: auto 1fr auto; height: 100%; background: var(--bg-2); }
.hud { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hud-left { display: flex; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 700; font-variant-numeric: tabular-nums; }
.pill.gold b { color: var(--gold); font-family: var(--display); font-weight: 400; }
.pill.combo { color: var(--gold); }
.steps { list-style: none; display: flex; gap: 4px; margin: 0 auto; padding: 0; flex-wrap: wrap; justify-content: center; }
.steps li { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.steps li.done { color: var(--good); border-color: #2d5a3e; }
.steps li.now { color: var(--gold-ink); background: var(--gold); border-color: var(--gold); }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--fg); font-weight: 700; }

.play-main { display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(330px, 400px); }
.board { container-type: size; min-height: 0; display: grid; place-items: center; padding: 10px; }
.board canvas { display: block; width: min(100cqw, calc(100cqh * 12 / 7)); aspect-ratio: 12 / 7; max-width: 100%; border-radius: 12px; touch-action: none; }
.panel { min-height: 0; overflow-y: auto; padding: 14px; border-left: 1px solid var(--line); background: var(--panel); display: grid; align-content: start; gap: 14px; }
#play.noboard .play-main { grid-template-columns: 1fr; }
#play.noboard .board { display: none; }
#play.noboard .panel { border-left: 0; max-width: 720px; width: 100%; margin: 0 auto; padding-top: 30px; }

@media (orientation: portrait), (max-width: 820px) {
  .play-main { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .board { container-type: inline-size; padding: 8px; }
  .board canvas { width: 100%; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
}

.phase-title { font-family: var(--display); font-size: 22px; }
.phase-sub { color: var(--muted); font-size: 15px; }

/* Ordkort */
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; }
.sentence { font-size: 22px; line-height: 1.45; }
.blank { display: inline-block; min-width: 3.6em; border-bottom: 3px solid var(--gold); }
.listen { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-weight: 700; color: var(--gold); justify-self: start; }
.listen .ic { width: 22px; height: 22px; color: var(--gold); }
.typed { min-height: 58px; display: flex; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--bg-2); border: 2px solid var(--line); font-size: 30px; font-weight: 700; letter-spacing: .06em; word-break: break-all; }
.typed.cursor::after { content: ""; width: 3px; height: 1.1em; background: var(--fg); margin-left: 3px; animation: blink 1s steps(1) infinite; }
.typed.ok { border-color: var(--good); color: var(--good); }
.typed.no { border-color: var(--bad); }
.typed.shake { animation: shake .3s; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.flash-word { font-size: 34px; font-weight: 700; color: var(--gold); letter-spacing: .06em; }
.feedback { display: grid; gap: 10px; }
.fb-good { color: var(--good); font-family: var(--display); font-size: 22px; }
.fb-bad { color: var(--bad); font-family: var(--display); font-size: 20px; }
.correct-word { font-size: 34px; font-weight: 700; letter-spacing: .08em; }
.correct-word .miss { color: var(--gold); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.your-word { color: var(--muted); font-size: 17px; }
.hint { font-size: 16px; background: var(--panel); border-left: 4px solid var(--gold); padding: 10px 12px; border-radius: 0 10px 10px 0; }
.hint b { font-family: var(--display); font-weight: 400; font-size: 14px; display: block; margin-bottom: 2px; }
.btn { font-family: var(--display); font-size: 17px; padding: 14px 18px; border-radius: 12px; border: 0; background: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 0 #a87600; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a87600; }
.btn.blue { background: #5cc8ff; color: #062033; box-shadow: 0 4px 0 #2a7aa6; }
.btn.dark { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); box-shadow: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Tastatur */
.kbd { padding: 8px 8px 10px; background: var(--panel); border-top: 1px solid var(--line); display: grid; gap: 7px; }
.krow { display: flex; gap: 6px; justify-content: center; }
.key { flex: 1 1 0; max-width: 72px; min-width: 0; height: 56px; border-radius: 10px; border: 1px solid var(--line); border-bottom-width: 4px; background: var(--panel-2); font-size: 22px; font-weight: 700; display: grid; place-items: center; padding: 0; }
.key:active { transform: translateY(2px); border-bottom-width: 2px; }
.key.wide { flex: 1.6 1 0; max-width: 110px; font-size: 16px; }
.key.ok { flex: 2.4 1 0; max-width: 200px; background: var(--gold); color: var(--gold-ink); border-color: #a87600; font-family: var(--display); font-size: 18px; font-weight: 400; }
.key.listen-key { color: var(--gold); }
.kbd.off .key { opacity: .35; pointer-events: none; }
@media (max-height: 760px) { .key { height: 48px; font-size: 20px; } }

/* Butik */
.shop { display: grid; gap: 10px; }
.shop-item { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--panel-2); border: 2px solid var(--line); text-align: left; }
.shop-item.on { border-color: var(--gold); }
.shop-item.poor { opacity: .55; }
.shop-item .sw { width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; }
.shop-item .nm { font-family: var(--display); font-size: 15px; }
.shop-item .ds { font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.shop-item .cost { display: inline-flex; gap: 4px; align-items: center; font-family: var(--display); color: var(--gold); }
.locked { font-size: 14px; color: var(--muted); padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; }
.tip { font-size: 15px; color: var(--fg); background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }

/* Bølge */
.bar { height: 14px; border-radius: 99px; background: var(--bg-2); overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--good); transition: width .2s; }
.bar.boss i { background: #a29bfe; }

/* Minispil */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { font-size: 28px; font-weight: 700; padding: 22px 10px; border-radius: 14px; background: var(--panel-2); border: 2px solid var(--line); border-bottom-width: 5px; letter-spacing: .04em; }
.choice.ok { border-color: var(--good); color: var(--good); }
.choice.no { border-color: var(--bad); color: var(--bad); }
.forge-eq { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 26px; font-weight: 700; }
.forge-eq .root { background: var(--gold); color: var(--gold-ink); padding: 6px 14px; border-radius: 10px; font-family: var(--display); font-weight: 400; }
.forge-eq .end { background: var(--panel); border: 2px solid var(--good); color: var(--good); padding: 4px 12px; border-radius: 10px; }
.counter { font-family: var(--display); color: var(--muted); font-size: 14px; }

/* Sider */
#collection, #upgrades, #parent { overflow-y: auto; }
.page { max-width: 900px; margin: 0 auto; padding-inline: 20px; padding-block: 24px 48px; display: grid; gap: 18px; }
.page.wide { max-width: 1040px; }
.page-head { display: flex; align-items: center; gap: 14px; }
.page-head h2 { font-size: clamp(24px, 5vw, 34px); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.wcard { border-radius: 12px; padding: 14px 10px; text-align: center; background: var(--panel); border: 2px solid var(--line); display: grid; gap: 4px; }
.wcard b { font-size: 20px; }
.wcard small { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.wcard.rare { border-color: var(--gold); background: linear-gradient(180deg, #2f2610, var(--panel)); }
.code-head { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; }
.code-head h3 { font-size: 18px; }
.up-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.up { padding: 16px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); display: grid; gap: 10px; align-content: start; }
.pips { display: flex; gap: 6px; }
.pips i { width: 22px; height: 10px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); }
.pips i.on { background: var(--gold); border-color: var(--gold); }

/* Modal, toast */
.modal { position: fixed; inset: 0; background: rgba(5,8,12,.72); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { width: min(560px, 100%); max-height: 90%; overflow-y: auto; background: var(--panel); border: 2px solid var(--gold); border-radius: 18px; padding: 22px; display: grid; gap: 14px; }
.modal-card h2 { color: var(--gold); font-size: 26px; }
.modal-card ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 64px); transform: translateX(-50%); background: var(--gold); color: var(--gold-ink); font-family: var(--display); padding: 10px 18px; border-radius: 12px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 90%; text-align: center; }
.net { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); left: 50%; transform: translateX(-50%); background: #3a2a10; border: 1px solid #7a5a1a; color: var(--fg); padding: 8px 14px; border-radius: 10px; z-index: 55; font-size: 14px; max-width: 92%; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.sum { background: var(--panel-2); border-radius: 12px; padding: 12px; display: grid; gap: 2px; }
.sum b { font-family: var(--display); font-weight: 400; font-size: 26px; color: var(--gold); }
.sum span { font-size: 14px; color: var(--muted); }

/* Forælder */
.pin { display: grid; gap: 12px; max-width: 320px; }
.pin input, .pform input, .pform select, .pform textarea, select.small {
  font: inherit; font-size: 18px; color: var(--fg); background: var(--panel); border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
  -webkit-user-select: text; user-select: text;
}
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.pbox { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.pbox h3 { font-size: 17px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 54px; gap: 10px; align-items: center; font-size: 15px; }
.hbar .track { height: 12px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 99px; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.days { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.days div { flex: 1; max-width: 28px; background: var(--good); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
td.wrap { white-space: normal; min-width: 200px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); }
.pform { display: grid; gap: 10px; }
.pform label { font-weight: 700; font-size: 14px; }
.small-btn { font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); }
.err { color: var(--bad); font-weight: 700; }
.okmsg { color: var(--good); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .typed.cursor::after { animation: none; }
  .typed.shake { animation: none; }
  .big, .btn { transition: none; }
}
