:root {
  color-scheme: dark;
  --bg: #070a0f;
  --panel: rgba(9, 13, 20, 0.78);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f7fafc;
  --muted: #9aa9b8;
  --accent: #ffd166;
  --cyan: #6ee7f9;
  --red: #ff4d68;
  --blue: #4f8cff;
  --green: #82f2aa;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% -20%, #1b2430 0, var(--bg) 46%, #020305 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
}

button {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 35%);
}

#gameCanvas {
  width: 100vw;
  height: 100vh;
  display: block;
  background: #080b10;
}

.hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
  pointer-events: none;
  z-index: 4;
}

.hud-left,
.hud-center,
.hud-right {
  min-width: 0;
}

.hud-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.score-label,
.nitro-wrap span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.score {
  font-size: clamp(24px, 5vw, 42px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 3px 20px rgba(0, 0, 0, 0.8);
}

.wanted {
  min-width: 152px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 21px;
  letter-spacing: 0.12em;
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.35);
}

.event-banner {
  min-height: 28px;
  margin-top: 4px;
  color: #fff;
  font-size: clamp(13px, 2.4vw, 17px);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.14em;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.88), 0 0 16px rgba(110, 231, 249, 0.28);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.event-banner.visible {
  opacity: 1;
  transform: translateY(0);
}

.condition {
  display: flex;
  gap: 5px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.condition span {
  width: 18px;
  height: 8px;
  border-radius: 2px;
  background: var(--green);
  box-shadow: 0 0 12px rgba(130, 242, 170, 0.35);
}

.condition span.low {
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 77, 104, 0.4);
}

.condition span.empty {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.nitro-wrap {
  width: min(26vw, 180px);
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.nitro-meter {
  height: 8px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.nitro-meter i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--accent));
  box-shadow: 0 0 18px rgba(110, 231, 249, 0.4);
}

.icon-button {
  min-width: 46px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.icon-button:focus-visible,
.primary-button:focus-visible,
.nitro-button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(4, 7, 11, 0.48), rgba(4, 7, 11, 0.84)),
    radial-gradient(circle at 50% 30%, rgba(77, 140, 255, 0.16), transparent 36%);
}

.hidden {
  display: none !important;
}

.title-lockup {
  transform: translateY(-2vh);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 950;
  letter-spacing: 0.02em;
  line-height: 0.9;
  text-shadow: 0 7px 30px rgba(0, 0, 0, 0.88);
}

h1 {
  font-size: clamp(68px, 15vw, 180px);
}

h2 {
  font-size: clamp(46px, 10vw, 108px);
}

.tagline {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(18px, 3.2vw, 30px);
  font-weight: 750;
}

.primary-button {
  min-width: 170px;
  height: 54px;
  margin-top: 28px;
  border: 0;
  border-radius: 8px;
  color: #061015;
  background: linear-gradient(135deg, #f8ff7a, #ffb347 56%, #ff6c55);
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 18px 42px rgba(255, 108, 85, 0.24), 0 8px 18px rgba(0, 0, 0, 0.35);
}

.controls,
.restart-hint {
  display: flex;
  gap: 16px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nitro-button {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 4;
  width: 88px;
  height: 88px;
  border: 1px solid rgba(110, 231, 249, 0.55);
  border-radius: 50%;
  color: #061015;
  background: radial-gradient(circle at 32% 24%, #ffffff, var(--cyan) 42%, #2f7cff 100%);
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0.08em;
  box-shadow: 0 0 28px rgba(110, 231, 249, 0.28), 0 16px 34px rgba(0, 0, 0, 0.36);
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px) scale(0.92);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.nitro-button.ready {
  opacity: 0.9;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.best-badge {
  min-height: 24px;
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 950;
  letter-spacing: 0.14em;
}

.final-score {
  margin-top: 12px;
  font-size: clamp(44px, 10vw, 96px);
  font-weight: 950;
  line-height: 1;
}

.stats {
  width: min(480px, 92vw);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
}

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.72);
}

.stat b {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat span {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 900;
}

@media (max-width: 720px) {
  .hud {
    grid-template-columns: 1fr 1fr;
  }

  .hud-center {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .hud-right {
    gap: 6px;
  }

  .nitro-wrap {
    width: 118px;
  }

  .icon-button {
    min-width: 42px;
  }

  .controls {
    flex-direction: column;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .event-banner,
  .nitro-button {
    transition: none;
  }
}
