/* ==========================================================================
   CHROMA VIPER: OVERDRIVE - Visual Design System & Arcade Styles
   ========================================================================== */

:root {
  --bg-dark: #07080e;
  --bg-surface: #0e121d;
  --bg-panel: rgba(14, 18, 32, 0.82);
  --bg-card: rgba(22, 28, 48, 0.65);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-cyan: rgba(0, 245, 212, 0.35);
  --border-magenta: rgba(247, 37, 133, 0.4);

  --cyan-laser: #00f5d4;
  --cyan-glow: rgba(0, 245, 212, 0.45);
  --magenta-hot: #f72585;
  --magenta-glow: rgba(247, 37, 133, 0.45);
  --gold-core: #ffb703;
  --purple-deep: #7209b7;
  --electric-blue: #4cc9f0;
  --danger-red: #ff0054;
  --text-white: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;

  --font-display: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
}

/* Background Atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 600px at 50% -15%, rgba(0, 245, 212, 0.12), transparent 70%),
    radial-gradient(800px 500px at 90% 85%, rgba(247, 37, 133, 0.08), transparent 60%),
    radial-gradient(800px 600px at 10% 90%, rgba(114, 9, 183, 0.09), transparent 65%);
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    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: 32px 32px;
  z-index: 0;
  opacity: 0.6;
}

/* App Wrapper */
.app-container {
  width: min(1040px, 95vw);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 0 32px;
  gap: 16px;
}

/* Header & Title */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 4px;
}

.brand-badge {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cyan-laser);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.brand-badge::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--cyan-laser);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--cyan-laser);
}

h1 {
  font-size: clamp(26px, 4.5vw, 42px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-transform: uppercase;
}

.title-glow {
  background: linear-gradient(90deg, var(--cyan-laser), var(--electric-blue), var(--magenta-hot));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 35px var(--cyan-glow);
}

.subtitle {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* Toolbar Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-tool {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(8px);
}

.btn-tool:hover {
  color: var(--text-white);
  border-color: var(--border-cyan);
  background: rgba(0, 245, 212, 0.08);
}

.btn-tool[aria-pressed="true"] {
  border-color: var(--magenta-hot);
  color: var(--magenta-hot);
}

/* Main Layout Grid */
main {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 840px) {
  main {
    grid-template-columns: 1fr;
  }
}

/* Arena Section */
.arena-wrapper {
  background: var(--bg-panel);
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow:
    0 20px 50px -15px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  backdrop-filter: blur(12px);
}

/* HUD Topbar */
.hud-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.stat-group {
  display: flex;
  gap: 8px;
}

.stat-pill {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.stat-pill small {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-pill b {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-white);
}

.stat-score b {
  color: var(--cyan-laser);
  text-shadow: 0 0 12px var(--cyan-glow);
}

.stat-best b {
  color: var(--gold-core);
}

/* Combo & Status Gauges */
.hud-meters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.combo-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.combo-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.combo-badge.tier-2 { background: rgba(0, 245, 212, 0.15); color: var(--cyan-laser); border: 1px solid var(--border-cyan); }
.combo-badge.tier-3 { background: rgba(255, 183, 3, 0.15); color: var(--gold-core); border: 1px solid rgba(255, 183, 3, 0.4); }
.combo-badge.tier-4 { background: rgba(76, 201, 240, 0.2); color: var(--electric-blue); border: 1px solid rgba(76, 201, 240, 0.5); }
.combo-badge.tier-5 {
  background: linear-gradient(90deg, var(--magenta-hot), var(--purple-deep));
  color: #ffffff;
  border: 1px solid var(--magenta-hot);
  box-shadow: 0 0 14px var(--magenta-glow);
  animation: pulse-badge 0.8s infinite alternate ease-in-out;
}

@keyframes pulse-badge {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); }
}

.combo-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.combo-fill {
  height: 100%;
  width: 0%;
  background: var(--cyan-laser);
  transition: width 0.08s linear;
}

/* Boost Gauge Meter */
.boost-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.boost-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.boost-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.boost-bar-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, var(--electric-blue), var(--cyan-laser));
  transition: width 0.06s linear;
}

.boost-bar-fill.boost-ready {
  background: linear-gradient(90deg, var(--gold-core), var(--magenta-hot));
  box-shadow: 0 0 10px var(--gold-core);
}

.shields-badge {
  font-size: 13px;
  font-weight: 800;
  color: #b388ff;
  text-shadow: 0 0 10px rgba(179, 136, 255, 0.6);
}

.status-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  min-height: 16px;
  margin-bottom: 4px;
  text-align: center;
}

.audio-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cyan-laser);
  text-align: center;
  min-height: 18px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.2s ease;
  opacity: 0.85;
}

.audio-caption.muted-active {
  color: var(--gold-core);
}

/* Arena Viewport */
.arena-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #080a10;
  border: 1px solid rgba(0, 245, 212, 0.15);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

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

/* Overlays (Start, Pause, Death) */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(7, 8, 15, 0.85);
  backdrop-filter: blur(8px);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

.overlay h2 {
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.overlay p {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 44ch;
  line-height: 1.6;
  margin-bottom: 18px;
}

.overlay-tag {
  color: var(--cyan-laser);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Death Overlay Stats Grid */
.run-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin-bottom: 20px;
}

.summary-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.summary-card small {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.summary-card b {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-white);
}

/* Primary Action Buttons */
.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(90deg, var(--cyan-laser), var(--electric-blue));
  color: #041014;
  border: none;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 13px 28px;
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 0 25px var(--cyan-glow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 35px var(--cyan-glow);
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-white);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 13px 22px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Sidebar Cards */
aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  backdrop-filter: blur(10px);
}

.card h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan-laser);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

kbd {
  background: #080a12;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-width: 2px;
  color: var(--cyan-laser);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

/* Speed Selector Pills */
.speed-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.speed-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 8px 0;
  text-align: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.speed-pill:hover {
  background: rgba(255, 255, 255, 0.1);
}

.speed-pill.active {
  background: rgba(0, 245, 212, 0.14);
  border-color: var(--cyan-laser);
  color: var(--cyan-laser);
  box-shadow: 0 0 10px rgba(0, 245, 212, 0.25);
}

/* Mechanics / Feature Bullets */
.card-mechanics {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}

.card-mechanics p {
  margin-bottom: 8px;
}

.card-mechanics strong {
  color: var(--text-white);
}

/* Mobile Virtual D-Pad & Touch Controls */
.mobile-controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding: 8px;
}

@media (pointer: coarse) {
  .mobile-controls {
    display: grid;
  }
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 48px);
  gap: 6px;
  justify-content: center;
}

.dpad-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--cyan-laser);
  border-radius: var(--radius-sm);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.dpad-btn:active {
  background: rgba(0, 245, 212, 0.3);
  border-color: var(--cyan-laser);
  transform: scale(0.95);
}

.touch-boost-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.btn-touch-boost {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(247, 37, 133, 0.2), rgba(0, 245, 212, 0.2));
  border: 2px solid var(--cyan-laser);
  box-shadow: 0 0 20px var(--cyan-glow);
  color: var(--text-white);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform 0.1s ease;
}

.btn-touch-boost:active {
  transform: scale(0.92);
  background: var(--cyan-laser);
  color: #041014;
}

/* Help Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  visibility: visible;
  transition: all 0.2s ease;
}

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

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--cyan-laser);
  font-family: var(--font-mono);
}

.modal-body {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mechanic-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.mechanic-icon {
  font-size: 22px;
  line-height: 1;
}

/* Footer */
footer {
  margin-top: 10px;
  padding: 12px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

footer a {
  color: var(--cyan-laser);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Accessibility: Focus visible */
:focus-visible {
  outline: 2px solid var(--cyan-laser);
  outline-offset: 3px;
}

/* Prefers Reduced Motion & User Override */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
