:root {
  --ink: #100e0c;
  --paper: #e6d7c3;
  --brass: #c6a15a;
  --blood: #8d1f1c;
  --signal: #ff4a42;
  --dim: #c98484;
  --sea: #07141c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); }
body {
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
canvas#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 0;
}
#ui { position: relative; z-index: 2; min-height: 100%; }

.screen { min-height: 100vh; }
.side-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.side-card {
  position: relative;
  border: 0;
  padding: 0;
  min-height: 100vh;
  background: #111 center/cover no-repeat;
  text-align: left;
  overflow: hidden;
}
.side-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}
.side-card .veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 8, 10, 0.15) 10%, rgba(8, 8, 10, 0.2) 40%, rgba(6, 5, 4, 0.88) 100%);
}
.side-card .copy {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 32px;
  z-index: 1;
}
.kicker {
  letter-spacing: 0.28em;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--brass);
  font-family: "Arial Narrow", "Helvetica Neue", sans-serif;
}
.side-card h2, .mast h1, .plate h2 { font-weight: 500; letter-spacing: 0.02em; margin: 6px 0; }
.side-card h2 { font-size: 42px; text-shadow: 0 2px 18px #000; }
.side-card p { max-width: 38ch; color: #f0e6d8; text-shadow: 0 1px 8px #000; }
.mast {
  position: absolute;
  top: 22px;
  left: 28px;
  z-index: 3;
  text-shadow: 0 2px 12px #000;
}
.mast h1 { font-size: 28px; margin: 0; letter-spacing: 0.16em; text-transform: uppercase; }
.mast span { color: var(--brass); letter-spacing: 0.22em; font-size: 11px; font-family: "Arial Narrow", sans-serif; }

.sheet {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(198, 161, 90, 0.08), transparent 50%),
    #141210;
}
.portrait-pane { position: relative; min-height: 100vh; }
.portrait-pane img { width: 100%; height: 100vh; object-fit: cover; display: block; }
.plate { padding: 36px 40px 48px; overflow: auto; max-height: 100vh; }
.plate h2 { font-size: 40px; margin-bottom: 0; }
.class-name { color: var(--brass); letter-spacing: 0.14em; text-transform: uppercase; font-size: 13px; font-family: "Arial Narrow", sans-serif; }
.summary { font-size: 18px; line-height: 1.45; max-width: 62ch; }
.spec-table { width: 100%; border-collapse: collapse; margin: 18px 0 22px; font-family: "Arial Narrow", "Helvetica Neue", sans-serif; font-size: 15px; }
.spec-table th { text-align: left; color: var(--brass); font-weight: 600; padding: 7px 12px 7px 0; width: 28%; vertical-align: top; }
.spec-table td { padding: 7px 0; border-bottom: 1px solid rgba(230, 215, 195, 0.12); }
.crew-line { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }
.crew-line span { border: 1px solid rgba(198, 161, 90, 0.4); padding: 4px 8px; font-size: 13px; font-family: "Arial Narrow", sans-serif; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  background: transparent;
  border: 1px solid var(--brass);
  padding: 12px 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: "Arial Narrow", sans-serif;
  font-size: 15px;
}
.btn.solid { background: var(--blood); border-color: var(--signal); }
.btn:hover { background: rgba(198, 161, 90, 0.12); }
.linkish { background: none; border: 0; color: var(--brass); padding: 8px 0; letter-spacing: 0.08em; text-transform: uppercase; font-family: "Arial Narrow", sans-serif; }

.board { padding: 28px 32px 60px; max-height: 100vh; overflow: auto; }
.campaign { margin: 22px 0 28px; }
.mission {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(230, 215, 195, 0.14);
  padding: 14px 16px;
  margin: 8px 0;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
}
.mission strong { display: block; font-size: 18px; }
.mission em { font-style: normal; color: #b7aa9a; font-size: 14px; }
.mission .num { color: var(--brass); font-family: "Arial Narrow", sans-serif; letter-spacing: 0.14em; }

.brief { max-width: 760px; margin: 0 auto; padding: 48px 22px 80px; }
.brief p { font-size: 18px; line-height: 1.5; }
.phase-list { color: #cbbba6; font-family: "Arial Narrow", sans-serif; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#hud .live { pointer-events: auto; }
.topbar, .bottombar {
  position: absolute;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-family: "Arial Narrow", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  text-shadow: 0 1px 4px #000;
}
.topbar, .bottombar { z-index: 8; }
.topbar { top: 14px; }
.bottombar { bottom: 14px; }
.pill { background: rgba(12, 4, 4, 0.55); border: 1px solid rgba(255, 80, 70, 0.35); padding: 6px 8px; }

.scope-ring {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(68vh, 640px);
  height: min(68vh, 640px);
  transform: translate(-50%, -52%);
  border-radius: 50%;
  box-shadow:
    0 0 0 2000px rgba(12, 2, 2, 0.94),
    inset 0 0 70px rgba(0, 0, 0, 0.55),
    inset 0 0 12px rgba(255, 236, 210, 0.18),
    inset 10px 0 16px rgba(90, 40, 20, 0.16),
    inset -12px 0 18px rgba(20, 40, 70, 0.14);
  pointer-events: none;
}
.scope-ring .lens-tint {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 46%, transparent 42%, rgba(0, 0, 0, 0.28) 78%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}
body.battle .scope-ring {
  box-shadow:
    0 0 0 2000px rgba(36, 0, 0, 0.96),
    inset 0 0 120px rgba(80, 0, 0, 0.45);
}
.reticle { position: absolute; inset: 8%; width: 84%; height: 84%; }
.salt, .sheen, .rain {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.salt {
  background:
    radial-gradient(circle at 22% 30%, rgba(255,255,255,0.45), transparent 1.2%),
    radial-gradient(circle at 70% 62%, rgba(255,255,255,0.35), transparent 1%),
    radial-gradient(circle at 40% 72%, rgba(255,255,255,0.3), transparent 0.8%),
    radial-gradient(circle at 58% 24%, rgba(255,255,255,0.28), transparent 0.7%),
    radial-gradient(circle at 33% 48%, rgba(255,255,255,0.2), transparent 2.2%),
    radial-gradient(circle at 64% 40%, rgba(200,220,230,0.18), transparent 3%);
  opacity: 0.55;
  mix-blend-mode: screen;
}
.sheen {
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,0.16) 48%, transparent 60%);
  animation: sheen 7s linear infinite;
}
.rain {
  background: repeating-linear-gradient(100deg, transparent 0 10px, rgba(180,200,210,0.18) 11px, transparent 13px);
  opacity: 0;
  animation: rain 0.7s linear infinite;
}
.scope-ring.wet .salt { opacity: 0.7; }
.scope-ring.storm .rain { opacity: 0.45; }
@keyframes sheen { from { transform: translateX(-12%); } to { transform: translateX(12%); } }
@keyframes rain { from { background-position: 0 0; } to { background-position: -40px 80px; } }

.instruments {
  position: absolute;
  top: 72px;
  bottom: 64px;
  width: min(250px, 24vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: "Arial Narrow", "Helvetica Neue", sans-serif;
  pointer-events: none;
}
.instruments.left { left: 16px; }
.instruments.right { right: 16px; }
.gauge {
  background: rgba(20, 4, 4, 0.72);
  border: 1px solid rgba(180, 60, 50, 0.45);
  padding: 8px 10px;
  color: #ffd0cc;
}
.gauge b { display: block; color: #ff5a52; font-size: 11px; letter-spacing: 0.16em; }
.gauge span { font-size: 22px; letter-spacing: 0.04em; }
.morale-track { height: 6px; background: #2a1010; margin-top: 6px; }
.morale-track i { display: block; height: 100%; background: #d24a42; width: 50%; }

.speaker {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 90, 80, 0.7);
  background: rgba(20, 0, 0, 0.7);
  color: #ffb0aa;
  display: grid;
  place-items: center;
  pointer-events: auto;
  z-index: 4;
}
.speaker.speaking { animation: pulse 0.7s ease-in-out infinite; box-shadow: 0 0 18px rgba(255, 60, 50, 0.85); }
@keyframes pulse { 50% { transform: scale(1.08); } }
.speaker.at-scope { left: calc(50% + min(30vh, 250px)); top: calc(48% + min(18vh, 160px)); }
.speaker.at-conn { left: calc(50% - 23px); bottom: 86px; }

.subtitles {
  position: absolute;
  left: 50%;
  bottom: 54px;
  transform: translateX(-50%);
  max-width: min(720px, 86vw);
  background: rgba(10, 0, 0, 0.78);
  border: 1px solid rgba(255, 70, 60, 0.35);
  padding: 8px 14px;
  text-align: center;
  font-size: 16px;
}
.subtitles b { color: #ff8a84; font-weight: 600; margin-right: 6px; }

.plot {
  width: 100%;
  height: 150px;
  background: #100808;
  border: 1px solid rgba(180, 60, 50, 0.4);
}
.choice, .hold-card, .f1 {
  pointer-events: auto;
}
.choice, .hold-card {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(760px, 92vw);
  background: rgba(18, 4, 4, 0.94);
  border: 1px solid rgba(255, 80, 70, 0.55);
  padding: 16px 16px 12px;
  color: #ffd0cc;
}
.choice h3, .hold-card h3 { margin: 0 0 8px; color: #ff5a52; letter-spacing: 0.12em; text-transform: uppercase; font-size: 14px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice button, .hold-card button {
  text-align: left;
  background: #220808;
  border: 1px solid rgba(255, 90, 80, 0.4);
  padding: 10px;
}
.choice button strong { display: block; color: #fff; }
.choice button span, .radio-copy { color: #e2b8b4; font-size: 14px; }

.coaming {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(#1a120e, transparent) top/100% 8px no-repeat,
    linear-gradient(#14100e, #14100e) bottom/100% 54px no-repeat;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.35);
}
.sights {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 280px;
  height: 160px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(230, 215, 195, 0.8);
  border-radius: 4px;
}
.sights:before, .sights:after {
  content: "";
  position: absolute;
  background: rgba(230, 215, 195, 0.8);
}
.sights:before { left: 50%; top: -20px; bottom: -20px; width: 1px; }
.sights:after { top: 50%; left: -30px; right: -30px; height: 1px; }

.f1 {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: rgba(10, 2, 2, 0.96);
  color: #ffb4b0;
  display: none;
  padding: 18px 18px 12px;
}
.f1.open { display: flex; flex-direction: column; }
.f1 header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.f1 h2 { margin: 0; color: #ff4a42; letter-spacing: 0.18em; text-transform: uppercase; font-size: 18px; }
.f1-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.f1-col {
  border: 1px solid rgba(255, 70, 60, 0.35);
  background: #160606;
  overflow: auto;
  padding: 8px;
}
.f1-col h3 {
  margin: 0 0 6px;
  color: #ff6a62;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  position: sticky;
  top: 0;
  background: #160606;
  padding-bottom: 4px;
}
.order {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255, 80, 70, 0.15);
  padding: 6px 4px;
  color: #ffd0cc;
}
.order b { display: block; color: #ff4d45; font-size: 14px; letter-spacing: 0.04em; }
.order span { color: #d7a3a0; font-size: 12px; font-family: "Arial Narrow", sans-serif; }
.listen {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 0, 0, 0.9);
  border: 1px solid #ff4a42;
  padding: 8px 12px;
  z-index: 5;
  pointer-events: none;
}

.debrief, .port, .pow {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 20px 80px;
}
.debrief p, .pow p { font-size: 17px; line-height: 1.5; }
.statline { display: flex; gap: 18px; font-family: "Arial Narrow", sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brass); }

@media (max-width: 900px) {
  .side-screen, .sheet { grid-template-columns: 1fr; }
  .side-card, .portrait-pane img { min-height: 48vh; height: 48vh; }
  .portrait-pane { min-height: 48vh; }
  .plate { max-height: none; }
  .instruments { display: none; }
  .scope-ring { width: min(78vw, 520px); height: min(78vw, 520px); }
  .f1-grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .choice-grid { grid-template-columns: 1fr; }
  .mission { grid-template-columns: 48px 1fr; }
}
