:root {
  --paper: #e9dfc7; --paper-dk: #d6c8a6; --ink: #2a241b; --ink-soft: #5b4f3d; --red: #8f2a1f; --brass: #b08a43;
  --night: #15120d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: 'Libre Baskerville', Georgia, serif; }
canvas#gl, canvas#hud { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
canvas#hud { pointer-events: none; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.screen.show { display: flex; }
#menu, #loading { background: radial-gradient(ellipse at center, rgba(30,24,16,0.25), rgba(10,8,5,0.85)); }
#briefing, #controls, #settings, #pause { background: rgba(12,10,7,0.72); overflow-y: auto; }

.load-inner { text-align: center; color: var(--paper); font-family: 'Special Elite', monospace; letter-spacing: 0.1em; }
.reel { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; border: 6px dotted var(--paper); animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.poster { text-align: center; color: var(--paper); max-width: 760px; text-shadow: 0 2px 12px rgba(0,0,0,0.8); }
.kicker { font-family: 'Oswald', sans-serif; letter-spacing: 0.45em; text-transform: uppercase; font-size: 14px; color: #e7c98a; }
.poster h1 { font-family: 'Oswald', sans-serif; font-weight: 700; text-transform: uppercase; font-size: clamp(56px, 12vw, 132px); line-height: 0.95; margin: 12px 0 6px; letter-spacing: 0.04em; color: #f1e6cc; }
.rule { width: 220px; height: 3px; margin: 10px auto 18px; background: linear-gradient(90deg, transparent, #c9a45c, transparent); }
.tag { font-style: italic; font-size: clamp(14px, 2vw, 18px); line-height: 1.6; color: #e6dabd; margin: 0 auto 28px; max-width: 560px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.foot { margin-top: 26px; font-size: 13px; color: #bfb08f; font-family: 'Special Elite', monospace; }

button { font-family: 'Oswald', sans-serif; font-weight: 500; text-transform: uppercase; letter-spacing: 0.18em; font-size: 15px; padding: 11px 26px; min-width: 260px; cursor: pointer;
  color: var(--paper); background: rgba(26,21,14,0.78); border: 1px solid #a88c55; border-radius: 2px; transition: background 0.15s, color 0.15s, transform 0.1s; }
button:hover { background: #a88c55; color: #1b160e; }
button:active { transform: translateY(1px); }
button.primary { background: #8f2a1f; border-color: #c9a45c; }
button.primary:hover { background: #b23a2a; color: #fff3dc; }
.paper button { color: var(--ink); background: transparent; border-color: var(--ink-soft); min-width: 0; }
.paper button:hover { background: var(--ink); color: var(--paper); }
.paper button.primary { background: var(--red); color: #f6ead0; border-color: var(--red); }

.paper { position: relative; background: var(--paper); background-image: radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.35), transparent 60%), radial-gradient(ellipse at 80% 90%, rgba(120,90,40,0.18), transparent 60%);
  max-width: 640px; width: 100%; padding: 34px 38px; box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 0 80px rgba(120,90,40,0.25); color: var(--ink); margin: auto; }
.paper.wide { max-width: 1040px; }
.paper.small-paper { max-width: 380px; text-align: center; }
.paper .hdr { font-family: 'Special Elite', monospace; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 1px solid var(--ink-soft); padding-bottom: 8px; margin-bottom: 14px; }
.paper h2 { font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 0.06em; font-size: 30px; margin: 4px 0 12px; }
.paper h3 { font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 0.12em; font-size: 15px; margin: 18px 0 8px; color: var(--red); }
.paper p { line-height: 1.6; font-size: 15px; }
.paper .note { font-style: italic; border-left: 3px solid var(--red); padding-left: 12px; }
.stamp { position: absolute; top: 22px; right: 26px; font-family: 'Oswald', sans-serif; font-weight: 700; letter-spacing: 0.2em; color: rgba(143,42,31,0.75); border: 3px solid rgba(143,42,31,0.75); padding: 2px 10px; transform: rotate(8deg); }
.row { display: flex; gap: 12px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } .paper { padding: 24px 18px; } button { min-width: 200px; } }
.opt { display: block; font-size: 14px; line-height: 1.5; margin: 6px 0; cursor: pointer; }
.chk { display: block; font-size: 14px; margin: 6px 0; cursor: pointer; }
.slider { display: grid; grid-template-columns: 150px 1fr 48px; align-items: center; gap: 10px; font-size: 14px; margin: 8px 0; }
.slider em { font-style: normal; font-family: 'Special Elite', monospace; text-align: right; }
input[type=range] { accent-color: var(--red); width: 100%; }
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys td { padding: 4px 6px; border-bottom: 1px dotted var(--ink-soft); }
.keys td:first-child { font-family: 'Special Elite', monospace; white-space: nowrap; }
.small { font-size: 13px !important; color: var(--ink-soft); }
.pad-status { font-family: 'Special Elite', monospace; font-size: 13px; padding: 10px; border: 1px dashed var(--ink-soft); margin: 8px 0; }
.pad-status.ok { border-style: solid; border-color: #2f5d2a; color: #2f5d2a; }
#padBind .bind { display: grid; grid-template-columns: 110px 1fr auto auto; gap: 8px; align-items: center; font-size: 13px; margin: 5px 0; }
#padBind .bar { height: 8px; background: var(--paper-dk); position: relative; }
#padBind .bar i { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: var(--red); }
#padBind button { padding: 4px 10px; font-size: 11px; letter-spacing: 0.08em; }
.buy { margin-top: 18px; padding: 4px 16px 10px; background: rgba(176,138,67,0.15); border: 1px solid rgba(91,79,61,0.35); }
.buy p { font-size: 13.5px; margin: 8px 0; }

#msg { position: fixed; left: 50%; top: 14%; transform: translateX(-50%); z-index: 5; pointer-events: none; text-align: center; font-family: 'Special Elite', monospace; color: #f3e8cc;
  font-size: clamp(14px, 1.8vw, 19px); letter-spacing: 0.06em; text-shadow: 0 1px 6px #000, 0 0 2px #000; max-width: 90vw; }
#msg div { margin: 4px 0; opacity: 1; transition: opacity 1s; }
#clickToFly { position: fixed; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 6; font-family: 'Oswald', sans-serif; letter-spacing: 0.25em; text-transform: uppercase; color: #f3e8cc;
  background: rgba(20,16,10,0.75); padding: 12px 24px; border: 1px solid #a88c55; pointer-events: none; }
#credits { position: fixed; left: 16px; right: 16px; bottom: 10px; z-index: 11; font-size: 10px; color: #a99c7e; text-align: center; }

/* ---------- touch controls */
#touch { position: fixed; inset: 0; z-index: 4; pointer-events: none; user-select: none; -webkit-user-select: none; touch-action: none; }
#touch > * { pointer-events: auto; }
.t-steer { position: absolute; left: 22%; right: 0; top: 0; bottom: 0; }
.t-throttle { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: 24px; top: 30%; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: 'Oswald', sans-serif; letter-spacing: 0.15em; font-size: 10px; color: rgba(243,232,204,0.7); }
.t-track { position: relative; flex: 1; width: 16px; border-radius: 8px; background: rgba(20,16,10,0.55); border: 1px solid rgba(168,140,85,0.6); }
.t-knob { position: absolute; left: 50%; bottom: calc(85% - 22px); width: 44px; height: 44px; margin-left: -22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4a4438, #14120e); border: 2px solid #a88c55; }
.t-fire { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: 28px; width: 92px; height: 92px; min-width: 0; padding: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b23a2a, #5b1a12); border: 3px solid #c9a45c; color: #f6ead0; font-size: 14px; letter-spacing: 0.15em; opacity: 0.85; }
.t-fire.on { transform: scale(0.94); background: radial-gradient(circle at 35% 30%, #e05a3a, #7b2016); }
.t-top { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.t-top button { min-width: 0; padding: 8px 12px; font-size: 11px; letter-spacing: 0.12em; background: rgba(20,16,10,0.55); }
@media (orientation: portrait) { body.is-touch #touch::after { content: 'Turn your phone sideways to fly'; position: absolute; left: 50%; top: 40%; transform: translateX(-50%); font-family: 'Oswald', sans-serif; letter-spacing: 0.2em; text-transform: uppercase; color: #f3e8cc; background: rgba(20,16,10,0.8); padding: 14px 20px; border: 1px solid #a88c55; } }
body.is-touch .foot { display: none; }

body.flying #gl { cursor: none; }

/* ---------- operations room */
.menu-clock { font-family: 'Special Elite', monospace; color: #e7c98a; letter-spacing: 0.08em; margin: -6px 0 16px; font-size: 15px; }
.ops { max-width: 1240px; }
.ops-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 24px; }
.ops-map canvas { width: 100%; height: auto; display: block; border: 1px solid #5b4f3d; box-shadow: inset 0 0 40px rgba(0,0,0,0.25); }
.ops h2 { margin-top: 0; }
.small-print { font-size: 13.5px !important; }
.tote { width: 100%; border-collapse: collapse; font-size: 13px; font-family: 'Special Elite', monospace; }
.tote th { text-align: left; font-family: 'Oswald', sans-serif; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; color: var(--ink-soft); border-bottom: 1px solid var(--ink-soft); padding: 3px 4px; }
.tote td { padding: 4px; border-bottom: 1px dotted rgba(91,79,61,0.5); }
.tote tr.me td { font-weight: bold; background: rgba(176,138,67,0.15); }
.lamp { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; box-shadow: 0 0 4px currentColor; }
.lamp.g { background: #3e8f3a; color: #3e8f3a; } .lamp.a { background: #d19a26; color: #d19a26; } .lamp.r { background: #a3261b; color: #a3261b; }
.teletype { font-family: 'Special Elite', monospace; font-size: 12.5px; line-height: 1.45; max-height: 240px; overflow-y: auto; background: rgba(255,255,255,0.35); border: 1px solid rgba(91,79,61,0.35); padding: 8px 10px; }
.teletype div { margin: 0 0 6px; } .teletype span { color: var(--red); margin-right: 4px; } .teletype .player { font-weight: bold; }
.brief { font-size: 15px; border-left: 3px solid var(--red); padding-left: 12px; min-height: 1.6em; }
.paper button:disabled { opacity: 0.4; cursor: default; }
@media (max-width: 900px) { .ops-grid { grid-template-columns: 1fr; } }

.t-look { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; }
.t-look button { min-width: 0; padding: 10px 14px; font-size: 13px; background: rgba(20,16,10,0.55); }

.hangar { font-family: 'Special Elite', monospace; font-size: 13px; }
.hangar div { padding: 6px 8px; border: 1px solid rgba(91,79,61,0.35); margin-bottom: 6px; background: rgba(255,255,255,0.25); }
.hangar b { font-family: 'Oswald', sans-serif; letter-spacing: 0.08em; }
.hangar .st-ready { color: #2f5d2a; } .hangar .st-repair { color: #9a6416; } .hangar .st-lost { color: #8f2a1f; }
.hangar .fly { float: right; font-family: 'Oswald', sans-serif; font-size: 11px; letter-spacing: 0.12em; color: var(--red); }

/* ---------- combat report and log book */
.report-paper { max-width: 760px; font-family: 'Special Elite', monospace; }
.form { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 10px; }
.form td { padding: 5px 6px; border-bottom: 1px dotted var(--ink-soft); vertical-align: top; }
.form td:first-child { width: 42%; color: var(--ink-soft); text-transform: uppercase; font-size: 11.5px; letter-spacing: 0.06em; }
.typed { font-family: 'Special Elite', monospace; font-size: 14px !important; line-height: 1.65 !important; }
.sig { text-align: right; font-style: italic; }
.gazette { border: 2px solid var(--red); padding: 6px 14px; margin-top: 10px; background: rgba(143,42,31,0.06); }
.gazette p { font-family: 'Oswald', sans-serif; letter-spacing: 0.05em; color: var(--red); margin: 6px 0; }
.lb-name { font-family: 'Special Elite', monospace; font-size: 14px; } .lb-name input { font-family: 'Special Elite', monospace; font-size: 15px; background: transparent; border: none; border-bottom: 1px solid var(--ink-soft); padding: 2px 6px; width: 260px; color: var(--ink); }
.lb-scroll { max-height: 52vh; overflow-y: auto; } .lb td { font-size: 12.5px; }

/* ---------- missions */
.mission-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 26px; }
.mission-list { display: flex; flex-direction: column; gap: 6px; max-height: 58vh; overflow-y: auto; }
.mission-list .era { font-family: 'Oswald', sans-serif; letter-spacing: 0.2em; font-size: 12px; color: var(--red); margin: 10px 0 2px; }
.mission-list button { text-align: left; min-width: 0; padding: 9px 12px; letter-spacing: 0.06em; text-transform: none; font-size: 15px; }
.mission-list button small { display: block; font-family: 'Special Elite', monospace; font-size: 11.5px; letter-spacing: 0; opacity: 0.75; }
.mission-list button.sel { background: var(--ink); color: var(--paper); }
.mission-brief p { line-height: 1.65; }
@media (max-width: 820px) { .mission-grid { grid-template-columns: 1fr; } }

.credits-btn { min-width: 0; padding: 4px 12px; font-size: 10px; letter-spacing: 0.15em; background: rgba(20,16,10,0.5); border-color: rgba(168,140,85,0.5); }
#creditsText { max-width: 900px; margin: 8px auto 0; background: rgba(15,12,8,0.85); padding: 10px 14px; line-height: 1.5; }
