:root {
  --bg: #0a0908;
  --panel: #15120f;
  --ink: #d8c7a6;
  --dim: #8a7a60;
  --ember: #e06a1f;
  --red: #b3261e;
  --line: #2a241d;
  --mono: "Courier New", Courier, "Lucida Console", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--mono); }
body { -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-transform: uppercase; }
button:focus-visible { outline: 1px solid var(--ember); }
canvas { display: block; }

/* ---------- landing / title ---------- */
#landing { max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
.hero { text-align: center; padding: 24px 0 12px; }
#logo { width: 100%; max-width: 480px; height: auto; margin: 0 auto; }
.enter { display: inline-block; margin: 18px auto 0; padding: 14px 22px; border: 1px solid var(--ink); letter-spacing: 0.12em; font-weight: bold; font-size: 15px; }
.enter:hover { border-color: var(--ember); color: #fff; }
.studio { margin: 42px 0 0; font-size: 11px; letter-spacing: 0.14em; color: var(--dim); }
.landing-section { margin-top: 36px; border-top: 1px solid var(--line); padding-top: 18px; font-size: 14px; line-height: 1.55; }
.landing-section h2 { font-size: 12px; letter-spacing: 0.14em; color: var(--dim); margin: 0 0 10px; font-weight: normal; text-transform: uppercase; }
.rating { border: 1px solid var(--ink); padding: 10px 12px; display: inline-block; font-weight: bold; letter-spacing: 0.06em; font-size: 13px; }
.rating div + div { margin-top: 4px; }
.tagline { margin: 16px 0 0; font-size: 12px; letter-spacing: 0.12em; color: var(--dim); }
.req div, .credits div { margin: 2px 0; }
.faq dt { margin-top: 8px; font-weight: bold; }
.faq dd { margin: 0; color: var(--ink); }
.patch h3 { font-size: 13px; margin: 12px 0 4px; font-weight: bold; }
.patch ul { margin: 0; padding-left: 18px; }
.credits { letter-spacing: 0.08em; font-size: 13px; }
.fg-sub { font-weight: bold; letter-spacing: 0.06em; font-size: 13px; margin-bottom: 10px; }
.fg-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; padding: 7px 0; border-top: 1px solid var(--line); }
.fg-name { font-weight: bold; letter-spacing: 0.06em; font-size: 13px; }
.fg-bonus { font-size: 13px; color: var(--dim); text-align: right; }
.fg-desc { grid-column: 1 / -1; color: var(--ink); }
.fg-foot { margin-top: 12px; font-size: 12px; letter-spacing: 0.06em; color: var(--dim); }
.nav { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 12px 24px; font-size: 12px; letter-spacing: 0.1em; }
.nav button { text-decoration: underline; text-underline-offset: 3px; color: var(--dim); }
.nav button:hover { color: var(--ink); }

/* ---------- game shell ---------- */
#game { position: fixed; inset: 0; background: var(--bg); overflow: hidden; }
#game[hidden] { display: none; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; padding: 24px 20px; text-align: left; overflow-y: auto; }
.screen.active { display: flex; }
.screen .box { width: 100%; max-width: 440px; }
.mono { white-space: pre-wrap; font-size: 15px; line-height: 1.7; letter-spacing: 0.04em; }
.mono.small { font-size: 13px; }
.mono.center { text-align: center; }
.caps { text-transform: uppercase; }
.btn { display: inline-block; margin-top: 28px; padding: 12px 18px; border: 1px solid var(--ink); letter-spacing: 0.12em; font-weight: bold; font-size: 14px; }
.btn:hover { border-color: var(--ember); color: #fff; }
.btn.quiet { border-color: var(--line); color: var(--dim); }
.btnrow { display: flex; gap: 14px; flex-wrap: wrap; }
.screen-title { font-size: 12px; letter-spacing: 0.16em; color: var(--dim); margin: 0 0 14px; font-weight: normal; }
.tap { position: absolute; inset: 0; }

/* crawl */
#s-crawl { background: #000; padding: 0; justify-content: flex-start; }
.crawl-wrap { position: absolute; inset: 0; overflow: hidden; }
.crawl { white-space: pre-line; position: absolute; left: 0; right: 0; top: 100%; color: var(--red); font-weight: bold; font-size: 20px; line-height: 2.2; text-align: center; letter-spacing: 0.08em; padding: 0 20px; animation: crawl 28s linear forwards; }
@keyframes crawl { from { transform: translateY(0); } to { transform: translateY(calc(-100vh - 100%)); } }

/* callsign */
.callsign-cells { display: flex; gap: 14px; font-size: 32px; letter-spacing: 0; margin: 18px 0 0; }
.callsign-cells span { width: 44px; height: 54px; border-bottom: 2px solid var(--ink); display: inline-flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; }
.callsign-cells span.cur { border-color: var(--ember); }
#callsignInput { position: absolute; opacity: 0; width: 1px; height: 1px; left: -100px; }
.keypad { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 24px; max-width: 360px; }
.keypad button { border: 1px solid var(--line); padding: 10px 0; font-size: 15px; }
.keypad button:active { background: var(--line); }

/* briefing */
.brief-wrap { position: relative; width: 100%; max-width: 440px; }
.brief-director { position: absolute; right: 0; top: -8px; text-align: center; font-size: 10px; letter-spacing: 0.14em; color: var(--dim); }
.brief-director canvas { width: 96px; height: 104px; image-rendering: pixelated; margin: 0 auto 4px; }

/* play */
#s-play { padding: 0; justify-content: flex-start; background: #000; }
.play-col { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; }
.topbar { width: 100%; max-width: 480px; display: flex; justify-content: center; align-items: center; height: 44px; font-size: 22px; font-weight: bold; letter-spacing: 0.1em; }
.viewport { position: relative; width: min(100vw, 62vh, 480px); aspect-ratio: 1 / 1; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
#view { width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
#automap { position: absolute; left: 6px; top: 6px; width: 84px; height: 84px; opacity: 0.85; pointer-events: none; }
#msg { position: absolute; left: 96px; right: 6px; top: 8px; font-size: 11px; letter-spacing: 0.06em; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; pointer-events: none; min-height: 14px; }
#assess { position: absolute; left: 8px; bottom: 8px; max-width: 56%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.5; letter-spacing: 0.06em; color: #fff; text-shadow: 0 0 2px #000, 0 1px 1px #000; pointer-events: none; background: rgba(0,0,0,0.35); padding: 4px 6px; }
#assess:empty { display: none; }
.hud { width: min(100vw, 62vh, 480px); display: flex; align-items: stretch; justify-content: space-between; background: var(--panel); border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); padding: 6px 8px; gap: 6px; }
.hud .cell { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 54px; }
.hud .lbl { font-size: 9px; letter-spacing: 0.14em; color: var(--dim); }
.hud .val { font-size: 22px; font-weight: bold; line-height: 1.1; }
.hud .val.low { color: var(--red); }
#face { width: 44px; height: 44px; image-rendering: pixelated; border: 1px solid var(--line); }
.hud .equip { font-size: 10px; letter-spacing: 0.08em; text-align: center; border: 1px solid var(--line); padding: 4px 6px; max-width: 86px; line-height: 1.3; }
.controls { position: relative; flex: 1; width: 100%; max-width: 480px; min-height: 150px; touch-action: none; user-select: none; -webkit-user-select: none; }
#stick { position: absolute; left: 16px; bottom: 16px; width: 120px; height: 120px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,0.02); touch-action: none; }
#stick .knob { position: absolute; left: 40px; top: 40px; width: 40px; height: 40px; border-radius: 50%; background: #8a6a2a; border: 1px solid var(--dim); }
#stick .knob.run { background: var(--ember); border-color: var(--ember); }
#contact { position: absolute; right: 16px; bottom: 22px; width: 108px; height: 108px; border-radius: 50%; border: 2px solid var(--ink); font-weight: bold; letter-spacing: 0.12em; font-size: 14px; touch-action: none; }
#contact:active { background: var(--ember); color: #000; border-color: var(--ember); }
.controls.left #stick { left: auto; right: 16px; }
.controls.left #contact { right: auto; left: 16px; }
.controls .hint { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 9px; letter-spacing: 0.12em; color: var(--line); }
@media (hover: hover) and (pointer: fine) { .controls { min-height: 90px; } }

/* overlays */
.overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.88); display: none; align-items: center; justify-content: center; padding: 24px; z-index: 5; }
.overlay.active { display: flex; }
#sysmsg { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 14px; font-size: 11px; letter-spacing: 0.1em; background: #000; color: var(--ink); border-top: 1px solid var(--line); display: none; z-index: 20; }
#sysmsg.show { display: block; }

/* tally */
.tally-lines { min-height: 60vh; }
.tally-lines div { min-height: 1.7em; }
.tally-lines .unpet { margin-top: 1.7em; font-weight: bold; }
.tally-lines .gap { min-height: 1.7em; }
.shareblock { margin: 22px 0 0; border: 1px solid var(--line); padding: 10px 12px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; display: block; max-width: 100%; font-family: var(--mono); }
.shareblock.flash { border-color: var(--ink); }
.ph { color: var(--dim); font-size: 10px; letter-spacing: 0.08em; margin-top: 6px; }

/* record */
.record-list { margin-top: 18px; }
.record-list h3 { font-size: 11px; letter-spacing: 0.14em; color: var(--dim); font-weight: normal; margin: 18px 0 6px; }
.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv span:last-child { font-weight: bold; }

/* prefs */
.pref-row { display: flex; justify-content: space-between; width: 100%; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; letter-spacing: 0.08em; }
.pref-row span:last-child { font-weight: bold; }

/* fail map */
#failmap { width: 180px; height: 180px; image-rendering: pixelated; margin-top: 16px; }
