/* ==========================================================================
   Silk Road 3D Expedition Visualizer Styles
   ========================================================================== */

:root {
  --bg-dark: #0f141c;
  --panel-bg: rgba(16, 22, 34, 0.78);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent-orange: #ff7a00;
  --accent-orange-glow: rgba(255, 122, 0, 0.4);
  --accent-cyan: #00d2ff;
  --accent-purple: #c084fc;
  --accent-green: #34d399;
  --accent-gold: #fbbf24;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: var(--bg-dark);
  color: var(--text-main);
}

#map {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
}

/* Glassmorphic Panel Styling */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* Responsive Label Visibility Helpers */
.btn-label-full,
.brand-title-full {
  display: inline;
}

.btn-label-short,
.brand-title-short {
  display: none;
}

/* Top Navigation Bar */
.top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 26px;
  background: rgba(255, 122, 0, 0.15);
  border: 1px solid var(--accent-orange);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-info h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtitle-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0, 210, 255, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.35);
  text-transform: uppercase;
}

.trip-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.trip-meta .highlight {
  color: var(--accent-orange);
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

select {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

select option {
  background: #182234;
  color: #fff;
}

.style-pill-group {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
  border: 1px solid var(--panel-border);
}

.style-pill {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.style-pill.active {
  background: var(--accent-orange);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-orange-glow);
}

.lang-pill-group {
  margin-left: 2px;
}

.lang-pill-group .style-pill {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn.active {
  background: rgba(0, 210, 255, 0.2);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* Mobile HUD Backdrop Overlay */
.hud-backdrop {
  display: none;
}

/* Mobile Sheet Drag Handle & Close Button (hidden on desktop) */
.hud-sheet-handle-bar {
  display: none;
}

/* Stage Telemetry HUD (Left on Desktop, Bottom Sheet on Mobile) */
.hud-panel {
  position: absolute;
  top: 92px;
  left: 16px;
  width: 370px;
  max-height: calc(100% - 200px);
  padding: 20px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.hud-panel.desktop-collapsed {
  transform: translateX(calc(-100% - 30px));
  opacity: 0;
  pointer-events: none;
}

.hud-panel::-webkit-scrollbar {
  width: 5px;
}
.hud-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

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

.day-badge {
  background: var(--accent-orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px var(--accent-orange-glow);
}

.mode-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.date-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.stage-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
}

.stage-title-main {
  display: block;
}

.stage-subtitle {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.3;
}

.stage-location-link {
  color: #ffffff;
  text-decoration: none;
  border-bottom: 1.5px dashed rgba(255, 122, 0, 0.45);
  padding: 0 1px;
  border-radius: 2px;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, text-shadow 0.18s ease;
  cursor: pointer;
  display: inline-block;
}

.stage-location-link:hover {
  color: var(--accent-orange);
  border-bottom-style: solid;
  border-bottom-color: var(--accent-orange);
  background: rgba(255, 122, 0, 0.12);
  text-shadow: 0 0 12px rgba(255, 122, 0, 0.45);
  transform: translateY(-1px);
}

.stage-location-link:active {
  transform: translateY(0);
  background: rgba(255, 122, 0, 0.25);
}

.stage-country-flag {
  display: inline-block;
  user-select: none;
}

.stage-route {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -2px;
}

.stage-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  transition: all 0.2s ease;
}

.stage-link-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stage-link-btn.link-ig {
  color: #f472b6;
  border-color: rgba(244, 114, 182, 0.35);
  background: rgba(244, 114, 182, 0.12);
}

.stage-link-btn.link-ig:hover {
  background: rgba(244, 114, 182, 0.24);
  border-color: #f472b6;
  color: #fff;
}

.stage-link-btn.link-komoot {
  color: #a3e635;
  border-color: rgba(163, 230, 53, 0.35);
  background: rgba(163, 230, 53, 0.12);
}

.stage-link-btn.link-komoot:hover {
  background: rgba(163, 230, 53, 0.24);
  border-color: #a3e635;
  color: #fff;
}

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

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.stat-val small {
  font-size: 11px;
  color: var(--text-muted);
}

/* Elevation Chart */
.elevation-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.profile-hover-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-orange);
}

.svg-chart-wrap {
  width: 100%;
  height: 75px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

#elevation-chart {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Narrative & Photos */
.narrative-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.journal-entries-wrap,
.narrative-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 2px;
}

.journal-entries-wrap::-webkit-scrollbar,
.narrative-text::-webkit-scrollbar {
  width: 4px;
}

.journal-entries-wrap::-webkit-scrollbar-thumb,
.narrative-text::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.journal-entry-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--accent-orange);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.journal-entry-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 122, 0, 0.35);
  border-left-color: #ff9d3b;
}

.journal-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.journal-day-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 122, 0, 0.16);
  border: 1px solid rgba(255, 122, 0, 0.35);
  padding: 2px 7px;
  border-radius: 4px;
}

.journal-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-orange);
  box-shadow: 0 0 5px var(--accent-orange-glow);
}

.journal-day-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ff9d3b;
  text-transform: uppercase;
}

.journal-entry-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.journal-entry-ig-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(244, 114, 182, 0.12);
  border: 1px solid rgba(244, 114, 182, 0.28);
  color: #f472b6;
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  transition: all 0.2s ease;
}

.journal-entry-ig-link:hover {
  background: rgba(244, 114, 182, 0.25);
  border-color: #f472b6;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(244, 114, 182, 0.3);
}

.journal-entry-ig-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  flex-shrink: 0;
}

.journal-entry-body {
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
  word-break: break-word;
}

.journal-entry-body p {
  margin: 0 0 6px 0;
}

.journal-entry-body p:last-child {
  margin-bottom: 0;
}

.journal-empty-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border-left: 2px solid rgba(255, 255, 255, 0.15);
  margin: 0;
}

.photo-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.photo-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.photo-thumb:hover {
  transform: scale(1.06);
  border-color: var(--accent-orange);
}

/* Bottom Playback Dock */
.bottom-controller {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px;
  z-index: 10;
}

/* Timeline Navigation Scrubber */
.timeline-slider-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 2px;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
  padding: 0 4px;
  line-height: 1.2;
}

.start-label, .end-label {
  white-space: nowrap;
}

.current-label {
  font-weight: 600;
  color: #fff;
  font-family: var(--font-mono);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

#day-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
  position: relative;
  margin: 6px 0 2px 0;
}

#day-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-orange);
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px var(--accent-orange-glow);
  cursor: pointer;
  transition: transform 0.1s;
}

#day-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-orange);
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px var(--accent-orange-glow);
  cursor: pointer;
}

#day-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Playback Controls Row - Uniform 38px Button Heights */
.playback-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: #fff;
  border-radius: 8px;
  padding: 0 14px;
  height: 38px;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.primary-btn {
  background: var(--accent-orange);
  color: #fff;
  border-color: var(--accent-orange);
  font-weight: 600;
  box-shadow: 0 2px 10px var(--accent-orange-glow);
  padding: 0 18px;
  height: 38px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn:hover {
  background: #ff8c1a;
}

.hud-toggle-btn {
  background: rgba(255, 122, 0, 0.15);
  border: 1px solid rgba(255, 122, 0, 0.4);
  color: #fff;
  font-weight: 600;
  padding: 0 14px;
  height: 38px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hud-toggle-btn:hover {
  background: rgba(255, 122, 0, 0.3);
  border-color: var(--accent-orange);
}

.hud-toggle-btn.active {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  box-shadow: 0 2px 8px var(--accent-orange-glow);
}

.ctrl-btn:disabled,
.primary-btn:disabled,
button:disabled {
  opacity: 0.35;
  cursor: not-allowed !important;
  pointer-events: none;
  filter: grayscale(0.8);
  box-shadow: none !important;
}

.playback-options {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speed-toggle-group {
  display: inline-flex;
  align-items: stretch;
  height: 38px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--panel-border);
}

.speed-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0 9px;
  height: 100%;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.speed-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.speed-btn.active {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 700;
}

.playback-controls-row .icon-btn {
  height: 38px;
  box-sizing: border-box;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* Stage Start & Finish Pins */
.stage-pin {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 5;
}

.stage-pin:hover {
  transform: scale(1.22);
}

.pin-start {
  background: rgba(34, 197, 94, 0.95);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.8), 0 4px 10px rgba(0, 0, 0, 0.5);
}

.pin-finish {
  background: rgba(239, 68, 68, 0.95);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.8), 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* Moving Marker Styling */
.rider-marker {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 122, 0, 0.9);
  border: 2px solid #ffffff;
  box-shadow: 0 0 16px rgba(255, 122, 0, 0.8), 0 0 4px rgba(0, 0, 0, 0.6);
  font-size: 18px;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease-out;
}

.rider-marker.mode-ferry,
.rider-marker.mode-plane,
.rider-marker.mode-train,
.rider-marker.mode-bus,
.rider-marker.mode-car,
.rider-marker.mode-transit,
.rider-marker.mode-transfer {
  background: rgba(56, 189, 248, 0.9);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.8), 0 0 4px rgba(0, 0, 0, 0.6);
}

.rider-marker.mode-rest {
  background: rgba(148, 163, 184, 0.9);
  box-shadow: 0 0 16px rgba(148, 163, 184, 0.8);
}

/* Pulsing aura */
.rider-marker::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  opacity: 0.6;
  animation: pulse-ring 1.8s infinite;
  z-index: -1;
}

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}


/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.lightbox-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-content {
  max-width: 90%;
  max-height: 80%;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 32px;
  color: #fff;
  font-size: 38px;
  font-weight: 700;
  cursor: pointer;
}

.lightbox-caption {
  margin-top: 14px;
  color: #e2e8f0;
  font-size: 14px;
}

/* ==========================================================================
   Overview Mode Styles
   ========================================================================== */

/* Hide HUD and bottom dock in overview mode */
body.overview-mode .hud-panel {
  display: none !important;
}

body.overview-mode .bottom-controller {
  display: none !important;
}

/* Mobile Stage Quick-Info Banner (Desktop hidden) */
.mobile-stage-banner {
  display: none !important;
}

/* Overview Banner at top center */
.overview-banner {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 16px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  z-index: 20;
  color: #ffffff;
  border-radius: 30px;
  border: 1px solid rgba(255, 122, 0, 0.4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
  from {
    transform: translate(-50%, -15px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

body.overview-mode .overview-banner {
  display: flex !important;
}

.banner-close-btn {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.banner-close-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.5);
}

/* Overview Map Popup Styling */
.overview-map-popup {
  z-index: 50;
  pointer-events: none;
}

.overview-map-popup .maplibregl-popup-content {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 122, 0, 0.5);
  border-radius: 8px;
  padding: 6px 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.overview-map-popup .maplibregl-popup-tip {
  border-top-color: rgba(15, 23, 42, 0.95) !important;
}

.overview-popup-card {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.overview-popup-card .popup-title {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}

.overview-popup-card .popup-days {
  font-size: 11px;
  color: var(--accent-orange);
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ==========================================================================
   Mobile & Tablet Responsive Styles (<= 768px)
   ========================================================================== */

@media (max-width: 768px) {
  /* Prevent horizontal bouncing and pull-down reload on mobile body */
  body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -webkit-text-size-adjust: 100%;
  }

  #map {
    touch-action: pan-x pan-y pinch-zoom;
  }

  /* Responsive Label Visibility on Mobile */
  .btn-label-full,
  .brand-title-full {
    display: none;
  }

  .btn-label-short,
  .brand-title-short {
    display: inline;
  }

  /* Compact Top Header */
  .top-bar {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    height: 48px;
    padding: 0 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    box-sizing: border-box;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .brand-info {
    min-width: 0;
    overflow: hidden;
  }

  .brand-info h1 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }

  .subtitle-badge {
    display: none;
  }

  .trip-meta {
    display: none;
  }

  .header-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
  }

  .style-pill-group {
    display: inline-flex;
    align-items: center;
    height: 32px;
    border-radius: 8px;
    padding: 2px;
    box-sizing: border-box;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
  }

  .style-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    white-space: nowrap;
    box-sizing: border-box;
    cursor: pointer;
  }

  .header-controls .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 8px;
    white-space: nowrap;
    box-sizing: border-box;
    flex-shrink: 0;
    gap: 3px;
  }

  .icon-btn {
    padding: 4px 7px;
    font-size: 11px;
    gap: 3px;
  }

  /* Mobile HUD Sheet Overlay Backdrop */
  .hud-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .hud-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* HUD Telemetry Panel as Mobile Bottom Sheet Drawer */
  .hud-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 80vh;
    max-height: 80dvh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    z-index: 60;
    padding: 10px 16px max(24px, env(safe-area-inset-bottom)) 16px;
    gap: 12px;
    transform: translateY(105%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.75);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .hud-panel.open {
    transform: translateY(0);
  }

  /* Drag Handle & Close Button in Mobile Sheet */
  .hud-sheet-handle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    width: 100%;
    height: 22px;
    margin-bottom: 2px;
  }

  .hud-drag-handle {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.35);
  }

  .hud-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
  }

  .hud-close-btn:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.92);
  }

  .stage-title {
    font-size: 17px;
    gap: 2px;
  }

  .stage-subtitle {
    font-size: 11.5px;
  }

  .stats-grid {
    gap: 6px;
  }

  .stat-card {
    padding: 6px 8px;
  }

  .stat-val {
    font-size: 15px;
  }

  .journal-entries-wrap,
  .narrative-text {
    max-height: 140px;
  }

  /* Mobile Stage Quick-Info Banner (Visible under top bar when HUD details are closed) */
  .mobile-stage-banner {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: calc(max(8px, env(safe-area-inset-top)) + 54px);
    left: 8px;
    right: 8px;
    max-width: 420px;
    margin: 0 auto;
    padding: 7px 12px;
    border-radius: 12px;
    z-index: 25;
    cursor: pointer;
    background: rgba(18, 20, 26, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.2);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-stage-banner:active {
    background: rgba(30, 35, 45, 0.95);
    transform: scale(0.98);
  }

  .msb-badge-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
  }

  .msb-badge-row .day-badge {
    font-size: 10px;
    padding: 2px 7px;
    font-weight: 700;
  }

  .msb-badge-row .date-label {
    font-size: 11px;
    color: var(--text-muted);
  }

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

  .msb-title {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
  }

  .msb-title .stage-title-main {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .msb-title .stage-location-link {
    border-bottom-width: 1px;
    padding: 0 1px;
  }

  .msb-title .stage-subtitle {
    font-size: 10.5px;
    font-weight: 400;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .msb-arrow {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-orange);
    line-height: 1;
    flex-shrink: 0;
  }

  /* When HUD drawer details are open or overview mode is active, hide mobile stage quick-info */
  body.hud-open .mobile-stage-banner,
  body.overview-mode .mobile-stage-banner {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
  }

  /* Mobile Bottom Playback Controller */
  .bottom-controller {
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 8px;
    right: 8px;
    height: auto;
    padding: 10px 12px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 40;
  }

  .timeline-slider-wrap {
    width: 100%;
    gap: 8px;
    padding-bottom: 2px;
  }

  .slider-labels {
    font-size: 11px;
    padding: 0 2px;
    margin-bottom: 2px;
  }

  .start-label, .end-label {
    white-space: nowrap;
    font-size: 10px;
    flex-shrink: 0;
  }

  .current-label {
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    text-align: center;
    padding: 0 4px;
  }

  #day-slider {
    height: 8px;
    margin: 8px 0 4px 0;
  }

  #day-slider::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  #day-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }

  .playback-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
  }

  .playback-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .playback-options {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .playback-controls-row .ctrl-btn {
    padding: 0 10px;
    font-size: 13px;
    border-radius: 8px;
    height: 38px;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .playback-controls-row .primary-btn {
    padding: 0 14px;
    font-size: 13px;
    height: 38px;
    min-width: 72px;
    box-sizing: border-box;
  }

  .playback-controls-row .hud-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 0 10px;
    height: 38px;
    box-sizing: border-box;
  }

  .playback-controls-row .speed-toggle-group {
    display: inline-flex;
    align-items: stretch;
    height: 38px;
    padding: 2px;
    box-sizing: border-box;
  }

  .playback-controls-row .speed-btn {
    padding: 0 6px;
    font-size: 10px;
    height: 100%;
    box-sizing: border-box;
  }

  .playback-controls-row .icon-btn {
    height: 38px;
    padding: 0 8px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  /* Overview Banner on Mobile */
  .overview-banner {
    top: max(56px, calc(env(safe-area-inset-top) + 52px));
    width: calc(100% - 24px);
    max-width: 380px;
    font-size: 11px;
    padding: 6px 12px;
    gap: 8px;
    justify-content: space-between;
  }

  .banner-close-btn {
    padding: 3px 8px;
    font-size: 11px;
    white-space: nowrap;
  }

  /* Lightbox on Mobile */
  .lightbox-content {
    max-width: 95vw;
    max-height: 72vh;
  }

  .lightbox-close {
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
  }
}

/* Extra Compact Phones (<= 480px, e.g. iPhone SE, mini) */
@media (max-width: 480px) {
  .brand-info h1 {
    font-size: 12.5px;
  }

  .header-controls {
    gap: 4px;
  }

  .style-pill {
    padding: 0 6px;
    font-size: 10.5px;
  }

  .lang-pill-group .style-pill {
    min-width: 24px;
    padding: 0 5px;
    font-size: 10px;
  }

  .header-controls .icon-btn {
    padding: 0 6px;
    font-size: 10.5px;
  }

  .start-label, .end-label {
    font-size: 9.5px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .slider-labels {
    justify-content: space-between;
    margin-bottom: 2px;
    padding: 0 1px;
  }

  .current-label {
    font-size: 10px;
    padding: 0 2px;
  }

  .playback-options #btn-auto-advance {
    display: none;
  }

  .playback-controls-row .ctrl-btn {
    padding: 0 8px;
    height: 36px;
    min-width: 36px;
    font-size: 12px;
  }

  .playback-controls-row .primary-btn {
    padding: 0 11px;
    height: 36px;
    min-width: 64px;
    font-size: 12px;
  }

  .playback-controls-row .hud-toggle-btn {
    padding: 0 8px;
    font-size: 11px;
    height: 36px;
  }

  .playback-controls-row .speed-toggle-group {
    height: 36px;
    padding: 2px;
  }

  .playback-controls-row .speed-btn {
    padding: 0 5px;
    font-size: 10px;
  }

  .playback-controls-row .icon-btn {
    padding: 0 7px;
    font-size: 10px;
    height: 36px;
  }
}
