/* STARWAKE — the instrument panel of a dying ship.
   Ink black, hairline ember-gold rules, letterspaced smallcaps. */

:root {
  --ink: #05060a;
  --ember: #ffb45e;
  --ember-hot: #ffd9a0;
  --ember-dim: rgba(255, 180, 110, 0.45);
  --hairline: rgba(255, 200, 140, 0.16);
  --bone: #e8e4da;
  --mist: rgba(216, 222, 240, 0.55);
  --display: 'Unbounded', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: var(--mono);
  color: var(--bone);
  -webkit-font-smoothing: antialiased;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ---------- film grain (static, zero per-frame cost) ---------- */
#grain {
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
  z-index: 40;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: clamp(14px, 3vh, 30px);
  left: 0; right: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2.2em;
  pointer-events: none;
  z-index: 10;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.9);
}

#hud-dist {
  font-size: clamp(26px, 4.4vh, 40px);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--ember-hot);
  font-variant-numeric: tabular-nums;
}

#hud .unit {
  font-size: 0.42em;
  letter-spacing: 0.3em;
  color: var(--ember-dim);
  margin-left: 0.5em;
}

#hud-stars {
  font-size: clamp(14px, 2vh, 18px);
  letter-spacing: 0.18em;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}

#hud-combo {
  position: absolute;
  top: 110%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ember);
  opacity: 0;
  transition: opacity 0.25s;
}
#hud-combo.on { opacity: 0.9; }

/* ---------- zone banner ---------- */
#zone-banner {
  position: fixed;
  top: 22vh;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(13px, 2.2vh, 20px);
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.8);
}
#zone-banner.show { animation: zone-in 3.2s ease forwards; }
@keyframes zone-in {
  0% { opacity: 0; transform: translateY(10px); }
  18% { opacity: 0.95; transform: translateY(0); }
  75% { opacity: 0.95; }
  100% { opacity: 0; }
}

/* ---------- hint ---------- */
#hint {
  position: fixed;
  bottom: 18vh;
  left: 0; right: 0;
  text-align: center;
  font-size: clamp(13px, 1.8vh, 17px);
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  text-transform: uppercase;
  color: var(--ember-hot);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  z-index: 10;
  animation: hint-pulse 1.6s ease-in-out infinite;
}
#hint.show { opacity: 0.9; }
@keyframes hint-pulse {
  0%, 100% { text-shadow: 0 0 6px rgba(255, 180, 110, 0.2); }
  50% { text-shadow: 0 0 22px rgba(255, 180, 110, 0.75); }
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
  background: radial-gradient(ellipse at 50% 60%, rgba(5, 6, 10, 0.25) 0%, rgba(5, 6, 10, 0.78) 100%);
  -webkit-user-select: none;
  user-select: none;
}

.title-block, .death-block, .pause-block {
  text-align: center;
  padding: 32px clamp(18px, 5vw, 64px);
  max-width: 680px;
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ember-dim);
  margin-bottom: 1.6em;
  animation: rise 0.9s ease both;
}

h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(44px, 9vw, 96px);
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: var(--ember-hot);
  text-shadow:
    0 0 28px rgba(255, 170, 80, 0.35),
    0 0 90px rgba(255, 140, 40, 0.18);
  animation: rise 0.9s 0.08s ease both, breathe 5s 1s ease-in-out infinite;
}
h1 span { font-weight: 300; color: var(--bone); }

@keyframes breathe {
  0%, 100% { text-shadow: 0 0 28px rgba(255, 170, 80, 0.35), 0 0 90px rgba(255, 140, 40, 0.18); }
  50% { text-shadow: 0 0 40px rgba(255, 170, 80, 0.55), 0 0 120px rgba(255, 140, 40, 0.3); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.lore {
  margin: 2.2em 0 2.6em;
  font-size: clamp(13px, 1.9vh, 16px);
  font-weight: 300;
  line-height: 2;
  color: var(--mist);
  animation: rise 0.9s 0.18s ease both;
}
.lore b { color: var(--ember-hot); font-weight: 500; }

.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  animation: rise 0.9s 0.28s ease both;
}
.menu.row { flex-direction: row; justify-content: center; flex-wrap: wrap; }

.btn {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--bone);
  background: rgba(8, 10, 16, 0.6);
  border: 1px solid var(--hairline);
  padding: 14px 30px;
  min-width: 300px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s, transform 0.12s;
}
.menu.row .btn { min-width: 150px; }

.btn small {
  display: block;
  margin-top: 5px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: none;
  color: var(--mist);
  opacity: 0.7;
}

.btn-key {
  position: absolute;
  top: -7px;
  left: 12px;
  font-size: 10px;
  padding: 0 6px;
  background: var(--ink);
  color: var(--ember-dim);
  letter-spacing: 0.1em;
}

.btn:hover, .btn:focus-visible {
  border-color: var(--ember);
  color: var(--ember-hot);
  box-shadow: 0 0 24px rgba(255, 160, 80, 0.2), inset 0 0 18px rgba(255, 160, 80, 0.06);
  outline: none;
}
.btn:active { transform: scale(0.97); }

.btn.primary {
  border-color: rgba(255, 180, 110, 0.55);
  color: var(--ember-hot);
}

.btn.ghost { border-color: transparent; opacity: 0.65; }
.btn.ghost:hover { opacity: 1; border-color: var(--hairline); }

.mod-line {
  margin-top: 16px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ember-dim);
  animation: rise 0.9s 0.3s ease both;
  min-height: 1.2em;
}

.settings-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
  animation: rise 0.9s 0.32s ease both;
}

.chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mist);
  background: rgba(8, 10, 16, 0.5);
  border: 1px solid rgba(216, 222, 240, 0.12);
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.chip:hover, .chip:focus-visible {
  border-color: var(--ember);
  color: var(--ember-hot);
  outline: none;
}

.best-line {
  margin-top: 2em;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--ember-dim);
  min-height: 1.2em;
  animation: rise 0.9s 0.36s ease both;
}

.keys-line {
  margin-top: 1.4em;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(216, 222, 240, 0.32);
  animation: rise 0.9s 0.44s ease both;
}

/* ---------- death screen ---------- */
#screen-death { background: radial-gradient(ellipse at 50% 55%, rgba(5, 6, 10, 0.15) 0%, rgba(3, 3, 6, 0.82) 100%); }

.death-dist {
  font-size: clamp(56px, 11vw, 110px);
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--ember-hot);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 36px rgba(255, 170, 80, 0.3);
  animation: rise 0.9s 0.1s ease both;
}
.death-dist .unit {
  font-size: 0.3em;
  letter-spacing: 0.3em;
  color: var(--ember-dim);
  margin-left: 0.4em;
}

.death-line {
  margin: 1.6em auto 0;
  max-width: 40ch;
  font-size: clamp(13px, 1.8vh, 15px);
  font-weight: 300;
  line-height: 1.9;
  color: var(--mist);
  animation: rise 0.9s 0.2s ease both;
}

.death-rank {
  margin-top: -1.4em;
  margin-bottom: 1.8em;
  color: var(--ember-hot) !important;
  min-height: 1.2em;
}

#death-map {
  display: block;
  margin: 18px auto 4px;
  animation: rise 0.9s 0.24s ease both;
}

.death-stats {
  margin-top: 1.6em;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(216, 222, 240, 0.45);
  animation: rise 0.9s 0.28s ease both;
}

.death-best {
  margin: 0.9em 0 2.2em;
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ember-dim);
  animation: rise 0.9s 0.34s ease both;
}
.death-best.new {
  color: var(--ember-hot);
  animation: rise 0.9s 0.34s ease both, hint-pulse 1.4s ease-in-out infinite;
}

/* ---------- pause ---------- */
h2 {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: var(--bone);
}

/* ---------- toast & fps ---------- */
#toast {
  position: fixed;
  bottom: 7vh;
  left: 50%;
  transform: translate(-50%, 16px);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ember-hot);
  background: rgba(8, 10, 16, 0.85);
  border: 1px solid var(--hairline);
  padding: 10px 22px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#fps {
  position: fixed;
  right: 12px;
  bottom: 10px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #69d98a;
  opacity: 0.75;
  pointer-events: none;
  z-index: 50;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .btn { min-width: 240px; padding: 13px 20px; }
  .keys-line { display: none; }
  #hud { gap: 1.2em; }
}
