/* ==========================================================================
   LAST STAND — interface.

   Visual identity: field-expedient military / quarantine signage. The chrome is
   a console bolted together out of stencilled crates and hazard tape, not a
   deck of rounded cards. Squared corners, hairline rules, stencil eyebrows.

   Deliberately single-theme: this is a night siege, and it commits to one
   visual world. Every colour is therefore painted explicitly (including on
   html/body) so the page never borrows a host background.
   ========================================================================== */

/* -- typefaces ------------------------------------------------------------ */
/* Self-hosted so the game still renders correctly with no network (PWA). */

@font-face {
  font-family: 'Big Shoulders';
  src: url('../fonts/bigshoulders-800.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Barlow';
  src: url('../fonts/barlow-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Barlow';
  src: url('../fonts/barlow-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('../fonts/plexmono-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  /* Ground is a warm charcoal biased toward olive — a chosen neutral, not #111. */
  --ground:     #14150f;
  --crate:      #1e2016;
  --crate-hi:   #262920;
  --rule:       #33372a;
  --rule-soft:  #262a1f;

  /* Bone, like a field manual page. */
  --canvas:     #e9e3d2;
  --muted:      #8b8874;
  --faint:      #63644f;

  /* Signal amber is THE accent: hazard tape, stencilled warnings. */
  --hazard:     #e8912a;
  --hazard-dim: #a4631a;

  /* Semantic colours, kept separate from the accent. */
  --drab:       #86924e;   /* holding / ok — olive-drab, deliberately not acid green */
  --drab-ink:   #a8b565;
  --oxide:      #c1442e;   /* danger — rust, not neon */
  --oxide-ink:  #ef7a5f;

  --display: 'Big Shoulders', 'Arial Narrow', sans-serif;
  --body:    'Barlow', system-ui, -apple-system, sans-serif;
  --mono:    'Plex Mono', ui-monospace, Consolas, monospace;

  /* One type scale. Everything picks from it. */
  --t-micro: 10px;
  --t-fine:  11px;
  --t-base:  13px;
  --t-lead:  15px;
  --t-stat:  19px;
  --t-head:  26px;
  --t-hero:  34px;

  --pad: 12px;
  --radius: 2px;         /* stamped metal, not soft cards */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--canvas);
  font-family: var(--body);
  font-size: var(--t-base);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: var(--radius);
}

/* Visible keyboard focus everywhere. */
:focus-visible {
  outline: 2px solid var(--hazard);
  outline-offset: 2px;
}

/* Stencilled eyebrow label — the repeating structural device. */
h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: var(--t-fine);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}

#app { display: flex; flex-direction: column; height: 100%; }

/* -- status strip --------------------------------------------------------- */

#hud {
  display: flex; align-items: stretch; gap: 0;
  background: linear-gradient(180deg, #1d1f16, #16180f);
  border-bottom: 1px solid var(--rule);
  flex: 0 0 auto;
  padding: 0 14px;
}

.brand {
  display: flex; flex-direction: column; justify-content: center;
  padding: 9px 20px 9px 0;
  border-right: 1px solid var(--rule-soft);
}
.brand-main {
  font-family: var(--display); font-weight: 800;
  font-size: 22px; line-height: .95; letter-spacing: .06em;
  color: var(--canvas);
}
.brand-sub {
  font-size: 9px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--hazard-dim); margin-top: 3px;
}

/* Vitals read as instrument gauges: tiny stencil label, big tabular number. */
.stats { display: flex; margin-left: auto; }
.stat {
  display: flex; flex-direction: column; justify-content: center;
  min-width: 88px; padding: 8px 18px;
  border-left: 1px solid var(--rule-soft);
}
.stat-label {
  font-family: var(--display); font-weight: 800;
  font-size: 9px; letter-spacing: .2em; color: var(--faint);
}
.stat-value {
  font-family: var(--mono); font-weight: 500;
  font-size: var(--t-stat); line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
#stat-cash  .stat-value { color: var(--hazard); }
#stat-wave  .stat-value { color: var(--canvas); }
#stat-hp    .stat-value { color: var(--drab-ink); }
#stat-kills .stat-value { color: var(--muted); }
#stat-hp.low .stat-value { color: var(--oxide-ink); }

.hpbar { height: 2px; background: #0b0c07; margin-top: 5px; overflow: hidden; }
.hpbar i {
  display: block; height: 100%; width: 100%;
  background: var(--drab); transition: width .2s linear, background .2s;
}
#stat-hp.low .hpbar i { background: var(--oxide); }

.controls {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 0 8px 18px; border-left: 1px solid var(--rule-soft); margin-left: 18px;
}
.speeds { display: flex; }
.ctl {
  background: transparent; border: 1px solid var(--rule);
  color: var(--muted); padding: 6px 10px;
  font-family: var(--mono); font-size: var(--t-fine);
  transition: color .12s, border-color .12s, background .12s;
}
.speeds .ctl { border-radius: 0; margin-left: -1px; }
.speeds .ctl:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.speeds .ctl:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.ctl:hover { color: var(--canvas); border-color: var(--muted); }
.ctl.is-on {
  color: var(--ground); background: var(--hazard);
  border-color: var(--hazard); font-weight: 500;
}

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

main { display: flex; flex: 1 1 auto; min-height: 0; }

#stage {
  position: relative; flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  padding: 14px; min-width: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, #191b12 0%, #0b0c07 100%);
}

#game {
  max-width: 100%; max-height: 100%;
  aspect-ratio: 32 / 20;
  border: 1px solid var(--rule);
  box-shadow: 0 18px 60px rgba(0,0,0,.75), 0 0 0 1px rgba(0,0,0,.5);
  cursor: crosshair;
  touch-action: none;
}

/* -- side console --------------------------------------------------------- */

#side {
  flex: 0 0 322px; overflow-y: auto; overflow-x: hidden;
  background: var(--ground);
  border-left: 1px solid var(--rule);
  padding: 0 0 40px;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
#side::-webkit-scrollbar { width: 9px; }
#side::-webkit-scrollbar-track { background: #101109; }
#side::-webkit-scrollbar-thumb { background: var(--rule); }

/* Panels are stacked bays divided by rules — not floating rounded cards. */
.panel {
  flex: 0 0 auto;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--ground);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 11px;
}
/* Hairline that runs out from each eyebrow to the panel edge.
   Pseudo-elements can't appear inside :not(), so order the real children
   explicitly instead of trying to exclude ::after. */
.panel-head::after {
  content: ''; flex: 1 1 auto; height: 1px;
  background: var(--rule); order: 1;
}
.panel-head > h2 { order: 0; }
.panel-head > *:not(h2) { order: 2; }

.hint { font-size: var(--t-micro); color: var(--faint); }

.chip {
  font-family: var(--mono); font-size: 9px; letter-spacing: .12em;
  padding: 3px 7px; text-transform: uppercase;
  background: var(--crate); color: var(--muted);
  border: 1px solid var(--rule);
}
.chip.boss     { background: #3a1109; color: #ff9878; border-color: #6d2313; }
.chip.swarm    { background: #3a3208; color: #ffd45e; border-color: #6d5c14; }
.chip.armoured { background: #1b2a33; color: #8fc6e0; border-color: #2f4a58; }

/* -- next wave ------------------------------------------------------------ */

.wave-preview {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 12px; min-height: 24px;
}
.wp-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--crate); border: 1px solid var(--rule-soft);
  padding: 3px 7px; font-size: var(--t-fine);
}
.wp-dot { width: 7px; height: 7px; flex: 0 0 auto; }
.wp-count {
  color: var(--muted); font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* The one loud element: real hazard tape. Everything else stays quiet. */
button.primary {
  position: relative; width: 100%; display: block; text-align: left;
  background: var(--crate-hi); border: 1px solid var(--rule);
  border-left: 3px solid var(--drab);
  padding: 11px 13px; color: var(--canvas);
  font-weight: 600; font-size: var(--t-lead);
  transition: background .12s, border-color .12s;
}
button.primary::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: repeating-linear-gradient(
    45deg, var(--drab) 0 6px, #0e0f09 6px 12px);
  opacity: .55;
}
button.primary:hover { background: #2e3226; border-color: var(--muted); }
button.primary small {
  display: block; font-weight: 400; font-size: var(--t-micro);
  color: var(--muted); margin-top: 3px; letter-spacing: .01em;
}
button.primary.hot { border-left-color: var(--hazard); }
button.primary.hot::before {
  background: repeating-linear-gradient(
    45deg, var(--hazard) 0 6px, #0e0f09 6px 12px);
  opacity: .85;
  animation: tape 1.1s linear infinite;
}
button.primary.hot small { color: var(--hazard); }
@keyframes tape { to { background-position: 17px 0; } }

.toggle {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: var(--t-fine); color: var(--muted); cursor: pointer;
}
.toggle input { accent-color: var(--hazard); }

/* -- build bay ------------------------------------------------------------ */

.build-list { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule-soft); }
.bt {
  position: relative; text-align: left;
  background: var(--crate); border: 0; border-radius: 0;
  padding: 9px 9px 8px; transition: background .12s;
}
.bt::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: transparent; transition: background .12s;
}
.bt:hover { background: var(--crate-hi); }
.bt.is-on { background: #33301c; }
.bt.is-on::before { background: var(--hazard); }
.bt.poor { opacity: .4; }
.bt-top { display: flex; align-items: center; gap: 6px; }
.bt-swatch { width: 9px; height: 9px; flex: 0 0 auto; }
.bt-name { font-size: 12px; font-weight: 600; letter-spacing: .01em; }
.bt-meta { display: flex; justify-content: space-between; align-items: baseline; margin-top: 5px; }
.bt-tag {
  font-family: var(--display); font-weight: 800;
  font-size: 9px; letter-spacing: .16em; color: var(--faint); text-transform: uppercase;
}
.bt-cost {
  font-family: var(--mono); font-size: var(--t-fine);
  color: var(--hazard); font-variant-numeric: tabular-nums;
}
.bt.poor .bt-cost { color: var(--oxide-ink); }
.bt-key {
  position: absolute; top: 5px; right: 6px;
  font-family: var(--mono); font-size: 9px; color: var(--faint);
}

/* -- selected tower ------------------------------------------------------- */

#panel-detail { min-height: 128px; }
.detail-empty { font-size: var(--t-fine); color: var(--muted); line-height: 1.65; }
.detail-empty b { color: var(--canvas); font-weight: 600; }

.d-head { display: flex; align-items: baseline; gap: 8px; }
.d-name {
  font-family: var(--display); font-weight: 800;
  font-size: 20px; letter-spacing: .03em; text-transform: uppercase;
}
.d-lvl {
  font-family: var(--mono); font-size: var(--t-micro);
  color: var(--hazard); margin-left: auto; font-variant-numeric: tabular-nums;
}
.d-desc { font-size: var(--t-fine); color: var(--muted); line-height: 1.6; margin: 7px 0 11px; }

.d-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0 14px; margin-bottom: 10px;
}
.d-stat {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: var(--t-fine); padding: 3px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.d-stat span:first-child { color: var(--muted); }
.d-stat span:last-child {
  font-family: var(--mono); color: var(--canvas);
  font-variant-numeric: tabular-nums;
}
.d-stat.up span:last-child { color: var(--drab-ink); }

.perf {
  font-size: var(--t-micro); color: var(--muted);
  margin: 0 0 10px; padding: 6px 8px;
  background: var(--crate); border-left: 2px solid var(--rule);
}
.perf b { color: var(--hazard); font-family: var(--mono); font-weight: 500; }

.d-row { display: flex; gap: 6px; margin-top: 8px; }

button.ghost {
  flex: 1; background: var(--crate); border: 1px solid var(--rule);
  padding: 9px 10px; font-size: var(--t-fine); font-weight: 600;
  transition: background .12s, border-color .12s, color .12s;
}
button.ghost:hover:not(:disabled) { background: var(--crate-hi); border-color: var(--muted); }
button.ghost:disabled { opacity: .35; cursor: not-allowed; }
button.ghost.wide { width: 100%; }
button.ghost.buy { border-color: var(--hazard-dim); color: var(--hazard); }
button.ghost.buy:hover:not(:disabled) { background: #33260f; border-color: var(--hazard); }
button.ghost.sell { color: var(--muted); }
button.ghost.sell:hover:not(:disabled) {
  color: var(--oxide-ink); border-color: #6d2313; background: #2a120c;
}

.sell-foot { margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--rule-soft); }
button.ghost.sell.wide { width: 100%; flex: none; }

.branch-wrap { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--rule); }
.branch-title {
  font-family: var(--display); font-weight: 800;
  font-size: var(--t-micro); letter-spacing: .18em;
  color: var(--hazard); text-transform: uppercase; margin-bottom: 8px;
}
.branch {
  width: 100%; text-align: left; margin-bottom: 6px;
  background: var(--crate); border: 1px solid var(--rule);
  border-left: 2px solid var(--rule); padding: 9px 10px;
  transition: background .12s, border-color .12s;
}
.branch:hover:not(:disabled) { background: var(--crate-hi); border-left-color: var(--hazard); }
.branch:disabled { opacity: .38; cursor: not-allowed; }
.branch-name { font-size: var(--t-base); font-weight: 600; }
.branch-blurb { font-size: var(--t-micro); color: var(--muted); line-height: 1.55; margin-top: 4px; }

.targeting { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 11px; }
.tg {
  font-size: var(--t-micro); padding: 4px 8px;
  background: var(--crate); border: 1px solid var(--rule); color: var(--muted);
  transition: color .12s, border-color .12s;
}
.tg:hover { color: var(--canvas); }
.tg.is-on { border-color: var(--hazard); color: var(--hazard); background: #2a2312; }

/* -- commander abilities -------------------------------------------------- */

#abilities {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 3;
}

.ab {
  position: relative; overflow: hidden;
  width: 84px; padding: 9px 0 7px;
  background: rgba(20,22,14,.92);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--hazard-dim);
  transition: border-color .12s, background .12s, transform .08s;
}
.ab:hover:not(.cooling) { background: rgba(40,44,28,.96); border-top-color: var(--hazard); }
.ab:active { transform: translateY(1px); }

/* Cooldown drains downward, so a full bar reads as "not yet". */
.ab-sweep {
  position: absolute; inset: auto 0 0 0; height: 0;
  background: rgba(10,12,7,.82); pointer-events: none;
  transition: height .1s linear;
}
.ab-body { position: relative; display: block; text-align: center; }
.ab-name {
  display: block; font-family: var(--display); font-weight: 800;
  font-size: var(--t-base); letter-spacing: .14em; color: var(--hazard);
}
.ab-key {
  display: block; margin-top: 2px;
  font-family: var(--mono); font-size: 9px; color: var(--faint);
}
.ab-cd {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 17px; font-weight: 500;
  color: var(--canvas); text-shadow: 0 1px 6px #000; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.ab.cooling { cursor: default; border-top-color: var(--rule); }
.ab.cooling .ab-name, .ab.cooling .ab-key { opacity: .3; }
.ab.aiming {
  border-color: var(--hazard); border-top-color: var(--hazard);
  background: rgba(70,48,14,.96);
  box-shadow: 0 0 0 1px var(--hazard) inset, 0 0 18px rgba(232,145,42,.4);
}

/* -- toast & banner ------------------------------------------------------- */

#toast {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 5px; align-items: center;
  pointer-events: none; width: max-content; max-width: 90%;
}
.toast-item {
  font-size: var(--t-fine);
  background: rgba(12,13,8,.95); border: 1px solid var(--rule);
  border-left: 3px solid var(--hazard);
  padding: 7px 13px;
  animation: toastIn .18s ease-out;
}
.toast-item.bad  { border-left-color: var(--oxide); color: var(--oxide-ink); }
.toast-item.good { border-left-color: var(--drab); color: var(--drab-ink); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } }

#banner {
  position: absolute; top: 30px; left: 50%; transform: translateX(-50%);
  font-family: var(--display); font-weight: 800;
  letter-spacing: .3em; font-size: 30px;
  pointer-events: none; opacity: 0; text-transform: uppercase;
  text-shadow: 0 3px 22px rgba(0,0,0,.95);
}
#banner.show { animation: bannerFlash 1.9s ease-out; }
@keyframes bannerFlash {
  0%   { opacity: 0; transform: translateX(-50%) scale(1.18); }
  14%  { opacity: 1; transform: translateX(-50%) scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; }
}

/* -- overlays ------------------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,9,5,.9); backdrop-filter: blur(4px); padding: 20px;
}
.overlay.hidden { display: none; }

.overlay-card {
  position: relative;
  background: var(--crate); border: 1px solid var(--rule);
  padding: 0 30px 26px; max-width: 600px; width: 100%;
  box-shadow: 0 30px 90px rgba(0,0,0,.8);
  max-height: 88vh; overflow-y: auto;
}
/* Hazard tape across the top of every dialog. */
.overlay-card::before {
  content: ''; display: block; height: 5px; margin: 0 -30px 24px;
  background: repeating-linear-gradient(45deg, var(--hazard) 0 9px, #16180f 9px 18px);
}
.overlay-card h1 {
  margin: 0 0 4px; font-family: var(--display); font-weight: 800;
  font-size: var(--t-hero); letter-spacing: .1em; color: var(--canvas);
  text-wrap: balance;
}
.overlay-card .sub {
  color: var(--hazard-dim); font-size: var(--t-fine);
  letter-spacing: .16em; text-transform: uppercase; margin-bottom: 18px;
}
.overlay-card p { font-size: var(--t-base); line-height: 1.7; color: #c8c3b0; max-width: 62ch; }
.overlay-card ul {
  font-size: var(--t-base); line-height: 1.75; color: #c8c3b0;
  padding-left: 17px; margin: 8px 0 16px; max-width: 62ch;
}
.overlay-card li::marker { color: var(--faint); }
.overlay-card li b { color: var(--hazard); font-weight: 600; }

.promise {
  background: #191b11; border-left: 3px solid var(--hazard);
  padding: 12px 15px; margin: 16px 0;
  font-size: var(--t-base); line-height: 1.65; color: #cfc9b4; max-width: 62ch;
}
.promise b { color: var(--hazard); font-weight: 600; }

.overlay-actions { display: flex; gap: 7px; margin-top: 20px; flex-wrap: wrap; }
.overlay-actions button {
  flex: 1; min-width: 130px; padding: 12px 15px;
  font-size: var(--t-base); font-weight: 600;
  border: 1px solid var(--rule); background: var(--crate-hi); color: var(--canvas);
  transition: background .12s, border-color .12s;
}
.overlay-actions button:hover { background: #34382a; border-color: var(--muted); }
.overlay-actions button.go {
  background: var(--hazard); border-color: var(--hazard); color: #1a1206;
}
.overlay-actions button.go:hover { background: #f5a03c; border-color: #f5a03c; }

/* Difficulty picker */
.diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0 18px; }
.diff {
  text-align: left; background: #191b11; border: 1px solid var(--rule);
  border-top: 2px solid var(--rule); padding: 11px 10px;
  transition: background .12s, border-color .12s;
}
.diff:hover { background: var(--crate-hi); }
.diff.is-on { background: #2a2716; border-top-color: var(--hazard); }
.diff-name {
  font-family: var(--display); font-weight: 800; font-size: var(--t-lead);
  letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px;
}
.diff.is-on .diff-name { color: var(--hazard); }
.diff-blurb { font-size: var(--t-micro); color: var(--muted); line-height: 1.5; }
.diff-rec {
  font-size: var(--t-micro); color: var(--hazard-dim);
  font-family: var(--mono); margin-top: 6px; font-variant-numeric: tabular-nums;
}

/* Research */
.intel-bar {
  display: flex; align-items: baseline; gap: 9px;
  background: #191b11; border-left: 3px solid var(--hazard);
  padding: 10px 14px; margin: 4px 0 14px;
}
.intel-n {
  font-family: var(--mono); font-size: 24px; font-weight: 500;
  color: var(--hazard); font-variant-numeric: tabular-nums;
}
.intel-l {
  font-family: var(--display); font-weight: 800; font-size: var(--t-fine);
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}

.rs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 14px 0 4px; }
.rs {
  background: #191b11; border: 1px solid var(--rule);
  border-top: 2px solid var(--rule); padding: 10px;
}
.rs.maxed { border-top-color: var(--drab); }
.rs-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rs-name {
  font-family: var(--display); font-weight: 800; font-size: var(--t-base);
  letter-spacing: .08em; text-transform: uppercase;
}
.rs-pips { display: flex; gap: 3px; flex: 0 0 auto; }
.pip { width: 7px; height: 7px; background: var(--rule); display: block; }
.pip.on { background: var(--hazard); }
.rs.maxed .pip.on { background: var(--drab-ink); }
.rs-blurb { font-size: var(--t-micro); color: var(--muted); line-height: 1.5; margin: 5px 0 8px; min-height: 30px; }
.rs-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rs-now {
  font-family: var(--mono); font-size: var(--t-micro);
  color: var(--drab-ink); font-variant-numeric: tabular-nums;
}
.rs-buy {
  background: var(--crate-hi); border: 1px solid var(--hazard-dim);
  color: var(--hazard); padding: 5px 10px;
  font-family: var(--mono); font-size: var(--t-micro); font-weight: 500;
  transition: background .12s, border-color .12s;
}
.rs-buy:hover:not(:disabled) { background: #33260f; border-color: var(--hazard); }
.rs-buy:disabled { opacity: .32; cursor: not-allowed; border-color: var(--rule); color: var(--muted); }

.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; margin: 16px 0; }
.score-item {
  display: flex; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--rule-soft); padding: 6px 0; font-size: var(--t-base);
}
.score-item span:first-child { color: var(--muted); }
.score-item span:last-child {
  font-family: var(--mono); color: var(--canvas);
  font-variant-numeric: tabular-nums;
}

kbd {
  font-family: var(--mono); font-size: var(--t-micro);
  background: var(--crate-hi); border: 1px solid var(--rule);
  border-bottom-width: 2px; padding: 2px 6px; color: var(--canvas);
}

/* -- responsive ----------------------------------------------------------- */

@media (max-width: 1120px) {
  #side { flex-basis: 292px; }
  .stat { min-width: 74px; padding: 8px 13px; }
}

@media (max-width: 880px), (pointer: coarse) and (max-width: 1100px) {
  html, body { overflow: auto; }
  #app { height: auto; min-height: 100%; }
  main { flex-direction: column; }

  #stage { padding: 8px; flex: 0 0 auto; }
  #game { width: 100%; height: auto; max-height: 56vh; }

  #side {
    flex: 1 1 auto; width: 100%;
    border-left: none; border-top: 1px solid var(--rule); overflow-y: visible;
  }

  #hud { flex-wrap: wrap; padding: 0 10px; }
  .brand { flex: 1 1 100%; border-right: none; border-bottom: 1px solid var(--rule-soft); padding: 8px 0; }
  .brand-main { font-size: 18px; }
  .stats { margin-left: 0; flex: 1 1 auto; }
  .stat { min-width: 0; flex: 1 1 0; padding: 7px 10px; }
  .stat:first-child { border-left: none; }
  .stat-value { font-size: var(--t-lead); }
  .controls { margin-left: 0; padding-left: 10px; }

  /* 44px is the accessible minimum tap target. */
  .ctl { padding: 10px 12px; min-height: 42px; }
  .bt { padding: 12px 10px; min-height: 60px; }
  button.primary { padding: 14px; }
  button.ghost { padding: 12px 10px; min-height: 44px; }
  .tg { padding: 9px 11px; font-size: var(--t-fine); }
  .branch { padding: 13px; }

  .diff-row { grid-template-columns: 1fr; }
  .score-grid { grid-template-columns: 1fr; }
  .rs-grid { grid-template-columns: 1fr; }
  .rs-blurb { min-height: 0; }
  #abilities { bottom: 8px; gap: 4px; }
  .ab { width: 68px; padding: 11px 0 9px; }
  .overlay-card { padding: 0 18px 20px; }
  .overlay-card::before { margin: 0 -18px 20px; }
  .overlay-card h1 { font-size: 24px; }
  #banner { font-size: 20px; }
}

@media (max-width: 430px) {
  .build-list { grid-template-columns: 1fr; }
  .d-stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
