:root {
  color-scheme: dark;
  --ink: #05070c;
  --cream: #ece0c6;
  --cream-dim: #c9bda5;
  --gold: #e8b45a;
  --line: rgba(232, 180, 90, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--cream);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#surface {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #020306;
  outline: none;
  touch-action: none;
}

/* ---------------------------------------------------------------- boot */
.boot {
  position: fixed;
  inset: 0;
  z-index: 10;
  opacity: 1;
  transition: opacity 900ms ease;
  overflow: hidden;
}
body.playing .boot {
  opacity: 0;
  pointer-events: none;
}
body.playing #surface { cursor: crosshair; }

.boot-scrim {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(90deg, rgba(3,5,9,0.97) 0%, rgba(3,5,9,0.88) 38%, rgba(3,5,9,0.35) 72%, rgba(3,5,9,0.55) 100%),
    linear-gradient(0deg, rgba(3,5,9,0.95) 0%, rgba(3,5,9,0.1) 45%, rgba(3,5,9,0.25) 100%),
    url("./assets/hero.jpg");
  background-size: cover;
  background-position: center 58%;
  transform: scale(1.04);
  animation: drift 28s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to   { transform: scale(1.10) translate3d(-1.2%, -1.4%, 0); }
}

/* film grain */
.boot-scrim::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.35'/></svg>");
  opacity: 0.10;
  mix-blend-mode: overlay;
}

.boot-content {
  position: relative;
  height: 100%;
  padding-bottom: calc(clamp(22px, 4vw, 56px) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(22px, 4vw, 56px) clamp(22px, 6vw, 96px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(236, 224, 198, 0.12);
  padding-bottom: 14px;
}
.boot-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(232, 180, 90, 0.35), 0 6px 24px rgba(0, 0, 0, 0.6);
  flex: 0 0 auto;
}
.brand-mark {
  font-family: "Iowan Old Style", Palatino, "Times New Roman", serif;
  font-size: 15px;
  letter-spacing: 0.10em;
  color: var(--gold);
}
.brand-line {
  font-size: 10px;
  letter-spacing: 0.34em;
  color: var(--cream-dim);
}

.intro {
  max-width: 660px;
  padding-bottom: 4vh;
}
.eyebrow {
  margin: 0 0 18px;
  font-size: 10px;
  letter-spacing: 0.42em;
  color: var(--gold);
}
h1 {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(58px, 10.5vw, 150px);
  line-height: 0.82;
  letter-spacing: 0.005em;
  text-wrap: balance;
}
h1 em {
  font-style: italic;
  color: var(--gold);
}
.lede {
  margin: 26px 0 0;
  max-width: 46ch;
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.65;
  color: var(--cream-dim);
}

.enter-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 34px;
  flex-wrap: wrap;
}
#enter {
  appearance: none;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--cream);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 15px 26px;
  cursor: pointer;
  transition: background 240ms ease, color 240ms ease, transform 240ms ease;
}
#enter:hover:not(:disabled) {
  background: var(--gold);
  color: #120c06;
  transform: translateY(-1px);
}
#enter:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.enter-note {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(201, 189, 165, 0.65);
}

.support {
  margin: 16px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(201, 189, 165, 0.55);
}
.support.bad { color: #e98b74; }

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 28px;
  margin: 30px 0 0;
  max-width: 520px;
  border-top: 1px solid rgba(236, 224, 198, 0.10);
  padding-top: 18px;
}
.controls div { display: flex; gap: 12px; align-items: baseline; }
.controls dt {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--gold);
  min-width: 84px;
}
.controls dd {
  margin: 0;
  font-size: 12px;
  color: var(--cream-dim);
}

.foot {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(201, 189, 165, 0.42);
  border-top: 1px solid rgba(236, 224, 198, 0.08);
  padding-top: 14px;
}
.dot { color: var(--line); }
.install {
  margin-left: auto;
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream-dim);
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 7px 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: color 200ms ease, border-color 200ms ease;
}
.install:hover { color: var(--cream); border-color: var(--gold); }
.install[hidden] { display: none; }

/* ------------------------------------------------------------- loading */
.loading {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  background: rgba(3, 5, 9, 0.55);
  backdrop-filter: blur(2px);
  transition: opacity 500ms ease;
}
.loading[hidden] { display: none; }
.loading-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--cream-dim);
}
.spark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px 4px rgba(232, 180, 90, 0.55);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.fatal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #05070c;
}
.fatal div {
  max-width: 560px;
  border: 1px solid rgba(233, 139, 116, 0.45);
  padding: 28px;
  line-height: 1.6;
  color: var(--cream-dim);
}
.fatal strong { color: var(--cream); display: block; margin-bottom: 8px; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #05070c;
  color: var(--cream);
  z-index: 30;
}

@media (max-width: 720px) {
  .boot-scrim {
    background-image:
      linear-gradient(0deg, rgba(3,5,9,0.96) 0%, rgba(3,5,9,0.65) 55%, rgba(3,5,9,0.35) 100%),
      url("./assets/hero.jpg");
  }
  .controls { grid-template-columns: 1fr; }
  .foot { display: none; }
}

/* ---------------------------------------------------------------- HUD */
.hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1200ms ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  text-transform: uppercase;
}
body.ready .hud { opacity: 1; }

.hud-top {
  position: absolute;
  left: clamp(18px, 2.2vw, 40px);
  top: clamp(16px, 2.2vw, 36px);
  max-width: min(560px, 60vw);
}
.hud-phase {
  margin: 0;
  font-size: clamp(13px, 1.25vw, 17px);
  letter-spacing: 0.20em;
  color: var(--cream);
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.75);
}
.hud-hint {
  margin: 7px 0 0;
  font-size: clamp(9px, 0.82vw, 11px);
  letter-spacing: 0.16em;
  color: rgba(201, 189, 165, 0.78);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8);
}
.hud-cam {
  position: absolute;
  right: clamp(18px, 2.2vw, 40px);
  top: clamp(18px, 2.3vw, 38px);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: rgba(201, 189, 165, 0.45);
}

.hud-prompt {
  position: absolute;
  left: 50%;
  bottom: 20%;
  transform: translateX(-50%);
  padding: 14px 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid rgba(232, 180, 90, 0.18);
  background: rgba(4, 6, 10, 0.55);
  backdrop-filter: blur(4px);
  font-size: clamp(11px, 1.05vw, 14px);
  letter-spacing: 0.22em;
  color: var(--cream);
  white-space: nowrap;
}
.hud-prompt[hidden] { display: none; }

.hud-meter {
  position: absolute;
  left: clamp(18px, 2.2vw, 40px);
  bottom: clamp(34px, 4.2vw, 62px);
  width: min(280px, 42vw);
}
.meter-label {
  font-size: 9px;
  letter-spacing: 0.24em;
  color: rgba(201, 189, 165, 0.7);
}
.meter-track {
  margin-top: 6px;
  height: 3px;
  width: 100%;
  background: rgba(236, 224, 198, 0.14);
}
.meter-track i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 120ms linear;
}
.hud-meter.overspeed .meter-track i { background: #e0603a; }
.hud-stats, .hud-score {
  margin: 7px 0 0;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: rgba(201, 189, 165, 0.72);
}
.hud-score { color: rgba(236, 224, 198, 0.82); }
.hud-meter[hidden] { display: none; }

.hud-controls {
  position: absolute;
  left: 50%;
  bottom: calc(clamp(12px, 1.4vw, 20px) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  margin: 0;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: rgba(201, 189, 165, 0.45);
  white-space: nowrap;
  transition: opacity 600ms ease;
}
@media (max-width: 760px) {
  .hud-controls { display: none; }
  .hud-prompt { white-space: normal; text-align: center; width: 80vw; }
  .hud-meter { width: 52vw; }
}

/* Installed app: no browser chrome, so keep the HUD off the notch. */
@media (display-mode: standalone) {
  .hud-top { top: calc(clamp(16px, 2.2vw, 36px) + env(safe-area-inset-top, 0px)); }
  .boot-content { padding-top: calc(clamp(22px, 4vw, 56px) + env(safe-area-inset-top, 0px)); }
}
