:root {
  --bg-dark: #0b0f17;
  --bg-panel: rgba(15, 22, 34, 0.84);
  --bg-card: rgba(22, 31, 48, 0.88);
  --bg-card-hover: rgba(31, 44, 66, 0.94);
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #f3f6fc;
  --text-muted: #9aa7bd;
  --accent: #38bdf8;
  --accent-2: #f59e0b;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  touch-action: manipulation;
}

.app-root {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.bg-canvas,
.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* =========================================================
   SCREENS & TRANSITIONS
   ========================================================= */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
  z-index: 5;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.screen-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  z-index: 10;
}

.screen-hud {
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}

.screen-hud.screen-active {
  pointer-events: none;
}

.screen-hud.screen-active .hud-top {
  pointer-events: auto;
}

.screen-overlay,
.screen-overlay.screen-active {
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

#screen-settings.screen-active {
  z-index: 25;
}

/* =========================================================
   COMMON COMPONENTS
   ========================================================= */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 12px 18px;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-color: rgba(125, 211, 252, 0.45);
  box-shadow: 0 10px 28px rgba(14, 165, 233, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #38bdf8, #3b82f6);
  box-shadow: 0 12px 32px rgba(56, 189, 248, 0.45);
}

.btn-secondary {
  background: rgba(20, 30, 46, 0.9);
  border-color: var(--border);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 14px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.88);
  border-color: rgba(252, 165, 165, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: #ef4444;
}

.btn-ghost-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn-ghost-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.24);
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1rem;
}

.btn-xl {
  padding: 16px 30px;
  font-size: 1.08rem;
  border-radius: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(12, 18, 28, 0.78);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  font-size: 0.86rem;
}

.stat-label,
.stat-badge {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

.coin-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 32%, #fde68a, #f59e0b 65%, #b45309);
  border: 1.5px solid #fef3c7;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.45);
}

/* =========================================================
   MAIN MENU
   ========================================================= */
.menu-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 48px);
  background: linear-gradient(180deg, rgba(7, 11, 18, 0.55) 0%, rgba(7, 11, 18, 0.22) 50%, rgba(7, 11, 18, 0.78) 100%);
}

.menu-top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.menu-hero {
  max-width: 560px;
  margin: auto 0;
  padding: 18px 0;
}

.brand-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 5px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.game-title {
  margin: 0;
  font-size: clamp(3rem, 8vw, 5.1rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.95;
  text-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
}

.game-title span {
  color: var(--accent);
}

.game-subtitle {
  margin: 12px 0 20px;
  color: #cbd5e1;
  font-size: 1rem;
  line-height: 1.5;
  max-width: 440px;
}

.menu-selection-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.summary-chip {
  background: rgba(15, 23, 38, 0.78);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-chip span {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 800;
}

.summary-chip strong {
  font-size: 0.92rem;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
}

.menu-secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.menu-footer {
  padding-top: 10px;
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  color: var(--text);
}

/* =========================================================
   PANELS: MAPS / DIFFICULTY / GARAGE / SETTINGS
   ========================================================= */
.panel-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 32px) 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-narrow {
  max-width: 860px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: rgba(11, 17, 27, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  backdrop-filter: blur(12px);
}

.panel-title-group {
  flex: 1;
  min-width: 200px;
}

.panel-title-group h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.panel-title-group p {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.header-spacer {
  width: 72px;
}

.panel-footer-actions {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

/* Maps Grid */
.maps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.map-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.map-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.map-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}

.map-preview-wrap {
  position: relative;
  height: 148px;
  overflow: hidden;
  background: #080c14;
}

.map-preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.map-lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 17, 0.62);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
}

.map-diff-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(8, 13, 22, 0.78);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
}

.map-best-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(8, 13, 22, 0.78);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
}

.map-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.map-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.map-title-row h3 {
  margin: 0;
  font-size: 1.1rem;
}

.map-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.map-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.trait-chip {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
}

.map-footer {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.unlock-req {
  font-size: 0.78rem;
  color: #fbbf24;
  font-weight: 600;
}

/* Difficulty Grid */
.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.diff-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.14s ease, border-color 0.16s ease, background 0.16s ease;
}

.diff-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.diff-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.2);
}

.diff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diff-head h3 {
  margin: 0;
  font-size: 1.25rem;
}

.multiplier-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.8rem;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.diff-bullets {
  margin: 0;
  padding-left: 18px;
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Garage Category Tabs */
.garage-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.garage-tab-btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 38, 0.72);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.garage-tab-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.garage-tab-btn.active {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-color: rgba(125, 211, 252, 0.5);
  color: #fff;
  box-shadow: 0 8px 22px rgba(14, 165, 233, 0.28);
}

.showcase-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.type-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(129, 140, 248, 0.18);
  color: #c7d2fe;
  border: 1px solid rgba(129, 140, 248, 0.4);
  text-transform: uppercase;
}

/* Bike Garage */
.garage-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1.15fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}

.garage-showcase {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.showcase-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.showcase-header h3 {
  margin: 6px 0 0;
  font-size: 1.45rem;
}

.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.status-badge.locked {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.35);
}

.status-badge.selected {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
}

.price-tag {
  font-weight: 800;
  font-size: 1.05rem;
  color: #fbbf24;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.showcase-canvas-wrap {
  background: radial-gradient(circle at 50% 60%, rgba(56, 189, 248, 0.12), rgba(7, 11, 18, 0.85));
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#garage-preview-canvas {
  width: 100%;
  height: auto;
  max-height: 220px;
  display: block;
}

.showcase-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.stat-row {
  display: grid;
  grid-template-columns: 112px 1fr 34px;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
}

.stat-row span {
  color: var(--text-muted);
}

.stat-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stat-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: 999px;
  transition: width 0.24s ease;
}

.showcase-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}

.garage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bike-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.bike-item:hover {
  background: var(--bg-card-hover);
  transform: translateX(2px);
}

.bike-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.bike-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bike-mini-canvas {
  width: 72px;
  height: 44px;
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.bike-item-name {
  font-weight: 700;
  font-size: 0.96rem;
}

.bike-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* =========================================================
   GAMEPLAY HUD & TOUCH CONTROLS
   ========================================================= */
.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px 14px;
  gap: 8px;
}

.hud-brand {
  font-weight: 900;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(10, 15, 24, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.hud-brand span {
  color: var(--accent);
}

.hud-subwallet {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hud-gauge-pill {
  gap: 7px;
}

.hud-bar {
  width: 58px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.hud-pickup-feed {
  position: absolute;
  top: 64px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

.pickup-pop {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: rgba(10, 15, 24, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.18);
  animation: pickupFloat 1.1s ease forwards;
}

.pickup-pop.coin {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.55);
}

.pickup-pop.fuel {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.55);
}

.pickup-pop.nitro {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.6);
}

@keyframes pickupFloat {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-16px);
  }
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(10, 15, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
}

.hud-primary {
  border-color: rgba(56, 189, 248, 0.4);
}

.hud-label {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.hud-val {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.hud-center-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 15, 24, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  font-weight: 600;
  color: #cbd5e1;
}

.hud-center-meta .dot {
  opacity: 0.45;
}

.btn-hud-pause {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: rgba(10, 15, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.9rem;
}

.hud-banner {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.24);
  border: 1px solid rgba(125, 211, 252, 0.55);
  color: #e0f2fe;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  pointer-events: none;
  animation: popFade 0.25s ease;
}

@keyframes popFade {
  from {
    opacity: 0;
    transform: translate(-50%, -6px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.touch-controls {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  gap: 12px;
  pointer-events: none !important;
}

.touch-cluster {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.screen-hud.screen-active .touch-cluster {
  pointer-events: auto;
}

.touch-lean-pair {
  display: flex;
  gap: 8px;
}

.touch-btn {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  background: rgba(10, 16, 26, 0.62);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease, background 0.1s ease, border-color 0.1s ease;
}

.touch-btn span {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.touch-btn small {
  font-size: 1rem;
  opacity: 0.9;
}

.touch-btn-sm {
  width: 62px;
  height: 62px;
}

.touch-btn-accent {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(14, 165, 233, 0.24);
}

.touch-btn-jump {
  width: 78px;
  height: 78px;
  border-radius: 22px;
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.22);
}

.touch-btn.pressed {
  transform: scale(0.93);
  background: rgba(56, 189, 248, 0.45);
  border-color: #fff;
}

/* Hide touch controls on wide pointer-fine desktop unless toggled/touch detected */
@media (hover: hover) and (pointer: fine) and (min-width: 1025px) {
  .touch-controls {
    opacity: 0.42;
  }
  .touch-controls:hover {
    opacity: 0.9;
  }
}

/* =========================================================
   MODALS: PAUSE & RESULTS
   ========================================================= */
.modal-card {
  width: 100%;
  max-width: 440px;
  background: rgba(14, 21, 34, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 26px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.modal-card h2,
.modal-card h3 {
  margin: 0;
}

.modal-tag {
  align-self: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.modal-tag-crash {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.pause-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pause-stats > div,
.result-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pause-stats span,
.result-item span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pause-stats strong,
.result-item strong {
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}

.results-card {
  max-width: 500px;
}

.results-reason {
  margin: -6px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.result-highlight {
  border-color: rgba(56, 189, 248, 0.38);
  background: rgba(56, 189, 248, 0.08);
}

.new-record-banner {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.48);
  color: #fde68a;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* =========================================================
   SETTINGS
   ========================================================= */
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.setting-row p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

.range-input {
  width: 150px;
  accent-color: var(--accent);
}

.controls-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 16px;
}

.controls-table > div {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.84rem;
}

.controls-table span {
  color: var(--text-muted);
}

.achievements-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.ach-item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.58;
}

.ach-item.unlocked {
  opacity: 1;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.1);
}

.ach-item strong {
  display: block;
  font-size: 0.85rem;
}

.ach-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.danger-zone {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  border-color: rgba(239, 68, 68, 0.35);
}

.danger-zone p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Confirmation Modal & Toast */
.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.confirm-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 38, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-left: 4px solid var(--accent);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: slideToast 0.25s ease;
}

.toast.toast-success {
  border-left-color: var(--success);
}

.toast.toast-warn {
  border-left-color: var(--accent-2);
}

@keyframes slideToast {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =========================================================
   CONTROLLER UI, NITRO HUD & MAPPING
   ========================================================= */
.controller-tutorial-card {
  margin-top: 14px;
  max-width: 480px;
  background: rgba(12, 19, 31, 0.8);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controller-tutorial-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.controller-device-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controller-tutorial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px;
  font-size: 0.76rem;
  color: #cbd5e1;
}

.controller-tutorial-grid b {
  color: var(--accent);
}

.ctrl-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ctrl-badge-on {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.ctrl-badge-off {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.hud-nitro-pill {
  gap: 8px;
}

.hud-nitro-bar {
  width: 64px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.hud-nitro-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #22d3ee);
  transition: width 0.08s linear;
}

.hud-nitro-fill.active {
  background: linear-gradient(90deg, #38bdf8, #f97316);
  box-shadow: 0 0 10px #38bdf8;
}

.hud-fuel-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: width 0.08s linear;
}

.hud-fuel-fill.low {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.hud-fuel-fill.empty {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.hud-fuel-warning {
  position: absolute;
  top: 66px;
  left: 16px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(248, 113, 113, 0.75);
  color: #fecaca;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  pointer-events: none;
  animation: pulseWarn 0.9s infinite alternate;
}

@keyframes pulseWarn {
  from {
    opacity: 0.72;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1.03);
  }
}

.hud-ctrl-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(10, 15, 24, 0.78);
  border: 1px solid rgba(34, 197, 94, 0.48);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #86efac;
}

.ctrl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.mapping-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.76rem;
}

.mapping-select {
  background: rgba(15, 23, 38, 0.95);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 700;
}

.hud-speed-pill {
  gap: 8px;
}

.speed-gauge {
  position: relative;
  width: 28px;
  height: 16px;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border: 2px solid rgba(56, 189, 248, 0.55);
  border-bottom: none;
  overflow: hidden;
  flex-shrink: 0;
}

.speed-needle {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 2px;
  height: 12px;
  background: #f97316;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(-75deg);
  transition: transform 0.08s linear;
}

.garage-upgrades {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.upgrade-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.upgrade-info strong {
  display: block;
  font-size: 0.78rem;
}

.upgrade-info span {
  display: block;
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 700;
}

/* =========================================================
   3-TAB GARAGE (BIKES / RIDER / UPGRADES) & CONFIRMATIONS
   ========================================================= */
.garage-main-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.garage-main-tab {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 38, 0.8);
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.garage-main-tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.garage-main-tab.active {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-color: rgba(125, 211, 252, 0.55);
  color: #fff;
  box-shadow: 0 10px 26px rgba(14, 165, 233, 0.3);
}

.garage-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rider-layout {
  display: grid;
  grid-template-columns: minmax(270px, 0.9fr) minmax(320px, 1.4fr);
  gap: 18px;
  align-items: start;
}

.rider-preview-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rider-active-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rider-custom-categories {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cosmetic-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cosmetic-section h4 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cosmetic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 8px;
}

.cosmetic-item {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.12s ease;
}

.cosmetic-item:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.cosmetic-item.equipped {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
  box-shadow: 0 0 0 1px var(--accent);
}

.cosmetic-item.locked {
  opacity: 0.85;
}

.cosmetic-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.cosmetic-name {
  font-size: 0.8rem;
  font-weight: 700;
}

.cosmetic-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.cosmetic-price {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fbbf24;
}

.cosmetic-price.owned {
  color: #86efac;
}

.upgrades-header-card {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.upgrades-header-card h3 {
  margin: 6px 0 4px;
}

.garage-upgrades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.upgrade-detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}

.upgrade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.upgrade-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1rem;
}

.upgrade-pips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.upgrade-pip {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.upgrade-pip.filled {
  background: linear-gradient(90deg, #38bdf8, #22c55e);
}

.upgrade-stat-diff {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 7px 10px;
}

.upgrade-stat-diff strong {
  color: #4ade80;
}

.purchase-flash {
  animation: purchaseSuccess 0.55s ease;
}

@keyframes purchaseSuccess {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.8);
    transform: scale(1);
  }
  45% {
    box-shadow: 0 0 26px 4px rgba(34, 197, 94, 0.55);
    transform: scale(1.02);
  }
  100% {
    box-shadow: var(--shadow);
    transform: scale(1);
  }
}

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

/* =========================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================= */
@media (max-width: 840px) {
  .garage-layout {
    grid-template-columns: 1fr;
  }
  .hud-hide-sm {
    display: none;
  }
}

@media (max-width: 540px) {
  .menu-secondary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .showcase-actions {
    grid-template-columns: 1fr;
  }
  .touch-btn {
    width: 62px;
    height: 62px;
  }
  .touch-btn-sm {
    width: 52px;
    height: 52px;
  }
  .touch-btn-jump {
    width: 66px;
    height: 66px;
  }
  .danger-zone {
    flex-direction: column;
    align-items: flex-start;
  }
}
