﻿:root {
  color-scheme: dark;
  --bg: #02050b;
  --bg-deep: #06101b;
  --panel: rgba(7, 11, 18, 0.82);
  --panel-strong: rgba(8, 13, 22, 0.94);
  --line: rgba(151, 174, 205, 0.16);
  --line-strong: rgba(151, 174, 205, 0.28);
  --text: #edf4ff;
  --muted: #8e9eb6;
  --accent: #9ec7ff;
  --accent-strong: #7ae2ff;
  --accent-soft: rgba(158, 199, 255, 0.18);
  --enemy: #ff6b7a;
  --warn: #ffcf7a;
  --good: #7ae2ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: "Bahnschrift", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0%, rgba(122, 226, 255, 0.08), transparent 24%),
    radial-gradient(circle at 20% 18%, rgba(158, 199, 255, 0.12), transparent 22%),
    radial-gradient(circle at 80% 16%, rgba(122, 226, 255, 0.06), transparent 18%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 54%, #010205 100%);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(circle at 24px 30px, rgba(255, 255, 255, 0.95) 0 1px, transparent 1.7px),
    radial-gradient(circle at 140px 88px, rgba(255, 255, 255, 0.78) 0 1px, transparent 1.7px),
    radial-gradient(circle at 74% 18%, rgba(122, 226, 255, 0.82) 0 1px, transparent 1.8px),
    radial-gradient(circle at 82% 68%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1.8px),
    radial-gradient(circle at 46% 76%, rgba(158, 199, 255, 0.8) 0 1px, transparent 1.8px);
  background-size: 260px 260px, 320px 320px, 420px 420px, 520px 520px, 620px 620px;
  mix-blend-mode: screen;
  opacity: 0.36;
  animation: skyDrift 180s linear infinite;
}

body::after {
  background:
    radial-gradient(circle at 50% 50%, transparent 50%, rgba(0, 0, 0, 0.48) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.02));
}

button {
  appearance: none;
  border: 0;
  font: inherit;
  color: inherit;
}

.app {
  position: relative;
  width: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 28px);
}

.app::before {
  content: "";
  position: absolute;
  inset: 8% 14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(122, 226, 255, 0.08), transparent 70%);
  filter: blur(40px);
  pointer-events: none;
}

.stage {
  position: relative;
  z-index: 1;
  width: min(1260px, 100%);
  min-height: calc(100svh - 28px);
  display: grid;
  align-content: center;
  gap: 12px;
}

.hud,
.panel {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
}

.hud {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(9, 14, 23, 0.92), rgba(5, 8, 14, 0.82));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
}

.hud > * {
  min-width: 0;
}

.pill,
.stat {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 4px;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 23, 36, 0.78), rgba(8, 12, 20, 0.72));
}

.pill::after,
.stat::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.06) 50%, transparent 80%);
  transform: translateX(-120%);
  opacity: 0;
}

.pill:hover::after,
.stat:hover::after {
  animation: sheen 640ms ease;
}

.pill span,
.stat span,
.speed-meter .label span,
.overlay-pill span {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.pill strong,
.stat strong,
.speed-meter .label strong,
.overlay-pill strong {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-pill {
  min-width: 190px;
}

.brand-pill strong {
  letter-spacing: 0.22em;
}

.glow {
  box-shadow: 0 0 0 1px rgba(122, 226, 255, 0.14), inset 0 0 24px rgba(122, 226, 255, 0.06);
}

.controls-pill {
  justify-self: stretch;
  align-self: stretch;
  min-height: 100%;
}

.controls-pill strong {
  color: #dce9ff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stat:nth-child(1) strong {
  color: #dce9ff;
}

.stat:nth-child(3) strong {
  color: #ffd7a1;
}

.stat:nth-child(5) strong {
  color: #a7f0ff;
}

.speed-meter {
  width: min(260px, 100%);
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 14, 23, 0.92), rgba(5, 8, 15, 0.8));
}

.system-stack {
  align-content: start;
}

.meter-block {
  display: grid;
  gap: 8px;
}

.speed-meter .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.track {
  position: relative;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(151, 174, 205, 0.14);
  background: rgba(10, 13, 20, 0.9);
}

.track::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.12) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: trackScan 3s linear infinite;
  opacity: 0.35;
}

.speed-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7ae2ff 0%, #9ec7ff 60%, #ffffff 100%);
  box-shadow: 0 0 20px rgba(122, 226, 255, 0.18);
  transition: width 140ms linear, opacity 160ms ease, filter 160ms ease;
}

.speed-fill.warn {
  background: linear-gradient(90deg, #ffcf7a 0%, #ff9d6b 56%, #ff6b7a 100%);
  box-shadow: 0 0 20px rgba(255, 159, 110, 0.22);
}

.speed-fill.cooldown {
  background: linear-gradient(90deg, #7affda 0%, #7ae2ff 58%, #ffffff 100%);
  box-shadow: 0 0 20px rgba(122, 255, 218, 0.18);
}

.speed-fill.danger {
  filter: saturate(1.15) brightness(1.05);
}

.panel {
  position: relative;
  display: grid;
  gap: 12px;
  padding: clamp(10px, 1.6vw, 16px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(8, 13, 21, 0.78), rgba(4, 6, 11, 0.96)),
    rgba(4, 6, 12, 0.92);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}

.panel::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 32px, 32px 100%;
  opacity: 0.06;
}

.panel::after {
  background:
    radial-gradient(circle at top left, rgba(158, 199, 255, 0.08), transparent 20%),
    radial-gradient(circle at bottom right, rgba(122, 226, 255, 0.06), transparent 22%);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: clamp(380px, 62vh, 760px);
  min-height: 360px;
  border-radius: calc(var(--radius-xl) - 8px);
  border: 1px solid rgba(151, 174, 205, 0.14);
  background: radial-gradient(circle at 50% 30%, rgba(122, 226, 255, 0.03), transparent 40%), #03060d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), inset 0 0 36px rgba(122, 226, 255, 0.04);
  touch-action: none;
}

.panel-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 4px;
}

.hint,
.subtle {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.shortcut-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.shortcut {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(122, 226, 255, 0.12);
  background: rgba(6, 9, 16, 0.78);
  color: #c8d6ea;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 40px);
  background: radial-gradient(circle at center, rgba(2, 5, 11, 0.12), rgba(2, 5, 11, 0.8));
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transform: scale(1.015);
  transition: opacity 220ms ease, visibility 220ms ease, transform 220ms ease;
}

.overlay.show,
.overlay.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.card {
  width: min(100%, 560px);
  padding: clamp(24px, 4vw, 34px);
  border-radius: 30px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9, 13, 21, 0.96), rgba(4, 6, 12, 0.94));
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  text-align: center;
}

.card h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.card p {
  margin: 14px 0 0;
}

.overlay-metrics {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.overlay-pill {
  padding: 14px 12px;
  border-radius: 18px;
  border: 1px solid rgba(151, 174, 205, 0.14);
  background: rgba(6, 9, 15, 0.8);
  text-align: left;
}

.overlay-pill strong {
  display: block;
  margin-top: 8px;
}

.actions {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

button.primary,
button.secondary {
  min-height: 50px;
  padding: 12px 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

button.primary {
  color: #f7fbff;
  background: linear-gradient(180deg, rgba(122, 226, 255, 0.22), rgba(158, 199, 255, 0.14));
  box-shadow: 0 0 0 1px rgba(122, 226, 255, 0.16), 0 10px 32px rgba(122, 226, 255, 0.1);
}

button.secondary {
  background: rgba(5, 8, 14, 0.86);
}

button:hover,
button:focus-visible {
  outline: none;
  transform: translateY(-2px);
}

button.primary:hover,
button.primary:focus-visible {
  box-shadow: 0 0 0 1px rgba(122, 226, 255, 0.24), 0 16px 36px rgba(122, 226, 255, 0.14);
}

button.secondary:hover,
button.secondary:focus-visible {
  border-color: var(--line-strong);
}

.start-screen .card {
  border-color: rgba(122, 226, 255, 0.16);
}

.pause-screen .card {
  border-color: rgba(151, 174, 205, 0.16);
}

.gameover-screen .card {
  border-color: rgba(255, 107, 122, 0.2);
}

.win-screen .card {
  border-color: rgba(122, 226, 255, 0.22);
}

.overlay.show .card {
  animation: hoverCard 6s ease-in-out infinite;
}

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

  .controls-pill,
  .speed-meter {
    justify-self: stretch;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app {
    padding: 10px;
  }

  .stage {
    min-height: calc(100svh - 20px);
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .shortcut-list {
    justify-content: flex-start;
  }

  .overlay-metrics {
    grid-template-columns: 1fr;
  }

  #gameCanvas {
    height: clamp(360px, 56svh, 640px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@keyframes skyDrift {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(-120px, 0, 0);
  }
}

@keyframes trackScan {
  to {
    transform: translateX(100%);
  }
}

@keyframes sheen {
  from {
    transform: translateX(-120%);
    opacity: 0;
  }

  40% {
    opacity: 0.7;
  }

  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

@keyframes hoverCard {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}
