/* Brass Harvest — "Sunbleached brutalist warfront" (GAME_DESIGN.md §3). HUD is DOM/CSS so
   it stays crisp and legible over the WebGL scene. */

:root {
  --concrete-light: #c9c0ae;
  --concrete-shadow: #6d675c;
  --sand: #a8987c;
  --rust: #8c4a26;
  --olive: #4e5340;
  --sky-low: #e8a35c;
  --sky-high: #2d3a52;
  --amber: #ffb43c;
  --shell: #ff6a2a;
  --violet: #c07dff;
  --cyan: #3ff0ff;
  --ink: #f3ecda;
  --dim: #cbb99e;
  --panel: rgba(20, 16, 10, 0.86);
  --danger: #ff4a4a;
  --font: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #14100a; color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
#app { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; }

/* ------------------------------------------------------------------ fx layers */
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.fx-layer { position: absolute; inset: 0; opacity: 0; }
#fx-flash { background: #fff; mix-blend-mode: screen; transition: opacity 60ms linear; }
#fx-vignette {
  background: radial-gradient(ellipse at 50% 50%, transparent 48%, rgba(255, 74, 74, 0.65) 100%);
  transition: opacity 140ms linear;
}

/* ---------------------------------------------------------------------- HUD */
#hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; font-variant-numeric: tabular-nums; }
.hud-corner { position: absolute; padding: 16px; }
.hud-tl { top: 0; left: 0; }
.hud-tr { top: 0; right: 0; text-align: right; }
.hud-bl { bottom: 0; left: 0; }

.armor-row { display: flex; gap: 8px; }
.chevron {
  width: 26px; height: 26px;
  clip-path: polygon(50% 0, 100% 35%, 82% 100%, 18% 100%, 0 35%);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255,255,255,0.2);
  transition: background 180ms, transform 180ms;
}
.chevron.filled { background: var(--cyan); box-shadow: 0 0 10px rgba(63,240,255,0.7); border-color: var(--cyan); }
.chevron.gone { opacity: 0; transform: scale(0.4) rotate(25deg); }

.score-panel {
  background: var(--panel); border: 1px solid rgba(255,180,60,0.35);
  padding: 8px 16px; min-width: 160px;
}
.score-main { font-size: clamp(20px, 2.6vw, 30px); font-weight: 800; letter-spacing: 0.04em; }
.hud-mult { margin-left: 8px; color: var(--amber); font-size: 0.65em; text-shadow: 0 0 8px rgba(255,180,60,0.6); }
.score-sub { display: flex; gap: 12px; font-size: 11px; letter-spacing: 0.14em; color: var(--dim); margin-top: 2px; }

.siphon-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.hud-label { font-size: 10px; letter-spacing: 0.3em; color: var(--dim); }
.siphon-arc {
  position: relative; width: 18px; height: 90px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(63,240,255,0.4);
  overflow: hidden; display: flex; align-items: flex-end;
}
.siphon-fill {
  width: 100%; height: 100%;
  background: linear-gradient(to top, #0d6b73, var(--cyan));
  box-shadow: 0 0 10px rgba(63,240,255,0.6);
  transition: height 80ms linear;
}
.siphon-arc.active { animation: siphonpulse 0.5s ease-in-out infinite; }
@keyframes siphonpulse { 0%, 100% { box-shadow: 0 0 0 rgba(63,240,255,0); } 50% { box-shadow: 0 0 16px rgba(63,240,255,0.9); } }
.siphon-flash { position: absolute; inset: 0; background: #fff; opacity: 0; transition: opacity 90ms linear; }
.siphon-arc.dry-flash { animation: siphondryarc 500ms ease-out; }
@keyframes siphondryarc {
  0% { box-shadow: 0 0 0 rgba(255,74,74,0); border-color: rgba(63,240,255,0.4); }
  25% { box-shadow: 0 0 18px rgba(255,74,74,0.95); border-color: var(--danger); }
  100% { box-shadow: 0 0 0 rgba(255,74,74,0); border-color: rgba(63,240,255,0.4); }
}
.siphon-dry-label {
  font-size: 10px; font-weight: 800; letter-spacing: 0.14em; color: var(--danger);
  text-shadow: 0 0 6px rgba(255,74,74,0.8), 0 1px 4px #000;
  opacity: 0; transition: opacity 150ms linear;
}
.siphon-dry-label.show { opacity: 1; animation: siphondrytext 900ms ease-out forwards; }
@keyframes siphondrytext { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

.ammo-row {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; pointer-events: none;
}
.ammo-chip {
  position: relative; width: 108px; padding: 8px 10px 6px;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.18);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform 140ms, border-color 140ms;
}
.ammo-chip.selected { transform: translateY(-6px); border-color: var(--ink); box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
.ammo-chip.empty { opacity: 0.45; }
.ammo-chip.fresh { animation: chippulse 0.9s ease-in-out infinite; }
@keyframes chippulse { 0%, 100% { box-shadow: 0 0 0 rgba(63,240,255,0); } 50% { box-shadow: 0 0 14px rgba(63,240,255,0.85); } }
.ammo-chip.dry-flash { animation: chipdry 280ms ease-out; }
@keyframes chipdry {
  0% { box-shadow: 0 0 0 rgba(255,74,74,0); border-color: rgba(255,255,255,0.18); }
  30% { box-shadow: 0 0 18px rgba(255,74,74,0.9); border-color: var(--danger); }
  100% { box-shadow: 0 0 0 rgba(255,74,74,0); }
}
.chip-swatch { width: 14px; height: 14px; border-radius: 2px; }
#chip-RIFLE .chip-swatch { background: var(--amber); }
#chip-SLUG .chip-swatch { background: var(--shell); }
#chip-LANCE .chip-swatch { background: var(--violet); }
.chip-count { font-size: 20px; font-weight: 800; }
.chip-cap { width: 100%; height: 4px; background: rgba(255,255,255,0.1); }
.chip-cap-fill { height: 100%; width: 0%; background: currentColor; }
#chip-RIFLE .chip-cap-fill { background: var(--amber); }
#chip-SLUG .chip-cap-fill { background: var(--shell); }
#chip-LANCE .chip-cap-fill { background: var(--violet); }
.chip-label { font-size: 10px; letter-spacing: 0.2em; color: var(--dim); }

.threat-pips { position: absolute; inset: 0; }
.threat-pip {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: var(--danger); clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform: rotate(var(--rot));
  box-shadow: 0 0 8px rgba(255,74,74,0.8);
  animation: pipblink 0.4s steps(2, end) infinite;
}
@keyframes pipblink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.35; } }

.hud-toasts {
  position: absolute; top: 38%; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.toast {
  font-size: clamp(14px, 1.6vw, 22px); font-weight: 800; letter-spacing: 0.08em;
  color: var(--cyan); text-shadow: 0 0 3px #000, 0 1px 8px #000, 0 0 16px currentColor;
  animation: toastpop 950ms ease-out forwards; white-space: nowrap;
}
.toast.bad { color: var(--danger); }
.toast.warn { color: var(--shell); }
@keyframes toastpop {
  0% { opacity: 0; transform: translateY(10px) scale(0.9); }
  16% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-28px) scale(0.98); }
}

.hud-banner {
  position: absolute; top: 16%; left: 50%; transform: translateX(-50%);
  padding: 10px clamp(20px, 4vw, 50px); text-align: center;
  font-size: clamp(20px, 3vw, 40px); font-weight: 800; letter-spacing: 0.16em;
  opacity: 0; white-space: nowrap; color: var(--amber);
  text-shadow: 0 0 4px #000, 0 2px 8px #000, 0 0 24px currentColor;
  background: radial-gradient(ellipse 60% 130% at 50% 50%, rgba(10,8,4,0.85), transparent 78%);
}
.hud-banner.show { animation: bannerpop 1.5s ease-out forwards; }
@keyframes bannerpop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.9); }
  15% { opacity: 1; transform: translateX(-50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

/* --------------------------------------------------------- defect-1 discoverability fixes */

/* Permanent, always-on control strip — never dismisses (unlike the coach card). Sits in
   the empty top-centre gap between the armour/score corner panels. */
/* This strip is the game's only PERMANENT statement of the controls, and under engine rule C
   the coach overlay is gone the moment the player first steers — so it has to stay readable
   for the whole run, not just the first seconds. It used to rely on a black text-shadow,
   which worked only while the sky behind it was near-black; once the sky became the intended
   warm dusk gradient, pale text on a bright ground lost its contrast. A backing pill makes it
   independent of whatever is rendered behind it. */
.control-strip {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 999px;
  background: rgba(12, 14, 20, 0.5);
  border: 1px solid rgba(233, 226, 212, 0.12);
  font-size: 10.5px; letter-spacing: 0.14em; color: var(--dim); opacity: 0.8;
  text-shadow: 0 1px 3px #000; pointer-events: none;
  /* Was `white-space: nowrap`, which ran the strip edge-to-edge at 640px and would overflow
     a narrower player frame — and CrazyGames embeds at sizes we do not choose. Wrapping
     inside a bounded, centred pill keeps it readable at any width. */
  max-width: min(92vw, 900px); text-align: center; text-wrap: balance;
}
.control-strip kbd { all: unset; }

/* Persistent empty/low-ammo banner — low-centre, clear of the ammo row beneath it and the
   player silhouette above it. */
.ammo-status-banner {
  position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%);
  text-align: center; font-weight: 800; letter-spacing: 0.12em; white-space: nowrap;
  opacity: 0; transition: opacity 200ms linear; pointer-events: none;
}
.ammo-status-banner.show-empty {
  opacity: 1; font-size: clamp(14px, 2vw, 22px); color: var(--cyan);
  text-shadow: 0 0 4px #000, 0 2px 8px #000, 0 0 18px currentColor;
  animation: ammobannerpulse 1.1s ease-in-out infinite;
}
.ammo-status-banner.show-low {
  opacity: 0.68; font-size: clamp(10.5px, 1.3vw, 13px); color: var(--dim);
  text-shadow: 0 0 3px #000, 0 1px 4px #000;
}
@keyframes ammobannerpulse {
  0%, 100% { opacity: 0.78; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.035); }
}

/* Teach-on-telegraph links — a cyan bar from player to an about-to-fire enemy, shown only
   until the first successful siphon (game.js clears both when bulletsSiphoned > 0). */
.teach-links { position: absolute; inset: 0; }
.teach-link {
  position: absolute; height: 2px; width: 0; transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--cyan), rgba(63,240,255,0));
  box-shadow: 0 0 6px rgba(63,240,255,0.65);
  animation: teachlinkpulse 0.8s ease-in-out infinite;
}
@keyframes teachlinkpulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.teach-label {
  position: absolute; transform: translate(-50%, -100%);
  font-size: 11px; font-weight: 800; letter-spacing: 0.1em; color: var(--cyan);
  background: rgba(10,8,4,0.78); padding: 2px 7px; white-space: nowrap;
  text-shadow: 0 0 6px currentColor;
}

/* --------------------------------------------------------------------- coach */
/* Visual-pass fix: was vertically centered at top:50%, which parked it over the middle of
   the frame — hiding the sun/skyline establishing shot behind the very first thing a player
   sees. Anchored to the lower-right instead (clear of the bottom-center ammo row and the
   top-right score panel) and narrowed, so the horizon stays visible the whole time it's up. */
#coach {
  position: absolute; bottom: 4vh; right: 3vw; top: auto; transform: none;
  z-index: 6; pointer-events: none; width: min(280px, 26vw);
  transition: opacity 200ms linear;
}
#coach[hidden] { display: none; }
.coach-card {
  background: var(--panel); border: 1px solid rgba(63,240,255,0.4);
  padding: 18px; box-shadow: 0 0 40px rgba(0,0,0,0.5);
}
.coach-cone { position: relative; height: 70px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; }
.coach-cone-shape {
  width: 0; height: 0; border-left: 40px solid transparent; border-right: 40px solid transparent;
  border-bottom: 60px solid rgba(63,240,255,0.35);
  filter: drop-shadow(0 0 10px rgba(63,240,255,0.6));
}
.coach-cone-key {
  position: absolute; bottom: 0; font-size: 11px; font-weight: 800; letter-spacing: 0.1em;
  background: var(--cyan); color: #06282b; padding: 2px 8px;
}
.coach-cone-arrow {
  position: absolute; top: 4px; width: 3px; height: 34px;
  background: linear-gradient(to bottom, transparent, var(--amber));
}
.coach-lines { margin-bottom: 12px; }
.coach-line { margin: 0 0 6px; font-size: 13.5px; line-height: 1.4; color: var(--ink); }
.coach-line-1 { font-weight: 800; color: var(--cyan); }
.coach-controls { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px solid rgba(255,255,255,0.12); font-size: 11.5px; color: var(--dim); }
.coach-controls li { margin-bottom: 5px; }
kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid rgba(63,240,255,0.5);
  border-radius: 3px; background: rgba(63,240,255,0.08); color: var(--cyan); font: inherit; font-size: 0.9em;
}

/* ------------------------------------------------------------------ screens */
.screen {
  position: absolute; inset: 0; z-index: 7; display: grid; place-items: center;
  padding: 4vh 4vw;
  background: radial-gradient(ellipse at 50% 45%, rgba(30, 20, 10, 0.75), rgba(10, 7, 4, 0.95));
  backdrop-filter: blur(3px);
}
.screen[hidden] { display: none; }
.panel {
  width: min(520px, 100%); max-height: 92vh; overflow-y: auto;
  padding: clamp(20px, 3vw, 34px);
  background: var(--panel); border: 1px solid rgba(255, 180, 60, 0.35);
  box-shadow: 0 0 50px rgba(0,0,0,0.5); text-align: center;
}
.panel-wide { width: min(760px, 100%); }
.heading { margin: 0 0 18px; font-size: clamp(20px, 2.6vw, 30px); letter-spacing: 0.2em; color: var(--amber); }
.result-score { margin-bottom: 18px; }
.result-score strong { display: block; font-size: clamp(32px, 4.6vw, 54px); font-weight: 800; color: var(--cyan);
  text-shadow: 0 0 24px rgba(63,240,255,0.5); }
.new-best { display: inline-block; margin-top: 6px; padding: 3px 10px; font-size: 10px; letter-spacing: 0.24em;
  color: #2a1c04; background: var(--amber); }
.new-best[hidden] { display: none; }
.record-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px; margin: 0 0 16px; }
.record-list div { padding: 8px 10px; border: 1px solid rgba(255,255,255,0.12); background: rgba(0,0,0,0.25); text-align: left; }
.record-list dt { font-size: 9px; letter-spacing: 0.16em; color: var(--dim); }
.record-list dd { margin: 3px 0 0; font-size: 15px; color: var(--ink); }
@media (max-width: 620px) { .record-list { grid-template-columns: repeat(2, 1fr); } }
.hint { margin: 4px 0 0; font-size: 12px; color: var(--dim); }
.pulse-hint { animation: hintpulse 1.6s ease-in-out infinite; }
@keyframes hintpulse { 0%, 100% { opacity: 0.62; } 50% { opacity: 1; } }

.loader { width: 160px; height: 3px; margin: 0 auto 14px; background: rgba(255,255,255,0.12); overflow: hidden; }
.loader::after {
  content: ""; display: block; width: 40%; height: 100%; background: var(--amber);
  box-shadow: 0 0 12px var(--amber); animation: load 1.1s infinite ease-in-out;
}
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.note { font-size: 11px; color: var(--dim); line-height: 1.6; }

@media (prefers-reduced-motion: reduce) {
  .hud-banner.show, .toast, .loader::after, .siphon-arc.active, .ammo-chip.fresh, .pulse-hint, .threat-pip,
  .ammo-status-banner.show-empty, .teach-link, .siphon-arc.dry-flash, .ammo-chip.dry-flash, .siphon-dry-label.show {
    animation-duration: 0.01ms;
  }
}

/* ---------------------------------------------------------------- pause overlay
   A paused frame must READ as paused (docs/VISUAL_QA.md). Previously P froze the
   last rendered frame with no indicator whatsoever. Dims the scene rather than
   hiding it, so the player keeps their read on the board while stopped. */
/* An explicit `display` beats the UA's `[hidden] { display: none }`, so this rule is what
   actually keeps the overlay off the screen during play — without it the dimming layer and
   the PAUSED card render over every gameplay frame. Same guard as #coach / .screen below. */
.pause-overlay[hidden] { display: none; }
.pause-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 14, 20, 0.62);
  backdrop-filter: blur(2px);
  z-index: 40;
  pointer-events: none;
}
.pause-card {
  padding: 1.4rem 2.6rem;
  text-align: center;
  border: 1px solid rgba(63, 240, 255, 0.35);
  border-radius: 4px;
  background: rgba(16, 20, 28, 0.92);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.pause-title {
  margin: 0;
  font-size: 2.1rem;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: #3ff0ff;
  text-shadow: 0 0 18px rgba(63, 240, 255, 0.45);
}
.pause-hint {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: rgba(233, 226, 212, 0.78);
}
.pause-hint kbd {
  padding: 0.1em 0.45em;
  border: 1px solid rgba(233, 226, 212, 0.35);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
}
