/* Layout: night side-scroller. HUD on top, a 1600x820 stage scaled into the sky, ground strip with runner and flags at the bottom. */
:root {
  color-scheme: dark;
  --night: #0A1626; --panel: rgba(10, 22, 40, .93); --panel-2: #12263F; --line: #2F4D6E; --rule: #1F3856; --shadow: #050C16;
  --ink: #EAF4FF; --soft: #C9DBEE; --muted: #9FB6CC;
  --gold: #F2C14E; --mint: #7FFFB2; --cyan: #7FD8FF; --ember: #FF8A3D; --rose: #FF5F8F;
  --display: 'Bungee', 'Be Vietnam Pro', Impact, sans-serif;
  --body: 'Be Vietnam Pro', 'Segoe UI', Arial, sans-serif;
  --hud: 'Chakra Petch', 'Be Vietnam Pro', ui-monospace, monospace;
  --hud-h: 64px; --pad-h: 110px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--night); color: var(--ink); font-family: var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
p, h1, h2, h3, ul, ol { margin: 0; }
#app { position: relative; height: 100%; overflow: hidden; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--hud); font-weight: 700; font-size: 15px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--ink); background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px;
  padding: 8px 14px; box-shadow: 0 4px 0 var(--shadow); cursor: pointer; white-space: nowrap;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
.btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.btn:disabled { opacity: .35; cursor: default; }
.btn[aria-pressed="true"] { color: var(--mint); border-color: var(--mint); }
kbd { font-family: var(--hud); font-size: 11px; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--muted); }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; height: var(--hud-h); z-index: 6;
  display: flex; align-items: center; gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, rgba(5, 12, 22, .92), rgba(5, 12, 22, 0)); font-family: var(--hud);
}
.brand { font-family: var(--display); color: var(--gold); font-size: 16px; text-transform: uppercase; white-space: nowrap; text-shadow: 0 3px 0 var(--shadow); }
.chip { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; padding: 6px 12px; border: 2px solid var(--line); border-radius: 6px; background: var(--panel); white-space: nowrap; color: var(--cyan); }
.chip.ghost { color: var(--ink); }
.spacer { flex: 1; }
.xp { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.xp-label { color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.xp-bar { display: block; width: 180px; height: 14px; border: 2px solid var(--line); border-radius: 4px; background: #0B1B2E; overflow: hidden; }
#xp-fill { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--gold) 0 10px, #FFD978 10px 12px); transition: width .6s cubic-bezier(.2, .8, .2, 1); }

/* ---------- stage ---------- */
#stage-wrap { position: absolute; left: 0; right: 0; top: var(--hud-h); bottom: var(--pad-h); z-index: 3; }
.screen { position: absolute; left: 50%; top: 50%; width: 1600px; height: 820px; transform-origin: center; display: flex; flex-direction: column; justify-content: center; gap: 20px; padding: 8px 16px; }
.checks li::before { content: none; }

/* ---------- bottom pad (over the ground) ---------- */
#pad {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--pad-h); z-index: 5;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-bottom: 50px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
#pad .btn { pointer-events: auto; }
.btn-nav { font-size: 16px; padding: 10px 18px; }
#btn-next { background: var(--mint); color: var(--night); border-color: #3E9E6A; box-shadow: 0 4px 0 #2B7A50; }
.hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-family: var(--hud); font-size: 12px; letter-spacing: 1px; color: #8FA7BF; white-space: nowrap; }

/* ---------- content ---------- */
.head { display: flex; flex-direction: column; gap: 8px; }
.mission { font-family: var(--hud); font-weight: 700; font-size: 20px; letter-spacing: 2px; text-transform: uppercase; color: var(--cyan); }
.title { font-family: var(--display); font-weight: 400; font-size: 44px; line-height: 1.16; text-transform: uppercase; text-wrap: balance; text-shadow: 0 5px 0 var(--shadow); max-width: 1560px; }
.title em, .cover-title em { font-style: normal; color: var(--c, var(--gold)); }

.panel { background: var(--panel); border: 3px solid var(--line); border-radius: 6px; box-shadow: 0 6px 0 var(--shadow); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.tab { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 400; font-size: 17px; text-transform: uppercase; padding: 8px 16px; background: var(--c, var(--cyan)); color: var(--night); }
.tab-split { justify-content: space-between; }
.tab .num { font-family: var(--hud); font-weight: 700; font-size: 15px; background: var(--night); color: var(--c); padding: 1px 8px; border-radius: 4px; }
.pbody { flex: 1; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; font-size: 20px; line-height: 1.42; }
.pbody ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pbody li { display: flex; gap: 12px; }
.pbody li::before { content: '▸'; color: var(--c); }
.pbody strong { color: var(--c); }
.when { margin-top: auto; font-family: var(--hud); font-weight: 700; font-size: 15px; letter-spacing: 1px; text-transform: uppercase; color: var(--c); }

.cards, .notes { display: grid; gap: 18px; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.stats { display: grid; gap: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .pbody { gap: 6px; }
.big { font-family: var(--display); font-size: 60px; line-height: 1; color: var(--c); font-variant-numeric: tabular-nums; text-shadow: 0 4px 0 var(--shadow); }
.unit { font-family: var(--hud); font-weight: 700; font-size: 18px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--c); }
.src { margin-top: auto; font-size: 15px; color: var(--muted); }
.srcline { font-size: 16px; color: var(--muted); }
.bar { background: var(--panel); border: 3px solid var(--line); border-radius: 6px; padding: 16px 22px; font-size: 21px; font-weight: 600; color: var(--soft); }
.note { border: 3px solid var(--c); border-radius: 6px; background: color-mix(in srgb, var(--c) 10%, #0A1626); padding: 14px 20px; font-size: 20px; line-height: 1.4; }
.note strong { color: var(--c); font-weight: 800; text-transform: uppercase; }

/* tables */
.tbl-wrap { border: 3px solid var(--line); border-radius: 6px; overflow: hidden; box-shadow: 0 6px 0 var(--shadow); background: var(--panel); }
.tbl { width: 100%; border-collapse: collapse; font-size: 19px; line-height: 1.35; }
.tbl.small { font-size: 17px; }
.tbl.lg { font-size: 23px; }
.tbl th { font-family: var(--hud); font-weight: 700; font-size: 15px; letter-spacing: 1.5px; text-transform: uppercase; text-align: left; padding: 11px 14px; background: var(--panel-2); color: var(--gold); vertical-align: bottom; }
.tbl.lg th { font-size: 17px; padding: 14px 18px; }
.tbl th.hl { background: var(--c); color: var(--night); }
.tbl td { padding: 10px 14px; border-top: 2px solid var(--rule); vertical-align: top; }
.tbl.small td { padding: 8px 12px; }
.tbl.lg td { padding: 18px; }
.tbl td:first-child { font-weight: 800; }
.tbl td.hot { color: var(--c); font-weight: 700; }
.tbl td.dim { color: var(--muted); }

/* timeline */
.tl { padding: 20px 22px; gap: 14px; }
.tl-row { display: grid; grid-template-columns: 230px repeat(13, minmax(0, 1fr)); gap: 8px; align-items: center; }
.tl-weeks span { font-family: var(--hud); font-weight: 700; font-size: 16px; color: var(--muted); text-align: center; }
.tl-weeks .tl-label { text-align: left; }
.tl-label { font-family: var(--hud); font-weight: 700; font-size: 18px; text-transform: uppercase; letter-spacing: 1px; }
.tl-label.gate { color: var(--ember); }
.tl-bar { background: var(--c); color: var(--night); border-radius: 4px; padding: 11px; font-family: var(--hud); font-weight: 700; font-size: 16px; text-align: center; white-space: nowrap; box-shadow: 0 4px 0 var(--shadow); transform-origin: left center; }
.tl-gate { justify-self: center; width: 46px; height: 46px; border-radius: 50%; background: var(--ember); color: var(--night); display: grid; place-items: center; font-family: var(--hud); font-weight: 700; font-size: 16px; box-shadow: 0 4px 0 #9C4A15, inset 0 -4px 0 rgba(0, 0, 0, .18); }

/* gates */
.gates { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.gate .pbody { font-size: 19px; gap: 12px; }
.gate h3 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.2; text-transform: uppercase; }
.gate.win { border-color: var(--mint); }
.meter { height: 22px; border: 2px solid var(--line); border-radius: 4px; background: #0B1B2E; overflow: hidden; }
.meter span { display: block; height: 100%; width: var(--w); background: repeating-linear-gradient(90deg, var(--mint) 0 12px, #B6FFD3 12px 14px); animation: fill 1.1s .45s cubic-bezier(.2, .8, .2, 1) both; }
.meter-label { font-family: var(--hud); font-weight: 700; font-size: 15px; color: var(--mint); }
.foot { margin-top: auto; font-family: var(--hud); font-weight: 700; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.gate.win .foot { color: var(--mint); }

/* quest log */
.checks { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chk { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: flex; gap: 20px; align-items: center; font-size: 26px; line-height: 1.35; padding: 8px 12px; border-radius: 6px; }
.chk:hover { background: rgba(127, 216, 255, .06); }
.chk:focus-visible { outline: 3px solid var(--cyan); }
.box { flex: none; width: 34px; height: 34px; border: 3px solid var(--gold); border-radius: 6px; display: grid; place-items: center; font-size: 24px; font-weight: 800; color: var(--night); }
.chk[aria-pressed="true"] .box { background: var(--gold); }
.chk[aria-pressed="true"] .box::after { content: '✓'; }
.chk[aria-pressed="true"] .txt { color: var(--muted); text-decoration: line-through; }

/* cover */
.cover { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 0 40px; }
.kicker { font-family: var(--hud); font-weight: 700; font-size: 22px; letter-spacing: 5px; text-transform: uppercase; color: var(--mint); }
.cover-title { font-family: var(--display); font-weight: 400; font-size: 86px; line-height: 1.12; text-transform: uppercase; text-wrap: balance; text-shadow: 0 8px 0 var(--shadow); max-width: 1450px; }
.cover-sub { font-size: 28px; line-height: 1.45; color: var(--soft); max-width: 1150px; }
.cover-menu { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.cover-meta { font-family: var(--hud); font-weight: 700; font-size: 17px; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }
.btn-start { background: var(--gold); color: var(--night); border-color: #9C7A22; font-size: 26px; padding: 18px 34px; box-shadow: 0 7px 0 #9C7A22; }
.btn-big { font-size: 18px; padding: 16px 26px; }

/* ---------- curtain (world transition) ---------- */
#curtain { position: absolute; inset: 0; z-index: 20; background: radial-gradient(circle at 50% 45%, #16304F, #050C16 70%); display: grid; place-items: center; text-align: center; }
.curtain-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.cw { font-family: var(--display); font-size: clamp(40px, 7vw, 96px); color: var(--gold); text-transform: uppercase; text-shadow: 0 6px 0 var(--shadow); line-height: 1.1; }
.cn { font-family: var(--display); font-size: clamp(20px, 3vw, 40px); text-transform: uppercase; line-height: 1.2; }
.cs { font-family: var(--hud); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; color: var(--cyan); font-size: clamp(13px, 1.4vw, 18px); }
.loading { display: flex; gap: 10px; padding-top: 8px; }
.loading span { width: 12px; height: 12px; background: var(--mint); animation: dot .9s infinite; }
.loading span:nth-child(2) { animation-delay: .15s; }
.loading span:nth-child(3) { animation-delay: .3s; }

/* ---------- world map ---------- */
#map { position: absolute; inset: 0; z-index: 18; background: rgba(5, 12, 22, .94); overflow-y: auto; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.map-inner { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.map-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.map-head h2 { font-family: var(--display); font-weight: 400; font-size: clamp(22px, 3vw, 36px); color: var(--gold); text-transform: uppercase; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.map-grid .tab { font-size: 14px; }
.world-desc { padding: 10px 14px 4px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.nodes { display: flex; flex-direction: column; padding: 6px 0 10px; }
.node { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 8px 14px; font-size: 15px; }
.node:hover { background: rgba(127, 216, 255, .08); }
.node:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.dot { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-family: var(--hud); font-weight: 700; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.node.visited .dot { background: var(--gold); border-color: var(--gold); color: var(--night); }
.node.current .dot { background: var(--mint); border-color: var(--mint); color: var(--night); animation: pulse 1.2s infinite; }

.toast { position: absolute; top: calc(var(--hud-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 19; font-family: var(--display); font-size: 18px; text-transform: uppercase; color: var(--night); background: var(--gold); padding: 10px 20px; border-radius: 6px; box-shadow: 0 5px 0 #9C7A22; white-space: nowrap; animation: drop .45s cubic-bezier(.2, .9, .3, 1.3) both; }

/* ---------- motion ---------- */
.fx { animation: rise .55s cubic-bezier(.2, .9, .3, 1.15) both; animation-delay: var(--d, 0ms); }
.stat.fx, .gate.fx, .tl-gate.fx { animation-name: pop; }
tr.fx { animation-name: fadein; animation-duration: .4s; }
.tl-bar.fx { animation-name: grow; }
.screen.leaving .fx { animation: leave .22s ease-in 0ms both; }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }
@keyframes pop { 0% { opacity: 0; transform: scale(.7); } 70% { opacity: 1; transform: scale(1.04); } 100% { transform: none; } }
@keyframes fadein { from { opacity: 0; } }
@keyframes grow { from { transform: scaleX(0); opacity: .2; } }
@keyframes leave { to { opacity: 0; transform: translateY(-16px); } }
@keyframes fill { from { width: 0; } }
@keyframes blink { to { visibility: hidden; } }
@keyframes dot { 0%, 100% { opacity: .2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-6px); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(127, 255, 178, .25); } }
@keyframes drop { from { transform: translate(-50%, -30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .fx, .blink, .meter span, .loading span, .node.current .dot, .toast, .screen.leaving .fx { animation: none !important; }
}

/* ---------- small screens: scrolling column instead of a scaled stage ---------- */
body.compact { --hud-h: 56px; --pad-h: 84px; }
body.compact #stage-wrap { overflow-y: auto; padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
body.compact .screen { position: static; width: auto; height: auto; transform: none !important; padding: 0 0 16px; gap: 16px; }
body.compact #stage-name, body.compact #world-chip, body.compact .xp-label, body.compact kbd, body.compact .hint { display: none; }
body.compact .brand { font-size: 13px; }
body.compact .xp-bar { width: 64px; }
body.compact #hud .btn { padding: 6px 9px; font-size: 12px; }
body.compact #pad { padding-bottom: 36px; }
body.compact .btn-nav { font-size: 13px; padding: 7px 12px; }
body.compact .mission { font-size: 13px; }
body.compact .title { font-size: 22px; }
body.compact .cards, body.compact .stats, body.compact .notes, body.compact .gates { grid-template-columns: minmax(0, 1fr); }
body.compact .pbody, body.compact .note, body.compact .bar { font-size: 15px; }
body.compact .tab { font-size: 14px; }
body.compact .big { font-size: 40px; }
body.compact .tbl-wrap, body.compact .tl { overflow-x: auto; }
body.compact .tbl { min-width: 640px; font-size: 14px; }
body.compact .tl-row { min-width: 760px; }
body.compact .chk { font-size: 16px; gap: 12px; }
body.compact .box { width: 26px; height: 26px; font-size: 18px; }
body.compact .cover { padding: 16px 0; gap: 18px; }
body.compact .kicker { font-size: 12px; letter-spacing: 2px; }
body.compact .cover-title { font-size: 32px; }
body.compact .cover-sub { font-size: 16px; }
body.compact .btn-start { font-size: 16px; padding: 12px 18px; }
body.compact .btn-big { font-size: 13px; padding: 10px 14px; }
body.compact .cover-meta { font-size: 11px; letter-spacing: 1.5px; }
