:root {
  --bg: #05080f;
  --text: #f3f7ff;
  --muted: #afbbd1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 30% 20%, #122038, var(--bg) 60%);
  color: var(--text);
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.viewport-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 18;
}

.viewport-label {
  position: fixed;
  padding: 0.34rem 0.6rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  background: rgba(0, 0, 0, 0.45);
}

.dash-flash {
  position: fixed;
  pointer-events: none;
  opacity: 0;
  border-radius: 10px;
  background:
    repeating-linear-gradient(
      -18deg,
      rgba(255, 255, 255, 0.0) 0px,
      rgba(255, 255, 255, 0.0) 9px,
      rgba(255, 255, 255, 0.38) 10px,
      rgba(255, 255, 255, 0.0) 14px
    ),
    linear-gradient(110deg, rgba(130, 210, 255, 0.0), rgba(130, 210, 255, 0.35), rgba(130, 210, 255, 0.0));
  mix-blend-mode: screen;
}

.dash-cooldown {
  position: fixed;
  width: 32px;
  height: 32px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 80ms linear;
  border-radius: 50%;
  --cooldown-half-angle: 0deg;
  --cooldown-color: rgba(160, 226, 255, 0.95);
  background: conic-gradient(
    from 180deg,
    var(--cooldown-color) 0deg var(--cooldown-half-angle),
    rgba(160, 226, 255, 0.12) var(--cooldown-half-angle) calc(360deg - var(--cooldown-half-angle)),
    var(--cooldown-color) calc(360deg - var(--cooldown-half-angle)) 360deg
  );
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(2, 8, 18, 0.48);
  backdrop-filter: blur(1px);
  transition: opacity 200ms ease;
  padding: 1rem;
  z-index: 12;
}

.menu-progress {
  position: absolute;
  top: 0.85rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.28rem 0.55rem;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  white-space: nowrap;
}

.menu-progress .dots {
  display: inline-flex;
  gap: 0.08em;
  margin-left: 0.08em;
}

.menu-progress .dot {
  display: inline-block;
  transform: translateY(0);
  animation: menu-dot-bob 0.9s ease-in-out infinite;
}

.menu-progress .dot:nth-child(2) {
  animation-delay: 0.12s;
}

.menu-progress .dot:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes menu-dot-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(0.22em);
  }
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 4.4rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#subtitle {
  margin: 0.7rem 0 0;
  font-size: clamp(1rem, 2vw, 1.4rem);
  color: var(--text);
}

.hint {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: pre-line;
  line-height: 1.4;
}

.mobile-controls {
  position: relative;
  margin-top: 1rem;
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  max-width: min(92vw, 680px);
  min-height: 5.8rem;
  padding: 1.8rem 0.2rem 1.9rem;
}

.mobile-btn {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.45);
  color: #f3f7ff;
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  min-width: 3.2rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mobile-btn:active {
  transform: scale(0.98);
  background: rgba(110, 180, 255, 0.3);
}

.mobile-btn-back {
  position: absolute;
  top: -0.35rem;
  left: -0.55rem;
}

.mobile-btn-saved {
  position: absolute;
  left: 50%;
  bottom: -0.35rem;
  transform: translateX(-50%);
  min-width: 16.8rem;
}

.mobile-btn-advance {
  font-size: 1.02rem;
  font-weight: 700;
  min-width: 12rem;
  padding: 0.68rem 1.1rem;
}

.menu-control-preview {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

.mobile-steering {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  gap: 0.55rem;
  padding: 0.6rem;
  pointer-events: none;
  z-index: 12;
}

.mobile-steering.two-player {
  grid-template-columns: 1fr 1fr;
}

.mobile-steer-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  pointer-events: auto;
}

.mobile-steer-btn {
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(0, 0, 0, 0.44);
  color: #f3f7ff;
  border-radius: 12px;
  min-height: 74px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.mobile-steering.two-player .mobile-steer-btn {
  min-height: 54px;
  font-size: 0.86rem;
}

.mobile-steer-btn:active {
  background: rgba(110, 180, 255, 0.32);
}
