/* ==========================================================================
   3D Neon Snake Arcade - Stylesheet
   Theme: Cyberpunk Glassmorphism & Tactile 3D Controls
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;900&family=Rajdhani:wght@500;600;700&display=swap');

/* Critical Hidden Attribute Specificity Overrides */
[hidden] {
  display: none !important;
}

.modal-backdrop[hidden],
.pause-overlay[hidden],
.freeze-indicator[hidden],
.start-overlay[hidden],
.icon-off[hidden],
.icon-play[hidden],
.new-best[hidden] {
  display: none !important;
}

:root {
  --bg-deep: #060814;
  --bg-surface: rgba(14, 20, 42, 0.75);
  --bg-surface-elevated: rgba(22, 32, 68, 0.85);
  --border-neon: rgba(0, 255, 170, 0.35);
  --border-neon-strong: #00ffaa;
  --neon-cyan: #00ffff;
  --neon-green: #00ff88;
  --neon-pink: #ff2d87;
  --neon-gold: #ffd700;
  --neon-blue: #00bfff;
  --font-display: 'Orbitron', monospace, sans-serif;
  --font-body: 'Rajdhani', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg-deep);
  color: #e2e8f0;
  font-family: var(--font-body);
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  /* Falls back to plain `center` in browsers without `safe` support (the
     invalid value is dropped, keeping the line above). Where supported, this
     stops the arcade-shell's top AND bottom from clipping out of view when
     racer mode's extra badges/pills make the cabinet taller than the
     viewport - centering only kicks in when everything actually fits. */
  align-items: safe center;
  min-height: 100vh;
  padding: 1rem;
  background:
    radial-gradient(circle at 50% 20%, rgba(0, 255, 170, 0.12), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(255, 45, 135, 0.08), transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(0, 191, 255, 0.08), transparent 50%),
    var(--bg-deep);
  position: relative;
}

/* Moving CRT scanlines overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0px,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: overlay;
  z-index: 99;
}

/* Arcade Cabinet Container */
.arcade-shell {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  z-index: 1;
  transition: max-width 0.3s ease;
}

/* Header */
.game-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-green) 55%, var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 25px rgba(0, 255, 170, 0.5);
}

.version-tag {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--neon-pink);
  border: 1px solid rgba(255, 45, 135, 0.5);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 45, 135, 0.12);
  box-shadow: 0 0 10px rgba(255, 45, 135, 0.3);
}

/* Cyberpunk Arcade Game Switcher Tabs */
.arcade-nav {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 820px;
  margin-bottom: 0.2rem;
}

.arcade-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1.1rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.arcade-tab-btn:hover {
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(30, 41, 59, 0.8);
  transform: translateY(-1px);
}

.arcade-tab-btn.active {
  color: #020408;
  background: linear-gradient(135deg, #00ffaa, #00e5ff);
  border-color: #00ffaa;
  box-shadow: 0 0 16px rgba(0, 255, 170, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

.arcade-tab-btn#tabRacer:hover {
  border-color: rgba(255, 45, 149, 0.45);
  color: #ff9fd6;
}

.arcade-tab-btn#tabRacer.active {
  color: #05010a;
  background: linear-gradient(135deg, #ff2d95, #00e5ff);
  border-color: #ff2d95;
  box-shadow:
    0 0 16px rgba(255, 45, 149, 0.55),
    0 0 22px rgba(0, 229, 255, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.45);
}

/* HUD Glassmorphic Bar */
.hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.2rem;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-neon);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.12);
}

.hud-badges {
  display: flex;
  gap: 0.6rem;
}

.badge {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.25rem 0.65rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  min-width: 68px;
}

.badge-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.badge-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.6);
}

.badge-high .badge-value {
  color: var(--neon-gold);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

.badge-speed .badge-value {
  color: #ffcc00;
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.6);
  font-size: 1.05rem;
}

.badge-speed small {
  font-size: 0.65rem;
  color: #94a3b8;
}

.badge-nitro {
  min-width: 90px;
}

.nitro-meter {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.35rem;
  border: 1px solid rgba(0, 229, 255, 0.3);
}

.nitro-fill {
  height: 100%;
  background: linear-gradient(90deg, #00e5ff, #ff0055);
  box-shadow: 0 0 8px #00e5ff;
  transition: width 0.15s ease;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 600px) {
  .hud {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
  }
  .hud-badges {
    width: 100%;
    justify-content: center;
  }
  .hud-controls {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: 0.4rem;
  }
}

/* 3D Tactile Buttons */
.difficulty-group {
  display: flex;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
}

.diff-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
  background: transparent;
  border: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.diff-btn:hover {
  color: #f8fafc;
}

.diff-btn.active {
  color: #060814;
  background: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.6);
  font-weight: 800;
}

/* Cyber Garage vehicle selector - visibility toggled via :has() further down */
.vehicle-group {
  display: flex;
  gap: 0.3rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
}

.vehicle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  font-size: 1.05rem;
  line-height: 1;
  background: rgba(0, 229, 255, 0.06);
  border: 1.5px solid rgba(0, 229, 255, 0.4);
  border-radius: 6px;
  color: #e2e8f0;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.vehicle-btn:hover {
  border-color: rgba(0, 229, 255, 0.8);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.45);
  transform: translateY(-1px);
}

.vehicle-btn.active {
  border-color: #ff2d95;
  background: linear-gradient(135deg, rgba(255, 45, 149, 0.28), rgba(0, 229, 255, 0.22));
  box-shadow:
    0 0 14px rgba(255, 45, 149, 0.65),
    0 0 10px rgba(0, 229, 255, 0.35),
    inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

.icon-controls {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 3px 8px rgba(0, 255, 255, 0.3);
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* 3D Game Viewport Container */
.game-container {
  position: relative;
  width: 100%;
  max-width: 820px;
  height: clamp(420px, 64vh, 680px);
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  border: 2px solid var(--border-neon);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.7),
    0 0 30px rgba(0, 255, 170, 0.2),
    inset 0 0 20px rgba(0, 255, 170, 0.1);
  transition: max-width 0.3s ease, border-radius 0.3s ease;
}

/* Native Fullscreen Mode Styles */
:fullscreen .game-container,
:-webkit-full-screen .game-container,
.game-container:fullscreen {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}

:fullscreen #webglContainer,
:-webkit-full-screen #webglContainer,
#webglContainer:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
}

#webglContainer {
  width: 100%;
  height: 100%;
}

#webglContainer canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Overlays inside 3D Viewport */
.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(6, 8, 20, 0.45);
  backdrop-filter: blur(2px);
  z-index: 8;
  cursor: pointer;
}

.start-card {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--neon-cyan);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--neon-cyan);
  padding: 0.9rem 1.6rem;
  border-radius: 12px;
  box-shadow: 0 0 25px rgba(0, 255, 255, 0.4);
  animation: pulseStart 1.5s infinite alternate ease-in-out;
  text-align: center;
}

@keyframes pulseStart {
  from { transform: scale(0.97); opacity: 0.85; }
  to { transform: scale(1.03); opacity: 1; }
}

.freeze-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--neon-blue);
  background: rgba(0, 191, 255, 0.2);
  border: 1px solid var(--neon-blue);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(0, 191, 255, 0.5);
  animation: pulseFreeze 1s infinite alternate ease-in-out;
}

@keyframes pulseFreeze {
  from { opacity: 0.6; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1.02); }
}

.pause-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(6, 8, 20, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.pause-card {
  text-align: center;
  padding: 1.5rem 2rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--neon-cyan);
  border-radius: 16px;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
}

.pause-card h2 {
  font-family: var(--font-display);
  color: var(--neon-cyan);
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.pause-card p {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

kbd {
  font-family: var(--font-display);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Primary Tactile 3D Action Button */
.primary-btn {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #060814;
  background: linear-gradient(135deg, var(--neon-green), var(--neon-cyan));
  border: none;
  padding: 0.75rem 1.8rem;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #008855, 0 8px 20px rgba(0, 255, 170, 0.4);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.primary-btn:hover {
  filter: brightness(1.1);
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #008855, 0 4px 10px rgba(0, 255, 170, 0.3);
}

.pulse-glow {
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 4px 0 #008855, 0 0 20px rgba(0, 255, 170, 0.6); }
  50% { box-shadow: 0 4px 0 #008855, 0 0 35px rgba(0, 255, 170, 0.9); }
}

/* Desktop Keyboard HUD Legend */
.desktop-controls-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 820px;
  padding: 0.55rem 0.8rem;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(0, 255, 170, 0.2);
  border-radius: 14px;
  backdrop-filter: blur(10px);
}

.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.key-pill kbd {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--neon-cyan);
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.toggle-dpad-btn {
  background: rgba(0, 255, 170, 0.1);
  border: 1px solid rgba(0, 255, 170, 0.3);
  color: var(--neon-green);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-dpad-btn:hover {
  background: rgba(0, 255, 170, 0.25);
  box-shadow: 0 0 10px rgba(0, 255, 170, 0.3);
  color: #fff;
}

/* 3D Tactile Touch D-Pad */
.dpad-container {
  width: 100%;
  display: flex;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* On desktop screens, hide physical D-Pad unless user toggles it */
@media (min-width: 860px) {
  .dpad-container:not(.force-show) {
    display: none;
  }
}

/* On mobile/tablet, hide desktop keyboard pill bar */
@media (max-width: 859px) {
  .desktop-controls-bar {
    display: none;
  }
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 3.4rem);
  grid-template-rows: repeat(3, 3.4rem);
  gap: 0.4rem;
  padding: 0.5rem;
  background: var(--bg-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-neon);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 2px 2px rgba(255, 255, 255, 0.1);
}

.dpad-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  color: #e2e8f0;
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.6);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.1s ease;
}

.dpad-btn:hover {
  background: rgba(0, 255, 170, 0.15);
  border-color: var(--neon-green);
  color: var(--neon-green);
}

.dpad-btn:active, .dpad-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  background: rgba(0, 255, 170, 0.3);
  border-color: var(--neon-green);
  color: #fff;
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-center-btn {
  grid-column: 2;
  grid-row: 2;
  background: radial-gradient(circle, rgba(255, 204, 0, 0.3), rgba(255, 0, 85, 0.2));
  border: 1.5px solid rgba(255, 204, 0, 0.5);
  color: #ffcc00;
  font-size: 1.45rem;
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transform: scale(1.18);
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  animation: nitroGlowPulse 1.6s ease-in-out infinite;
}

.dpad-center-btn:hover {
  background: radial-gradient(circle, rgba(255, 204, 0, 0.5), rgba(255, 0, 85, 0.4));
  border-color: #ffcc00;
  color: #fff;
}

.dpad-center-btn:active, .dpad-center-btn.pressed {
  transform: translateY(3px) scale(1.18);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  background: #ffcc00;
  color: #000;
  animation-play-state: paused;
}

@keyframes nitroGlowPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 204, 0, 0.45), 0 4px 0 rgba(0, 0, 0, 0.6); }
  50% { box-shadow: 0 0 26px rgba(255, 204, 0, 0.9), 0 0 12px rgba(255, 0, 85, 0.55), 0 4px 0 rgba(0, 0, 0, 0.6); }
}
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

/* Footer Hint - Hidden to prevent overflow; desktopControlsBar provides clean interactive key pills */
.game-footer {
  display: none;
}

.hint {
  font-size: 0.8rem;
  color: #64748b;
  letter-spacing: 0.02em;
  padding: 0 0.25rem;
  overflow-wrap: break-word;
}

/* Game Over 3D Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(6, 8, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  padding: 1.5rem;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--neon-pink);
  border-radius: 24px;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 45, 135, 0.35);
  transform: scale(1);
  animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.game-over-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--neon-pink);
  text-shadow: 0 0 15px rgba(255, 45, 135, 0.8);
  margin-bottom: 1rem;
}

.final-stats {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

.stat-highlight {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--neon-cyan);
}

.new-best {
  margin-top: 0.5rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--neon-gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
  animation: bounceNewBest 1s infinite alternate ease-in-out;
}

@keyframes bounceNewBest {
  from { transform: scale(0.95); }
  to { transform: scale(1.05); }
}

.modal-actions {
  display: flex;
  justify-content: center;
}

/* ==========================================================================
   Multi-Mode Arcade Selector Styles
   ========================================================================== */
.mode-selector-btn {
  background: rgba(191, 85, 236, 0.15) !important;
  border-color: rgba(191, 85, 236, 0.5) !important;
  color: #e0aaff !important;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mode-selector-btn:hover {
  background: rgba(191, 85, 236, 0.3) !important;
  border-color: #bf55ec !important;
  box-shadow: 0 0 12px rgba(191, 85, 236, 0.6);
}

.mode-modal-card {
  max-width: 540px !important;
  border-color: #bf55ec !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(191, 85, 236, 0.3) !important;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
  margin: 1rem 0 1.5rem;
  text-align: left;
}

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

.mode-card {
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 0.9rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.mode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(30, 41, 59, 0.8);
}

.mode-card.active {
  border-color: var(--neon-green);
  background: rgba(0, 255, 170, 0.08);
  box-shadow: 0 0 20px rgba(0, 255, 170, 0.25), inset 0 0 12px rgba(0, 255, 170, 0.1);
}

.mode-card[data-mode="portal"].active {
  border-color: #bf55ec;
  background: rgba(191, 85, 236, 0.08);
  box-shadow: 0 0 20px rgba(191, 85, 236, 0.25), inset 0 0 12px rgba(191, 85, 236, 0.1);
}

.mode-card[data-mode="labyrinth"].active {
  border-color: #ff6600;
  background: rgba(255, 102, 0, 0.08);
  box-shadow: 0 0 20px rgba(255, 102, 0, 0.25), inset 0 0 12px rgba(255, 102, 0, 0.1);
}

.mode-card[data-mode="hyper"].active {
  border-color: #00e5ff;
  background: rgba(0, 229, 255, 0.08);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.25), inset 0 0 12px rgba(0, 229, 255, 0.1);
}

.mode-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.mode-badge {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.badge-classic { background: #00ffaa; color: #020408; }
.badge-portal { background: #bf55ec; color: #ffffff; }
.badge-labyrinth { background: #ff6600; color: #ffffff; }
.badge-hyper { background: #00e5ff; color: #020408; }

.mode-mult {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: #94a3b8;
  font-weight: 700;
}

.mode-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
  color: #f8fafc;
}

.mode-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

.mode-best {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: #64748b;
}

.mode-best span {
  color: var(--neon-gold);
  font-weight: 700;
}

/* ==========================================================================
   Racer/Snake pill swap - pure CSS, driven by the .active class game.js
   already toggles on #tabSnake/#tabRacer. No JS changes needed for this.
   ========================================================================== */
#pillSteerRacer,
#pillNitro {
  display: none;
}

/* Cyber Garage vehicle selector: HUD-only in Racer mode */
#vehicleGroup {
  display: none;
}

.arcade-shell:has(#tabRacer.active) #vehicleGroup {
  display: flex;
}

.arcade-shell:has(#tabRacer.active) #pillSteerSnake,
.arcade-shell:has(#tabRacer.active) #pillModes,
.arcade-shell:has(#tabRacer.active) #pillCamera {
  display: none;
}

.arcade-shell:has(#tabRacer.active) #pillSteerRacer,
.arcade-shell:has(#tabRacer.active) #pillNitro {
  display: inline-flex;
}

.arcade-shell:has(#tabRacer.active) #pillNitro kbd {
  color: #ffcc00;
  background: rgba(255, 204, 0, 0.14);
  border-color: rgba(255, 204, 0, 0.35);
}

/* ==========================================================================
   Nitro Boost FX - speed lines + cabinet shake
   Pure CSS/DOM effect: toggle `.boost-active` on #gameContainer to trigger it
   (e.g. add it when RacerEngine.activateBoost() succeeds, remove it after the
   boost duration / when racerState.isBoosting goes false). No canvas/WebGL
   camera code needed - this is a cheap DOM overlay layered on top of it.
   ========================================================================== */
.speed-lines-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background:
    repeating-conic-gradient(
      from 0deg,
      rgba(255, 255, 255, 0.08) 0deg 1.2deg,
      transparent 1.2deg 6deg
    );
  mix-blend-mode: screen;
  transform: scale(1.4);
  transition: opacity 0.15s ease;
}

.game-container.boost-active .speed-lines-overlay {
  opacity: 1;
  animation: speedLinesRush 0.4s linear infinite;
}

.game-container.boost-active {
  animation: cabinetShake 0.22s ease-in-out infinite;
}

@keyframes speedLinesRush {
  0% { transform: scale(1.4) rotate(0deg); }
  100% { transform: scale(1.4) rotate(6deg); }
}

@keyframes cabinetShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(1px, -1px); }
  50% { transform: translate(-1px, 1px); }
  75% { transform: translate(1px, 1px); }
}

@media (prefers-reduced-motion: reduce) {
  .game-container.boost-active {
    animation: none;
  }
  .game-container.boost-active .speed-lines-overlay {
    animation: none;
    opacity: 0.6;
  }
}

/* ==========================================================================
   Trophy Cabinet - Achievements Modal
   ========================================================================== */
.modal-close-btn {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35);
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-close-btn:hover {
  color: #fff;
  border-color: var(--neon-gold);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.trophy-modal-card {
  max-width: 620px !important;
  border-color: var(--neon-gold) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(255, 215, 0, 0.3) !important;
  position: relative;
}

.trophy-modal-title {
  color: var(--neon-gold);
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

#trophyProgress {
  color: var(--neon-cyan);
  font-weight: 700;
}

.trophy-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
  margin: 1rem 0 0.25rem;
  text-align: left;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 0.2rem;
}

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

.trophy-card {
  position: relative;
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.8rem 2rem 0.8rem 0.8rem;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.7);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.trophy-card-icon {
  font-size: 1.6rem;
  line-height: 1;
  filter: grayscale(1) brightness(0.6);
  flex-shrink: 0;
}

.trophy-card-body {
  flex: 1;
  min-width: 0;
}

.trophy-card-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.trophy-card-desc {
  font-size: 0.7rem;
  color: #64748b;
  line-height: 1.35;
}

.trophy-card-lock {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  font-size: 0.75rem;
  opacity: 0.55;
}

/* Unlocked state - glowing gold/cyan */
.trophy-card.unlocked {
  border-color: var(--neon-gold);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.14), rgba(0, 255, 255, 0.08));
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.3), inset 0 0 10px rgba(0, 255, 255, 0.08);
}

.trophy-card.unlocked .trophy-card-icon {
  filter: none;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.trophy-card.unlocked .trophy-card-name {
  color: var(--neon-gold);
}

.trophy-card.unlocked .trophy-card-desc {
  color: #cbd5e1;
}

/* ==========================================================================
   Achievement unlock toasts
   ========================================================================== */
#toastContainer {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
  max-width: min(90vw, 340px);
}

.achievement-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--neon-gold);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 215, 0, 0.5);
  animation:
    toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    toastPulse 1.6s ease-in-out 0.35s infinite;
}

.achievement-toast.toast-exit {
  animation: toastSlideOut 0.3s ease forwards;
}

.achievement-toast-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.achievement-toast-body {
  min-width: 0;
}

.achievement-toast-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--neon-gold);
}

.achievement-toast-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  color: #f8fafc;
}

@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

@keyframes toastPulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 215, 0, 0.5); }
  50% { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 32px rgba(255, 215, 0, 0.9); }
}

@media (prefers-reduced-motion: reduce) {
  .achievement-toast {
    animation: none;
  }
  .achievement-toast.toast-exit {
    animation: none;
    display: none;
  }
}
