:root {
  --ink: #15120e;
  --cream: #fbf8f0;
  --lime: #c6f432;
  --pink: #ffa3dc;
  --red: #ff4d4d;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
/* Several elements below set an explicit display, which would otherwise beat
   the UA rule behind the hidden attribute and leave them stuck on screen. */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  background: var(--ink);
  color: var(--cream);
  font-family: "Space Grotesk", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the game owns exactly one viewport; the page scrolls past it to the info section */
#stage {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#gl { display: block; width: 100%; height: 100%; }

#back, #howto {
  position: absolute;
  top: 14px;
  z-index: 6;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(21, 18, 14, 0.72);
  border: 2px solid rgba(251, 248, 240, 0.35);
  color: var(--cream);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}
#back { left: 16px; }
#howto { right: 16px; }
#back:hover, #back:focus-visible, #howto:hover, #howto:focus-visible { opacity: 1; }

/* ── overlay shell ──────────────────────────────────────────────────────── */

#ui {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
}
#ui > .panel { pointer-events: auto; }

.panel {
  width: min(440px, 100%);
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  background: var(--ink);
  border: 4px solid var(--cream);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.45);
  border-radius: 18px;
  padding: 26px 24px;
  text-align: center;
}
.panel-wide { width: min(520px, 100%); }

.title {
  font-family: "Archivo Black", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(34px, 8vw, 52px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: lowercase;
}
.title em { color: var(--lime); font-style: normal; }
.panel h2 {
  font-family: "Archivo Black", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(20px, 5vw, 28px);
  line-height: 1.15;
  text-transform: lowercase;
}
.tagline { color: var(--pink); margin-top: 8px; font-size: 15px; }
.best { color: rgba(251, 248, 240, 0.65); font-size: 14px; margin-top: 10px; }
.score {
  font-family: "Archivo Black", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(38px, 10vw, 56px);
  color: var(--lime);
  margin-top: 12px;
}
.step { color: var(--lime); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
.hint { color: rgba(251, 248, 240, 0.6); font-size: 13px; margin-top: 12px; line-height: 1.5; }
.fineprint {
  margin-top: 16px;
  font-size: 11.5px;
  line-height: 1.5;
  color: rgba(251, 248, 240, 0.5);
}
.fineprint a { color: rgba(198, 244, 50, 0.85); }
.sticker {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  background: var(--pink);
  color: var(--ink);
  font-weight: 700;
  border-radius: 999px;
  transform: rotate(-3deg);
}

.btns { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.btns.row { flex-direction: row; justify-content: center; flex-wrap: wrap; }
.btn {
  display: block;
  width: 100%;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-transform: lowercase;
  color: var(--cream);
  background: transparent;
  border: 3px solid var(--cream);
  border-radius: 999px;
  padding: 12px 18px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btns.row .btn { width: auto; }
.btn small {
  display: block;
  font-weight: 400;
  font-size: 11.5px;
  opacity: 0.65;
  margin-top: 3px;
  text-transform: lowercase;
}
.btn-primary {
  background: var(--lime);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--lime);
}
.btn:hover, .btn:focus-visible { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 rgba(0,0,0,0.5); }
.btn-primary:hover, .btn-primary:focus-visible { box-shadow: 0 0 0 3px var(--lime), 4px 4px 0 rgba(0,0,0,0.5); }
.link-btn {
  background: none;
  border: 0;
  color: rgba(251, 248, 240, 0.7);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}
.row { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; align-items: center; margin-top: 14px; }
.row .link-btn { white-space: nowrap; }

/* ── mode chooser: two ends of the same food chain ───────────────────────── */
.modes { display: flex; gap: 8px; margin-top: 14px; }
.mode {
  flex: 1;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-transform: lowercase;
  color: rgba(251, 248, 240, 0.6);
  background: transparent;
  border: 3px solid rgba(251, 248, 240, 0.28);
  border-radius: 14px;
  padding: 8px 6px;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.mode small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}
.mode:hover, .mode:focus-visible { color: var(--cream); border-color: rgba(251, 248, 240, 0.6); }
/* The chosen one is filled rather than merely outlined: on a menu with two
   equally sized buttons, a border weight alone does not survive a glance. */
.mode.is-on {
  color: var(--ink);
  background: var(--pink);
  border-color: var(--pink);
}

/* setup + calibration */
.spinner {
  width: 34px;
  height: 34px;
  margin: 4px auto 14px;
  border: 4px solid rgba(251, 248, 240, 0.25);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#p-setup.error #setup-text { color: var(--pink); }
#p-setup p { line-height: 1.5; }

.preview {
  margin: 16px auto 0;
  width: min(320px, 100%);
  aspect-ratio: 4 / 3;
  background: #000;
  border: 3px solid var(--cream);
  border-radius: 12px;
  overflow: hidden;
}
.preview canvas { display: block; width: 100%; height: 100%; }
.bar {
  height: 10px;
  margin-top: 14px;
  background: rgba(251, 248, 240, 0.16);
  border-radius: 999px;
  overflow: hidden;
}
.bar i { display: block; height: 100%; width: 0; background: var(--lime); transition: width 0.1s linear; }

/* ── the move coach ─────────────────────────────────────────────────────────
   Three little stick men doing the thing the camera is looking for. Drawn in
   js/coach.js from the tracker's own thresholds; everything here is the frame
   around them and the caption underneath. */

.moves { display: flex; gap: 8px; justify-content: center; }
.move { flex: 1 1 0; min-width: 0; margin: 0; }
.move canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(251, 248, 240, 0.05);
  border: 2px solid rgba(251, 248, 240, 0.2);
  border-radius: 12px;
}
.move figcaption {
  margin-top: 5px;
  font-size: 10.5px;
  line-height: 1.35;
  color: rgba(251, 248, 240, 0.5);
  text-transform: lowercase;
}
.move figcaption b {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--lime);
}

/* The menu strip belongs to the camera button above it, so it sits inside the
   button stack and inherits its gap rather than adding one of its own. */
#menu-moves { margin-top: -2px; }

/* The calibration panel puts the live preview and the pose you are being asked
   for side by side: what it sees, and what it wants to see. */
.calib-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}
.calib-row .preview { margin: 0; flex: 1 1 170px; max-width: 260px; width: auto; }
.move-solo { flex: 0 0 100px; }
.move-solo figcaption { font-size: 11px; }

/* ── hud ────────────────────────────────────────────────────────────────── */

#hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.hud-tl, .hud-tr {
  position: absolute;
  top: 56px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.hud-tl { left: 18px; }
.hud-tr { right: 18px; align-items: flex-end; }
#hud-time { font-size: 13px; opacity: 0.7; }
#hud-dist {
  font-family: "Archivo Black", ui-sans-serif, system-ui, sans-serif;
  font-size: 30px;
  color: var(--lime);
  line-height: 1;
}
#hud-best { font-size: 12px; opacity: 0.6; }

#cam-chip { margin-top: 8px; text-align: right; }
.cam-wrap {
  width: 160px;
  height: 120px;
  border: 2px solid rgba(251, 248, 240, 0.5);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  position: relative;
}
/* the video must stay rendered for the tracker; the canvas shows the mirror */
.cam-wrap video { position: absolute; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; }
.cam-wrap canvas { display: block; width: 100%; height: 100%; }
.cam-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; opacity: 0.75; margin-top: 4px; }
#cam-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); }
#cam-dot.ok { background: var(--lime); }

/* Shared gauge furniture: the altitude and hawk meters and the stamina bar all
   read as the same instrument, so a glance costs nothing mid-flap. */
.gauge-name { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.6; }
.gauge-cap { font-size: 12px; opacity: 0.85; font-variant-numeric: tabular-nums; }
.gauge-row { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }

/* ── hawk meter: fills as it closes, so the bar itself is the alarm ──────── */
.hud-hawk {
  position: absolute;
  right: 18px;
  bottom: 26px;
  width: 128px;
  padding: 7px 12px 9px;
  border-radius: 12px;
  background: rgba(21, 18, 14, 0.7);
  border: 2px solid rgba(251, 248, 240, 0.4);
  font-size: 13px;
}
.hawk-track {
  margin-top: 6px;
  height: 8px;
  border-radius: 999px;
  background: rgba(251, 248, 240, 0.16);
  overflow: hidden;
}
/* It grows from the right, toward you — the direction the hawk is travelling. */
.hawk-track i {
  display: block;
  height: 100%;
  width: 0;
  margin-left: auto;
  background: var(--cream);
  transition: width 0.12s linear, background 0.2s ease;
}
.hawk-track i.near { background: var(--pink); }
.hawk-track i.close { background: var(--red); }
/* The one line on the menu that sells the camera over the keyboard. It sits on
   the lime primary button, so it earns attention with weight, not colour. */
.btn .perk { opacity: 1; font-weight: 700; margin-top: 5px; }

.hud-hawk.close {
  color: var(--red);
  border-color: var(--red);
  animation: pulse 0.6s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ── altitude: height above the ground under you, not above sea level, ─────
   because the ground is what you hit. Vertical, because altitude is. */
.hud-alt {
  position: absolute;
  left: 18px;
  bottom: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.alt-track {
  position: relative;
  width: 12px;
  height: min(190px, 30vh);
  background: rgba(21, 18, 14, 0.65);
  border: 2px solid rgba(251, 248, 240, 0.4);
  border-radius: 999px;
  overflow: hidden;
}
/* A hairline where the danger band starts, so "low" is a place on the gauge
   and not just a colour you have to have learnt. */
.alt-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20%;
  height: 2px;
  background: rgba(251, 248, 240, 0.28);
}
.alt-track i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: var(--lime);
  transition: height 0.1s linear, background 0.2s ease;
}
.alt-track i.low { background: var(--pink); }
.alt-track i.danger { background: var(--red); animation: shake 0.25s linear infinite; }

.hud-stamina {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  width: min(260px, 60vw);
  height: 12px;
  background: rgba(21, 18, 14, 0.65);
  border: 2px solid rgba(251, 248, 240, 0.4);
  border-radius: 999px;
  overflow: hidden;
}
.hud-stamina i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--lime);
  transition: width 0.12s linear, background 0.2s ease;
}
.hud-stamina i.low { background: var(--pink); }
.hud-stamina i.empty { animation: shake 0.25s linear infinite; }
@keyframes shake { 50% { transform: translateX(2px); } }

/* ── hunt mode: the score is a count, and hunger is the clock under it ───── */
#hud-sub { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.6; }
#hud-hunger {
  width: 104px;
  height: 9px;
  margin-top: 5px;
  background: rgba(21, 18, 14, 0.65);
  border: 2px solid rgba(251, 248, 240, 0.4);
  border-radius: 999px;
  overflow: hidden;
}
#hunger-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--pink);
  transition: width 0.12s linear, background 0.2s ease;
}
#hunger-fill.low { background: var(--red); }
#hunger-fill.empty { animation: shake 0.25s linear infinite; }

/* The bottom-right gauge is the hawk in one mode and the nearest bird in the
   other. Same instrument, same geometry — full means close — but closing on
   something is good news here, so it is lime rather than red and the chip
   celebrates instead of shouting. */
.gauge-read { display: inline-flex; align-items: baseline; gap: 5px; }
#prey-arrow { font-style: normal; color: var(--lime); font-size: 11px; }
.hawk-track.hunt i { background: rgba(251, 248, 240, 0.55); }
.hawk-track.hunt i.near { background: var(--lime); }
.hawk-track.hunt i.close { background: var(--lime); }
.hud-hawk.hunt.close { color: var(--lime); border-color: var(--lime); }

.icon-btn {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
  background: rgba(21, 18, 14, 0.7);
  border: 2px solid rgba(251, 248, 240, 0.4);
  color: var(--cream);
  border-radius: 999px;
  font-size: 12px;
  padding: 7px 14px;
  letter-spacing: 0.1em;
}

#countdown {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: "Archivo Black", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(56px, 16vw, 120px);
  color: var(--lime);
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.4);
  text-transform: lowercase;
}
#countdown.pop { animation: pop 0.45s ease-out; }
@keyframes pop { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#toast {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  z-index: 6;
  background: var(--ink);
  border: 2px solid var(--cream);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

#vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(220, 16, 16, 0.42) 100%);
}
#vignette.on { opacity: 1; animation: vig 0.8s ease-in-out infinite; }
#vignette.on { will-change: opacity; }
@keyframes vig { 50% { opacity: 0.6; } }

#debug {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 20;
  font: 12px/1.4 Consolas, monospace;
  background: rgba(21, 18, 14, 0.8);
  color: var(--lime);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: pre;
}

@media (prefers-reduced-motion: reduce) {
  .hud-hawk.close, .hud-stamina i.empty, .alt-track i.danger,
  #hunger-fill.empty, #vignette.on, #countdown.pop { animation: none; }
}

@media (max-width: 520px) {
  .hud-tl, .hud-tr { top: 52px; }
  .cam-wrap { width: 108px; height: 81px; }
  .panel { padding: 20px 16px; }
  /* Three gauges do not fit across a phone. Altitude and the hawk keep the
     bottom corners; stamina moves up onto its own line between them rather
     than being squeezed until it stops being readable. */
  .hud-alt, .hud-hawk { bottom: 18px; }
  .hud-hawk { width: 104px; padding: 5px 9px 7px; font-size: 11px; }
  .alt-track { height: min(140px, 24vh); }
  .hud-stamina { width: min(190px, 54vw); bottom: 62px; }
  #hud-hunger { width: 86px; }
}

/* ── crawlable info below the fold ──────────────────────────────────────── */

#info {
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 20px 80px;
  font-size: 15px;
  line-height: 1.7;
}
#info h1 { font-size: 22px; line-height: 1.35; color: var(--lime); margin-bottom: 18px; }
#info h2 { font-size: 17px; color: var(--pink); margin: 32px 0 10px; }
#info p { margin-bottom: 12px; }
#info a { color: var(--lime); }
#info a:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }
#info table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; }
#info th, #info td {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid rgba(251, 248, 240, 0.25);
  vertical-align: top;
}
#info th { color: var(--lime); font-weight: 700; }
.moves-info { max-width: 440px; gap: 12px; margin: 14px 0 20px; }
.moves-info .move figcaption { font-size: 12px; color: rgba(251, 248, 240, 0.6); }
.moves-info .move figcaption b { font-size: 14px; margin-bottom: 1px; }
