/* ==========================================================================
   STAND B12 — Visual-First Spatial HUD
   95% unobstructed 3D world. Whisper-quiet neutral glass floating controls.
   ========================================================================== */

:root {
  --glass-bg: rgba(15, 16, 19, 0.52);
  --glass-bg-hi: rgba(20, 21, 26, 0.78);
  --glass-border: rgba(255, 255, 255, 0.11);
  --glass-border-hi: rgba(255, 255, 255, 0.24);
  --ink: #F5F4F0;
  --ink-dim: rgba(245, 244, 240, 0.62);
  --ink-faint: rgba(245, 244, 240, 0.38);
  --cta-bg: #F5F4F0;
  --cta-ink: #111214;
  --surface-pill: rgba(255, 255, 255, 0.08);
  --surface-pill-hi: rgba(255, 255, 255, 0.17);
  --shadow-glass: 0 18px 46px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --text-glow: 0 2px 18px rgba(0, 0, 0, 0.48);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

body[data-mood="day"] {
  --glass-bg: rgba(250, 249, 246, 0.68);
  --glass-bg-hi: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(18, 20, 24, 0.1);
  --glass-border-hi: rgba(18, 20, 24, 0.24);
  --ink: #15171C;
  --ink-dim: rgba(21, 23, 28, 0.6);
  --ink-faint: rgba(21, 23, 28, 0.38);
  --cta-bg: #15171C;
  --cta-ink: #F7F6F2;
  --surface-pill: rgba(18, 20, 24, 0.06);
  --surface-pill-hi: rgba(18, 20, 24, 0.13);
  --shadow-glass: 0 14px 36px rgba(18, 20, 24, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.78);
  --text-glow: 0 1px 12px rgba(255, 255, 255, 0.7);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0C121D;
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.viewport {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 1;
  cursor: grab;
}

.viewport:active {
  cursor: grabbing;
}

.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(ellipse at 50% 48%, transparent 58%, rgba(5, 7, 12, 0.36) 100%),
    linear-gradient(180deg, rgba(6, 9, 15, 0.28) 0%, transparent 16%, transparent 82%, rgba(6, 9, 15, 0.34) 100%);
}

body[data-mood="day"] .vignette {
  background: linear-gradient(180deg, rgba(242, 240, 234, 0.28) 0%, transparent 18%, transparent 84%, rgba(230, 226, 218, 0.28) 100%);
}

/* ==========================================================================
   TOP-LEFT — Minimal Floating Readout
   ========================================================================== */
.hud-topleft {
  position: fixed;
  top: 22px;
  left: 26px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
  text-shadow: var(--text-glow);
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.gate-chip {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--cta-bg);
  color: var(--cta-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-shadow: none;
}

.pax-inline {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
}

.pax-inline strong {
  color: var(--ink);
  font-weight: 600;
}

.shuffle-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-dim);
}

.hero-timer {
  font-size: 46px;
  font-weight: 300;
  letter-spacing: -0.045em;
  line-height: 1.02;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Race 2x compact inline selector */
.race-readout {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 14px;
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  pointer-events: auto;
  text-shadow: none;
  min-width: 280px;
}

.race-readout.visible {
  display: flex;
}

.race-lane-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.lane-marker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  min-width: 34px;
  text-align: center;
}

.lane-marker.a {
  background: rgba(56, 189, 248, 0.22);
  color: #38BDF8;
}

.lane-marker.b {
  background: rgba(249, 115, 91, 0.22);
  color: #F9735B;
}

body[data-mood="day"] .lane-marker.a { color: #0284C7; }
body[data-mood="day"] .lane-marker.b { color: #DC4B32; }

.race-inline-select {
  appearance: none;
  background: var(--surface-pill);
  color: var(--ink);
  border: 1px solid var(--glass-border);
  border-radius: 7px;
  padding: 4px 22px 4px 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.lane-stat {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  white-space: nowrap;
}

.race-verdict {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  padding-top: 4px;
  border-top: 1px solid var(--glass-border);
}

.race-verdict:empty {
  display: none;
}

/* ==========================================================================
   TOP-RIGHT — Visual-First Spatial Controls
   ========================================================================== */
.hud-topright {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 7px;
}

.glass-seg {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  gap: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--ink-dim);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms ease;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.active {
  background: var(--surface-pill-hi);
  color: var(--ink);
}

.seg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 140ms ease;
}

.seg-icon:hover {
  color: var(--ink);
}

.seg-icon.active {
  background: var(--surface-pill-hi);
  color: var(--ink);
}

.glass-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  color: var(--ink);
  cursor: pointer;
  transition: all 140ms ease;
}

.glass-pill-btn:hover,
.glass-pill-btn.active {
  background: var(--glass-bg-hi);
  border-color: var(--glass-border-hi);
}

.pill-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.glass-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 140ms ease;
}

.glass-icon-btn:hover,
.glass-icon-btn.active {
  color: var(--ink);
}

/* ==========================================================================
   ON-DEMAND RUNS & CURVE DRAWER
   ========================================================================== */
.runs-sheet {
  position: fixed;
  top: 68px;
  right: 24px;
  width: 294px;
  max-height: calc(100dvh - 196px);
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px;
  border-radius: 18px;
  background: var(--glass-bg-hi);
  backdrop-filter: blur(32px) saturate(150%);
  -webkit-backdrop-filter: blur(32px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  z-index: 15;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: all 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.runs-sheet.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

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

.sheet-head h3 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
}

.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sheet-close,
.text-btn {
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font-size: 11.5px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
}

.sheet-close:hover,
.text-btn:hover {
  color: var(--ink);
  background: var(--surface-pill);
}

.sheet-chart {
  padding: 9px 9px 5px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
}

body[data-mood="day"] .sheet-chart {
  background: rgba(255, 255, 255, 0.55);
}

#curve-svg {
  display: block;
  width: 100%;
  height: 100px;
  overflow: visible;
}

.sheet-chart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
}

.curve-legend {
  display: flex;
  align-items: center;
  gap: 9px;
}

.legend-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-dim);
}

.legend-line {
  width: 10px;
  height: 2px;
  border-radius: 2px;
  display: inline-block;
}

.runs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.runs-empty {
  font-size: 11.5px;
  color: var(--ink-faint);
  padding: 10px 4px;
  text-align: center;
}

.run-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--surface-pill);
  border: 1px solid transparent;
}

.run-item.is-best {
  border-color: var(--glass-border-hi);
  background: var(--surface-pill-hi);
}

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

.run-name {
  font-size: 12px;
  font-weight: 500;
}

.run-time-wrap {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-mono);
}

.run-time {
  font-size: 12px;
  font-weight: 600;
}

.run-delta {
  font-size: 10px;
  color: var(--ink-dim);
}

.run-bar-track {
  height: 2.5px;
  border-radius: 99px;
  background: rgba(128, 128, 128, 0.2);
  overflow: hidden;
}

.run-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--ink);
  opacity: 0.55;
}

.run-item.is-best .run-bar-fill {
  opacity: 0.95;
}

/* ==========================================================================
   3D TOOLTIP & COMPACT FINISH PILL
   ========================================================================== */
.scene-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 20;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--glass-bg-hi);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -125%);
  transition: opacity 100ms ease;
}

.scene-tooltip.visible {
  opacity: 1;
}

.finish-banner {
  position: fixed;
  bottom: 118px;
  left: 50%;
  transform: translate(-50%, 10px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--glass-bg-hi);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border: 1px solid var(--glass-border-hi);
  box-shadow: var(--shadow-glass);
  font-size: 12px;
  color: var(--ink);
  z-index: 16;
  opacity: 0;
  pointer-events: none;
  transition: all 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.finish-banner.visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.finish-cta {
  border: none;
  background: var(--cta-bg);
  color: var(--cta-ink);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.finish-dismiss {
  border: none;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 11.5px;
  padding: 2px 4px;
}

/* ==========================================================================
   BOTTOM-CENTER — Visual Strategy Thumbnails + Compact Transport Dock
   ========================================================================== */
.dock-container {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  max-width: calc(100vw - 24px);
}

.strategy-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  max-width: 100%;
  overflow-x: auto;
}

.strat-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 8px 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms ease;
  white-space: nowrap;
}

.strat-pill:hover {
  color: var(--ink);
  background: var(--surface-pill);
}

.strat-pill.active {
  background: var(--surface-pill-hi);
  border-color: var(--glass-border-hi);
  color: var(--ink);
}

.strat-mini-canvas {
  display: block;
  width: 66px;
  height: 17px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
}

.floating-dock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px 5px 5px;
  border-radius: 999px;
  background: var(--glass-bg-hi);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
}

.dock-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 86px;
  padding: 0 15px;
  border: none;
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.dock-play:hover {
  opacity: 0.92;
}

.dock-play:active {
  transform: scale(0.97);
}

.dock-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 130ms ease;
}

.dock-icon:hover,
.dock-icon.active {
  background: var(--surface-pill);
  color: var(--ink);
}

.dock-sep {
  width: 1px;
  height: 18px;
  background: var(--glass-border);
  flex-shrink: 0;
}

.dock-speeds {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.spd-btn {
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 120ms ease;
}

.spd-btn:hover {
  color: var(--ink);
}

.spd-btn.active {
  background: var(--surface-pill-hi);
  color: var(--ink);
  font-weight: 600;
}

/* Compact Options Popover */
.options-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 248px;
  padding: 12px;
  border-radius: 16px;
  background: var(--glass-bg-hi);
  backdrop-filter: blur(32px) saturate(150%);
  -webkit-backdrop-filter: blur(32px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition: all 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.options-popover.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

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

.opt-label {
  font-size: 11.5px;
  color: var(--ink-dim);
}

.opt-switch,
.opt-mini-btn {
  border: 1px solid var(--glass-border);
  background: var(--surface-pill);
  color: var(--ink-dim);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.opt-switch.active,
.opt-mini-btn.active {
  background: var(--cta-bg);
  color: var(--cta-ink);
  border-color: transparent;
}

.opt-actions {
  display: flex;
  gap: 4px;
}

.opt-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface-pill);
  gap: 2px;
}

.opt-seg-btn {
  border: none;
  background: transparent;
  color: var(--ink-dim);
  padding: 3px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  cursor: pointer;
}

.opt-seg-btn.active {
  background: var(--surface-pill-hi);
  color: var(--ink);
}

.opt-divider {
  height: 1px;
  background: var(--glass-border);
}

.opt-legend {
  display: flex;
  align-items: center;
  justify-content: space-around;
  font-size: 11px;
  color: var(--ink-dim);
}

.opt-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 10, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #F5F4F0;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

@media (max-width: 680px) {
  .hud-topleft { top: 14px; left: 16px; }
  .hero-timer { font-size: 34px; }
  .hud-topright { top: 14px; right: 14px; }
  .icon-seg { display: none; }
  .strat-mini-canvas { width: 48px; height: 14px; }
}

.site-credit {
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 14;
  font-size: 11px;
  color: var(--ink-faint);
  text-shadow: var(--text-glow);
}
.site-credit a {
  color: var(--ink-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.site-credit a:hover {
  color: var(--ink);
}
@media (max-width: 820px) {
  .site-credit { display: none; }
}
