/* Canopy Run — HUD is DOM/CSS, deliberately outside the WebGL glitch post pass so the
   clock, gate counter and chevron stay crisp no matter how bad the picture gets. */

:root {
  --bg: #060b08;
  --green: #39ffc8;
  --green-dim: #1f8a68;
  --amber: #ffcf4a;
  --red: #ff4a5a;
  --ink: #eafff4;
  --dim: #8fb3a4;
  --panel: rgba(4, 12, 9, 0.86);
  --font: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); 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-miss-vignette {
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(255, 74, 90, 0.55) 100%);
  transition: opacity 120ms linear;
}

/* ------------------------------------------------------------- prop overlay */

#prop-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: 0.85; }
.prop-nub {
  position: absolute; width: 26px; height: 26px;
  border: 2px solid rgba(200, 255, 235, 0.55);
  border-radius: 3px;
}
.prop-tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.prop-tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.prop-bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.prop-br { bottom: 10px; right: 10px; border-left: none; border-top: none; }
.antenna {
  position: absolute; bottom: 0; left: 50%; width: 2px; height: 46px;
  background: linear-gradient(to top, rgba(200, 255, 235, 0.55), transparent);
  transform: translateX(-50%) rotate(4deg);
  transform-origin: bottom center;
}

/* ---------------------------------------------------------------------- HUD */

#hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; font-variant-numeric: tabular-nums; }
#hud[hidden] { display: none; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: center; gap: 14px;
  padding: 14px;
}
.hud-chip {
  padding: 6px 14px;
  background: rgba(2, 8, 6, 0.72);
  border: 1px solid rgba(57, 255, 200, 0.35);
  font-size: clamp(13px, 1.4vw, 18px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-shadow: 0 0 10px rgba(57, 255, 200, 0.4);
}
.hud-clock[data-low="true"] { color: var(--red); animation: clockpulse 1s steps(2, end) infinite; }
@keyframes clockpulse { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.45; } }
.hud-mult { margin-left: 10px; color: var(--amber); }

.hud-skim-wrap {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  width: min(46vw, 420px); text-align: center;
}
.hud-label { font-size: 10px; letter-spacing: 0.3em; color: var(--dim); margin-bottom: 4px; }
.skim-track {
  height: 10px; background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(57, 255, 200, 0.3);
  overflow: hidden;
}
.skim-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green-dim), var(--green), #fff);
  box-shadow: 0 0 12px rgba(57, 255, 200, 0.6);
  transition: width 80ms linear;
}
.skim-track.is-charging { animation: skimpulse 0.5s ease-in-out infinite; }
@keyframes skimpulse { 0%, 100% { box-shadow: 0 0 0 rgba(57,255,200,0); } 50% { box-shadow: 0 0 14px rgba(57,255,200,0.8); } }

.hud-signal {
  position: absolute; bottom: 20px; right: 20px;
  display: flex; gap: 3px; align-items: flex-end;
}
.hud-signal span { width: 5px; background: var(--green); opacity: 0.9; }
.hud-signal span:nth-child(1) { height: 6px; }
.hud-signal span:nth-child(2) { height: 10px; }
.hud-signal span:nth-child(3) { height: 14px; }
.hud-signal span:nth-child(4) { height: 18px; }
.hud-signal span:nth-child(5) { height: 22px; }
.hud-signal span.dead { background: rgba(255, 255, 255, 0.15); }

.horizon {
  position: absolute; top: 50%; left: 50%;
  width: 140px; height: 2px; margin-left: -70px;
  pointer-events: none;
}
.horizon-line {
  width: 100%; height: 100%;
  background: rgba(200, 255, 235, 0.55);
  transform-origin: center;
}
.horizon::before, .horizon::after {
  content: ""; position: absolute; top: -3px; width: 2px; height: 8px;
  background: rgba(200, 255, 235, 0.55);
}
.horizon::before { left: 0; }
.horizon::after { right: 0; }

.hud-ceiling, .hud-clipped {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%);
  font-size: 14px; letter-spacing: 0.3em; font-weight: 700;
  padding: 4px 12px; background: rgba(2, 8, 6, 0.72);
  border: 1px solid var(--amber); color: var(--amber);
}
.hud-clipped { top: 36%; border-color: var(--red); color: var(--red); }

.hud-ghost {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  font-size: clamp(13px, 1.6vw, 20px); letter-spacing: 0.18em; font-weight: 700;
  color: var(--ink);
  text-shadow: 0 0 4px #000, 0 0 16px rgba(57, 255, 200, 0.5);
  opacity: 0; white-space: nowrap;
  transition: opacity 400ms ease;
}
.hud-ghost.show { opacity: 0.92; }

.hud-banner {
  position: absolute; top: 14%; left: 50%; transform: translateX(-50%);
  padding: 10px clamp(20px, 4vw, 50px); text-align: center;
  font-size: clamp(18px, 2.6vw, 36px); font-weight: 800; letter-spacing: 0.14em;
  opacity: 0; white-space: nowrap; color: var(--red);
  text-shadow: 0 0 4px #000, 0 2px 8px #000, 0 0 24px currentColor;
  background: radial-gradient(ellipse 60% 130% at 50% 50%, rgba(2, 8, 6, 0.85), transparent 78%);
}
.hud-banner.show { animation: bannerpop 1.4s 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; }
}

.hud-toasts {
  position: absolute; top: 40%; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none;
}
.toast {
  font-size: clamp(14px, 1.6vw, 24px); font-weight: 800; letter-spacing: 0.1em;
  color: var(--green);
  text-shadow: 0 0 3px #000, 0 1px 8px #000, 0 0 16px currentColor;
  animation: toastpop 900ms ease-out forwards;
  white-space: nowrap;
}
.toast.bad { color: var(--red); }
@keyframes toastpop {
  0% { opacity: 0; transform: translateY(10px) scale(0.92); }
  16% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(0.98); }
}

/* ------------------------------------------------------------------ screens */

#screens { position: absolute; inset: 0; z-index: 5; }
.screen {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 4vh 4vw;
  background: radial-gradient(ellipse at 50% 45%, rgba(6, 16, 12, 0.7), rgba(2, 6, 5, 0.94));
  backdrop-filter: blur(3px);
}
.screen[hidden] { display: none; }

.panel {
  width: min(480px, 100%); max-height: 92vh; overflow-y: auto;
  padding: clamp(20px, 3vw, 34px);
  background: var(--panel);
  border: 1px solid rgba(57, 255, 200, 0.35);
  box-shadow: 0 0 50px rgba(57, 255, 200, 0.12);
  text-align: center;
}
.panel-wide { width: min(760px, 100%); }

.title { margin: 0 0 4px; font-size: clamp(30px, 5.5vw, 58px); font-weight: 800; letter-spacing: 0.1em; color: #fff;
  text-shadow: 0 0 10px rgba(255,255,255,0.5), 0 0 30px var(--green); }
.tagline { margin: 0 0 20px; color: var(--dim); letter-spacing: 0.08em; font-size: clamp(11px, 1.1vw, 14px); }
.heading { margin: 0 0 18px; font-size: clamp(18px, 2.4vw, 28px); letter-spacing: 0.24em; color: var(--green); }
.cause { color: var(--dim); font-size: 13px; margin: -10px 0 18px; }

.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; text-align: left; margin-bottom: 20px; }
.menu-col h3 { font-size: 11px; letter-spacing: 0.26em; color: var(--green); margin: 0 0 8px; }
.keylist { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--dim); }
.keylist li { margin-bottom: 6px; }
.objective { font-size: 12.5px; color: var(--dim); line-height: 1.6; margin: 0 0 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); margin-top: 6px; }
.check input { accent-color: var(--green); width: 15px; height: 15px; }
@media (max-width: 620px) { .menu-grid { grid-template-columns: 1fr; } }

.menu { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.menu-row { flex-direction: row; justify-content: center; }
.btn {
  appearance: none; font: inherit; font-size: clamp(13px, 1.2vw, 16px); letter-spacing: 0.16em;
  padding: 12px 24px; color: var(--ink); background: rgba(0, 40, 30, 0.4);
  border: 1px solid rgba(57, 255, 200, 0.45); cursor: pointer;
  transition: background 140ms, box-shadow 140ms, transform 100ms;
}
.btn:hover, .btn:focus-visible { background: rgba(57, 255, 200, 0.16); box-shadow: 0 0 20px rgba(57,255,200,0.35); outline: none; }
.btn:active { transform: translateY(1px); }
/* color was #04120d (near-black) — legible only if the tinted background were much more
   opaque than the 15% it actually is; against the real dark page it read as dark-green-on-
   dark-green (reviewer-flagged: START/RETRY were the hardest text on screen to read, not
   the primary call-to-action they are). Bright ink text, matching every other button and
   every other piece of UI text in the game — the brighter border/background tint alone is
   still enough to read as the primary action. */
.btn-primary { border-color: var(--green); background: rgba(57, 255, 200, 0.15); color: var(--ink); font-weight: 700; }
.btn-primary:hover, .btn-primary:focus-visible { background: rgba(57, 255, 200, 0.4); }

.best { margin-top: 16px; font-size: 12px; color: var(--dim); letter-spacing: 0.08em; }
.hint { margin: 18px 0 0; font-size: 11px; color: var(--dim); }
kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid rgba(57,255,200,0.5);
  border-radius: 3px; background: rgba(57,255,200,0.08); color: var(--green); font: inherit; font-size: 0.9em;
}

.result { margin-bottom: 18px; }
.result-score { margin-bottom: 16px; }
.result-score strong { display: block; font-size: clamp(32px, 4.6vw, 54px); font-weight: 800; color: var(--green);
  text-shadow: 0 0 24px rgba(57,255,200,0.5); }
.new-best { display: inline-block; margin-top: 6px; padding: 3px 10px; font-size: 10px; letter-spacing: 0.24em;
  color: #06121a; background: var(--amber); }
.new-best[hidden] { display: none; }
.record-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 16px; margin: 0; }
.record-list div { padding: 8px 10px; border: 1px solid rgba(57,255,200,0.16); background: rgba(0,20,15,0.35); text-align: left; }
.record-list dt { font-size: 9px; letter-spacing: 0.18em; color: var(--dim); }
.record-list dd { margin: 3px 0 0; font-size: 14px; color: var(--ink); }
@media (max-width: 620px) { .record-list { grid-template-columns: repeat(2, 1fr); } }

.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(--green);
  box-shadow: 0 0 12px var(--green); 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, .skim-track.is-charging { animation-duration: 0.01ms; }
}
