:root {
  --gold: #d4af37;
  --gold-lit: #e8c65a;
  --fire: #ff5a1f;
  --bg-0: #05060a;
  --panel: rgba(10, 12, 20, 0.78);
  --border: rgba(212, 175, 55, 0.5);
  --text: #eef1f7;

  /* Display cuts where the platform has them, falling back to the UI face.
     Self-hosted fonts were deliberately avoided: no external requests, no
     committed binaries. Tracking does the heavy lifting instead — tight on the
     hero, wide only on small caps-style labels. */
  --font-display: "Segoe UI Variable Display", "SF Pro Display", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --font-ui: "Segoe UI Variable Text", -apple-system, BlinkMacSystemFont,
    "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app { height: 100%; width: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg-0);
  color: var(--text);
  overflow: hidden;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation; /* tap-to-henshin without the 300ms delay */
}

/* Scrim under the chrome. Without it, HUD contrast over the canvas is
   non-deterministic — gold text can land on lit gold dots at ~1:1. */
#app::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34vh;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(2, 3, 6, 0) 0%, rgba(2, 3, 6, 0.62) 58%, rgba(2, 3, 6, 0.85) 100%);
  opacity: 1;
  transition: opacity 0.8s ease;
}

body.cinematic #app::after { opacity: 0; }

/* Chrome should not be selectable, but the page text should be. */
#lockup, #controls, #shots, #keys, #title-card, #btn-skip { user-select: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Focus ------------------------------------------------------------------
   A gold ring plus a black halo, so it stays visible whether focus lands over
   the near-black background or a brightly lit patch of dots. */
:focus-visible {
  outline: 2px solid var(--gold-lit);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.85);
  border-radius: 10px;
}

/* Corner lockup ----------------------------------------------------------
   Replaces the old centred hero heading, which sat on the helmet crest and
   duplicated the end title card. */
#lockup {
  position: fixed;
  top: 20px;
  left: 22px;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(238, 241, 247, 0.62);
  pointer-events: none;
  transition: opacity 0.8s ease, visibility 0.8s;
}

#lockup span {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.24em;
}

/* Controls --------------------------------------------------------------- */
#controls {
  position: fixed;
  bottom: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  transition: opacity 0.8s ease, visibility 0.8s;
}

.btn {
  font: inherit;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  min-height: 44px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.42); }
.btn:active { transform: translateY(1px); }

/* Secondary actions: quieter fill, but the border stays at 3:1 against the panel
   so it still satisfies non-text contrast. */
.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(238, 241, 247, 0.34);
  color: rgba(238, 241, 247, 0.88);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(238, 241, 247, 0.55);
  color: #fff;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-lit), #b8912b);
  border-color: var(--gold);
  color: #171103;
  font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(135deg, #f0d066, var(--gold)); }

/* #d7431a rather than #c73a10: the darker stop put the label at 3.65:1. */
.btn-primary.fire {
  background: linear-gradient(135deg, #ff7a45, #d7431a);
  border-color: var(--fire);
  color: #1c0700;
}

#form-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 0 10px 0 4px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(238, 241, 247, 0.55);
}

#form-chip::before { content: "Form"; }

#form-name {
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: none;
  font-weight: 700;
  color: var(--gold-lit);
  transition: color 0.5s ease;
}

#form-name.fire { color: #ff8a52; }

/* Shot picker ------------------------------------------------------------ */
#shots {
  position: fixed;
  bottom: 112px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(94vw, 620px);
  transition: opacity 0.8s ease, visibility 0.8s;
}

#shots .btn {
  font-size: 12.5px;
  min-height: 40px;
  padding: 10px 13px;
  background: rgba(10, 12, 20, 0.82);
}

#shots .btn[aria-current="true"] {
  border-color: var(--gold);
  color: var(--gold-lit);
}

/* Keyboard hints --------------------------------------------------------
   Was an 11px line at 35% opacity — 2.86:1, failing AA even as large text.
   Chips at 72% measure 9.24:1 on the scrim. */
#keys {
  position: fixed;
  bottom: 18px;
  left: 0;
  right: 0;
  z-index: 2;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: rgba(238, 241, 247, 0.72);
  pointer-events: none;
  transition: opacity 0.8s ease, visibility 0.8s;
}

#keys kbd {
  font: inherit;
  font-size: 11px;
  display: inline-block;
  min-width: 20px;
  margin: 0 2px 0 9px;
  padding: 3px 6px;
  border: 1px solid rgba(238, 241, 247, 0.34);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

#keys kbd:first-child { margin-left: 0; }

/* Skip ------------------------------------------------------------------ */
#btn-skip {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 4;
  font-size: 12px;
  letter-spacing: 0.1em;
  min-height: 40px;
  padding: 10px 15px;
  transition: opacity 0.5s ease, visibility 0.5s;
}

/* Chrome starts hidden and is revealed by `body.live`, rather than being hidden
   by a `.cinematic` class that JS can only add after first paint — otherwise the
   whole HUD is briefly visible on load and then fades out, which looks broken.
   `visibility` matters as much as opacity: opacity alone leaves the controls in
   the tab order, putting four invisible buttons ahead of Skip during the intro. */
#lockup,
#controls,
#keys,
#btn-skip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.live #lockup,
body.live #controls,
body.live #keys {
  opacity: 1;
  visibility: visible;
}

body.live #controls { pointer-events: auto; }

/* The shot picker is deliberately exempt from the cinematic chrome-hiding: it is
   only ever on screen because the viewer asked for it, and jumping between shots
   is most useful while the sequence is actually running. Its visibility is
   carried by the `hidden` attribute alone. */
#shots[hidden] { display: none; }

body.cinematic #btn-skip {
  opacity: 0.8;
  visibility: visible;
  pointer-events: auto;
}

body.cinematic #btn-skip:hover { opacity: 1; }

/* End title card --------------------------------------------------------
   Sits in the lower third — the director rides the figure upward during the
   final beat so the type lands in clear space rather than across the visor. */
#title-card {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: clamp(56px, 15vh, 170px);
  gap: 14px;
  opacity: 0;
  transition: opacity 1.1s ease, transform 1.6s ease;
  transform: translateY(10px);
  pointer-events: none;
}

#title-card::before {
  content: "";
  position: absolute;
  inset: 45% 0 0 0;
  background: linear-gradient(to bottom, rgba(4, 2, 6, 0) 0%, rgba(4, 2, 6, 0.72) 62%, rgba(4, 2, 6, 0.86) 100%);
  z-index: -1;
}

body.title-in #title-card {
  opacity: 1;
  transform: translateY(0);
}

/* Tight tracking at display size, wide only on the small line beneath it. */
#title-card h2 {
  font-family: var(--font-display);
  font-size: clamp(32px, 7.2vw, 96px);
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 0.95;
  color: #fff6e8;
  text-shadow: 0 0 14px rgba(255, 140, 40, 0.75), 0 0 64px rgba(255, 90, 20, 0.6);
}

#title-card p {
  font-size: clamp(11px, 2.2vw, 19px);
  font-weight: 600;
  letter-spacing: 0.5em;
  padding-left: 0.5em; /* balance the tracking */
  color: #ffb27a;
  text-shadow: 0 0 18px rgba(255, 90, 31, 0.9);
}

/* Responsive ------------------------------------------------------------ */
@media (pointer: coarse) {
  .btn { min-height: 48px; }
  #shots .btn, #btn-skip { min-height: 44px; }
}

@media (max-width: 620px) {
  #controls {
    width: min(94vw, 420px);
    flex-wrap: wrap;
    justify-content: center;
    bottom: 50px;
  }
  #shots { bottom: 150px; }
  #keys { display: none; } /* shortcuts are meaningless without a keyboard */
  #lockup { font-size: 10px; top: 14px; left: 14px; }
}

/* Landscape phones: very short viewports. Pull the chrome in tight and let the
   canvas keep the vertical room, since the subject is a tall portrait. */
@media (max-height: 480px) {
  #controls { bottom: 12px; padding: 6px 8px; gap: 6px; }
  .btn { min-height: 38px; padding: 9px 12px; font-size: 13px; }
  #shots { bottom: 68px; }
  #keys, #lockup { display: none; }
  #title-card { padding-bottom: 68px; }
  #title-card h2 { font-size: clamp(34px, 9vh, 64px); }
}

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