/* IT Dungeon. Phone first (portrait), fine on a desktop.
   Theme: every colour is a token here. A reskin changes this block and
   content/theme.json, nothing else. */
:root {
  --bg: #0f1512;
  --panel: #18201c;
  --panel-2: #202a25;
  --line: #2c3832;
  --ink: #e4ede7;
  --muted: #94a59b;
  --accent: #9fcf74; /* green */
  --accent-ink: #0f1512;
  --good: #9fcf74;
  --bad: #ef6f62;
  --crit: #f2c14e;
  --enemy: #ef6f62;
  --rare: #6fb1ef;
  --epic: #c48cf0;
  --volt: #f5d547;
  --heat: #f08a4b;
  --chill: #7fd3f0;
  --corrosion: #a3d977;
  --code-bg: #0b100d;
  --code-kw: #c48cf0;
  --code-fn: #6fb1ef;
  --code-num: #f2c14e;
  --code-com: #6b7d72;
  --radius: 12px;
  --tap: 48px;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 480px; margin: 0 auto; padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }
h1, h2 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 26px; }
h2 { font-size: 18px; margin-top: 20px; }
p { margin: 0 0 10px; }
.mono { font-family: var(--mono); }
.fine { color: var(--muted); font-size: 13px; }
.center { text-align: center; display: block; margin-inline: auto; }
.kicker { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; margin: 10px 0 4px; }
.boot, .boot-error { padding: 40px 0; text-align: center; color: var(--muted); }
.boot-error { color: var(--bad); }

/* ---------- buttons */
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary {
  min-height: var(--tap);
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.primary.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.wide { width: 100%; margin: 8px 0; }
.link { background: none; border: 0; color: var(--accent); padding: 10px 6px; min-height: var(--tap); text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--bad); }
.tag {
  display: inline-block;
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.08em;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  text-transform: uppercase;
  margin-right: 6px;
}

/* ---------- bars */
.bar { display: inline-block; position: relative; height: 8px; flex: 1; min-width: 60px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; transition: width 0.25s ease; }
.bar.low .fill { background: var(--bad); }
.bar.enemy .fill { background: var(--enemy); }

/* ---------- title */
.title { text-align: center; padding-top: 28px; }
.logo { display: flex; justify-content: center; align-items: baseline; gap: 10px; }
.logo h1 { font-size: 34px; margin: 0; }
.prompt-glyph { font: 700 28px var(--mono); color: var(--accent); }
.sub { color: var(--ink); margin-top: 8px; }
.tagline { color: var(--muted); margin-bottom: 22px; }
.modes, .tabs { display: flex; gap: 6px; margin: 14px 0 6px; }
.tabs { flex-wrap: wrap; }
.mode { flex: 1; min-height: 40px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 6px 10px; }
.mode.on { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.mode-blurb { color: var(--muted); font-size: 14px; min-height: 2.6em; }
.links { display: flex; justify-content: center; gap: 18px; }

/* ---------- screens */
.back { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.back h1 { font-size: 20px; margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.dungeon .topic { color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.dungeon .certs { color: var(--muted); font-weight: 400; }
.locked { color: var(--muted); font-style: italic; }
.skills { list-style: none; padding: 0; margin: 10px 0; }
.skills li { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.skills .name { flex: 0 0 48%; }
.skills .delta { font: 600 12px var(--mono); color: var(--muted); min-width: 40px; text-align: right; }
.skills .delta.up { color: var(--good); }
.skill-line { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

/* ---------- HUD */
.hud { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.hud-top, .hud-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.hud .where { color: var(--muted); }
.hud .step { font: 600 12px var(--mono); }
.hp { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.hp .label { font-weight: 700; min-width: 54px; }
.num { font: 600 13px var(--mono); min-width: 44px; text-align: right; }
.bugs { font: 600 12px var(--mono); color: var(--crit); }
.squashed { font: 600 12px var(--mono); color: var(--good); }
.tools { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
.tool-chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 99px; padding: 3px 8px; font-size: 12px; }

/* ---------- doors & rewards */
.pick-door { text-align: center; margin: 14px 0 10px; }
.doors { display: grid; gap: 10px; }
.door, .reward {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  min-height: 84px; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
}
.door:hover, .reward:hover { border-color: var(--accent); }
.door-title { font-size: 18px; font-weight: 700; }
.door-sub { font: 12px var(--mono); color: var(--muted); }
.door-text { color: var(--muted); font-size: 14px; }
.door-boss { border-color: var(--enemy); }
.door-boss .tag { background: var(--enemy); color: var(--accent-ink); }
.door-vault .tag { background: var(--rare); color: var(--accent-ink); }
.door-bugs .tag { background: var(--crit); color: var(--accent-ink); }
.door-rest .tag { background: var(--accent); color: var(--accent-ink); }
.r-rare { border-color: var(--rare); } .r-rare .tag { background: var(--rare); color: var(--accent-ink); }
.r-epic { border-color: var(--epic); } .r-epic .tag { background: var(--epic); color: var(--accent-ink); }
.foot { display: flex; justify-content: space-between; margin-top: 16px; }

/* ---------- room */
.enemy { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--enemy); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.enemy.boss { border-color: var(--enemy); }
.enemy.vault { border-left-color: var(--rare); }
.enemy-name { font-weight: 700; font-size: 18px; margin-bottom: 6px; }
.enemy-hp { display: flex; align-items: center; gap: 8px; }
.intent { font: 13px var(--mono); color: var(--muted); margin: 8px 0 0; }
.intent .glyph { color: var(--enemy); }
.intent .hits { color: var(--enemy); }

.clock { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.timer { flex: 1; height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; position: relative; }
.timer .fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--muted); }
.timer.crit .fill { background: var(--crit); }
.timer-label { font: 11px var(--mono); color: var(--muted); min-width: 90px; text-align: right; }

.puzzle-wrap, .teach, .outcome { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.prompt { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.options, .lines { display: grid; gap: 8px; }
.option, .line, .chip {
  display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: var(--tap); padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2);
}
.option:hover:not(:disabled), .line:hover, .chip:hover { border-color: var(--accent); }
.line { font-size: 14px; white-space: pre-wrap; }
.k { font: 700 11px var(--mono); color: var(--muted); min-width: 14px; }
.k.empty { opacity: 0.5; }
.typed { display: flex; gap: 8px; }
.answer { flex: 1; min-width: 0; min-height: var(--tap); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 18px; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.chip { font-size: 14px; }
.chip.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chip.paired { background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); }
.slots { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.slot { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font: 12px var(--mono); }
.slots .chip { width: 100%; }
.pool { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }

.teach { border-color: var(--accent); }
.intel { font-size: 20px; font-weight: 700; color: var(--accent); margin: 6px 0 10px; overflow-wrap: anywhere; }
.why { color: var(--ink); opacity: 0.9; font-size: 15px; }
.outcome.good { border-color: var(--good); }
.outcome.bad { border-color: var(--bad); }
.result { font-weight: 800; font-size: 20px; }
.result.good { color: var(--good); }
.result.bad { color: var(--bad); }
.answer-line { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.match-results { list-style: none; padding: 0; font-size: 14px; }
.match-results .good { color: var(--good); }
.match-results .bad { color: var(--bad); }
.note { color: var(--crit); font-size: 14px; }

/* ---------- results & codex */
.results h1 { font-size: 30px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { margin: 0; font: 700 15px var(--mono); }
.incidents { padding-left: 20px; }
.incidents li { margin-bottom: 14px; }
.incidents .q { color: var(--muted); font-size: 14px; margin-bottom: 2px; }
.facts { list-style: none; padding: 0; margin: 0; }
.facts li { border-top: 1px solid var(--line); padding: 8px 0; font-size: 14px; }
.facts .unknown { color: var(--muted); font-family: var(--mono); }
.facts summary { display: flex; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; }
.facts summary::-webkit-details-marker { display: none; }
.pips { display: inline-flex; gap: 3px; flex: none; align-items: center; }
.pip { width: 7px; height: 7px; border-radius: 2px; background: var(--panel-2); }
.pip.on { background: var(--accent); }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--accent); font-size: 14px; transition: opacity 0.4s;
}
.toast.out { opacity: 0; }

/* ---------- v0.2: setup, fights, code */
.small { font-size: 13px; min-height: 36px; padding: 6px 4px; }
.pick-list { display: grid; gap: 8px; }
.pick-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
}
.pick-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pick-title { font-weight: 700; font-size: 17px; }
.pick-text { color: var(--muted); font-size: 14px; }
.pick-stats { font-size: 12px; color: var(--ink); display: flex; align-items: center; gap: 6px; width: 100%; }
.pick-kit { font: 12px var(--mono); color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; color: var(--muted); }
.start { margin-top: 18px; }
.floor-blurb { color: var(--muted); text-align: center; margin: 4px 0 0; }
.hud .link.small { min-height: 0; padding: 2px 4px; }
.shield-chip { font: 600 12px var(--mono); color: var(--rare); white-space: nowrap; }

.enemies { display: grid; gap: 8px; margin-bottom: 10px; }
.enemy {
  display: flex; flex-direction: column; align-items: stretch; gap: 5px; width: 100%; text-align: left;
  margin: 0; padding: 10px 12px; font: inherit;
}
.enemy.target { border-color: var(--crit); border-left-color: var(--crit); box-shadow: 0 0 0 1px var(--crit) inset; }
.enemy.bug { border-left-color: var(--crit); }
.enemy-head { display: flex; align-items: baseline; gap: 8px; }
.enemy-head .enemy-name { flex: 1; font-size: 16px; margin: 0; }
.enemy .intent { margin: 0; }
.enemy .intent.hurts { color: var(--enemy); }
.real { color: var(--muted); font-size: 12px; opacity: 0.85; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font: 700 11px var(--mono); padding: 3px 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); }
.badge.el-volt { color: var(--volt); border-color: var(--volt); }
.badge.el-heat { color: var(--heat); border-color: var(--heat); }
.badge.el-chill { color: var(--chill); border-color: var(--chill); }
.badge.el-corrosion { color: var(--corrosion); border-color: var(--corrosion); }
.badge.warn { color: var(--bad); border-color: var(--bad); }
.badge.dim { color: var(--muted); }
.notes { margin-bottom: 10px; }

.actions { display: grid; gap: 8px; margin: 10px 0; }
.actions .kicker { margin: 0; }
.action {
  display: grid; grid-template-columns: 16px 1fr; column-gap: 8px; align-items: baseline; text-align: left;
  min-height: var(--tap); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
}
.action:hover:not(:disabled) { border-color: var(--accent); }
.action.patch { border-color: color-mix(in srgb, var(--rare) 50%, var(--line)); }
.action-name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.action-sub { grid-column: 2; color: var(--muted); font-size: 13px; }
.question { display: grid; gap: 8px; }
.question .kicker { margin: 0; }

.code {
  margin: 6px 0; padding: 10px 12px; border-radius: 10px; background: var(--code-bg); border: 1px solid var(--line);
  font: 13px/1.5 var(--mono); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; width: 100%; text-align: left;
}
.code .mark { background: color-mix(in srgb, var(--crit) 18%, transparent); }
.c-kw { color: var(--code-kw); }
.c-fn { color: var(--code-fn); }
.c-num { color: var(--code-num); }
.c-com { color: var(--code-com); font-style: italic; }
.c-deco { color: var(--crit); }
.c-el.el-volt { color: var(--volt); } .c-el.el-heat { color: var(--heat); } .c-el.el-chill { color: var(--chill); } .c-el.el-corrosion { color: var(--corrosion); }
.code-peek { margin-top: 10px; }
.code-peek summary { cursor: pointer; color: var(--accent); font-size: 14px; padding: 6px 0; }

.log { list-style: none; padding: 0; margin: 8px 0 0; font: 13px/1.45 var(--mono); }
.log li { padding: 1px 0; animation: logIn 0.25s ease both; white-space: pre-wrap; }
.log-crit { color: var(--crit); font-weight: 700; }
.log-hit, .log-you { color: var(--ink); }
.log-el { color: var(--heat); }
.log-react { color: var(--volt); font-weight: 700; }
.log-kill { color: var(--good); font-weight: 700; }
.log-enemy { color: var(--enemy); }
.log-err { color: var(--bad); font-style: italic; }
.log-info { color: var(--muted); }
@keyframes logIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.outcome { margin-bottom: 4px; }

.reward-head { display: flex; flex-wrap: wrap; gap: 4px; }
.tag.dim { background: transparent; border: 1px solid var(--line); }
.tag.rar-rare { background: var(--rare); color: var(--accent-ink); }
.tag.rar-epic { background: var(--epic); color: var(--accent-ink); }
.reward .code { pointer-events: none; }
.place {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
}
.place:hover { border-color: var(--accent); }
.place .door-title { font-size: 15px; }

.build h2 { margin-top: 18px; }
.fn { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.fn-head { display: flex; flex-direction: column; gap: 2px; }
.stats.compact { grid-template-columns: repeat(3, 1fr); }
.hw { padding-left: 18px; font-size: 14px; }
.hw li { margin-bottom: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .log li { animation: none; }
}

/* --- 2026-11-15: achievements, toggles, floor cleared */
.toggles { display: flex; justify-content: center; gap: 14px; margin-top: 4px; }
.toggles .ico { width: 16px; height: 16px; vertical-align: -3px; }
.toast.ach { top: calc(10px + env(safe-area-inset-top)); bottom: auto; z-index: 60; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--crit); }
.toast.ach > .ico { flex: none; width: 28px; height: 28px; color: var(--crit); }
.toast.ach span { display: flex; flex-direction: column; }
.toast.ach small { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--crit); }
.achievements { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.achievements li { border: 1px solid var(--line, rgba(255, 255, 255, 0.12)); border-radius: 12px; padding: 8px 10px; }
.achievements li.got { border-color: rgba(242, 193, 78, 0.55); }
.achievements li.locked { opacity: 0.7; }
.achievements summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.achievements summary::-webkit-details-marker { display: none; }
.ach-ico .ico { width: 24px; height: 24px; }
.achievements li.got .ach-ico { color: var(--crit); }
.ach-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ach-body .dim { font-size: 13px; }
.ach-when { font-size: 11px; }
.achievements .why { margin: 8px 0 0; }

/* --- from Order Up (2026-11-15): settings, past runs, confirm, what your code did */
.links.two-rows { flex-wrap: wrap; row-gap: 4px; column-gap: 16px; }
.card.confirm { text-align: left; }
.card.confirm .row2 { display: flex; gap: 8px; margin-top: 10px; }
.card.confirm .row2 button { flex: 1; }
.vol-row { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.vol-label { font-weight: 700; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.history li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line, rgba(255, 255, 255, 0.12)); }
.history li.won { border-color: var(--good); }
.history li.lost { border-color: rgba(239, 111, 98, 0.5); }
.h-art .sprite { width: 40px; height: 40px; }
.h-body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.h-body .dim { font-size: 12px; }
.h-score { display: flex; flex-direction: column; align-items: flex-end; font-family: var(--mono); }
.code-did { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.code-did li { display: grid; grid-template-columns: 1fr; gap: 3px; }
.foot.sticky { position: sticky; bottom: 0; z-index: 5; padding: 10px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
/* --- sound test page (?debug&sound, 2026-11-15) */
.soundtest .row2 { display: flex; gap: 8px; margin: 8px 0; }
.soundtest .row2 button { flex: 1; }
.st-slider { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.st-slider input { width: 100%; }
.st-readout { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.45); font: 12px/1.5 var(--mono); white-space: pre-wrap; }
.st-sfx { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.st-sfx button { min-height: 40px; padding: 4px; font: 12px var(--mono); }
