/* Burn Rate — UI chrome. The game itself is drawn on <canvas>; this styles the
   overlays, HUD and the rotate prompt, and locks down mobile gestures. */

:root {
  /* Compute-burn datacenter palette. (Names kept stable from the original
     theme to avoid churn; values remapped: "magenta" -> cyan circuit accent,
     "ember" -> money-green token.) */
  --indigo: #05070f;
  --violet: #0a1320;
  --magenta: #5be8ff; /* cyan circuit accent */
  --magenta-soft: #8af0ff;
  --ember: #5dff8a; /* money-green token */
  --ember-hot: #ff8a46; /* thermal burn */
  --hazard: #ff2d4f; /* shutdown red */
  --ink: #04070e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* Kill text selection + the iOS tap highlight; gestures are gameplay. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  /* Disable double-tap-to-zoom and pull gestures. */
  touch-action: none;
  overscroll-behavior: none;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #fff;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
  transition: filter 0.3s ease;
}
/* Glare mode: lift the dark datacenter scene for direct-sun readability. The
   new palette is much darker than the old dusk look, so a gentler boost keeps
   the neon/glow legible outdoors without washing out the scanlines. */
body.daylight #game {
  filter: brightness(1.35) contrast(1.06) saturate(1.1);
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 16px);
  right: calc(var(--safe-right) + 16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
  pointer-events: none;
}
.hud-left { display: flex; gap: 18px; align-items: center; }
.hud-right { display: flex; gap: 10px; align-items: center; pointer-events: none; }
.hud-stat {
  font-size: clamp(16px, 3.4vh, 26px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(91, 232, 255, 0.6);
}
.hud-stat.ember { color: var(--ember); text-shadow: 0 0 14px rgba(93, 255, 138, 0.85); }

/* Runway burn meter. */
.burn-meter {
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}
.burn-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.burn-label {
  font-size: clamp(8px, 1.5vh, 11px);
  letter-spacing: 0.22em;
  font-weight: 700;
  color: #8af0ff;
  opacity: 0.8;
}
/* Live tokens-per-wage exchange rate. Money-green normally; warms to thermal
   amber ("lean") as it slides toward the floor at high speed. */
.burn-rate {
  font-size: clamp(8px, 1.5vh, 11px);
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ember);
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}
.burn-rate.lean { color: var(--ember-hot); opacity: 1; }
.burn-meter.critical .burn-rate { color: var(--hazard); }
.burn-track {
  width: clamp(90px, 22vw, 200px);
  height: clamp(7px, 1.4vh, 11px);
  border-radius: 999px;
  background: rgba(8, 20, 28, 0.7);
  border: 1px solid rgba(91, 232, 255, 0.4);
  overflow: hidden;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}
.burn-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ember-hot), var(--ember));
  box-shadow: 0 0 10px rgba(93, 255, 138, 0.7);
  transition: width 0.12s linear, background 0.3s ease;
}
/* When the runway is critical the whole meter goes hazard-red and pulses. */
.burn-meter.critical .burn-fill {
  background: linear-gradient(90deg, #ff6a3c, var(--hazard));
  box-shadow: 0 0 12px rgba(255, 45, 79, 0.9);
}
.burn-meter.critical .burn-label { color: var(--hazard); opacity: 1; }
.burn-meter.critical { animation: burn-pulse 0.6s ease-in-out infinite; }
@keyframes burn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.icon-btn {
  pointer-events: auto;
  width: clamp(40px, 7vh, 52px);
  height: clamp(40px, 7vh, 52px);
  border-radius: 50%;
  border: 1.5px solid rgba(91, 232, 255, 0.5);
  background: rgba(20, 8, 36, 0.55);
  color: var(--magenta-soft);
  font-size: clamp(18px, 3.4vh, 24px);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease, opacity 0.2s ease, color 0.2s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.muted { color: #6a5878; border-color: rgba(120, 100, 140, 0.5); }
/* Daylight button glows amber when active. */
#daylight.active {
  color: var(--ember);
  border-color: rgba(255, 200, 120, 0.8);
  box-shadow: 0 0 14px rgba(255, 190, 110, 0.6);
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, var(--safe-top)) max(20px, var(--safe-right))
           max(20px, var(--safe-bottom)) max(20px, var(--safe-left));
  background:
    radial-gradient(120% 120% at 50% 90%, rgba(91, 232, 255, 0.22), transparent 60%),
    linear-gradient(180deg, rgba(4, 8, 14, 0.82), rgba(4, 8, 14, 0.94));
  backdrop-filter: blur(3px);
  text-align: center;
  animation: fade-in 0.4s ease both;
}
.overlay.hidden { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.panel {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.title {
  font-size: clamp(40px, 12vh, 88px);
  font-weight: 800;
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, #fff 0%, var(--ember) 40%, var(--magenta) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 24px rgba(91, 232, 255, 0.55));
}
.title-sm {
  font-size: clamp(22px, 6vh, 40px);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 0 22px rgba(91, 232, 255, 0.6);
}
.tagline {
  font-size: clamp(14px, 3vh, 20px);
  line-height: 1.5;
  color: #bfe9f5;
  opacity: 0.92;
}
.hint {
  font-size: clamp(12px, 2.4vh, 17px);
  color: #9fc7d6;
  line-height: 1.7;
}
.hint.subtle { opacity: 0.55; font-size: clamp(11px, 2vh, 14px); }
.kbd-hint { opacity: 0.6; font-size: 0.85em; }

/* First-launch controls card: one row per core move. */
.controls {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.controls li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px; /* comfortable tap/scan target */
}
.ctrl-key {
  flex: none;
  min-width: 84px;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #04121a;
  background: linear-gradient(180deg, var(--magenta-soft), var(--magenta));
  box-shadow: 0 0 14px rgba(91, 232, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  text-align: center;
}
.ctrl-alt {
  flex: none;
  opacity: 0.6;
  font-size: 0.85em;
  color: #9fc7d6;
}
.ctrl-desc {
  flex: 1;
  min-width: 0;
  text-align: left;
  color: #9fc7d6;
  font-size: clamp(12px, 2.4vh, 17px);
  line-height: 1.4;
}
/* On very short landscape viewports the desktop legend crowds the row — drop it. */
@media (max-height: 380px) {
  .ctrl-alt { display: none; }
}

.cta {
  margin-top: 6px;
  padding: 14px 34px;
  font-size: clamp(15px, 3vh, 20px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--magenta-soft), var(--magenta));
  box-shadow: 0 0 30px rgba(91, 232, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.cta:active { transform: scale(0.95); box-shadow: 0 0 18px rgba(91, 232, 255, 0.4); }

/* ---------- Game-over results ---------- */
.results {
  display: flex;
  gap: clamp(18px, 5vw, 44px);
  margin: 10px 0 4px;
}
.result { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.result-val {
  font-size: clamp(26px, 7vh, 48px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 16px rgba(91, 232, 255, 0.5);
}
.result-val.ember { color: var(--ember); text-shadow: 0 0 16px rgba(93, 255, 138, 0.7); }
.result-val.best { color: var(--magenta-soft); }
.result-label {
  font-size: clamp(10px, 2vh, 13px);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #7fa6b8;
}

/* ---------- Game-over burn ledger ("inference invoice") ---------- */
/* Monospace, terminal-receipt aesthetic — no font assets, just a system mono
   stack. Epitaph reads as a dev signal (SIGSEGV / SIGKILL). */
.epitaph {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(11px, 2.2vh, 15px);
  letter-spacing: 0.04em;
  color: var(--ember-hot); /* thermal amber for a fault */
  opacity: 0.92;
  margin-top: -4px;
}
.epitaph.shutdown { color: var(--hazard); } /* hazard red for an OOM kill */
.invoice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.invoice-rule {
  font-size: clamp(8px, 1.6vh, 11px);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #5be8ff;
  opacity: 0.7;
}
.invoice-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  font-size: clamp(12px, 2.4vh, 16px);
  color: #9fc7d6;
  font-variant-numeric: tabular-nums;
}
.invoice-line span { white-space: nowrap; }
.invoice-line i { font-style: normal; opacity: 0.6; letter-spacing: 0.06em; }
.invoice-line b { color: #fff; font-weight: 700; }
/* Thin separators between the three stats. */
.invoice-line span:not(:first-child)::before {
  content: "·";
  margin-right: 14px;
  color: #5be8ff;
  opacity: 0.5;
}

/* ---------- Rotate prompt ---------- */
.rotate-icon {
  font-size: clamp(48px, 14vh, 96px);
  color: var(--magenta-soft);
  filter: drop-shadow(0 0 20px rgba(91, 232, 255, 0.6));
  animation: rock 2.2s ease-in-out infinite;
}
@keyframes rock {
  0%, 100% { transform: rotate(-18deg); }
  50% { transform: rotate(72deg); }
}
