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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f172a;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #f8fafc;
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* Hide Race-only HUD panels when in Drone Photo Inspector Mode */
body.mode-drone .race-only {
  display: none !important;
}

/* Dim background HUD softly when the Garage & Setup Modal is open so nothing clashes */
body.modal-open #top-bar,
body.modal-open #hud-bottom-left,
body.modal-open #hud-bottom-right,
body.modal-open #drone-presets,
body.modal-open #photo-pip {
  opacity: 0.18;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* ===================================================================
   SHARED GLASS HUD CARD
   =================================================================== */
.hud-card {
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(45, 212, 191, 0.32);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
}

/* ===================================================================
   UNIFIED TOP BAR (Flexbox — Zero Overlap)
   =================================================================== */
.top-bar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 12;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

/* Left: School Identity & Current Sector */
.brand-card {
  padding: 8px 12px;
  flex-shrink: 0;
  max-width: 280px;
}

.school-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.school-crest {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.school-titles {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.school-name {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  color: #ffffff;
  white-space: nowrap;
}

.zone-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zone-label {
  font-size: 0.58rem;
  font-weight: 800;
  background: #0d9488;
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.zone-name {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: #facc15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 185px;
}

/* Center: Rear-View Mirror + Compact Telemetry Strip */
.top-center-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
}

.mirror-wrap {
  display: flex;
  justify-content: center;
}

.mirror-wrap.hidden {
  display: none;
}

.mirror-frame {
  width: 220px;
  height: 50px;
  border-radius: 9px;
  border: 2px solid rgba(148, 163, 184, 0.7);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.45);
  position: relative;
  pointer-events: none;
  background: transparent;
}

.mirror-tag {
  position: absolute;
  bottom: 2px;
  right: 6px;
  font-size: 0.52rem;
  font-weight: 800;
  color: rgba(248, 250, 252, 0.8);
  background: rgba(15, 23, 42, 0.72);
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.telemetry-card {
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.86);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.telemetry-divider {
  width: 1px;
  height: 22px;
  background: rgba(148, 163, 184, 0.22);
}

.telemetry-box {
  text-align: center;
  min-width: 44px;
  padding: 0 2px;
}

.telemetry-box.wide {
  min-width: 78px;
}

.t-label {
  font-size: 0.55rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.07em;
}

.t-value {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.15;
}

.t-value.mono {
  font-variant-numeric: tabular-nums;
  color: #38bdf8;
}

.t-value.gold {
  color: #facc15;
  font-variant-numeric: tabular-nums;
}

.t-small {
  font-size: 0.72rem;
  color: #64748b;
}

.checkpoint-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  padding-top: 4px;
}

.cp-dots {
  display: flex;
  gap: 4px;
}

.cp-dot {
  width: 10px;
  height: 5px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.25);
  border: 1px solid rgba(148, 163, 184, 0.4);
  transition: all 0.2s ease;
}

.cp-dot.passed {
  background: #10b981;
  border-color: #34d399;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.55);
}

.cp-dot.next {
  background: #facc15;
  border-color: #fef08a;
  transform: scale(1.18);
}

.record-badge {
  font-size: 0.6rem;
  font-weight: 800;
  color: #facc15;
  font-variant-numeric: tabular-nums;
}

.style-popup {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.64rem;
  font-weight: 800;
  color: #facc15;
  background: rgba(234, 179, 8, 0.22);
  border: 1px solid #facc15;
  padding: 1px 6px;
  border-radius: 99px;
}

.style-popup.hidden {
  display: none;
}

/* Right: Navigation & Quick Actions */
.nav-card {
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.nav-mode-group {
  display: flex;
  gap: 5px;
}

.nav-tab {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.92);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 7px;
  padding: 6px 10px;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  background: rgba(13, 148, 136, 0.32);
  color: #fff;
  border-color: #2dd4bf;
}

.nav-tab.active {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  color: #fff;
  border-color: #5eead4;
  box-shadow: 0 0 10px rgba(20, 184, 166, 0.35);
}

.nav-tab.highlight-tab {
  background: rgba(234, 179, 8, 0.16);
  border-color: rgba(250, 204, 21, 0.6);
  color: #fde047;
}

.nav-tab.highlight-tab:hover {
  background: rgba(234, 179, 8, 0.32);
  color: #fff;
  border-color: #facc15;
}

.nav-quick-group {
  display: flex;
  gap: 5px;
}

.icon-pill {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.66rem;
  transition: all 0.15s;
  white-space: nowrap;
}

.icon-pill:hover,
.icon-pill.active {
  background: rgba(13, 148, 136, 0.35);
  color: #fff;
  border-color: #2dd4bf;
}

/* ===================================================================
   DRONE MODE RIGHT SIDEBAR (All 12 Reference Photo Angles)
   =================================================================== */
.drone-sidebar {
  position: fixed;
  top: 86px;
  right: 12px;
  width: 320px;
  z-index: 12;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.drone-sidebar.hidden {
  display: none;
}

.drone-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.sidebar-eyebrow {
  font-size: 0.55rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.08em;
}

.sidebar-title {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  color: #f8fafc;
}

.preset-toggles {
  display: flex;
  gap: 4px;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.preset-btn {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.88);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 0.65rem;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s;
  line-height: 1.2;
}

.preset-btn .p-num {
  font-family: monospace;
  font-size: 0.6rem;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(2, 132, 199, 0.2);
  padding: 1px 4px;
  border-radius: 4px;
  flex-shrink: 0;
}

.preset-btn:hover,
.preset-btn.active {
  background: #0284c7;
  color: #fff;
  border-color: #7dd3fc;
}

.preset-btn.active .p-num {
  color: #facc15;
  background: rgba(15, 23, 42, 0.45);
}

.drone-sidebar-hint {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  font-size: 0.62rem;
  color: #94a3b8;
  line-height: 1.35;
}

/* Reference Photo Comparison PiP Window (Docked Bottom-Right in Drone Mode) */
.photo-pip {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 320px;
  z-index: 14;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.55);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.photo-pip.hidden {
  display: none;
}

.pip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(2, 132, 199, 0.28);
  border-bottom: 1px solid rgba(56, 189, 248, 0.3);
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  color: #7dd3fc;
  letter-spacing: 0.04em;
}

.pip-close {
  cursor: pointer;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 800;
}

.pip-close:hover {
  color: #fff;
}

#pip-img {
  display: block;
  width: 100%;
  max-height: 185px;
  object-fit: cover;
  background: #0f172a;
}

.pip-caption {
  padding: 4px 8px;
  font-size: 0.6rem;
  color: #94a3b8;
  text-align: center;
}

/* ===================================================================
   BOTTOM LEFT: Campus Radar Minimap
   =================================================================== */
.minimap-card {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 12;
  padding: 8px 10px;
}

.minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.6rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.minimap-legend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.55rem;
  color: #cbd5e1;
}

.dot-you {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2dd4bf;
}

.dot-crest {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #facc15;
  margin-left: 3px;
}

#minimap-canvas {
  display: block;
  width: 186px;
  height: 186px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #1e293b;
}

/* ===================================================================
   BOTTOM RIGHT: Digital Speedometer + Quick Environment Bar
   =================================================================== */
.speedo-card {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 12;
  padding: 10px 14px;
  min-width: 260px;
}

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

.gear-badge {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: rgba(13, 148, 136, 0.25);
  border: 2px solid #2dd4bf;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #facc15;
}

.speed-readout {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.speed-val {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 16px rgba(45, 212, 191, 0.45);
  font-variant-numeric: tabular-nums;
}

.speed-unit {
  font-size: 0.68rem;
  font-weight: 800;
  color: #2dd4bf;
  letter-spacing: 0.08em;
}

.rpm-bar-bg {
  width: 100%;
  height: 7px;
  background: rgba(30, 41, 59, 0.9);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rpm-bar-fill {
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, #2dd4bf 0%, #facc15 70%, #ef4444 100%);
  transition: width 0.08s linear;
}

.boost-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
}

.boost-status {
  font-size: 0.64rem;
  font-weight: 800;
  color: #facc15;
  letter-spacing: 0.05em;
}

.controls-mini {
  font-size: 0.6rem;
  color: #94a3b8;
}

.quick-env-bar {
  display: flex;
  gap: 5px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.chip-btn {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.9);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.64rem;
  transition: all 0.15s ease;
  flex: 1;
  text-align: center;
  white-space: nowrap;
}

.chip-btn:hover {
  background: rgba(13, 148, 136, 0.35);
  color: #fff;
  border-color: #2dd4bf;
}

.chip-btn.active {
  background: rgba(13, 148, 136, 0.35);
  color: #5eead4;
  border-color: #2dd4bf;
}

.chip-btn.small {
  padding: 3px 6px;
  font-size: 0.6rem;
  flex: 0 1 auto;
}

kbd {
  background: #334155;
  border: 1px solid #64748b;
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.58rem;
  font-family: monospace;
  color: #f8fafc;
}

/* ===================================================================
   GARAGE & RACE SETUP HUB MODAL (2-Column Professional Layout)
   =================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 780px;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.97), rgba(30, 41, 59, 0.97));
  border: 1px solid rgba(45, 212, 191, 0.45);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.hub-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-badge {
  display: inline-block;
  background: rgba(13, 148, 136, 0.25);
  border: 1px solid #2dd4bf;
  color: #5eead4;
  font-size: 0.64rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 99px;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.modal-card h1 {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 1.55rem;
  line-height: 1.15;
  color: #fff;
}

.modal-card h1 span {
  color: #facc15;
}

.hub-close-btn {
  cursor: pointer;
  background: rgba(51, 65, 85, 0.9);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.74rem;
  font-weight: 800;
}

.hub-close-btn:hover {
  background: #0d9488;
  border-color: #2dd4bf;
}

.hub-close-btn.hidden {
  display: none;
}

/* 2-Column Settings Grid */
.hub-grid {
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}

@media (max-width: 720px) {
  .hub-grid {
    grid-template-columns: 1fr;
  }
}

.hub-panel {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.hub-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.66rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.08em;
}

.vehicle-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.v-select-btn {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.85);
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-radius: 9px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #f8fafc;
  transition: all 0.15s ease;
}

.v-select-btn:hover {
  border-color: #38bdf8;
}

.v-select-btn.selected {
  background: rgba(13, 148, 136, 0.28);
  border-color: #2dd4bf;
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.28);
}

.v-icon {
  font-size: 1.35rem;
}

.v-title {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.74rem;
}

.v-sub {
  font-size: 0.58rem;
  color: #94a3b8;
}

.custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.custom-label {
  font-size: 0.62rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.06em;
}

.color-swatches {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}

.swatch:hover {
  transform: scale(1.14);
}

.swatch.active {
  border-color: #facc15;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.75);
  transform: scale(1.14);
}

.setup-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.track-pills {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

.pill-btn {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.92);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 7px;
  padding: 6px 10px;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  transition: all 0.14s;
  text-align: left;
}

.pill-btn:hover {
  border-color: #38bdf8;
  color: #fff;
}

.pill-btn.active {
  background: rgba(13, 148, 136, 0.38);
  border-color: #2dd4bf;
  color: #5eead4;
}

.hub-shortcuts-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  padding: 7px 12px;
  margin-bottom: 14px;
  font-size: 0.65rem;
  color: #cbd5e1;
}

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

.start-btn {
  flex: 1.6;
  cursor: pointer;
  background: linear-gradient(135deg, #0d9488, #059669);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.45);
  transition: transform 0.12s, box-shadow 0.12s;
}

.start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(13, 148, 136, 0.6);
}

.secondary-btn {
  flex: 1;
  cursor: pointer;
  background: rgba(51, 65, 85, 0.88);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
}

.secondary-btn:hover {
  background: #0284c7;
  color: #fff;
  border-color: #7dd3fc;
}

.secondary-btn.hidden {
  display: none;
}

/* ===================================================================
   RESULTS MODAL
   =================================================================== */
.results-card {
  max-width: 580px;
  text-align: center;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0 20px;
}

.res-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  padding: 12px 8px;
}

.res-val {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  color: #f8fafc;
  margin-top: 4px;
}

.res-val.highlight {
  color: #facc15;
  font-size: 1.75rem;
}

.res-val.mono {
  font-variant-numeric: tabular-nums;
  color: #38bdf8;
}

/* ===================================================================
   CENTER BANNER, PHOTO MODE BAR, 3D HOTSPOTS & TOUCH CONTROLS
   =================================================================== */
.center-banner {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 2.1rem;
  font-weight: 800;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.88);
  border: 2px solid #facc15;
  padding: 10px 28px;
  border-radius: 12px;
  text-shadow: 0 2px 12px rgba(250, 204, 21, 0.5);
  pointer-events: none;
  text-align: center;
}

.center-banner.big {
  font-size: 2.9rem;
  padding: 14px 36px;
  border-color: #2dd4bf;
  color: #facc15;
}

.center-banner.hidden {
  display: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: #2dd4bf;
}

.loading-overlay.hidden {
  display: none;
}

/* 3D Campus Building Hotspots */
.hotspot-layer {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.hotspot-layer.hidden {
  display: none;
}

.hotspot-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.9);
  border: 1.5px solid #2dd4bf;
  color: #f8fafc;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 99px;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.hotspot-pin::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #2dd4bf;
}

.hotspot-pin:hover {
  background: #0d9488;
  border-color: #facc15;
  transform: translate(-50%, -106%) scale(1.06);
}

/* Photo Mode Control Bar */
.photo-bar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  background: rgba(15, 23, 42, 0.94);
  border: 2px solid #facc15;
  border-radius: 12px;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
}

.photo-bar.hidden {
  display: none;
}

.photo-bar-title {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.74rem;
  font-weight: 800;
  color: #facc15;
  letter-spacing: 0.04em;
}

.photo-bar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #cbd5e1;
}

.photo-bar-controls input[type="range"] {
  width: 90px;
  accent-color: #2dd4bf;
  vertical-align: middle;
}

/* Collapsible state for 12-Photo Drone Sidebar / Mobile Drawer */
.drone-sidebar.collapsed .preset-grid,
.drone-sidebar.collapsed .drone-sidebar-hint {
  display: none !important;
}
.drone-sidebar.collapsed .drone-sidebar-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* ===================================================================
   ERGONOMIC SMARTPHONE TOUCH CONTROLS & RESPONSIVE MOBILE UX/UI
   =================================================================== */
.touch-controls {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 18;
}

/* Hide touch controls when modal is open or in Drone/Photo mode */
body.modal-open .touch-controls,
body.mode-drone .touch-controls {
  display: none !important;
}

@media (pointer: coarse), (max-width: 920px) {
  .touch-controls {
    display: flex;
  }
}

.touch-left {
  display: flex;
  gap: 10px;
  pointer-events: auto;
  touch-action: none;
}

.touch-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  touch-action: none;
}

.touch-right-top,
.touch-right-bottom {
  display: flex;
  gap: 8px;
}

.touch-btn {
  width: 64px;
  height: 58px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(148, 163, 184, 0.5);
  color: #f8fafc;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn.steer-btn {
  width: 68px;
  height: 64px;
  font-size: 1.35rem;
}

.touch-btn.gas-btn {
  width: 82px;
  height: 64px;
  font-size: 0.88rem;
}

.touch-btn.brake-btn {
  width: 64px;
  height: 64px;
}

.touch-btn:active,
.touch-btn.pressed {
  background: rgba(13, 148, 136, 0.78);
  border-color: #2dd4bf;
  transform: scale(0.95);
  box-shadow: 0 0 14px rgba(45, 212, 191, 0.6);
}

.touch-btn.go {
  background: rgba(5, 150, 105, 0.68);
  border-color: #34d399;
}

.touch-btn.warn {
  height: 46px;
  border-color: #facc15;
  color: #facc15;
}

.touch-btn.accent {
  height: 46px;
  border-color: #38bdf8;
  color: #38bdf8;
}

/* ===================================================================
   SMARTPHONE & TABLET ADAPTIVE LAYOUT (Zero Overlap in Portrait & Landscape)
   =================================================================== */
@media (pointer: coarse), (max-width: 920px) {
  /* Respect notches / Dynamic Island / home indicator bars */
  .top-bar {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    gap: 6px;
    flex-wrap: wrap;
  }

  /* Compact School Brand Card */
  .brand-card {
    padding: 5px 8px;
    max-width: 205px;
  }
  .school-crest svg {
    width: 24px;
    height: 27px;
  }
  .school-name {
    font-size: 0.74rem;
  }
  .zone-label {
    font-size: 0.5rem;
    padding: 1px 4px;
  }
  .zone-name {
    font-size: 0.62rem;
    max-width: 125px;
  }

  /* Compact Top-Center Telemetry & Mirror */
  .mirror-frame {
    width: 140px;
    height: 34px;
  }
  .telemetry-card {
    padding: 4px 8px;
  }
  .telemetry-row {
    gap: 5px;
  }
  .telemetry-box {
    min-width: 34px;
  }
  .telemetry-box.wide {
    min-width: 58px;
  }
  .t-label {
    font-size: 0.48rem;
  }
  .t-value {
    font-size: 0.82rem;
  }
  .checkpoint-bar {
    display: none;
  }

  /* Compact Top-Right Navigation */
  .nav-card {
    padding: 5px 7px;
    gap: 4px;
  }
  .nav-tab {
    padding: 5px 8px;
    font-size: 0.64rem;
  }
  .icon-pill {
    padding: 4px 7px;
    font-size: 0.6rem;
  }

  /* Move Minimap to Top-Left (below Top Bar) so Bottom-Left is 100% free for Left Steering Thumb */
  .minimap-card {
    top: calc(68px + env(safe-area-inset-top, 0px));
    bottom: auto;
    left: calc(8px + env(safe-area-inset-left, 0px));
    padding: 5px 6px;
  }
  .minimap-header {
    font-size: 0.5rem;
    margin-bottom: 3px;
  }
  .minimap-legend {
    display: none;
  }
  #minimap-canvas {
    width: 96px;
    height: 96px;
  }

  /* Move Digital Speedometer to Bottom-Center between Left & Right Thumb Pads */
  .speedo-card {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    min-width: 175px;
    max-width: 215px;
    padding: 6px 10px;
    z-index: 16;
  }
  .gear-badge {
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
  }
  .speed-val {
    font-size: 1.65rem;
  }
  .speed-unit {
    font-size: 0.54rem;
  }
  .controls-mini {
    display: none;
  }
  .boost-status {
    font-size: 0.55rem;
  }
  .quick-env-bar {
    margin-top: 4px;
    padding-top: 4px;
    gap: 3px;
  }
  .quick-env-bar .chip-btn {
    padding: 3px 4px;
    font-size: 0.52rem;
  }

  /* Drone 12-Photo Sidebar becomes a Sleek Bottom Swipe Sheet on Smartphones */
  .drone-sidebar {
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    width: auto;
    padding: 8px 10px;
    z-index: 22;
  }
  .preset-grid {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .preset-btn {
    flex: 0 0 auto;
    min-width: 155px;
    scroll-snap-align: start;
    padding: 7px 9px;
    font-size: 0.66rem;
  }
  .drone-sidebar-hint {
    margin-top: 4px;
    padding-top: 4px;
    font-size: 0.56rem;
    text-align: center;
  }

  /* Reference Photo PiP Card docks cleanly at Top-Right below Top Bar in Drone Mode */
  .photo-pip {
    top: calc(68px + env(safe-area-inset-top, 0px));
    bottom: auto;
    right: calc(8px + env(safe-area-inset-right, 0px));
    width: 200px;
  }
  #pip-img {
    max-height: 112px;
  }
  .pip-caption {
    display: none;
  }

  /* Scrollable Modals with Sticky Action Buttons so Start/Resume is always reachable */
  .modal-overlay {
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px));
  }
  .modal-card {
    max-height: calc(100dvh - 18px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 16px;
  }
  .modal-card h1 {
    font-size: 1.15rem;
  }
  .hub-shortcuts-bar {
    display: none;
  }
  .modal-actions {
    position: sticky;
    bottom: -14px;
    background: rgba(15, 23, 42, 0.96);
    padding: 10px 0 4px;
    margin-top: 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    z-index: 5;
  }
  .start-btn,
  .secondary-btn {
    padding: 10px 12px;
    font-size: 0.78rem;
  }
}

/* Portrait Smartphones (Narrow Width <= 600px) */
@media (max-width: 600px) {
  .hide-xs {
    display: none !important;
  }
  .top-center-cluster {
    order: 3;
    width: 100%;
    flex-direction: row;
    justify-content: center;
  }
  .mirror-wrap {
    display: none;
  }
  .telemetry-card {
    width: 100%;
    align-items: center;
  }
  .telemetry-row {
    width: 100%;
    justify-content: space-around;
  }
  .minimap-card {
    top: calc(108px + env(safe-area-inset-top, 0px));
  }
  #minimap-canvas {
    width: 78px;
    height: 78px;
  }
  .photo-pip {
    top: calc(108px + env(safe-area-inset-top, 0px));
    width: 170px;
  }
  /* Stack Speedometer cleanly above the thumb buttons on narrow portrait screens */
  .speedo-card {
    bottom: calc(136px + env(safe-area-inset-bottom, 0px));
    min-width: 185px;
  }
  .touch-btn.steer-btn {
    width: 62px;
    height: 58px;
  }
  .touch-btn.gas-btn {
    width: 74px;
    height: 58px;
  }
  .touch-btn.brake-btn {
    width: 58px;
    height: 58px;
  }
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 12px 0;
  }
  .modal-actions {
    flex-wrap: wrap;
  }
  .start-btn {
    flex: 1 1 100%;
  }
}

/* Short Landscape Smartphones (Height <= 460px, e.g. iPhone/Android in Landscape) */
@media (max-height: 460px) {
  .mirror-wrap {
    display: none;
  }
  .quick-env-bar {
    display: none;
  }
  .hub-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .hub-panel {
    padding: 8px 10px;
    gap: 6px;
  }
  .v-select-btn {
    padding: 5px 4px;
  }
  .v-icon {
    font-size: 1.05rem;
  }
}

