/* DON'T PANIC — Catch the Ship
   Palette: stainless steel, Gulf-night navy, plasma orange, methalox blue */
:root {
  --bg: #0a0f1c;
  --bg2: #111a2e;
  --panel: #152038;
  --panel2: #1b2944;
  --line: #2a3a5c;
  --text: #e9edf4;
  --muted: #9aa7bf;
  --steel: #c9d0da;
  --plasma: #ff6a2b;
  --plasma2: #ffb03b;
  --blue: #5ad1ff;
  --good: #3ee08f;
  --bad: #ff4d6a;
  --warn: #ffc23d;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --display: "Saira Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3efe7;
  --bg2: #e9e3d6;
  --panel: #ffffff;
  --panel2: #f6f2ea;
  --line: #d6cdbb;
  --text: #141b2c;
  --muted: #56607a;
  --steel: #59606d;
  --plasma: #d9480f;
  --plasma2: #b86e00;
  --blue: #0b74a8;
  --good: #11804c;
  --bad: #c41d3a;
  --warn: #9a6a00;
  --shadow: 0 10px 26px rgba(40, 30, 10, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--blue); }
a:hover { color: var(--plasma2); }
:focus-visible { outline: 3px solid var(--plasma2); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--plasma); color: #fff; padding: 8px 14px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { font-family: var(--display); letter-spacing: .02em; line-height: 1.1; margin: 0 0 .5em; }
h1 { font-size: clamp(2.4rem, 8vw, 4.6rem); text-transform: uppercase; }
h2 { font-size: clamp(1.6rem, 5vw, 2.4rem); text-transform: uppercase; }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* Header */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.brand b { color: var(--plasma); }
.nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: .92rem; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--plasma); }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--text); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; flex: none; font-size: 1.05rem; }
.icon-btn:hover { border-color: var(--plasma); }
@media (max-width: 640px) {
  .site-head .wrap { flex-wrap: wrap; padding-block: 6px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .brand span.long { display: none; }
  .head-tools { margin-left: auto; }
}
.head-tools { display: flex; gap: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem var(--display); letter-spacing: .08em; text-transform: uppercase;
  padding: 12px 20px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); cursor: pointer; text-decoration: none;
  transition: transform .12s, background .2s, border-color .2s;
  min-height: 46px;
}
.btn:hover { border-color: var(--plasma); color: var(--text); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--plasma), #e2441a); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(255, 106, 43, .35); }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: .9rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Hero */
.hero { position: relative; overflow: hidden; padding: 38px 0 22px; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(800px 380px at 80% -10%, rgba(255, 106, 43, .25), transparent 60%),
    radial-gradient(700px 400px at 0% 0%, rgba(90, 209, 255, .14), transparent 60%);
}
.eyebrow { font-family: var(--mono); font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--plasma2); margin-bottom: 10px; }
.hero h1 .accent { color: var(--plasma); }
.hero .lede { font-size: 1.12rem; max-width: 62ch; color: var(--muted); }
.hero .lede strong { color: var(--text); }
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 22px 0 6px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--display); font-size: 1.6rem; color: var(--text); line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
@media (max-width: 640px) { .stat-strip { grid-template-columns: repeat(2, 1fr); } }

/* Panels / cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.modes { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
section { padding: 26px 0; }

/* Mode picker */
.mode-card {
  text-align: left; cursor: pointer; background: var(--panel); border: 2px solid var(--line);
  color: var(--text); border-radius: var(--radius); padding: 16px; font: inherit; position: relative;
  transition: border-color .2s, transform .15s;
}
.mode-card:hover { transform: translateY(-2px); border-color: var(--steel); }
.mode-card[aria-pressed="true"] { border-color: var(--plasma); background: linear-gradient(180deg, color-mix(in srgb, var(--plasma) 12%, var(--panel)), var(--panel)); }
.mode-card h3 { margin: 6px 0 4px; font-size: 1.3rem; text-transform: uppercase; }
.mode-card p { margin: 0; font-size: .9rem; color: var(--muted); }
.mode-card .tag { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; color: var(--plasma2); text-transform: uppercase; }
.mode-card .best { margin-top: 8px; font-family: var(--mono); font-size: .78rem; color: var(--blue); }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.seg button { font: 600 .9rem var(--body); background: transparent; color: var(--muted); border: 0; padding: 8px 12px; border-radius: 9px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--blue); }
.setup-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-top: 16px; }
.setup-row label { font-family: var(--mono); font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-right: 6px; }

/* Game */
.game-shell { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #050812; box-shadow: var(--shadow); }
.game-shell canvas { display: block; width: 100%; height: min(74vh, 620px); min-height: 460px; touch-action: none; }
.game-shell.fs { position: fixed; inset: 0; z-index: 200; border-radius: 0; }
.game-shell.fs canvas { height: 100vh; height: 100dvh; }
.hud-top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.hud-top .phase-pill { pointer-events: none; font: 700 .85rem var(--display); letter-spacing: .12em; text-transform: uppercase; background: rgba(5, 8, 18, .7); color: #fff; padding: 6px 10px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .15); }
.hud-top .hud-tools { display: flex; gap: 6px; pointer-events: auto; }
.hud-top .icon-btn { background: rgba(5, 8, 18, .7); color: #fff; border-color: rgba(255, 255, 255, .2); width: 34px; height: 34px; }
.touch-pad { position: absolute; left: 0; right: 0; bottom: 0; display: none; justify-content: space-between; align-items: flex-end; padding: 10px; gap: 10px; pointer-events: none; }
.touch-pad .cluster { display: flex; gap: 10px; pointer-events: auto; }
.touch-pad button {
  width: 66px; height: 66px; border-radius: 18px; border: 2px solid rgba(255, 255, 255, .35);
  background: rgba(10, 15, 28, .55); color: #fff; font: 800 1rem var(--display); letter-spacing: .06em;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.touch-pad button.big { width: 96px; background: rgba(255, 106, 43, .55); border-color: rgba(255, 176, 59, .8); }
.touch-pad button.on { background: rgba(255, 106, 43, .9); }
.touch-pad button[hidden] { display: none; }
.has-touch .touch-pad { display: flex; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(10, 15, 28, .55), rgba(5, 8, 18, .88));
  color: #fff; text-align: center; z-index: 5; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay .box { max-width: 520px; }
.overlay h2 { color: #fff; }
.overlay p { color: #c8d2e6; }
.overlay .kbd { font-family: var(--mono); background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); border-radius: 6px; padding: 1px 6px; font-size: .85em; }
.overlay .btn { color: #fff; }
.overlay .btn:not(.primary) { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .25); }
.overlay ul { text-align: left; color: #c8d2e6; padding-left: 20px; }
.legend { font-size: .85rem; color: var(--muted); margin-top: 8px; }

/* Flight card */
.card-wrap { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .card-wrap { grid-template-columns: 1fr; } }
#cardCanvas { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); background: #0a0f1c; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-family: var(--mono); font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.banner { border-left: 4px solid var(--plasma); background: var(--panel); padding: 12px 14px; border-radius: 8px; margin: 12px 0; }
.banner.blue { border-color: var(--blue); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 300; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Flight log */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.chip { font: 600 .88rem var(--body); padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--plasma); background: color-mix(in srgb, var(--plasma) 14%, var(--panel)); }
.timeline { position: relative; list-style: none; padding: 0; margin: 0; }
.timeline::before { content: ""; position: absolute; left: 22px; top: 0; bottom: 0; width: 2px; background: linear-gradient(var(--line), var(--plasma)); }
.flight { position: relative; padding-left: 58px; margin-bottom: 14px; }
.flight .num { position: absolute; left: 0; top: 12px; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); border: 2px solid var(--line); font: 800 1.15rem var(--display); }
.flight.hero-flight .num { border-color: var(--plasma); background: var(--plasma); color: #fff; }
.flight .panel { padding: 14px 16px; }
.flight button.open { all: unset; cursor: pointer; display: block; width: 100%; }
.flight button.open:focus-visible { outline: 3px solid var(--plasma2); }
.flight .meta { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.flight h3 { margin: 4px 0 8px; font-size: 1.2rem; }
.flight .outcomes { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font: 600 .78rem var(--mono); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); }
.pill.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.pill.ctl { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 50%, transparent); }
.pill.fail { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.pill.na { color: var(--muted); }
.pill.catch { color: #fff; background: var(--plasma); border-color: var(--plasma); }
.flight .detail { margin-top: 10px; color: var(--muted); font-size: .95rem; }
.flight .detail[hidden] { display: none; }
.scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.bar-chart { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; align-items: end; height: 120px; margin-top: 10px; }
.bar-chart .col { display: flex; flex-direction: column; gap: 3px; align-items: stretch; }
.bar-chart .blk { height: 26px; border-radius: 4px; background: var(--line); }
.bar-chart .blk.ok { background: var(--good); }
.bar-chart .blk.catch { background: var(--plasma); }
.bar-chart .blk.ctl { background: var(--blue); }
.bar-chart .blk.fail { background: var(--bad); opacity: .8; }
.bar-chart .lbl { font: 600 .7rem var(--mono); text-align: center; color: var(--muted); }

/* Quiz */
.quiz-q { font-family: var(--display); font-size: clamp(1.4rem, 4.5vw, 2rem); margin: 6px 0 16px; line-height: 1.2; }
.answers { display: grid; gap: 10px; }
.answer { text-align: left; font: 600 1rem var(--body); padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; }
.answer:hover:not([disabled]) { border-color: var(--steel); }
.answer.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 16%, var(--panel2)); }
.answer.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--panel2)); }
.answer[disabled] { cursor: default; }
.progress { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin: 10px 0 14px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--plasma)); width: 0; transition: width .3s; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--panel2); border-left: 4px solid var(--blue); }
.explain[hidden] { display: none; }

/* Hull painter */
.painter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 16px; align-items: start; }
@media (max-width: 820px) { .painter { grid-template-columns: 1fr; } }
#hullCanvas { width: 100%; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--line); background: #0a0f1c; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .field .lab { font-family: var(--mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
input[type="text"], input[type="number"], select {
  font: 600 1rem var(--body); padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--plasma); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.swatches button[aria-pressed="true"] { outline: 3px solid var(--plasma2); outline-offset: 2px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }

/* About */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.4em; }
.prose li { margin-bottom: .4em; }
.sources li { word-break: break-word; }

footer.site-foot { border-top: 1px solid var(--line); margin-top: 30px; padding: 22px 0 40px; color: var(--muted); font-size: .9rem; }
footer.site-foot a { color: var(--muted); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .6s both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
