/* Reset & Core Setup */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --font-title: 'Orbitron', -apple-system, sans-serif;
  --font-body: 'Rajdhani', -apple-system, sans-serif;
  
  --color-bg: #07070c;
  --color-cyan: #00f3ff;
  --color-magenta: #ff007f;
  --color-purple: #9d00ff;
  --color-gold: #ffd700;
  --color-dark-glass: rgba(12, 12, 22, 0.85);
  --color-text-bright: #ffffff;
  --color-text-dim: #a0a5c0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--color-bg);
  font-family: var(--font-body);
  color: var(--color-text-bright);
}

/* Application Wrapper */
#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #14142b 0%, #06060a 100%);
  overflow: hidden;
}

/* Canvas Styling */
#gameCanvas {
  display: block;
  box-shadow: 0 0 50px rgba(0, 243, 255, 0.15), 0 0 100px rgba(255, 0, 127, 0.1);
  border-left: 2px solid rgba(0, 243, 255, 0.3);
  border-right: 2px solid rgba(0, 243, 255, 0.3);
}

/* Flash Overlay */
#flash-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease-out;
  z-index: 5;
}

#flash-overlay.flash-near-miss {
  background: radial-gradient(circle at center, rgba(0, 243, 255, 0.3) 0%, transparent 80%);
  opacity: 1;
}

#flash-overlay.flash-crash {
  background: rgba(255, 0, 80, 0.4);
  opacity: 1;
}

/* Overlay Generic */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* Glass Panel UI Card */
.glass-panel {
  background: var(--color-dark-glass);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8),
              inset 0 0 15px rgba(0, 243, 255, 0.15),
              0 0 20px rgba(255, 0, 127, 0.2);
  padding: 2.5rem;
  max-width: 520px;
  width: 90%;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.glass-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-cyan), var(--color-magenta), transparent);
  animation: scanline 4s linear infinite;
}

@keyframes scanline {
  0% { transform: translateX(-50%); }
  100% { transform: translateX(50%); }
}

/* Title Screen Specifics */
.cyber-badge {
  font-family: var(--font-title);
  font-size: 0.75rem;
  letter-spacing: 4px;
  color: var(--color-cyan);
  background: rgba(0, 243, 255, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--color-cyan);
  display: inline-block;
  margin-bottom: 1rem;
}

.glitch-title {
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 2px;
  text-shadow: 0 0 15px rgba(0, 243, 255, 0.8);
  margin-bottom: 0.5rem;
}

.highlight-cyan {
  color: var(--color-cyan);
  text-shadow: 0 0 20px var(--color-cyan);
}

.highlight-magenta {
  color: var(--color-magenta);
  text-shadow: 0 0 20px var(--color-magenta);
}

.highlight-gold {
  color: var(--color-gold);
  text-shadow: 0 0 20px var(--color-gold);
}

.tagline {
  font-size: 1.1rem;
  color: var(--color-text-dim);
  font-style: italic;
  margin-bottom: 1.8rem;
}

.stats-preview {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.8rem;
}

.stat-pill {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-icon {
  font-size: 1.4rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.stat-lbl {
  font-size: 0.7rem;
  color: var(--color-text-dim);
  letter-spacing: 1px;
  font-family: var(--font-title);
}

.stat-val {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-gold);
}

/* Controls Guide */
.controls-guide {
  margin-top: 1.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1.2rem;
}

.controls-guide h3 {
  font-family: var(--font-title);
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--color-text-dim);
  margin-bottom: 0.8rem;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
  text-align: left;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-dim);
}

kbd {
  background: rgba(0, 243, 255, 0.15);
  border: 1px solid var(--color-cyan);
  color: var(--color-cyan);
  font-family: var(--font-title);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 24px;
  text-align: center;
  box-shadow: 0 0 6px rgba(0, 243, 255, 0.3);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 1rem 1.5rem;
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #000;
  background: linear-gradient(135deg, var(--color-cyan) 0%, #0099ff 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 35px rgba(0, 243, 255, 0.8);
  filter: brightness(1.15);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.99);
}

.btn-secondary {
  width: 100%;
  padding: 0.85rem 1.2rem;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-text-bright);
  background: rgba(255, 0, 127, 0.2);
  border: 1px solid var(--color-magenta);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--color-magenta);
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.6);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--color-text-dim);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #fff;
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.menu-btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

/* HUD Overlay Styling */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
  transition: opacity 0.3s ease;
}

#hud.hidden {
  opacity: 0;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 650px;
  width: 100%;
  margin: 0 auto;
}

.hud-box {
  background: rgba(8, 8, 16, 0.75);
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-radius: 10px;
  padding: 0.5rem 1rem;
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.hud-label {
  font-family: var(--font-title);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--color-text-dim);
}

.hud-value {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.speed-box .hud-value {
  color: var(--color-cyan);
  text-shadow: 0 0 12px var(--color-cyan);
}

.speed-value-container {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.speed-unit {
  font-family: var(--font-title);
  font-size: 0.65rem;
  color: var(--color-text-dim);
}

.coin-box .hud-value {
  color: var(--color-gold);
  text-shadow: 0 0 12px var(--color-gold);
}

.best-box .hud-value {
  color: var(--color-purple);
}

.hud-bottom {
  max-width: 650px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: center;
}

.nitro-container {
  background: rgba(8, 8, 16, 0.8);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  width: 100%;
  max-width: 400px;
  backdrop-filter: blur(6px);
}

.nitro-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-title);
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--color-cyan);
  margin-bottom: 0.4rem;
}

.nitro-hint {
  display: block;
  text-align: right;
  font-size: 0.65rem;
  color: var(--color-text-dim);
  margin-top: 0.3rem;
  font-family: var(--font-title);
}

.nitro-bar-outer {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(0, 243, 255, 0.2);
  padding: 2px;
}

.nitro-bar-inner {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00f3ff, #ff007f);
  border-radius: 4px;
  box-shadow: 0 0 12px var(--color-cyan);
  transition: width 0.1s linear;
}

.hud-controls {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(8, 8, 16, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 1.1rem;
  backdrop-filter: blur(5px);
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: rgba(0, 243, 255, 0.2);
  border-color: var(--color-cyan);
  box-shadow: 0 0 10px var(--color-cyan);
}

/* Banner Notification */
.banner-notification {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 12, 24, 0.9);
  border: 2px solid var(--color-cyan);
  box-shadow: 0 0 30px var(--color-cyan);
  border-radius: 12px;
  padding: 1rem 2.5rem;
  text-align: center;
  z-index: 9;
  animation: bannerPulse 0.5s ease;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.banner-notification h2 {
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: var(--color-cyan);
  letter-spacing: 3px;
  text-shadow: 0 0 10px var(--color-cyan);
}

.banner-notification p {
  font-size: 1rem;
  color: var(--color-text-bright);
}

@keyframes bannerPulse {
  0% { transform: translate(-50%, -20px) scale(0.8); opacity: 0; }
  60% { transform: translate(-50%, 5px) scale(1.05); opacity: 1; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* Countdown Overlay */
#countdown-overlay {
  background: rgba(5, 5, 10, 0.6);
}

.countdown-pop {
  font-family: var(--font-title);
  font-size: 8rem;
  font-weight: 900;
  color: var(--color-cyan);
  text-shadow: 0 0 30px var(--color-cyan), 0 0 60px var(--color-magenta);
  animation: popScale 0.8s ease infinite;
}

@keyframes popScale {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

/* Results Grid on Game Over */
.crash-title {
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--color-magenta);
  text-shadow: 0 0 25px var(--color-magenta);
  margin-bottom: 1.2rem;
}

.results-grid {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.05rem;
}

.res-lbl {
  color: var(--color-text-dim);
  font-family: var(--font-title);
  font-size: 0.8rem;
  letter-spacing: 1px;
}

.res-val {
  font-family: var(--font-title);
  font-weight: 700;
}

.high-score-badge {
  background: linear-gradient(90deg, #ff007f, #ffd700);
  color: #000;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 2px;
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 0.8rem;
  box-shadow: 0 0 15px var(--color-gold);
  animation: shineBadge 1.5s ease-in-out infinite alternate;
}

@keyframes shineBadge {
  0% { transform: scale(0.96); filter: brightness(1); }
  100% { transform: scale(1.04); filter: brightness(1.25); }
}

.pause-title {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--color-cyan);
  text-shadow: 0 0 20px var(--color-cyan);
  letter-spacing: 3px;
}
