@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Noto+Sans+SC:wght@300;400;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: #0a0a0f;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Sans SC', sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  image-rendering: auto;
}

#overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

#title-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: linear-gradient(180deg, #0d1117 0%, #1a1a2e 40%, #2d1b4e 70%, #e94560 95%, #f5a623 100%);
  transition: opacity 0.3s ease;
}

#title-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

#title-screen:not(.hidden) {
  transition: opacity 0.3s ease;
}

.title-main {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(233, 69, 96, 0.6), 0 0 80px rgba(233, 69, 96, 0.3);
  letter-spacing: 0.15em;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

.title-sub {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.8rem);
  font-weight: 300;
  color: rgba(255,255,255,0.6);
  margin-top: 0.5rem;
  letter-spacing: 0.5em;
}

.title-road {
  width: 2px;
  height: 80px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.4), transparent);
  margin: 2rem 0;
  position: relative;
}

.title-road::before, .title-road::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.6);
}

.title-road::before { top: 5px; }
.title-road::after { bottom: 5px; }

.start-btn {
  margin-top: 1rem;
  padding: 0.8rem 3rem;
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  cursor: pointer;
  pointer-events: all;
  transition: all 0.3s ease;
  text-transform: uppercase;
}

.start-btn:hover {
  background: rgba(233,69,96,0.2);
  border-color: #e94560;
  box-shadow: 0 0 30px rgba(233,69,96,0.3);
  transform: scale(1.05);
}

.best-distance {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.35);
  font-weight: 300;
  letter-spacing: 0.1em;
}

.controls-hint {
  position: absolute;
  bottom: 2rem;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.1em;
}

#pause-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 25;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(8px);
}

#pause-screen.active {
  display: flex;
}

.pause-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 2rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.3em;
  margin-bottom: 2rem;
}

.pause-btn {
  padding: 0.6rem 2rem;
  margin: 0.5rem;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.7);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: all 0.3s ease;
}

.pause-btn:hover {
  border-color: rgba(255,255,255,0.6);
  color: #fff;
}

#gameover-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 25;
  background: rgba(10,10,15,0.9);
  backdrop-filter: blur(12px);
}

#gameover-screen.active {
  display: flex;
}

.gameover-title {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 300;
  color: rgba(255,255,255,0.8);
  margin-bottom: 0.5rem;
  letter-spacing: 0.2em;
}

.gameover-message {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.35);
  margin-bottom: 2.5rem;
  font-weight: 300;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  width: 280px;
  margin: 0.4rem 0;
  font-size: 0.9rem;
}

.stat-label {
  color: rgba(255,255,255,0.4);
  font-weight: 300;
}

.stat-value {
  font-family: 'Orbitron', sans-serif;
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;
}

.gameover-btns {
  margin-top: 2.5rem;
  display: flex;
  gap: 1rem;
}

@keyframes titleGlow {
  0% { text-shadow: 0 0 40px rgba(233,69,96,0.4), 0 0 80px rgba(233,69,96,0.2); }
  100% { text-shadow: 0 0 60px rgba(233,69,96,0.7), 0 0 120px rgba(233,69,96,0.4); }
}
