/* HackDev Build Quest — retro stage styles.
   Palette: HackDev logo olive + hackdev.my dark canvas and green. */
:root {
  --bg: #0b0e0d;
  --panel: #101512;
  --panel-2: #161d19;
  --panel-3: #1c2520;
  --ink: #edf1ee;
  --ink-2: #b2bcb6;
  --mute: #929f96;
  --line: #27332c;
  --line-strong: #3f5145;
  --neon: #3ecf8e;
  --neon-soft: #5ee09e;
  --neon-deep: #20a06b;
  --on-neon: #092116;
  --olive: #536440;
  --olive-dark: #3a4a2c;
  --olive-light: #7d9460;
  --gold: #f2c94c;
  --gold-deep: #b8892a;
  --red: #ff6b5b;
  --shadow: #000;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --hud-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 var(--mono);
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--neon); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
.pixel { font-family: var(--pixel); letter-spacing: 0.02em; line-height: 1.5; font-weight: 400; }
.small { font-size: 10px; }
.muted { color: var(--mute); }
kbd { font-family: var(--mono); background: var(--panel-3); border: 1px solid var(--line-strong); padding: 1px 6px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--neon); color: var(--on-neon); padding: 8px 12px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* CRT scanlines */
body.crt::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 90;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,.45) 100%);
}

/* ───────── buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 10px/1.4 var(--pixel);
  color: var(--ink);
  background: var(--panel-3);
  border: 3px solid var(--line-strong);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.btn:hover { background: var(--panel-2); border-color: var(--neon-deep); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--shadow); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 var(--shadow); }
.btn-primary { background: var(--neon); color: var(--on-neon); border-color: var(--neon-soft); }
.btn-primary:hover { background: var(--neon-soft); border-color: var(--ink); }
.btn-primary:disabled:hover { background: var(--neon); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: #6b2f29; }
.btn-xl { font-size: 13px; padding: 16px 22px; }
.btn-block { width: 100%; }
.btn-icon { width: 42px; height: 42px; padding: 0; }
.btn-link { font-size: 9px; padding: 8px 12px 8px 10px; box-shadow: 3px 3px 0 var(--shadow); gap: 10px; }
.link-ico { width: 22px; height: 22px; flex: none; object-fit: contain; }
.btn-signin .link-ico { width: 20px; height: 20px; }
.btn-signin { background: var(--olive); border-color: var(--olive-light); }
.btn-signin:hover { background: var(--olive-light); color: var(--bg); }

/* ───────── HUD ───────── */
.hud {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  min-height: var(--hud-h);
  padding: 10px 20px;
  background: rgba(11, 14, 13, .96);
  border-bottom: 3px solid var(--line-strong);
  box-shadow: 0 4px 0 var(--shadow);
}
.hud-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 18px var(--mono); }
.caret { color: var(--neon); animation: blink 1s steps(1) infinite; }
.pixel-shield {
  width: 26px; height: 30px;
  background: var(--neon);
  clip-path: polygon(50% 0, 100% 14%, 100% 52%, 84% 78%, 50% 100%, 16% 78%, 0 52%, 0 14%);
  position: relative;
}
.pixel-shield::after {
  content: ""; position: absolute; inset: 4px;
  background: var(--bg);
  clip-path: polygon(50% 0, 100% 14%, 100% 52%, 84% 78%, 50% 100%, 16% 78%, 0 52%, 0 14%);
}
.pixel-shield::before {
  content: ""; position: absolute; z-index: 1; left: 9px; top: 11px; width: 8px; height: 7px;
  background: var(--neon); box-shadow: 0 -4px 0 -1px var(--bg);
  border-top: 3px solid var(--neon);
}
.hud-stats { display: flex; justify-content: center; gap: 28px; margin: 0; }
.hud-stats div { text-align: left; }
.hud-stats dt { font: 8px var(--pixel); color: var(--mute); display: flex; align-items: center; gap: 4px; }
.hud-stats dd { margin: 4px 0 0; font: 12px var(--pixel); color: var(--ink); }
#hud-score { color: var(--neon); }
#hud-coins { color: var(--gold); }
.hud-actions { display: flex; gap: 10px; align-items: center; }

.coin-ico {
  display: inline-block; width: 10px; height: 12px; flex: none;
  background: var(--gold); border-radius: 40%;
  box-shadow: inset -2px 0 0 var(--gold-deep), inset 0 0 0 1px #6b4f12;
}

/* ───────── screens ───────── */
#app { outline: none; }
.screen { max-width: 920px; margin: 0 auto; padding: 32px 20px 80px; }

.eyebrow { font: 10px/1.6 var(--pixel); color: var(--neon); letter-spacing: .08em; margin-bottom: 10px; }

/* title */
.title-screen { text-align: center; position: relative; padding-top: 40px; }
.stars {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1px 1px at 10% 20%, #edf1ee 99%, transparent),
    radial-gradient(1px 1px at 80% 12%, #5ee09e 99%, transparent),
    radial-gradient(2px 2px at 30% 70%, #edf1ee 99%, transparent),
    radial-gradient(1px 1px at 65% 40%, #edf1ee 99%, transparent),
    radial-gradient(2px 2px at 90% 75%, #3ecf8e 99%, transparent),
    radial-gradient(1px 1px at 45% 15%, #edf1ee 99%, transparent),
    radial-gradient(1px 1px at 15% 88%, #7d9460 99%, transparent),
    linear-gradient(#0b0e0d, #101c15 70%, #1a2615);
}
.title-logo {
  width: min(380px, 78vw); height: auto; margin: 0 auto 34px;
  filter: drop-shadow(0 0 18px rgba(62, 207, 142, .25));
  animation: float 3.2s ease-in-out infinite;
}
.title-h1 {
  display: flex; flex-direction: column; gap: 14px;
  font-size: clamp(34px, 9vw, 72px);
  line-height: 1.1;
  color: var(--ink);
  text-shadow: 4px 4px 0 var(--neon-deep), 8px 8px 0 var(--olive-dark), 12px 12px 0 var(--shadow);
  margin: 6px 0 22px;
}
.title-h1 span:last-child { color: var(--neon); text-shadow: 4px 4px 0 var(--olive), 8px 8px 0 var(--olive-dark), 12px 12px 0 var(--shadow); }
.tagline { color: var(--ink-2); font-size: 15px; margin-bottom: 30px; }
.start-form { display: grid; gap: 14px; justify-items: center; max-width: 360px; margin: 0 auto 36px; }
.start-form label { color: var(--mute); }
.start-form input {
  width: 100%;
  font: 16px var(--pixel);
  text-align: center; text-transform: uppercase;
  color: var(--gold);
  background: var(--bg);
  border: 3px solid var(--line-strong);
  box-shadow: inset 4px 4px 0 var(--shadow);
  padding: 14px 10px;
}
.start-form input:focus { border-color: var(--neon); outline: none; }
.how { list-style: none; padding: 0; margin: 0 auto 30px; display: grid; gap: 10px; max-width: 460px; text-align: left; color: var(--ink-2); font-size: 14px; }
.how li { display: flex; align-items: center; gap: 12px; }
.q-ico { width: 18px; height: 18px; flex: none; display: grid; place-items: center; font: 9px var(--pixel); background: var(--neon); color: var(--on-neon); box-shadow: 2px 2px 0 var(--shadow); }
.flag-ico { width: 18px; height: 18px; flex: none; position: relative; }
.flag-ico::before { content: ""; position: absolute; left: 2px; top: 0; width: 3px; height: 18px; background: var(--ink); }
.flag-ico::after { content: ""; position: absolute; left: 5px; top: 1px; border-left: 12px solid var(--neon); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.how .coin-ico { width: 14px; height: 18px; margin: 0 2px; }
.legal { font-size: 12px; color: var(--mute); }

/* ───────── world map ───────── */
.map-head { text-align: center; margin-bottom: 28px; }
.map-head h1 { font-size: clamp(20px, 4vw, 28px); text-shadow: 4px 4px 0 var(--olive-dark); }
.map-sub { color: var(--ink-2); margin: 10px 0 12px; }
.bar { height: 14px; background: var(--bg); border: 3px solid var(--line-strong); max-width: 420px; margin: 0 auto; }
.bar span { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--neon) 0 10px, var(--neon-deep) 10px 12px); transition: width .4s; }

.world {
  position: relative;
  margin-bottom: 26px;
  border: 4px solid var(--shadow);
  box-shadow: 6px 6px 0 var(--shadow);
  overflow: hidden;
}
.world--field { background: linear-gradient(#5f7449, var(--olive) 60%); }
.world--forest { background: linear-gradient(#2c3a24, #3a4a2c 70%); }
.world--circuit {
  background-color: #101c15;
  background-image:
    linear-gradient(rgba(62,207,142,.08) 2px, transparent 2px),
    linear-gradient(90deg, rgba(62,207,142,.08) 2px, transparent 2px);
  background-size: 32px 32px;
}
.world--castle {
  background:
    radial-gradient(2px 2px at 12% 18%, #edf1ee 99%, transparent),
    radial-gradient(2px 2px at 70% 10%, #edf1ee 99%, transparent),
    radial-gradient(1px 1px at 40% 30%, #5ee09e 99%, transparent),
    radial-gradient(1px 1px at 88% 34%, #edf1ee 99%, transparent),
    linear-gradient(#0b0e0d, #161d19);
}
.world-banner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px;
  padding: 14px 18px 4px;
}
.world-no { font-size: 10px; color: var(--gold); text-shadow: 2px 2px 0 var(--shadow); }
.world-banner h2 { font-size: 16px; text-shadow: 3px 3px 0 var(--shadow); }
.world-time {
  margin-left: auto;
  font: 9px var(--pixel); color: var(--ink); background: rgba(0,0,0,.4); padding: 5px 8px; border: 2px solid rgba(255,255,255,.15);
}
.world-goal { padding: 0 18px 8px; color: var(--ink); opacity: .85; font-size: 13px; text-shadow: 1px 1px 0 var(--shadow); }
.world--done .world-banner h2::after { content: " ✓"; color: var(--neon); }

.path {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap;
}
.stop {
  position: relative;
  flex: 1 1 140px;
  display: flex; justify-content: center;
  padding: 60px 8px 40px;
}
/* brick ground under every stop, so wrapped rows keep their floor */
.stop::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 28px;
  background:
    linear-gradient(var(--shadow) 2px, transparent 2px) 0 0 / 100% 14px,
    repeating-linear-gradient(90deg, transparent 0 26px, var(--shadow) 26px 28px) 0 0 / 28px 14px,
    repeating-linear-gradient(90deg, transparent 0 12px, var(--shadow) 12px 14px, transparent 14px 28px) 0 14px / 28px 14px no-repeat,
    #8a5a2b;
  border-top: 4px solid var(--neon-deep);
}
.world--circuit .stop::after { background-color: #2c3e32; border-top-color: var(--neon); }
.world--castle .stop::after { background-color: #4a4f55; border-top-color: #6c737a; }
/* dashed path between stops */
.stop::before {
  content: ""; position: absolute; left: 0; right: 0; top: 92px; height: 4px;
  background: repeating-linear-gradient(90deg, rgba(237,241,238,.55) 0 8px, transparent 8px 16px);
}
.stop:first-child::before { left: 50%; }
.stop:last-child::before { right: 50%; }

.node {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink);
  font: inherit;
}
.block {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  font: 22px var(--pixel);
  color: var(--on-neon);
  background: var(--neon);
  border: 4px solid var(--shadow);
  box-shadow: inset -6px -6px 0 var(--neon-deep), inset 6px 6px 0 var(--neon-soft), 4px 4px 0 var(--shadow);
  transition: transform .12s;
}
.node:hover .block, .node:focus-visible .block { transform: translateY(-6px); }
.node:focus-visible { outline: none; }
.node:focus-visible .block { outline: 3px solid var(--gold); outline-offset: 4px; }
.node--current .block {
  background: var(--gold); color: #3a2a05;
  box-shadow: inset -6px -6px 0 var(--gold-deep), inset 6px 6px 0 #ffe08a, 4px 4px 0 var(--shadow);
  animation: pulse 1.2s ease-in-out infinite;
}
.node--cleared .block {
  background: var(--olive-light);
  box-shadow: inset -6px -6px 0 var(--olive-dark), inset 6px 6px 0 #a3b986, 4px 4px 0 var(--shadow);
}
.node--locked { cursor: not-allowed; }
.node--locked .block {
  background: #4b5a50;
  box-shadow: inset -6px -6px 0 #333e37, inset 6px 6px 0 #6a7a6f, 4px 4px 0 var(--shadow);
}
.node--boss .block { width: 76px; height: 76px; font-size: 28px; }
.node--boss:not(.node--locked):not(.node--cleared):not(.node--current) .block {
  background: var(--ink); color: var(--bg);
  box-shadow: inset -6px -6px 0 #9aa69f, inset 6px 6px 0 #fff, 4px 4px 0 var(--shadow);
}
.node-label {
  font: 9px/1.5 var(--pixel); text-align: center; text-shadow: 2px 2px 0 var(--shadow);
  display: flex; flex-direction: column; gap: 3px;
}
.node-label b { color: var(--gold); font-weight: 400; }
.node--locked .node-label { opacity: .6; }

i.lock { position: relative; width: 20px; height: 14px; background: #1b221e; margin-top: 8px; }
i.lock::before { content: ""; position: absolute; left: 3px; top: -10px; width: 8px; height: 8px; border: 3px solid #1b221e; border-bottom: 0; }
i.lock::after { content: ""; position: absolute; left: 8px; top: 4px; width: 4px; height: 6px; background: #6a7a6f; }
i.flag { position: relative; width: 26px; height: 30px; }
i.flag::before { content: ""; position: absolute; left: 4px; top: 0; width: 4px; height: 30px; background: var(--bg); }
i.flag::after { content: ""; position: absolute; left: 8px; top: 2px; border-left: 16px solid var(--ink); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }

.player {
  position: absolute; z-index: 2; top: 4px; left: 50%;
  width: 36px; transform: translateX(-50%);
  animation: bob .7s steps(2) infinite;
  filter: drop-shadow(3px 3px 0 var(--shadow));
}
.player .sprite { width: 36px; height: 42px; }
.map-foot { text-align: center; color: var(--mute); font-size: 12px; }

/* ───────── level ───────── */
.level { max-width: 860px; }
/* each world tints the stage badge strip */
.level--field .crumbs { border-bottom: 4px solid var(--olive-light); padding-bottom: 14px; }
.level--forest .crumbs { border-bottom: 4px solid var(--olive); padding-bottom: 14px; }
.level--circuit .crumbs { border-bottom: 4px solid var(--neon-deep); padding-bottom: 14px; }
.level--castle .crumbs { border-bottom: 4px solid #6c737a; padding-bottom: 14px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 24px; }
.crumbs .world-time { margin-left: auto; }
.stage-head { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: start; margin-bottom: 22px; }
.stage-badge {
  display: grid; place-items: center; align-content: center; gap: 4px;
  width: 92px; height: 92px;
  font-size: 18px; color: var(--on-neon);
  background: var(--neon);
  border: 4px solid var(--shadow);
  box-shadow: inset -7px -7px 0 var(--neon-deep), inset 7px 7px 0 var(--neon-soft), 6px 6px 0 var(--shadow);
}
.stage-badge small { font-size: 8px; }
.level--boss .stage-badge {
  background: var(--ink); color: var(--bg);
  box-shadow: inset -7px -7px 0 #9aa69f, inset 7px 7px 0 #fff, 6px 6px 0 var(--shadow);
}
.stage-head h1 { font-size: clamp(24px, 4.2vw, 36px); font-weight: 700; letter-spacing: -0.01em; margin-bottom: 12px; }
.lead { color: var(--ink-2); font-size: 16px; }

.meter {
  position: sticky; top: calc(var(--hud-h) + 6px); z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 12px 16px; margin-bottom: 24px;
  background: var(--panel); border: 3px solid var(--line-strong); box-shadow: 4px 4px 0 var(--shadow);
  font-size: 13px;
}
.meter b { font-size: 9px; color: var(--mute); margin-right: 6px; }
.meter .bar { flex: 1 1 160px; margin: 0; max-width: none; height: 12px; }
.cleared-tag { font-size: 9px; color: var(--on-neon); background: var(--neon); padding: 4px 8px; }

.box {
  background: var(--panel);
  border: 3px solid var(--line-strong);
  box-shadow: 5px 5px 0 var(--shadow);
  padding: 18px 20px;
  margin-bottom: 22px;
}
.box-title { font-size: 10px; color: var(--neon); margin-bottom: 12px; }
.box--rule { background: var(--olive); border-color: var(--olive-light); }
.box--rule .box-title { color: var(--gold); text-shadow: 2px 2px 0 var(--shadow); }
.rule-text { font-size: 19px; font-weight: 700; line-height: 1.45; }
.box--warn { background: #1d1310; border-color: #6b2f29; }
.box--warn .box-title { color: var(--red); }
.box--note { background: var(--panel-2); border-style: dashed; }
.box--note .box-title { color: var(--gold); }
.loot { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; counter-reset: n; }
.loot li { position: relative; padding-left: 28px; }
.loot li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 12px; background: var(--gold); border-radius: 40%; box-shadow: inset -2px 0 0 var(--gold-deep); }
ol.loot li::before { counter-increment: n; content: counter(n); width: 18px; height: 18px; top: 2px; left: 0; border-radius: 0; display: grid; place-items: center; font: 9px var(--pixel); color: var(--on-neon); background: var(--neon); box-shadow: 2px 2px 0 var(--shadow); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 2px solid var(--line); }
thead th { font: 9px var(--pixel); color: var(--mute); border-bottom: 3px solid var(--line-strong); white-space: nowrap; }
tbody th { font-weight: 700; color: var(--ink); }
td { color: var(--ink-2); }
tbody tr:last-child > * { border-bottom: 0; }

.term {
  margin: 0 0 14px;
  max-height: 340px; overflow: auto;
  padding: 16px;
  background: #050706;
  color: var(--neon-soft);
  border: 3px solid var(--line-strong);
  box-shadow: inset 4px 4px 0 var(--shadow);
  font: 13px/1.6 var(--mono);
  white-space: pre-wrap; word-break: break-word;
}
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.hint { color: var(--mute); font-size: 13px; flex: 1 1 240px; }

.section-title { font-size: 13px; margin: 34px 0 16px; color: var(--ink); text-shadow: 3px 3px 0 var(--olive-dark); }

/* quests */
.quest {
  position: relative;
  background: var(--panel);
  border: 3px solid var(--line-strong);
  box-shadow: 5px 5px 0 var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
  transition: border-color .2s, background .2s;
}
.quest.done { border-color: var(--neon-deep); background: var(--panel-2); }
.quest--hd { border-color: var(--olive-light); }
.quest-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.quest-num { font-size: 11px; color: var(--gold); }
.quest-head h3 { font-size: 17px; }
.tag { margin-left: auto; font: 8px var(--pixel); background: var(--olive); color: var(--ink); padding: 5px 7px; border: 2px solid var(--olive-light); }
.quest-body { margin: 0 0 14px; display: grid; gap: 10px; }
.quest-body div { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
.quest-body dt { font: 8px/2 var(--pixel); color: var(--mute); }
.quest-body dd { margin: 0; color: var(--ink-2); font-size: 14px; }
.quest-body div:first-child dd { color: var(--ink); }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

.tick {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--bg);
  border: 2px dashed var(--line-strong);
  cursor: pointer;
}
.tick:hover { border-color: var(--neon-deep); }
.tick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tick-box {
  flex: none; width: 34px; height: 34px;
  display: grid; place-items: center;
  font: 14px var(--pixel); color: #3a2a05;
  background: var(--gold);
  border: 3px solid var(--shadow);
  box-shadow: inset -4px -4px 0 var(--gold-deep), inset 4px 4px 0 #ffe08a;
}
.tick-box::before { content: "?"; }
.tick input:checked + .tick-box { background: var(--neon); color: var(--on-neon); box-shadow: inset -4px -4px 0 var(--neon-deep), inset 4px 4px 0 var(--neon-soft); animation: bump .25s; }
.tick input:checked + .tick-box::before { content: "✓"; font-family: var(--mono); font-weight: 700; font-size: 20px; }
.tick input:focus-visible + .tick-box { outline: 3px solid var(--gold); outline-offset: 3px; }
.tick-text { font-size: 14px; }
.quest.done .tick { border-style: solid; border-color: var(--neon-deep); }

/* quiz */
.quiz-q { background: var(--panel); border: 3px solid var(--line-strong); box-shadow: 5px 5px 0 var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.quiz-q.solved { border-color: var(--neon-deep); }
.q { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.q .pixel { font-size: 11px; color: var(--gold); margin-right: 6px; }
.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; font: 14px/1.5 var(--mono); color: var(--ink);
  background: var(--bg); border: 3px solid var(--line-strong); padding: 12px 14px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
}
.opt:hover:not(:disabled) { border-color: var(--neon); }
.opt:disabled { cursor: default; opacity: .55; }
.opt.right { border-color: var(--neon); background: #0f2a1d; opacity: 1; }
.opt.wrong { border-color: var(--red); text-decoration: line-through; color: var(--mute); }
.explain { margin-top: 12px; color: var(--neon-soft); font-size: 14px; }

/* glossary cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card {
  min-height: 112px; padding: 14px;
  text-align: left; color: var(--ink); cursor: pointer;
  background: var(--olive); border: 3px solid var(--shadow);
  box-shadow: inset -5px -5px 0 var(--olive-dark), inset 5px 5px 0 var(--olive-light), 4px 4px 0 var(--shadow);
  font: 13px/1.5 var(--mono);
  display: flex; align-items: center; justify-content: center;
}
.card-front { font-size: 10px; text-align: center; text-shadow: 2px 2px 0 var(--shadow); }
.card-back { display: none; }
.card.flipped { background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--neon-deep), 4px 4px 0 var(--shadow); align-items: flex-start; justify-content: flex-start; }
.card.flipped .card-front { display: none; }
.card.flipped .card-back { display: block; color: var(--ink-2); }
.card-back b { display: block; color: var(--neon); font: 9px var(--pixel); margin-bottom: 6px; }

/* final */
.ranks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.rank {
  position: relative; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center;
  padding: 14px; background: var(--panel); border: 3px solid var(--line-strong); box-shadow: 4px 4px 0 var(--shadow);
}
.rank input { position: absolute; opacity: 0; }
.rank:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 3px; }
.rank-lv { grid-row: span 2; font-size: 10px; color: var(--on-neon); background: var(--gold); padding: 10px 8px; box-shadow: 2px 2px 0 var(--shadow); }
.rank-t { font-size: 10px; }
.rank-d { font-size: 13px; color: var(--ink-2); }
.rank.picked { border-color: var(--neon); background: #0f2a1d; }
.rank.picked .rank-lv { background: var(--neon); }
.next-label { display: grid; gap: 4px; margin-bottom: 10px; }
#next-step {
  width: 100%; font: 15px/1.5 var(--mono); color: var(--ink);
  background: var(--bg); border: 3px solid var(--line-strong); box-shadow: inset 4px 4px 0 var(--shadow); padding: 12px;
}
#next-step:focus { border-color: var(--neon); outline: none; }

/* goal / flagpole */
.goal {
  display: grid; grid-template-columns: 70px 1fr; gap: 20px; align-items: end;
  margin: 40px 0 26px; padding: 22px 22px 0;
  background: linear-gradient(var(--panel-2), var(--panel));
  border: 3px solid var(--line-strong); box-shadow: 6px 6px 0 var(--shadow);
}
.goal-body { padding-bottom: 22px; display: grid; gap: 12px; justify-items: start; }
.flagpole { position: relative; height: 170px; }
.pole { position: absolute; left: 30px; bottom: 0; width: 6px; height: 160px; background: var(--ink-2); }
.pole::before { content: ""; position: absolute; left: -5px; top: -14px; width: 16px; height: 16px; border-radius: 50%; background: var(--gold); }
.pole::after { content: ""; position: absolute; left: -16px; bottom: 0; width: 38px; height: 14px; background: var(--olive); border-top: 3px solid var(--olive-light); }
.pflag {
  position: absolute; left: 36px; bottom: 18px;
  border-left: 34px solid var(--neon); border-top: 13px solid transparent; border-bottom: 13px solid transparent;
  transition: bottom .9s cubic-bezier(.23,1,.32,1);
}
.goal.ready .pflag { bottom: 128px; }
.goal.ready { border-color: var(--neon-deep); }
.goal.ready #btn-clear { animation: glow 1.4s ease-in-out infinite; }
.goal-hint { font-size: 13px; }

.stage-nav { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* stage clear overlay */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 20px;
  background: rgba(5, 7, 6, .86);
  animation: fade .2s;
}
.clear-box {
  width: min(440px, 100%); text-align: center;
  background: var(--panel); border: 4px solid var(--neon); box-shadow: 8px 8px 0 var(--shadow), 0 0 0 8px var(--olive-dark);
  padding: 28px 24px; display: grid; gap: 16px; justify-items: center;
  animation: pop .35s cubic-bezier(.23,1,.32,1);
}
.clear-title { font-size: clamp(16px, 5vw, 22px); color: var(--gold); text-shadow: 3px 3px 0 var(--shadow); }
.clear-sprite .sprite, .end-sprite .sprite { width: 60px; height: 70px; }
.sprite-jump { animation: jump .6s ease-in-out infinite alternate; }
.tally { margin: 0; width: 100%; display: grid; gap: 6px; font: 10px/1.6 var(--pixel); }
.tally div { display: flex; justify-content: space-between; gap: 12px; }
.tally dt { color: var(--mute); }
.tally dd { margin: 0; }
.tally-total { border-top: 3px dashed var(--line-strong); padding-top: 8px; margin-top: 4px; }
.tally-total dd { color: var(--neon); font-size: 14px; }
.clear-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* end */
.end { text-align: center; position: relative; overflow: hidden; display: grid; gap: 18px; justify-items: center; }
.end-kicker { font-size: 14px; color: var(--gold); }
.end-name { font-size: clamp(26px, 7vw, 48px); text-shadow: 4px 4px 0 var(--neon-deep), 8px 8px 0 var(--shadow); word-break: break-word; }
.end-line { font-size: 19px; font-weight: 700; }
.end-stats { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; width: 100%; }
.end-stats div { background: var(--panel); border: 3px solid var(--line-strong); box-shadow: 4px 4px 0 var(--shadow); padding: 14px; }
.end-stats dt { font: 8px var(--pixel); color: var(--mute); margin-bottom: 8px; }
.end-stats dd { margin: 0; font-size: 13px; color: var(--neon); }
.end-next { width: 100%; text-align: left; }
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -20px; left: var(--x); width: 8px; height: 8px; background: var(--c); animation: fall 3.4s linear var(--d) infinite; }

/* pause menu */
.pause { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: calc(100vw - 32px); }
.pause::backdrop { background: rgba(5, 7, 6, .82); }
.pause-box {
  width: min(360px, 100%); display: grid; gap: 12px; padding: 26px;
  background: var(--panel); border: 4px solid var(--neon); box-shadow: 8px 8px 0 var(--shadow);
}
.pause-box h2 { text-align: center; font-size: 18px; color: var(--gold); margin-bottom: 6px; animation: blink 1.2s steps(1) infinite; }
.pause-hint { text-align: center; font: 8px var(--pixel); color: var(--mute); }

/* toast + floating points */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 95;
  transform: translate(-50%, 140%);
  font: 10px/1.5 var(--pixel); color: var(--on-neon); background: var(--gold);
  border: 3px solid var(--shadow); box-shadow: 4px 4px 0 var(--shadow);
  padding: 12px 16px; max-width: calc(100vw - 32px); text-align: center;
  visibility: hidden;
  transition: transform .25s cubic-bezier(.23,1,.32,1), visibility 0s .25s;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }
.float-pts {
  position: fixed; z-index: 96; pointer-events: none;
  font: 12px var(--pixel); color: var(--gold); text-shadow: 2px 2px 0 var(--shadow);
  transform: translate(-50%, 0);
  animation: rise .9s ease-out forwards;
}

/* ───────── animations ───────── */
@keyframes blink { 50% { opacity: 0; } }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }
@keyframes pulse { 50% { transform: translateY(-4px); } }
@keyframes bump { 40% { transform: translateY(-8px); } }
@keyframes jump { to { transform: translateY(-14px); } }
@keyframes rise { to { transform: translate(-50%, -48px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@keyframes glow { 50% { box-shadow: 4px 4px 0 var(--shadow), 0 0 0 6px rgba(62,207,142,.35); } }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake { animation: shake .35s; }
.blink-soft { animation: glow 1.6s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ───────── small screens ───────── */
@media (max-width: 760px) {
  :root { --hud-h: 104px; }
  .hud { grid-template-columns: 1fr auto; padding: 10px 16px; gap: 10px; }
  .hud-stats { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; gap: 10px; }
  .hud-stats dd { font-size: 10px; }
  .hide-sm { display: none; }
  .screen { padding: 24px 16px 64px; }
  .stage-head { grid-template-columns: 1fr; gap: 16px; }
  .stage-badge { width: 72px; height: 72px; font-size: 14px; }
  .quest-body div { grid-template-columns: 1fr; gap: 2px; }
  .quest-body dt { line-height: 1.6; }
  .stop { flex-basis: 110px; padding: 58px 4px 36px; }
  .block { width: 56px; height: 56px; font-size: 18px; }
  .node--boss .block { width: 64px; height: 64px; }
  .stop::before { top: 86px; }
  .goal { grid-template-columns: 1fr; padding-top: 18px; }
  .flagpole { display: none; }
  .crumbs .world-time { margin-left: 0; }
  .meter { top: calc(var(--hud-h) + 4px); }
  .btn-xl { font-size: 11px; padding: 14px 16px; }
  .quest, .quiz-q, .box { padding: 16px; }
}
