/* Fonts are self-hosted (SIL OFL, see fonts/LICENSE-*.txt): no request leaves this site. */
@font-face {
  font-family: "Pixelify Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/pixelify-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Silkscreen"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/silkscreen-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
html,body{margin:0;background:#07081a}
/* v2 layout: the sky carries the game state (HUD, altimeter, feedback); the panel only asks the question. */
:root {
  --void: #07081a;
  --panel: #0f1129;
  --panel-2: #171a3c;
  --line: #2f3672;
  --edge: #6068b0;
  --bone: #f4ecda;
  --dim: #9a9dcb;
  --flame: #ffb42e;
  --ember: #ff6a45;
  --ice: #8fe6ff;
  --g-sputter: #a3a7d0;
  --g-kindle: #ffe08a;
  --g-boost: #ffb42e;
  --g-kick: #ff7d3b;
  --g-blaze: #ff4f72;
  --g-nova: #c9f6ff;
  --display: "Pixelify Sans", "Silkscreen", ui-monospace, "Courier New", monospace;
  --label: "Silkscreen", "Pixelify Sans", ui-monospace, "Courier New", monospace;
  --notch: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
  --panel-h: 200px;
  color-scheme: dark;
}
[hidden]:not([hidden=until-found i]) { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--void); }
body {
  color: var(--bone); font-family: var(--display); position: fixed; inset: 0;
  -webkit-text-size-adjust: 100%; touch-action: manipulation;
}
p, h1 { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ice); outline-offset: 2px; }
#sky { position: fixed; top: 0; left: 0; display: block; image-rendering: pixelated; image-rendering: crisp-edges; will-change: transform; }
.lbl { font-family: var(--label); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.num { font-family: var(--label); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--bone); }
.num b { font-weight: 400; color: var(--flame); }

/* ---- HUD: on the sky, above the panel ---- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; bottom: var(--panel-h); z-index: 4; pointer-events: none;
  padding: max(14px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
#hud button, #hud input { pointer-events: auto; }
#hud p, #hud span, #hud b { text-shadow: 0 1px 0 #07081a, 0 0 10px rgba(7, 8, 26, 0.7); }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hud-l { display: grid; gap: 4px; min-width: 0; }
.hud-alt {
  font-family: var(--display); font-weight: 600; line-height: 0.95; color: var(--bone);
  font-size: clamp(34px, 4.5vw + 14px, 56px); font-variant-numeric: tabular-nums;
}
.hud-place { font-family: var(--label); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--flame); }
.hud-ctl { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px 12px; max-width: 58%; }
.scoreline { font-family: var(--label); font-size: 13px; letter-spacing: 0.06em; color: var(--bone); font-variant-numeric: tabular-nums; }
.scoreline b { font-weight: 400; color: var(--flame); }
#pips { display: inline-flex; gap: 4px; }
#pips i { width: 10px; height: 10px; background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--line); display: block; }
#pips i.now { box-shadow: inset 0 0 0 2px var(--flame); }
#pips i.closed { background: #3a2230; box-shadow: inset 0 0 0 2px #6b3446; }
#pips i.g-sputter { background: var(--g-sputter); box-shadow: none; }
#pips i.g-kindle { background: var(--g-kindle); box-shadow: none; }
#pips i.g-boost { background: var(--g-boost); box-shadow: none; }
#pips i.g-kick { background: var(--g-kick); box-shadow: none; }
#pips i.g-blaze { background: var(--g-blaze); box-shadow: none; }
#pips i.g-nova { background: var(--g-nova); box-shadow: 0 0 0 2px #fff; }
#pips i.g-hole { background: #000; box-shadow: 0 0 0 2px var(--flame); }
.ico-row { display: flex; align-items: center; gap: 6px; }
#vol { -webkit-appearance: none; appearance: none; width: 84px; height: 36px; margin: 0; background: transparent; cursor: pointer; }
#vol::-webkit-slider-runnable-track { height: 6px; background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--edge); }
#vol::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 16px; margin-top: -5px; border: 0; background: var(--flame); box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.28); }
#vol::-moz-range-track { height: 6px; background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--edge); }
#vol::-moz-range-thumb { width: 12px; height: 16px; border: 0; border-radius: 0; background: var(--flame); }
#vol:focus-visible { outline: 3px solid var(--ice); outline-offset: 2px; }
.ico {
  position: relative; min-width: 36px; height: 36px; padding: 0 8px; display: inline-grid; place-items: center;
  font-family: var(--label); font-size: 14px; color: var(--bone); background: var(--panel);
  box-shadow: inset 0 0 0 2px var(--edge); clip-path: var(--notch);
}
.ico:hover { box-shadow: inset 0 0 0 2px var(--dim); }
.ico[aria-pressed="false"] { color: var(--dim); }
.ico.off::after { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; background: var(--ember); transform: rotate(-35deg); }
.ico[data-armed] {
  background: var(--ember); color: #240800; box-shadow: none; padding: 0 10px;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
}
@media (pointer: coarse) { .ico { min-width: 44px; height: 44px; } }

/* altimeter: bottom is the pad (0 km of score), top is interstellar */
#rail { position: absolute; right: 20px; top: 120px; bottom: 18px; width: 3px; background: var(--line); box-shadow: 0 0 0 1px #07081a; }
#ticks { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; }
#ticks li {
  position: absolute; right: 100%; margin-right: 14px; transform: translateY(50%); text-align: right; white-space: nowrap;
  font-family: var(--label); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim);
}
#ticks li::after { content: ""; position: absolute; left: 100%; top: 50%; width: 8px; height: 2px; margin-left: 3px; background: var(--line); transform: translateY(-50%); }
#marks { position: absolute; inset: 0; }
.mk { position: absolute; left: -3px; width: 9px; height: 9px; background: var(--c, var(--flame)); box-shadow: 0 0 0 2px #07081a; transform: translateY(50%); }
#railmark {
  position: absolute; left: -5px; bottom: 0; width: 13px; height: 13px; background: var(--flame);
  box-shadow: 0 0 0 2px #07081a, inset 0 0 0 2px #fff2cf; transform: translateY(50%) rotate(45deg);
}

/* intro title sits on the sky */
#title { display: none; position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); top: max(16px, env(safe-area-inset-top, 0px)); right: 16px; }
#title h1 {
  font-size: clamp(48px, 8vw, 96px); line-height: 0.92; font-weight: 700; color: var(--flame); letter-spacing: 0.02em;
  text-shadow: 0 4px 0 #07081a, 0 0 28px rgba(255, 180, 46, 0.35);
}
#title p { margin-top: 12px; font-size: clamp(15px, 1.5vw, 18px); color: var(--bone); max-width: 24ch; }
body.intro #title { display: block; }
body.intro .hud-stat { visibility: hidden; }
body.intro #qcount { visibility: hidden; }

/* feedback that floats beside the rocket */
#pop {
  position: absolute; left: 0; top: 0; display: grid; gap: 2px; white-space: nowrap; --c: var(--flame);
}
#popg { font-family: var(--label); font-weight: 400; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c); }
#popn { font-family: var(--display); font-size: 20px; font-weight: 500; color: var(--bone); }

/* ---- Panel: question only ---- */
#panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--panel); border-top: 3px solid var(--line);
  box-shadow: 0 -3px 0 0 #0a0b1f;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  will-change: transform;
}
/* the fuse: the answer window burns down along the panel's top edge */
#fuse { position: absolute; left: 0; right: 0; top: -3px; height: 5px; background: #0a0b1f; overflow: hidden; }
#fuse i { position: absolute; inset: 0; display: block; background: var(--flame); transform-origin: left center; }
#fuse.low i { background: var(--ember); }
#fuse.idle i { background: var(--line); }
.wrap {
  max-width: 780px; margin: 0 auto; display: grid; gap: 10px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
.stage { display: grid; }
.stage > * { grid-area: 1 / 1; min-width: 0; }
.stage > .off { visibility: hidden; pointer-events: none; }

#intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 18px; align-items: center; }
.intro-copy { grid-column: 1; max-width: 60ch; color: #d8d2e8; font-size: 15px; line-height: 1.4; }
.long { display: inline; }
.short { display: none; }
.ladder { grid-column: 1; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.ladder li { display: grid; gap: 3px; padding: 7px 8px; background: var(--panel-2); box-shadow: inset 0 -3px 0 var(--c); }
.ladder b { font-family: var(--label); font-weight: 400; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--c); }
.ladder span { font-family: var(--label); font-size: 10px; color: var(--dim); font-variant-numeric: tabular-nums; }
#ignite { grid-column: 2; grid-row: 1 / span 2; min-height: 48px; }

#play { display: grid; gap: 9px; margin: 0; grid-template-columns: minmax(0, 1fr); }
#play > * { min-width: 0; }
#prompt { font-size: clamp(21px, 1.6vw + 15px, 30px); line-height: 1.12; font-weight: 600; text-wrap: balance; min-height: 2.24em; display: flex; align-items: end; }
.row { display: flex; gap: 8px; }
#answer {
  flex: 1 1 0; width: 0; min-width: 0; font-family: var(--display); font-size: 20px; color: var(--bone);
  background: #090a1d; border: 0; padding: 0 14px; min-height: 48px;
  box-shadow: inset 0 0 0 3px var(--edge); clip-path: var(--notch); caret-color: var(--flame);
}
#answer::placeholder { color: #7f83b8; }
#answer:focus { outline: none; box-shadow: inset 0 0 0 3px var(--flame); }
#answer[readonly] { color: var(--dim); }
.msgrow { display: flex; align-items: baseline; gap: 12px; min-height: 1.35em; }
#msg { flex: 1 1 auto; min-width: 0; font-size: 15px; line-height: 1.35; color: #d8d2e8; padding-bottom: 2px; }
#msg.warn { color: var(--ember); }
#msg.fix { color: var(--ice); }
#msg.hole { color: var(--flame); }
#msg.g-sputter { color: var(--g-sputter); } #msg.g-kindle { color: var(--g-kindle); } #msg.g-boost { color: var(--g-boost); }
#msg.g-kick { color: var(--g-kick); } #msg.g-blaze { color: var(--g-blaze); } #msg.g-nova { color: var(--g-nova); }
#tnum { white-space: nowrap; }

button.big {
  font-family: var(--label); font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0 18px; min-height: 48px; color: #241300; background: var(--flame);
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.28), inset 4px 4px 0 rgba(255, 255, 255, 0.35);
  clip-path: var(--notch); white-space: nowrap;
}
button.big:hover { filter: brightness(1.08); }
button.big:active { transform: translateY(2px); box-shadow: inset 4px 4px 0 rgba(0, 0, 0, 0.25); }
button.big[data-mode="confirm"] { background: var(--ice); color: #04202a; }
.mini {
  font-family: var(--label); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0 10px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  color: var(--bone); background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--edge); clip-path: var(--notch);
}
.mini:hover { box-shadow: inset 0 0 0 2px var(--dim); }
@media (pointer: coarse) { .mini { min-height: 44px; } }

/* keyboard open on a phone: keep only what is needed to type */
body.kb #title, body.kb #rail, body.kb .hud-ctl { display: none; }
body.kb #intro { display: none; }
body.kb #prompt { min-height: 0; font-size: 19px; }
body.kb .wrap { gap: 6px; padding-top: 8px; }

/* ---- Results ---- */
#results {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  background: rgba(3, 3, 12, 0.72);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
}
.report {
  width: min(560px, 100%); max-height: 100%; align-self: center; overflow: auto; overscroll-behavior: contain;
  background: var(--panel); box-shadow: inset 0 0 0 3px var(--line), inset 0 0 0 6px #0a0b1f;
  clip-path: var(--notch); padding: 18px 18px 16px; display: grid; gap: 12px;
}
.report h2 { margin: 0; font-size: clamp(30px, 4vw + 14px, 44px); line-height: 1; font-weight: 700; color: var(--flame); text-wrap: balance; }
.report p { margin: 0; }
#ralt { font-size: 14px; }
#rline { font-size: 16px; color: var(--bone); }
#rline.hole { color: var(--g-nova); font-size: 18px; }
#cmp { display: grid; gap: 8px; }
#cmpline { font-size: 16px; line-height: 1.3; color: var(--bone); }
#cmpline b { font-weight: 700; color: var(--ice); }
#cmpline .par { display: block; margin-top: 2px; font-family: var(--label); font-size: 11px; letter-spacing: 0.04em; color: var(--dim); }
#curve { width: 100%; height: auto; image-rendering: pixelated; display: block; background: #07081a; box-shadow: inset 0 0 0 2px var(--line); }
#cmpnote { line-height: 1.5; text-transform: none; letter-spacing: 0.02em; }
#cmpretry { justify-self: start; }
#rlist .st { font-family: var(--label); font-size: 9px; letter-spacing: 0.03em; color: var(--ice); }
#rlist .st:empty { display: none; }
.intro-msg { grid-column: 1 / -1; min-height: 1.2em; font-family: var(--label); font-size: 11px; letter-spacing: 0.04em; color: var(--ember); }
.intro-msg:empty { display: none; }
#card { width: 100%; height: auto; image-rendering: pixelated; display: block; background: #000; }
#rlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#rlist li { display: grid; grid-template-columns: 1.4em minmax(0, 1fr) auto auto; gap: 4px 10px; align-items: center; padding: 6px 8px; background: var(--panel-2); }
#rlist .n { font-family: var(--label); font-size: 10px; color: var(--dim); }
#rlist .qa { min-width: 0; display: grid; gap: 1px; }
#rlist .q { font-family: var(--label); font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rlist .a { font-size: 16px; overflow-wrap: anywhere; }
#rlist .chip { font-family: var(--label); font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 6px; color: #120a00; background: var(--c, var(--line)); white-space: nowrap; }
#rlist .pts { font-family: var(--label); font-size: 11px; font-variant-numeric: tabular-nums; min-width: 3.4em; text-align: right; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* the report owns the screen: the play panel is hidden and inert behind it */
body.report-open #panel { visibility: hidden; }
#sharetext { width: 100%; min-height: 4.5em; font: 14px/1.4 var(--display); color: var(--bone); background: #090a1d; border: 0; box-shadow: inset 0 0 0 2px var(--line); padding: 8px; resize: none; }

@media (min-width: 900px) and (min-height: 520px) {
  .report {
    width: min(960px, 100%); column-gap: 22px; align-items: start;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    grid-template-areas: "lbl list" "title list" "alt list" "line list" "cmp list" "card list" "actions list" "share list" ". list";
  }
  .report > .lbl { grid-area: lbl; } .report h2 { grid-area: title; } #ralt { grid-area: alt; } #rline { grid-area: line; } #cmp { grid-area: cmp; }
  #card { grid-area: card; } .actions { grid-area: actions; } #sharetext { grid-area: share; } #rlist { grid-area: list; }
}

@media (max-width: 560px) {
  .long { display: none; } .short { display: inline; }
  .hud-alt { font-size: 34px; }
  #rail { right: 12px; top: 112px; }
  #ticks li { font-size: 8px; }
  #intro { grid-template-columns: minmax(0, 1fr); }
  .intro-copy, .ladder { grid-column: 1; }
  .ladder { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ladder li { grid-template-columns: 1fr auto; align-items: baseline; padding: 6px 8px; }
  #ignite { grid-column: 1; grid-row: auto; width: 100%; }
  #pips i { width: 8px; height: 8px; }
  button.big { padding: 0 14px; }
  .actions .big { flex: 1 1 100%; }
  .actions .mini { flex: 1 1 0; }
}
@media (prefers-reduced-motion: reduce) {
  button.big:active { transform: none; }
}
