/* Binary Fission, Round 3: HELIX SOC
 *
 * The Bloomfield Hall STEM Olympiad II look: deep navy, hairline rules, a
 * condensed display face for headings, Exo 2 for reading, a mono face for
 * labels. One rule decides every colour: colour means status or action,
 * never decoration. Green is OK or the main action, amber a warning, red
 * danger, blue information. Mint belongs to Binary Fission itself and marks
 * only the round's identity and the active tab.
 *
 * Hardware budget (4th/5th-gen i5, 4GB RAM, integrated graphics): no
 * backdrop-filter, no blur, no animated shadows or filters. The background
 * glows and grid are two fixed layers painted once. Motion is opacity and
 * transform only, and stops under prefers-reduced-motion.
 */

/* ======================================================================
   FONTS (self-hosted, see /fonts/LICENSE.txt)
   ====================================================================== */

@font-face { font-family: 'Big Shoulders Display'; font-weight: 900; font-display: swap;
  src: url('/fonts/big-shoulders-display-900.woff2') format('woff2'); }
@font-face { font-family: 'Exo 2'; font-weight: 300; font-display: swap;
  src: url('/fonts/exo-2-300.woff2') format('woff2'); }
@font-face { font-family: 'Exo 2'; font-weight: 400; font-display: swap;
  src: url('/fonts/exo-2-400.woff2') format('woff2'); }
@font-face { font-family: 'Exo 2'; font-weight: 500; font-display: swap;
  src: url('/fonts/exo-2-500.woff2') format('woff2'); }
@font-face { font-family: 'Share Tech Mono'; font-weight: 400; font-display: swap;
  src: url('/fonts/share-tech-mono-400.woff2') format('woff2'); }

/* ======================================================================
   TOKENS
   ====================================================================== */

:root {
  /* surfaces */
  --bg: #020b18;
  --bg-deep: #010810;
  --surface: rgba(255, 255, 255, 0.025);
  --surface-2: rgba(255, 255, 255, 0.05);
  --solid: #06111f;                 /* opaque surface, for things that float */
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);

  /* text */
  --text: #e2f0ff;
  --text-2: #b8c7d9;
  --muted: #8a9bb0;

  /* status and action */
  --green: #71fb78;  --green-t: rgba(113, 251, 120, 0.09); --green-l: rgba(113, 251, 120, 0.45);
  --amber: #ffc247;  --amber-t: rgba(255, 194, 71, 0.09);  --amber-l: rgba(255, 194, 71, 0.45);
  --red: #ff5252;    --red-t: rgba(255, 82, 82, 0.09);     --red-l: rgba(255, 82, 82, 0.5);
  --blue: #56c4e9;   --blue-t: rgba(86, 196, 233, 0.08);   --blue-l: rgba(86, 196, 233, 0.45);

  /* Decorative accents, kept clear of the status hues: one per shop category,
     so each tab has its own colour, and blue for section marks and icons. */
  --cat-prevent: #56c4e9;  --cat-prevent-t: rgba(86, 196, 233, 0.12);  --cat-prevent-l: rgba(86, 196, 233, 0.4);
  --cat-detect: #b39dff;   --cat-detect-t: rgba(179, 157, 255, 0.12);  --cat-detect-l: rgba(179, 157, 255, 0.4);
  --cat-process: #8fa8ff;  --cat-process-t: rgba(143, 168, 255, 0.12); --cat-process-l: rgba(143, 168, 255, 0.4);

  /* Binary Fission's own colour: the round label and the active tab only */
  --mint: #6ae7ac;   --mint-t: rgba(106, 231, 172, 0.08);  --mint-l: rgba(106, 231, 172, 0.45);

  --ok: var(--green);
  --warn: var(--amber);
  --danger: var(--red);
  --info: var(--blue);
  --accent: var(--blue);
  /* older names some scripts still pass in inline styles */
  --orange: var(--amber);
  --yellow: var(--amber);
  --cyan: var(--blue);

  /* type */
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;  /* uppercase headings */
  --body: 'Exo 2', 'Segoe UI', system-ui, sans-serif;               /* reading, and every number */
  --label: 'Share Tech Mono', ui-monospace, Consolas, monospace;    /* uppercase labels */
  --mono: 'Share Tech Mono', ui-monospace, Consolas, monospace;     /* log lines, codes */

  --r: 4px;
  --r-sm: 2px;
  --gap: 16px;

  /* status marks, drawn as masks so they take the colour of their text */
  --st-icon-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m16 9-5.5 5.5L8 12'/%3E%3C/svg%3E");
  --st-icon-degraded: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
  --st-icon-breached: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 9-6 6'/%3E%3Cpath d='M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z'/%3E%3Cpath d='m9 9 6 6'/%3E%3C/svg%3E");
  --st-icon-target: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='22' x2='18' y1='12' y2='12'/%3E%3Cline x1='6' x2='2' y1='12' y2='12'/%3E%3Cline x1='12' x2='12' y1='6' y2='2'/%3E%3Cline x1='12' x2='12' y1='22' y2='18'/%3E%3C/svg%3E");
}

/* ======================================================================
   BASE
   ====================================================================== */

* { box-sizing: border-box; }

html { background: var(--bg); color-scheme: dark; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--body);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Two fixed layers behind everything: the glows, then a 60px grid that
   fades out toward the bottom of the screen. */
body::before,
body::after {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  pointer-events: none;
}
body::before {
  background:
    radial-gradient(ellipse 55% 50% at 0% 0%, rgba(0, 72, 50, 0.3), transparent 70%),
    radial-gradient(ellipse 45% 60% at 100% 45%, rgba(20, 50, 90, 0.22), transparent 70%),
    radial-gradient(ellipse 45% 40% at 10% 100%, rgba(70, 50, 150, 0.14), transparent 70%);
}
body::after {
  background-image:
    linear-gradient(to right, rgba(113, 251, 120, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(113, 251, 120, 0.045) 1px, transparent 1px);
  background-size: 60px 60px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.55) 45%, transparent 92%);
          mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.55) 45%, transparent 92%);
}

h1, h2, h3 {
  font-family: var(--display); font-weight: 900;
  text-transform: uppercase; letter-spacing: 0.02em; line-height: 0.95;
  margin: 0; color: var(--text);
}
h1 { font-size: 40px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
p { margin: 0 0 10px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

.label {
  font-family: var(--label); font-weight: 400;
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}

/* Keyboard focus is always visible, and always the same. */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ---- layout ---- */

.wrap { max-width: 1680px; margin: 0 auto; padding: 16px 24px 48px; }
.grid { display: grid; gap: var(--gap); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.split { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.split.wide-side { grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); }
@media (max-width: 1100px) {
  .split, .split.wide-side { grid-template-columns: minmax(0, 1fr); }
}

/* ======================================================================
   COMPONENTS
   ====================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}
.panel > h2:first-child, .panel > .row:first-child { margin-bottom: 12px; }

.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px;
  font-family: var(--display); font-weight: 900; font-size: 22px; line-height: 1;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.section-title .st-icon { display: inline-flex; color: var(--blue); }
.section-title .ico { width: 18px; height: 18px; }

/* ---- icons: one stroke weight at any size ---- */

.ico { display: block; flex: none; }
.ico * { vector-effect: non-scaling-stroke; }
.with-icon { display: inline-flex; align-items: center; gap: 8px; }
h3.with-icon { display: flex; }
.label.with-icon { display: flex; gap: 6px; }

/* ---- buttons: hairline by default; filled green only for the main action ---- */

button, .btn {
  font-family: var(--body); font-weight: 500;
  font-size: 15px; line-height: 1.2; letter-spacing: 0.01em;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 16px; min-height: 38px;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
button:hover:not(:disabled), .btn:hover { background: var(--surface-2); border-color: rgba(255, 255, 255, 0.3); }
button:disabled { cursor: not-allowed; color: var(--muted); border-color: var(--line); background: transparent; }

button.primary { color: #021208; background: var(--green); border-color: var(--green); }
button.primary:hover:not(:disabled) { background: #93fd98; border-color: #93fd98; }
button.primary:disabled { color: var(--muted); background: transparent; border-color: var(--line); }
button.danger { color: var(--red); border-color: var(--red-l); }
button.danger:hover:not(:disabled) { background: var(--red-t); border-color: var(--red); }
button.blue { color: var(--blue); border-color: var(--blue-l); }
button.big { font-size: 16px; padding: 12px 22px; min-height: 46px; }
button.block { width: 100%; }
button.small, .btn.small { font-size: 13px; padding: 6px 12px; min-height: 30px; }

input, select {
  font: inherit;
  color: var(--text);
  background: rgba(1, 8, 16, 0.7);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 12px; min-height: 38px;
}
input::placeholder { color: var(--muted); }

/* ---- pills: small mono labels with a hairline, coloured only by status ---- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-family: var(--label); font-size: 11px; line-height: 1.6;
  letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
  color: var(--text-2); background: transparent;
}
.pill.ok, .pill.live { color: var(--green); border-color: var(--green-l); }
.pill.warn   { color: var(--amber); border-color: var(--amber-l); }
.pill.danger { color: var(--red); border-color: var(--red-l); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- tables: ruled rows ---- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th {
  font-family: var(--label); font-weight: 400; font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
th.num, td.num { text-align: right; }
td.num { font-weight: 500; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* ---- the in-game currency: coin, then the number ---- */

.credits { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.credits .ico { width: 15px; height: 15px; color: var(--muted); }
.credits .amt { font-weight: 500; font-variant-numeric: tabular-nums; }
button .credits .ico { color: currentColor; }
td.num .credits { justify-content: flex-end; }

/* ---- a static tooltip, for hover and keyboard alike ---- */

.tip { position: relative; display: inline-flex; align-items: center; gap: 4px; cursor: help; }
.tip .ico { width: 13px; height: 13px; }
.tip::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 20;
  width: 250px; padding: 8px 10px;
  background: var(--solid); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-family: var(--body); font-size: 13px; line-height: 1.4;
  letter-spacing: 0; text-transform: none; color: var(--text);
  opacity: 0; pointer-events: none; transition: opacity 0.12s ease;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; }

/* ======================================================================
   HUD (top bar)
   ====================================================================== */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 20px;
  /* same edges as the page content below it, at any width */
  padding: 10px max(24px, calc((100% - 1680px) / 2 + 24px));
  background: rgba(1, 8, 16, 0.95);
  border-bottom: 1px solid var(--line);
}
.topbar > :last-child { justify-self: end; }
.topbar-id { min-width: 0; }

.brand {
  font-family: var(--display); font-weight: 900;
  font-size: 26px; line-height: 0.9; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--text);
}
.brand-sub {
  margin-top: 6px;
  font-family: var(--label); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub .round-id { color: var(--mint); }
.brand-sub #team-name { color: var(--text-2); }

/* Credits, integrity and score: one ruled strip. */
.readouts {
  display: flex; flex-wrap: nowrap; gap: 0; margin: 0;
  border: 1px solid var(--line); background: var(--surface);
}
.readouts .stat {
  position: relative;
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 6px 18px 6px 14px; min-width: 132px;
}
.readouts .stat + .stat { border-left: 1px solid var(--line); }
.hud-icon { display: inline-flex; color: var(--blue); }
.hud-icon .ico { width: 18px; height: 18px; }
.stat-col { display: flex; flex-direction: column; }
.stat .label { font-size: 12px; line-height: 1.35; color: var(--text-2); }
.stat .value {
  font-family: var(--body); font-weight: 500; font-size: 26px; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.value.ok { color: var(--green); }
#cash.value.ok { color: var(--text); }   /* plenty of credits is not a status */
.value.warn { color: var(--amber); }
.value.danger { color: var(--red); }

.topbar .row { flex-wrap: nowrap; gap: 14px; }
.clock-box { display: flex; flex-direction: column; align-items: flex-end; }
.clock {
  font-family: var(--body); font-weight: 500;
  font-size: 40px; line-height: 1; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.clock.urgent { color: var(--amber); }

@media (max-width: 900px) {
  #game .topbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 10px; padding: 10px 16px; }
  #game .topbar > .readouts { grid-column: 1 / -1; grid-row: 2; }
  .readouts .stat { flex: 1; min-width: 0; padding: 6px 10px; }
  .wrap { padding: 12px 16px 40px; }
}
@media (max-width: 480px) {
  .readouts .hud-icon { display: none; }
  .stat .value { font-size: 22px; }
  .clock { font-size: 32px; }
  .brand-sub { white-space: normal; }
}

/* A purchase or a top-up shows briefly under the credits. */
.cash-delta {
  position: absolute; left: 14px; top: calc(100% + 6px); z-index: 2;
  padding: 3px 7px;
  font-family: var(--body); font-weight: 500; font-size: 13px; line-height: 1.2;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  color: var(--text-2); background: var(--bg-deep);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  pointer-events: none;
  animation: cash-fade 1.4s ease-out forwards;
}
.cash-delta.up { color: var(--green); border-color: var(--green-l); }
@keyframes cash-fade {
  0% { opacity: 0; transform: translateY(-4px); }
  15% { opacity: 1; transform: none; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- phase banner: one slim line saying what to do now ---- */

.phase-banner {
  --pb: var(--text-2);
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--line); border-left: 2px solid var(--pb);
  border-radius: var(--r-sm);
}
.phase-banner .pb-icon { display: inline-flex; flex: none; color: var(--pb); }
.phase-banner .pb-icon .ico { width: 20px; height: 20px; }
.phase-banner > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.phase-banner .pb-title {
  font-family: var(--display); font-weight: 900; font-size: 24px; line-height: 1;
  text-transform: uppercase; letter-spacing: 0.02em; color: var(--text);
}
.phase-banner .pb-sub { font-size: 16px; color: var(--text-2); }
.phase-banner.shop     { --pb: var(--blue); }
.phase-banner.lobby    { --pb: var(--blue); }
.phase-banner.result   { --pb: var(--blue); }
.phase-banner.incident { --pb: var(--red); }
.phase-banner.debrief  { --pb: var(--green); }

/* ======================================================================
   JOIN SCREEN
   ====================================================================== */

.join-screen { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.scanlines { display: none; }

.join-inner { position: relative; width: 100%; max-width: 560px; }
.join-mark { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.join-round {
  margin-top: 4px;
  font-family: var(--label); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}

.join-title { font-size: clamp(40px, 7vw, 64px); line-height: 0.92; margin-bottom: 18px; }
.join-title .t-line { display: block; }
.t-accent { color: var(--text-2); }

.bootlog {
  font-family: var(--mono); font-size: 13px; line-height: 1.75;
  color: var(--green); white-space: pre-wrap;
  min-height: 9em; margin: 0 0 16px; padding: 12px 14px;
  background: rgba(1, 8, 16, 0.7); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.bootlog .dim { color: var(--muted); }
.bootlog .warn { color: var(--amber); }
.cursor, .feed-cursor {
  display: inline-block; width: 8px; height: 1em; vertical-align: -2px;
  background: currentColor; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.join-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px;
  opacity: 0; transition: opacity 0.4s ease;
}
.join-card.ready { opacity: 1; }
.join-form { display: flex; gap: 10px; margin-top: 8px; }
.code-input {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 28px; letter-spacing: 0.4em;
  text-align: center; text-transform: uppercase; padding: 8px 10px;
}
.join-form button { min-width: 150px; }

.join-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 18px;
  border: 1px solid var(--line); background: var(--surface);
}
.join-stats div { padding: 12px 10px; text-align: center; }
.join-stats div + div { border-left: 1px solid var(--line); }
.join-stats strong {
  display: block; font-weight: 500; font-size: 26px; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.join-stats span {
  font-family: var(--label); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
@media (max-width: 560px) {
  .join-stats { grid-template-columns: repeat(2, 1fr); }
  .join-stats div:nth-child(3) { border-left: 0; }
  .join-stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .join-form { flex-direction: column; }
}

/* ======================================================================
   LOBBY
   ====================================================================== */

.lobby-hero { text-align: center; padding: 32px 20px; }
.lobby-hero h1 { font-size: 44px; margin: 10px 0 10px; }
.lobby-cast { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.lobby-cast figure { margin: 0; text-align: center; }
.lobby-cast figcaption {
  margin-top: 6px;
  font-family: var(--label); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-2);
}
.lobby-cast .sprite-frame { padding: 6px; }

/* ======================================================================
   ASSETS: what you are defending
   ====================================================================== */

.topo-wrap {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden;
}
.topo-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px 24px; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.topo-title { display: flex; align-items: center; gap: 10px; font-size: 22px; line-height: 1; }
.topo-title::before { content: ''; flex: none; width: 3px; height: 18px; background: var(--blue); }
.topo-legend {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  font-family: var(--label); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-2);
}
.topo-legend span { display: inline-flex; align-items: center; gap: 6px; }
.topo-legend .ico { width: 14px; height: 14px; }
.lg-ok .ico { color: var(--green); }
.lg-degraded .ico { color: var(--amber); }
.lg-breached .ico { color: var(--red); }

/* Six equal cells in one ruled strip. Every cell is styled the same way;
   only the status bar and the status word carry colour. */
.asset-strip {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow: hidden;
}
@media (max-width: 1150px) { .asset-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .asset-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.achip {
  --st: var(--green);
  --st-icon: var(--st-icon-ok);
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  grid-template-areas:
    "icon name  name"
    "bar  bar   bar"
    "state state pct";
  gap: 9px 10px; align-items: center;
  padding: 12px 14px;
  /* hairlines on the left and top; the strip clips the outer ones */
  box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line);
}
.achip-top { display: contents; }
.achip-icon { grid-area: icon; align-self: start; display: inline-flex; color: var(--text-2); }
.achip-icon .ico { width: 20px; height: 20px; }
.achip-name {
  grid-area: name; align-self: start;
  min-height: 2.5em;              /* two lines for every title, so the rows below line up */
  font-weight: 500; font-size: 15px; line-height: 1.25; color: var(--text);
}
.achip-bar { grid-area: bar; height: 3px; background: rgba(255, 255, 255, 0.08); }
.achip-bar i { display: block; height: 100%; width: 100%; background: var(--st); transition: width 0.4s ease; }
.achip-state {
  grid-area: state;
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  font-family: var(--label); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; white-space: nowrap; color: var(--st);
}
.achip-state::before {
  content: ''; flex: none; width: 13px; height: 13px;
  background: currentColor;
  -webkit-mask: var(--st-icon) center / contain no-repeat;
          mask: var(--st-icon) center / contain no-repeat;
}
.achip-pct {
  grid-area: pct; justify-self: end;
  font-weight: 500; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text);
}
.achip-state { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .achip { grid-template-areas: "icon name pct" "bar bar bar" "state state state"; }
  .achip-pct { align-self: start; }
}
.achip.status-degraded { --st: var(--amber); --st-icon: var(--st-icon-degraded); }
.achip.status-breached { --st: var(--red);   --st-icon: var(--st-icon-breached); }
.achip.is-target       { --st: var(--red);   --st-icon: var(--st-icon-target); background: var(--red-t); }

/* Identify and respond: one slim row, so every answer fits on screen. The
   status word steps aside, but its icon stays beside the number. */
.topo-wrap.mini .topo-head { display: none; }
.topo-wrap.mini .achip {
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  grid-template-areas: "icon name pct state";
  gap: 8px; padding: 8px 12px;
}
.topo-wrap.mini .achip-icon { align-self: center; }
.topo-wrap.mini .achip-icon .ico { width: 16px; height: 16px; }
.topo-wrap.mini .achip-name {
  min-height: 0; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topo-wrap.mini .achip-bar { display: none; }
.topo-wrap.mini .achip-state { font-size: 0; letter-spacing: 0; gap: 0; }

/* ======================================================================
   NETWORK TOPOLOGY (the full map, shown in a briefing)
   ====================================================================== */

.topo-wrap:not(.compact) { background: rgba(1, 8, 16, 0.55); }
.topo { display: block; width: 100%; height: auto; clip-path: inset(10px 0 0 10px); }

.topo-link { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 1.5; }
.topo-link.is-hot { stroke: var(--red); stroke-width: 2; stroke-dasharray: 7 6; animation: flow 0.9s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -26; } }

.pkt { fill: var(--blue); opacity: 0.8; }
.pkt.is-hot { fill: var(--red); }
.pkt-attack { fill: var(--red); }

.node-glow { display: none; }
.node-box { fill: #06111f; stroke: rgba(255, 255, 255, 0.22); stroke-width: 1.25; }
.node-label { text-anchor: middle; font-family: var(--body); font-size: 15px; font-weight: 500; fill: var(--text); }
.node-status {
  text-anchor: middle; font-family: var(--label); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase; fill: var(--green);
}
.node-bar-bg { fill: rgba(255, 255, 255, 0.08); }
.node-bar { fill: var(--green); transition: width 0.4s ease; }

.kind-ext .node-box { fill: transparent; stroke: rgba(255, 255, 255, 0.22); stroke-dasharray: 5 4; }
.kind-ext .node-label { fill: var(--text-2); font-family: var(--label); font-size: 12px; letter-spacing: 0.16em; }
.kind-edge .node-box { stroke: var(--blue-l); }
.kind-edge .node-label { fill: var(--text-2); font-size: 13px; }

.status-degraded .node-box { stroke: var(--amber); }
.status-degraded .node-status { fill: var(--amber); }
.status-degraded .node-bar { fill: var(--amber); }
.status-breached .node-box { stroke: var(--red); }
.status-breached .node-status { fill: var(--red); }
.status-breached .node-bar { fill: var(--red); }
.is-target .node-box { stroke: var(--red); stroke-width: 2; }

/* ======================================================================
   SHOP
   ====================================================================== */

/* The shop is a section, not a box around boxes. */
.shop-panel { background: none; border: 0; padding: 0; border-radius: 0; }

.shop-tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 10px; }
.shop-tab {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 8px 16px; margin: 0 0 -1px;
  font-size: 16px; color: var(--text-2);
  background: transparent;
  border: 1px solid var(--line); border-bottom-color: transparent; border-radius: 0;
}
.shop-tab + .shop-tab { margin-left: -1px; }
.shop-tab .ico { width: 17px; height: 17px; color: var(--cat); }
.shop-tab.cat-prevent, .cards.cat-prevent { --cat: var(--cat-prevent); --cat-t: var(--cat-prevent-t); --cat-l: var(--cat-prevent-l); }
.shop-tab.cat-detect,  .cards.cat-detect  { --cat: var(--cat-detect);  --cat-t: var(--cat-detect-t);  --cat-l: var(--cat-detect-l); }
.shop-tab.cat-process, .cards.cat-process { --cat: var(--cat-process); --cat-t: var(--cat-process-t); --cat-l: var(--cat-process-l); }
.shop-tab .count {
  padding: 0 6px;
  font-family: var(--label); font-size: 12px; line-height: 1.5; letter-spacing: 0.06em;
  color: var(--text-2); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.shop-tab:hover:not(.active) { color: var(--text); background: var(--surface); border-color: var(--line); border-bottom-color: transparent; }
.shop-tab.active {
  color: var(--mint); background: var(--mint-t);
  box-shadow: inset 0 -2px 0 var(--mint);
}
.shop-tab.active .count { color: var(--mint); border-color: var(--mint-l); }

.tab-hint { margin: 0 0 12px; font-size: 15px; color: var(--text-2); }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* Every card has the same frame: icon, a two-line name with the price beside
   it, the description, the chips, and the action pinned to the bottom. */
.card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color 0.12s ease;
}
.card:hover { border-color: var(--line-strong); }
.card-head { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: start; }
.card-icon {
  width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--cat, var(--text-2)); background: var(--cat-t, transparent);
  border: 1px solid var(--cat-l, var(--line)); border-radius: var(--r-sm);
}
.card-icon .ico { width: 18px; height: 18px; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.card-name {
  min-height: 2.5em;              /* two lines for every name */
  font-weight: 500; font-size: 16px; line-height: 1.25; color: var(--text);
}
.card-cost { flex: none; padding-top: 1px; font-size: 16px; color: var(--text); }
.card-blurb { font-size: 15px; line-height: 1.45; color: var(--text-2); }

.card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.tag-label {
  min-width: 52px;
  font-family: var(--label); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-2);
}
.tag {
  padding: 0 7px;
  font-size: 13px; line-height: 1.6;
  color: var(--text-2);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.tag.see { color: var(--blue); border-color: var(--blue-l); }

.card > button, .card > .owned-flag { margin-top: auto; }
.card button { width: 100%; color: var(--green); background: var(--green-t); border-color: var(--green-l); }
.card button:hover:not(:disabled) { background: rgba(113, 251, 120, 0.16); border-color: var(--green); }
.card button:disabled { color: var(--muted); border-color: var(--line); background: transparent; }
.card.owned { border-color: var(--green-l); }
.owned-flag {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px;
  font-family: var(--label); font-size: 13px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--green);
  background: var(--green-t); border: 1px solid var(--green-l); border-radius: var(--r-sm);
}
.owned-flag .ico { width: 15px; height: 15px; }

/* ---- side: what you can see, and what you own ---- */

.coverage { display: flex; flex-direction: column; }
.cov-row {
  display: grid; grid-template-columns: 17px minmax(0, 1fr) 96px 14px;
  align-items: center; gap: 10px;
  padding: 7px 0; border-top: 1px solid var(--line);
}
.cov-row:last-child { border-bottom: 1px solid var(--line); }
.cov-icon { display: inline-flex; color: var(--text-2); }
.cov-icon .ico { width: 17px; height: 17px; }
.cov-name { font-size: 15px; color: var(--text); }
.cov-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.cov-pip { height: 10px; border: 1px solid var(--line-strong); border-radius: 1px; }
.cov-pip.on { background: var(--blue); border-color: var(--blue); }
.cov-level { font-family: var(--label); font-size: 14px; text-align: right; color: var(--text-2); }
.cov-row:has(.cov-blind) .cov-level { color: var(--amber); }

.blind-note, .blind-alert, .missing-note {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; font-size: 15px; color: var(--text);
  border-radius: var(--r-sm);
}
.blind-note { margin: 12px 0 0; background: var(--amber-t); border: 1px solid var(--amber-l); }
.blind-note .ico { width: 16px; height: 16px; color: var(--amber); }

.kit { display: flex; flex-wrap: wrap; gap: 6px; }
.kit span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; font-size: 14px; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.kit span .ico { width: 15px; height: 15px; color: var(--green); }   /* deployed */
.kit-empty { margin: 0; font-size: 14px; color: var(--muted); }

/* ======================================================================
   INCIDENT
   ====================================================================== */

.brief {
  margin: 0; padding: 12px 16px;
  font-size: 16px; line-height: 1.6; font-weight: 500; color: var(--text);
  background: var(--surface-2); border-left: 2px solid var(--red);
}

/* ---- a character speaking ---- */

.comms { display: flex; gap: 14px; align-items: flex-start; margin: 16px 0 4px; }
.comms-portrait {
  flex: none; line-height: 0;
  padding: 5px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: rgba(1, 8, 16, 0.6);
}
.comms-body {
  flex: 1; min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
}
.comms-who { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.comms-name { font-weight: 500; font-size: 15px; color: var(--text); }
.comms-role {
  font-family: var(--label); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.comms-line { margin: 0; min-height: 1.5em; font-size: 16px; line-height: 1.5; color: var(--text); }
.comms-line .feed-cursor { background: var(--text-2); }

/* ---- evidence ---- */

.evidence-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 20px 0 8px; }
.evidence-head h3 .ico { width: 18px; height: 18px; color: var(--text-2); }
.signal-count {
  padding: 0 7px;
  font-family: var(--label); font-size: 12px; line-height: 1.6; letter-spacing: 0.06em;
  color: var(--blue); border: 1px solid var(--blue-l); border-radius: var(--r-sm);
}

.feed { display: flex; flex-direction: column; }
.feed-line {
  display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 9px 2px; border-top: 1px solid var(--line);
  opacity: 0; animation: lineIn 0.3s ease forwards;
}
.feed-line:last-child { border-bottom: 1px solid var(--line); }
@keyframes lineIn { to { opacity: 1; } }
.feed-text { font-family: var(--mono); font-size: 14px; line-height: 1.55; color: var(--text); word-break: break-word; }

.ch {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 6px;
  font-family: var(--label); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-2); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}

.missing-note { margin: 12px 0 0; background: var(--amber-t); border: 1px solid var(--amber-l); }
.missing-note .ico { width: 16px; height: 16px; color: var(--amber); }
.blind-alert { background: var(--red-t); border: 1px solid var(--red-l); }
.blind-alert .ico { width: 16px; height: 16px; color: var(--red); }

/* ---- answers: neutral rows; the one you pick turns green ---- */

.tiles { display: grid; grid-template-columns: 1fr; gap: 8px; }
.choices { display: flex; flex-direction: column; gap: 8px; }

.choice {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; cursor: pointer;
  font-size: 15px; line-height: 1.35; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.choice:hover:not(.disabled) { border-color: rgba(255, 255, 255, 0.32); background: var(--surface-2); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: 2px; }
.choice-letter {
  width: 30px; height: 30px; display: grid; place-items: center;
  font-family: var(--label); font-size: 14px; color: var(--text-2);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.choice-letter .ico { width: 16px; height: 16px; }
.choice.on { border-color: var(--green); background: var(--green-t); }
.choice.on .choice-letter { color: #021208; background: var(--green); border-color: var(--green); }
.choice.disabled { cursor: not-allowed; color: var(--muted); }
.choice-cost { font-size: 14px; color: var(--text-2); }

.locked {
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  padding: 14px; background: var(--green-t); border: 1px solid var(--green-l); border-radius: var(--r-sm);
}
.locked .answer { font-weight: 500; font-size: 16px; }
.locked .answer .ico { width: 16px; height: 16px; color: var(--green); }

.hint {
  margin-bottom: 12px; padding: 11px 13px;
  font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--blue-t); border: 1px solid var(--blue-l); border-radius: var(--r-sm);
}
.hint .label { color: var(--blue); margin-bottom: 4px; }
.hint .label .ico { width: 14px; height: 14px; }

/* ---- resolution ---- */

.verdict { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.verdict .pill { font-size: 12px; padding: 4px 10px; }
.reveal {
  margin-bottom: 12px; padding: 10px 13px; font-size: 15px; color: var(--text);
  background: var(--amber-t); border: 1px solid var(--amber-l); border-radius: var(--r-sm);
}
.narrative {
  margin: 0 0 6px; padding: 12px 16px;
  font-size: 16px; line-height: 1.6; color: var(--text);
  background: var(--surface-2); border-left: 2px solid var(--line-strong);
}
.score-rows { margin-top: 12px; }
.score-rows td:first-child .ico { width: 16px; height: 16px; color: var(--text-2); }

/* A decision on the clock: the submit button stays on screen, and whatever
   scrolls beneath it fades out rather than being sliced in half. */
.submit-bar {
  position: sticky; bottom: 0; z-index: 5;
  margin: 6px 0 -6px; padding: 20px 0 14px;
  background: linear-gradient(to bottom, rgba(6, 17, 31, 0), #06111f 45%);
}
.phase-banner.tight { min-height: 40px; padding: 7px 14px; }
.phase-banner.tight .pb-icon .ico { width: 18px; height: 18px; }
.phase-banner.tight .pb-title { font-size: 20px; }
.phase-banner.tight .pb-sub { font-size: 14px; }

@media (max-height: 820px) {
  .choice { padding: 8px 12px; }
  .choices { gap: 6px; }
  .choice-letter { width: 28px; height: 28px; }
}

/* ======================================================================
   DEBRIEF
   ====================================================================== */

.final-score { text-align: center; padding: 22px 12px 10px; }
.final-score .big {
  font-family: var(--display); font-weight: 900; line-height: 0.9;
  font-size: clamp(64px, 9vw, 104px); color: var(--text);
}
.final-score .of {
  font-family: var(--label); font-size: 12px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}

/* ======================================================================
   WAVE ALERT (the klaxon)
   ====================================================================== */

.wave-alert {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(1, 8, 16, 0.96);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.wave-alert.show { opacity: 1; }
.wave-alert-inner { text-align: center; padding: 0 20px; }
.wave-alert-tag {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 18px; padding: 6px 14px;
  font-family: var(--label); font-size: clamp(13px, 1.6vw, 18px);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--red); border: 1px solid var(--red-l); background: var(--red-t);
}
.wave-alert-name {
  font-family: var(--display); font-weight: 900; text-transform: uppercase;
  font-size: clamp(40px, 7vw, 88px); line-height: 0.95; color: var(--text);
}

/* ======================================================================
   SPRITES
   ====================================================================== */

.sprite { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }

/* ======================================================================
   SYSTEM: toasts, offline banner
   ====================================================================== */

#toasts .panel { background: var(--solid); padding: 10px 14px; font-size: 14px; }

.offline-banner {
  display: none; position: sticky; top: 0; z-index: 40;
  padding: 8px; text-align: center;
  font-family: var(--label); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--red); background: #1b0709; border-bottom: 1px solid var(--red-l);
}
body.is-offline .offline-banner { display: block; }

/* ======================================================================
   ADMIN
   ====================================================================== */

.team-count {
  padding: 1px 8px;
  font-family: var(--label); font-size: 13px; letter-spacing: 0.08em;
  color: var(--green); border: 1px solid var(--green-l); border-radius: var(--r-sm);
}
.team-count.short { color: var(--amber); border-color: var(--amber-l); }
.team-count.full { color: var(--text-2); border-color: var(--line-strong); }
.code-cell { font-family: var(--mono); font-size: 18px; letter-spacing: 0.18em; color: var(--text); }

/* ======================================================================
   PROJECTOR
   ====================================================================== */

.projector { overflow: hidden; }
.board { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.board-head {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: clamp(14px, 2vw, 28px) clamp(18px, 3vw, 44px);
  background: rgba(1, 8, 16, 0.92); border-bottom: 1px solid var(--line);
}
.board-title { font-size: clamp(36px, 5vw, 72px); margin: 0; }
.board-sub {
  margin-top: 8px;
  font-family: var(--label); font-size: clamp(12px, 1.2vw, 18px);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.board-clock {
  font-family: var(--body); font-weight: 500; line-height: 1;
  font-size: clamp(48px, 7vw, 112px); font-variant-numeric: tabular-nums; color: var(--text);
}
.board-clock.urgent { color: var(--amber); }
.board-body { padding: clamp(14px, 2.2vw, 34px) clamp(18px, 3vw, 44px); overflow: hidden; }

.lb { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.lb-row {
  display: grid; grid-template-columns: clamp(56px, 6vw, 96px) minmax(0, 1fr) auto auto auto;
  align-items: center; gap: clamp(12px, 1.8vw, 28px);
  padding: clamp(10px, 1.6vh, 20px) clamp(14px, 1.8vw, 26px);
  border-bottom: 1px solid var(--line); border-left: 2px solid transparent;
  font-size: clamp(18px, 2vw, 32px);
}
.lb-rank { font-family: var(--label); font-size: 0.8em; color: var(--muted); text-align: center; }
.lb-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-num {
  font-family: var(--label); font-size: 0.5em; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.lb-score { font-weight: 500; font-size: 1.1em; font-variant-numeric: tabular-nums; color: var(--text); }
.lb-row.lead { border-left-color: var(--green); background: var(--green-t); }
.lb-row.lead .lb-rank { color: var(--green); }
.centered { display: grid; place-items: center; height: 100%; text-align: center; }
.big-idle { font-family: var(--display); font-weight: 900; text-transform: uppercase; font-size: clamp(32px, 4vw, 56px); }

/* ======================================================================
   REDUCED MOTION
   ====================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .feed-line, .join-card { opacity: 1; }
  .pkt, .pkt-attack { display: none; }
}
