:root {
  --bg: #050814;
  --glass: rgba(8, 13, 28, 0.72);
  --glass-border: rgba(125, 211, 252, 0.25);
  --text: #f8fafc;
  --muted: #94a3b8;
  --cyan: #38bdf8;
  --gold: #fbbf24;
  --emerald: #34d399;
  --rose: #fb7185;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

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

.gl-canvas, .fx-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.fx-overlay { pointer-events: none; z-index: 4; }
.ico { width: 14px; height: 14px; flex-shrink: 0; }

/* Top HUD */
.hud-top {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.hud-brand, .hud-stats, .hud-right { pointer-events: auto; }

.hud-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 6px 11px;
}

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ff5e1a, #0ea5e9);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.76rem;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.55);
}

.brand-title-line { display: flex; align-items: center; gap: 6px; }
.hud-brand h1 { font-size: 0.90rem; font-weight: 900; letter-spacing: 0.08em; line-height: 1; }

.course-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.60rem;
  font-weight: 800;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 1px 5px;
  border-radius: 4px;
}

.track-subtitle {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  color: var(--cyan);
  font-weight: 700;
  margin-top: 2px;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 4px 10px;
  text-align: center;
  min-width: 58px;
}

.stat-k {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.54rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.stat-v {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.12;
}
.stat-v.cyan { color: var(--cyan); }
.stat-v.gold { color: var(--gold); }
.stat-v.ok { color: var(--emerald); }
.stat-v.warn { color: var(--rose); }

.hud-right { display: flex; align-items: center; gap: 6px; }

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.1s ease;
}
.hud-btn:hover { border-color: var(--cyan); }
.hud-btn:active { transform: scale(0.95); }
.hud-btn.active { border-color: rgba(56, 189, 248, 0.7); color: var(--cyan); }

/* Progress Track Bar */
.progress-track {
  position: absolute;
  top: 56px;
  left: 12px;
  right: 12px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  z-index: 9;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #34d399, #fbbf24);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
  transition: width 0.08s linear;
}

/* Floating Non-Blocking Start Banner over Live 3D Highway */
.start-banner {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 410px);
  background: rgba(8, 12, 26, 0.78);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 16px;
  padding: 16px 18px;
  text-align: center;
  z-index: 15;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65);
}

.banner-kicker {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 4px;
}

.start-banner h2 {
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.start-banner p {
  font-size: 0.78rem;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.cta-launch {
  width: 100%;
  padding: 11px 16px !important;
  font-size: 0.86rem !important;
  letter-spacing: 0.06em;
}

/* Bottom Bar */
.hud-bottom {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.bottom-left, .jump-btn { pointer-events: auto; }
.bottom-left { display: flex; align-items: center; gap: 6px; }

.seg-tabs, .archive-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 3px 5px;
}

.seg-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}
.seg-tab.active { background: rgba(56, 189, 248, 0.24); color: #e0f2fe; }

.mini-btn {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 0.66rem;
  padding: 2px 5px;
  cursor: pointer;
}
.mini-btn:disabled { opacity: 0.28; cursor: default; }

.archive-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 800;
  min-width: 44px;
  text-align: center;
}

.jump-btn {
  border-color: rgba(52, 211, 153, 0.65);
  color: #a7f3d0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 18, 0.84);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  background: linear-gradient(180deg, #0f172a 0%, #080c1a 100%);
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.78);
}

.modal-kicker {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-bottom: 4px;
}

.modal-card h2 { font-size: 1.3rem; font-weight: 900; }

.sc-stars {
  font-size: 1.6rem;
  letter-spacing: 6px;
  color: var(--gold);
  margin: 4px 0 6px;
  text-shadow: 0 0 14px rgba(251, 191, 36, 0.6);
}

.sc-summary { font-size: 0.78rem; color: var(--muted); margin-bottom: 10px; }

.sc-share-box {
  background: #050814;
  border: 1px solid rgba(148, 185, 235, 0.22);
  border-radius: 10px;
  padding: 9px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.70rem;
  line-height: 1.4;
  color: #e2e8f0;
  white-space: pre-wrap;
  text-align: left;
  margin-bottom: 8px;
}

.sc-toast { min-height: 16px; font-size: 0.74rem; font-weight: 700; color: var(--emerald); margin-bottom: 8px; }
.modal-actions { display: flex; flex-direction: column; gap: 7px; }
.modal-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.cta-btn {
  border: 1px solid rgba(148, 185, 235, 0.25);
  background: #17223a;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}
.cta-primary { background: linear-gradient(135deg, #0ea5e9, #10b981); color: #041926; border: none; }
.cta-reddit { background: linear-gradient(135deg, #ff4500, #ea580c); color: #ffffff; border: none; }
.cta-ghost { background: transparent; color: var(--muted); }

.lb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
  max-height: 190px;
  overflow-y: auto;
  text-align: left;
}
.lb-item {
  display: flex;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 185, 235, 0.16);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}
.lb-rank { color: var(--gold); font-weight: 900; margin-right: 7px; }
.hidden { display: none !important; }

@media (max-width: 640px) {
  .hud-stats { gap: 4px; }
  .stat-chip { min-width: 44px; padding: 3px 6px; }
  .track-subtitle { display: none; }
}
