:root {
  --bg-void: #050713;
  --bg-panel: rgba(10, 14, 30, 0.84);
  --bg-panel-solid: #0d1226;
  --bg-card: rgba(255, 255, 255, 0.04);
  --line: rgba(100, 180, 255, 0.18);
  --line-strong: rgba(100, 180, 255, 0.35);
  
  --cyan: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.4);
  --magenta: #ff007f;
  --magenta-glow: rgba(255, 0, 127, 0.4);
  --amber: #ffb800;
  --amber-glow: rgba(255, 184, 0, 0.4);
  --lime: #00ff88;
  --lime-glow: rgba(0, 255, 136, 0.4);
  --purple: #9d4edd;
  --purple-glow: rgba(157, 78, 221, 0.4);
  --blue: #3a86ff;
  --danger: #ff3366;
  
  --text: #f0f6ff;
  --text-dim: #8fa2c7;
  --text-dark: #070915;
  
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  
  --font-display: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-void);
  color: var(--text);
  font-family: var(--font-display);
  overflow: hidden;
  overscroll-behavior: none;
}

/* =========================================================
   1. FULLSCREEN APP & CANVAS CONTAINER
   ========================================================= */
#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  background: var(--bg-void);
  overflow: hidden;
}

#gameFrame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #020308;
}

canvas#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* =========================================================
   2. EDGE-TO-EDGE HUD SYSTEM
   ========================================================= */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  z-index: 10;
  pointer-events: none;
  font-family: var(--font-mono);
}

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
}

.hud-pill {
  background: rgba(6, 9, 24, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  box-shadow: 0 8px 24px -6px rgba(0,0,0,0.5);
  transition: transform 0.15s ease;
}

.hud-pill .k {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 700;
}

.hud-pill .sep {
  margin-left: 6px;
}

.hud-pill.score {
  font-size: 20px;
  font-weight: 900;
  color: #e8f4ff;
  padding: 8px 14px;
}

.hud-pill.score .m-unit {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 2px;
  font-weight: 700;
}

.hud-pill.coins-pill {
  color: var(--amber);
  font-weight: 800;
}

.hud-pill.coins-pill .ic {
  font-size: 14px;
}

.hud-btn-row {
  display: flex;
  gap: 8px;
  align-self: flex-end;
  pointer-events: all;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(14, 19, 42, 0.75);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 16px -4px rgba(0,0,0,0.6);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(25, 34, 70, 0.9);
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.92);
}

#comboPill {
  display: none;
  color: var(--lime);
  font-weight: 800;
  border-color: rgba(0, 255, 136, 0.4);
  box-shadow: 0 0 14px -2px var(--lime-glow);
}

#dashMeterPill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-bar-wrap {
  width: 58px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

#dashBarFill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  border-radius: 4px;
  transition: width 0.08s linear;
  box-shadow: 0 0 8px var(--magenta-glow);
}

/* Powerups HUD */
#hudPowerups {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 2px;
}

.powerup-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(8, 12, 28, 0.85);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  backdrop-filter: blur(8px);
  animation: slideInLeft 0.2s ease-out;
}

.powerup-pill .p-icon { font-size: 14px; }
.powerup-pill .p-name { color: var(--text); letter-spacing: 0.5px; }

.powerup-pill .p-timer-wrap {
  width: 44px;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-left: auto;
}

.powerup-pill .p-timer-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.08s linear;
}

.powerup-pill.shield { border-color: var(--cyan); box-shadow: 0 0 10px var(--cyan-glow); }
.powerup-pill.shield .p-timer-fill { background: var(--cyan); }

.powerup-pill.magnet { border-color: var(--purple); box-shadow: 0 0 10px var(--purple-glow); }
.powerup-pill.magnet .p-timer-fill { background: var(--purple); }

.powerup-pill.jetpack { border-color: var(--magenta); box-shadow: 0 0 10px var(--magenta-glow); }
.powerup-pill.jetpack .p-timer-fill { background: var(--magenta); }

.powerup-pill.slowmo { border-color: var(--lime); box-shadow: 0 0 10px var(--lime-glow); }
.powerup-pill.slowmo .p-timer-fill { background: var(--lime); }

.powerup-pill.multiplier { border-color: var(--amber); box-shadow: 0 0 10px var(--amber-glow); }
.powerup-pill.multiplier .p-timer-fill { background: var(--amber); }

/* =========================================================
   3. TOASTS, STUNT NOTIFICATIONS & MILESTONES
   ========================================================= */
#milestoneBanner {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  text-align: center;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
}

#milestoneBanner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#milestoneBanner .m1 {
  font-size: clamp(24px, 5vw, 42px);
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.7));
}

#milestoneBanner .m2 {
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--amber);
  margin-top: 4px;
  text-shadow: 0 0 10px var(--amber-glow);
}

#stuntToast {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, 0);
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--cyan);
  font-size: 16px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  text-shadow: 0 0 14px var(--cyan-glow);
  transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

#comboToast {
  position: absolute;
  top: 19%;
  left: 50%;
  transform: translate(-50%, 0);
  font-family: var(--font-mono);
  font-weight: 900;
  color: var(--lime);
  font-size: 18px;
  letter-spacing: 1.5px;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  text-shadow: 0 0 14px var(--lime-glow);
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

#missionToast {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translate(-50%, -20px);
  background: rgba(10, 16, 36, 0.92);
  border: 1px solid var(--lime);
  box-shadow: 0 10px 30px -5px rgba(0,0,0,0.8), 0 0 16px var(--lime-glow);
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
}

#missionToast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================================================
   4. TOUCH CONTROLS (MOBILE & TABLET)
   ========================================================= */
#touchControls {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  pointer-events: none;
}

#jumpZone {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 65%;
  pointer-events: all;
}

.touch-hint {
  position: absolute;
  left: 20px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 1.5px;
  pointer-events: none;
}

.touch-actions {
  position: absolute;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: flex;
  gap: 14px;
  pointer-events: none;
}

.touch-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  box-shadow: 0 10px 25px -4px rgba(0,0,0,0.6);
  transition: transform 0.1s ease, filter 0.1s ease;
}

.touch-btn:active {
  transform: scale(0.9);
}

.touch-btn.dash {
  background: radial-gradient(circle at 35% 30%, #ff007f, #8c0046);
  box-shadow: 0 8px 24px -4px var(--magenta-glow);
}

.touch-btn.slam {
  background: radial-gradient(circle at 35% 30%, #00f0ff, #006b8c);
  box-shadow: 0 8px 24px -4px var(--cyan-glow);
}

/* =========================================================
   5. MODAL SCREENS & GLASSMORPHISM SYSTEM
   ========================================================= */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 7, 14, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
  overflow-y: auto;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

.panel {
  width: 100%;
  max-width: 580px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: 0 30px 80px -15px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  max-height: 90vh;
  overflow-y: auto;
}

.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* Main Menu Header */
.title-lockup {
  text-align: center;
  margin-bottom: 8px;
}

.title-lockup .super-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.16em;
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.title-lockup h1 {
  font-size: clamp(40px, 8vw, 64px);
  margin: 0;
  letter-spacing: 0.06em;
  font-weight: 900;
  color: #f4f7fb;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.title-lockup .sub {
  text-align: center;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  font-size: 14px;
  font-weight: 500;
  margin-top: 8px;
}

/* Stat Chips */
.stat-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.chip b { color: var(--text); font-weight: 800; }
.chip .ic { font-size: 13px; }

/* Hero Showcase Card */
.hero-preview-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 18px auto 10px;
  background: rgba(8, 12, 22, 0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px 18px;
  max-width: 440px;
  box-shadow: 0 18px 40px -18px rgba(0,0,0,0.8);
}

#menuCharCanvas {
  width: 110px;
  height: 126px;
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(61, 214, 224, 0.12), transparent 60%),
    linear-gradient(180deg, #1a2438 0%, #0a101c 100%);
}

.hero-info .k-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase; }
.hero-info .h-name { font-size: 17px; font-weight: 800; color: var(--text); margin-top: 4px; }
.hero-info .h-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.hero-info .h-perk { font-size: 11px; color: #8fd4a8; margin-top: 6px; font-weight: 600; }

.menu-lab-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0 0;
}
.linkish {
  background: none;
  border: none;
  color: var(--cyan);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Buttons */
.btn-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  margin: 16px auto 0;
}

.btn-row-dual {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-row-dual .btn {
  flex: 1;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: var(--text-dark);
  background: linear-gradient(180deg, #7ee8f2, #3dd6e0);
  box-shadow: 0 8px 20px -8px rgba(0, 40, 50, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn.btn-hero {
  padding: 18px 22px;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #9ef4ff 0%, #2ec4d4 100%);
  box-shadow: 0 12px 32px -10px rgba(46, 196, 212, 0.45);
  animation: playPulse 2.4s ease-in-out infinite;
}

.btn.magenta {
  background: linear-gradient(135deg, var(--magenta), #ff66b2);
  color: #fff;
  box-shadow: 0 8px 24px -6px var(--magenta-glow);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}

.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--line-strong);
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger), #ff708f);
  color: #fff;
  box-shadow: 0 8px 24px -6px rgba(255, 51, 102, 0.5);
}

.btn.small { padding: 8px 14px; font-size: 11px; letter-spacing: 1px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; transform: none; box-shadow: none; }

.footer-controls-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.footer-controls-legend kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text);
  font-weight: 700;
}

/* =========================================================
   6. SHOP, TECH LAB & RUNNER GRID
   ========================================================= */
.shop-panel {
  max-width: 680px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 3px;
  font-weight: 900;
}

.panel-head .coins-mini {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--amber);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1.5px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: var(--text-dark);
  box-shadow: 0 4px 16px -4px var(--cyan-glow);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Runner Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 2px 10px;
}

.grid::-webkit-scrollbar { width: 6px; }
.grid::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.item-card.equipped {
  border-color: var(--lime);
  box-shadow: 0 0 0 1px var(--lime), 0 0 20px -4px var(--lime-glow);
}

.item-swatch-wrap {
  width: 76px;
  height: 76px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.1), transparent 70%);
  position: relative;
}

.item-swatch-canvas {
  width: 68px;
  height: 68px;
}

.item-name {
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.5px;
  color: var(--text);
}

.item-sub {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  font-family: var(--font-mono);
}

.item-price {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber);
  font-weight: 800;
}

.item-tag {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 8px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 255, 136, 0.2);
  color: var(--lime);
  letter-spacing: 1px;
  font-weight: 800;
}

.item-tag.rarity {
  left: 6px;
  right: auto;
  background: rgba(0,0,0,0.45);
  color: var(--rarity, var(--text-dim));
}

.go-tag { color: var(--danger) !important; }
.go-title { font-size: 32px !important; letter-spacing: 0.08em !important; }

@keyframes playPulse {
  0%, 100% { box-shadow: 0 12px 32px -10px rgba(46, 196, 212, 0.35); }
  50% { box-shadow: 0 14px 36px -8px rgba(46, 196, 212, 0.55); }
}

.item-card .btn {
  width: 100%;
  margin-top: 4px;
}

/* Tech Lab Grid */
.tech-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 2px 10px;
}

.tech-grid::-webkit-scrollbar { width: 6px; }
.tech-grid::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.tech-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.tech-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.tech-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tech-icon { font-size: 18px; }
.tech-name { font-weight: 800; font-size: 14px; color: var(--text); letter-spacing: 0.5px; }
.tech-desc { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }

.tech-pips {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.pip {
  width: 18px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.pip.filled {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan-glow);
}

.tech-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.msg-flash {
  font-size: 12px;
  color: var(--danger);
  text-align: center;
  min-height: 18px;
  font-family: var(--font-mono);
  font-weight: 700;
  margin-top: 6px;
}

/* =========================================================
   7. MISSIONS & STATS MODALS
   ========================================================= */
.modal-panel {
  max-width: 540px;
}

.missions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 2px 8px;
}

.mission-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mission-card.completed {
  border-color: rgba(0, 255, 136, 0.4);
  background: rgba(0, 255, 136, 0.04);
}

.mission-info {
  flex: 1;
}

.mission-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.5px;
}

.mission-progress-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 2px 8px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card .k {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

.stat-card b {
  font-size: 18px;
  color: var(--cyan);
  font-weight: 900;
  font-family: var(--font-mono);
}

/* =========================================================
   8. SETTINGS SYSTEM & CONTROLS
   ========================================================= */
.settings-panel {
  max-width: 520px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}

.setting-row:last-of-type { border-bottom: none; }
.setting-row .label { font-size: 14px; font-weight: 800; letter-spacing: 1px; color: var(--text); }
.setting-row .desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-family: var(--font-mono); }

.setting-control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vol-slider {
  width: 90px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.toggle {
  width: 52px;
  height: 28px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.15s ease;
}

.toggle.on { background: linear-gradient(135deg, var(--cyan), var(--lime)); }
.toggle.on .knob { left: 26px; background: #08101a; }

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.seg button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 7px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 1px;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg button.active {
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  color: #06070f;
  font-weight: 900;
}

#helpList {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
  font-family: var(--font-mono);
  text-align: left;
  margin: 12px 0;
  background: rgba(0, 0, 0, 0.3);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

#helpList b { color: var(--text); }

/* Reset & Confirm */
.confirm-box { text-align: center; max-width: 440px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* Game Over & Pause Screen */
.game-over-panel, .pause-panel {
  text-align: center;
  max-width: 440px;
}

#newHighBadge {
  color: var(--amber);
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 13px;
  margin: 8px 0;
  text-shadow: 0 0 12px var(--amber-glow);
  animation: pulse 1s infinite alternate;
}

.game-over-stats {
  margin: 14px 0 10px;
}

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  from { opacity: 0.8; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1.02); }
}

.hidden { display: none !important; }

/* Campaign map select & level path */
.campaign-panel { max-width: 640px; }
.map-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}
.map-hero {
  flex: 1;
  text-align: center;
  position: relative;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.25);
}
#mapPreviewCanvas {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
  margin-bottom: 8px;
}
.map-num {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--cyan);
}
.map-hero h3 {
  margin: 4px 0 2px;
  font-size: 22px;
  letter-spacing: 2px;
}
.map-sub { margin: 0; color: var(--text-dim); font-size: 13px; }
.map-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.map-lock {
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--amber);
  font-size: 12px;
}
.level-path {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
  margin: 12px 0;
  padding-left: 20px;
}
.level-node {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: rgba(8,12,28,0.9);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.level-node::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 2px;
  height: 10px;
  background: linear-gradient(var(--cyan), transparent);
  transform: translateX(-50%);
  opacity: 0.5;
}
.level-node:first-child::before { display: none; }
.level-node.done { border-color: var(--lime); }
.level-node.sel { border-color: var(--cyan); box-shadow: 0 0 16px var(--cyan-glow); }
.level-node.locked { opacity: 0.45; cursor: not-allowed; }
.node-num { font-weight: 800; font-size: 14px; }
.node-stars { font-size: 8px; letter-spacing: 1px; color: var(--amber); margin-top: 2px; }

.campaign-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}
.cp-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}
#cpBarFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  transition: width 0.12s linear;
}
#cpPct { font-size: 11px; color: var(--text-dim); min-width: 32px; }

.intro-lockup, .cd-lockup {
  text-align: center;
  padding: 40px 24px;
}
.intro-lockup h2, .cd-lockup h2 {
  font-size: 28px;
  letter-spacing: 4px;
  margin: 8px 0;
}
.cd-num {
  font-size: 48px;
  font-weight: 900;
  color: var(--cyan);
  margin-top: 16px;
  text-shadow: 0 0 24px var(--cyan-glow);
}
.star-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 12px 0;
}
.star-icon {
  width: 28px;
  height: 28px;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  background: rgba(255,255,255,0.15);
}
.star-icon.on { background: linear-gradient(135deg, var(--amber), #ffe066); box-shadow: 0 0 12px var(--amber-glow); }
.obj-line { color: var(--text-dim); font-size: 12px; margin: 0 0 8px; }
.revive-info {
  font-size: 12px;
  color: var(--text-dim);
  margin: 10px 0;
  line-height: 1.6;
}
.revive-info b { color: var(--amber); }
.revive-msg { color: var(--danger); font-weight: 700; margin-top: 4px; }
.go-sub { color: var(--text-dim); font-size: 13px; margin: 4px 0 10px; letter-spacing: 1px; }
#btnRevive:disabled { opacity: 0.45; cursor: not-allowed; }

/* Responsive adjustments */
@media (max-width: 600px) {
  .panel { padding: 18px 16px; border-radius: var(--radius); }
  .stats-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .title-lockup h1 { font-size: 34px; letter-spacing: 5px; }
}
