:root {
  --ocean-deep: #040d1a;
  --ocean-mid: #071830;
  --ocean-surface: #0a2244;
  --ocean-glow: #0d3060;
  --accent-cyan: #00e5ff;
  --accent-lime: #b0ff00;
  --accent-gold: #ffd54f;
  --accent-red: #ff4444;
  --text-primary: #e8f4fd;
  --text-muted: #6a9bbf;
  --border: rgba(0, 180, 255, 0.15);
  --card-bg: rgba(7, 24, 48, 0.85);
  --panel-bg: rgba(4, 13, 26, 0.95);
}

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

body {
  background-color: var(--ocean-deep);
  color: var(--text-primary);
  font-family: 'Space Mono', monospace;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Animated ocean background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 100, 200, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 50, 120, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(0, 30, 80, 0.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Scan lines overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.03) 2px,
      rgba(0, 0, 0, 0.03) 4px);
  pointer-events: none;
  z-index: 1;
}

/* ========== HEADER ========== */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-family: 'Bebas Neue', cursive;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--accent-cyan);
  text-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

.logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.2);
  padding: 4px 12px;
  border-radius: 2px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
}

.dot-pulse {
  width: 6px;
  height: 6px;
  background: var(--accent-lime);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-lime);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

/* ========== LAYOUT ========== */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  padding-top: 56px;
  position: relative;
  z-index: 2;
}

/* ========== SIDEBAR ========== */
.sidebar {
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stats-row {
  display: flex;
  gap: 12px;
}

.mini-stat {
  flex: 1;
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 2px;
  text-align: center;
}

.mini-stat-value {
  font-family: 'Bebas Neue', cursive;
  font-size: 20px;
  color: var(--accent-cyan);
  line-height: 1;
}

.mini-stat-label {
  font-size: 8px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: 3px;
}

/* Probability bar */
.prob-bar-container {
  margin-top: 4px;
}

.prob-label-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.prob-bar {
  display: flex;
  height: 22px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
  gap: 1px;
}

.prob-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', cursive;
  font-size: 12px;
  letter-spacing: 1px;
  transition: opacity 0.2s;
  cursor: default;
  min-width: 18px;
}

.prob-seg:hover {
  opacity: 0.8;
}

.seg-finish {
  background: rgba(176, 255, 0, 0.25);
  color: var(--accent-lime);
  border-left: 2px solid var(--accent-lime);
}

.seg-dnf-mid {
  background: rgba(255, 68, 68, 0.20);
  color: var(--accent-red);
  border-left: 2px solid var(--accent-red);
}

.seg-dnf-late {
  background: rgba(255, 213, 79, 0.20);
  color: var(--accent-gold);
  border-left: 2px solid var(--accent-gold);
}

.prob-legend {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 9px;
  letter-spacing: 1px;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.leg-finish {
  color: var(--accent-lime);
}

.leg-dnf-mid {
  color: var(--accent-red);
}

.leg-dnf-late {
  color: var(--accent-gold);
}

.episode-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.episode-list::-webkit-scrollbar {
  width: 4px;
}

.episode-list::-webkit-scrollbar-track {
  background: transparent;
}

.episode-list::-webkit-scrollbar-thumb {
  background: var(--ocean-glow);
  border-radius: 2px;
}

.episode-card {
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--card-bg);
  position: relative;
  overflow: hidden;
}

.episode-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
  transition: background 0.2s;
}

.episode-card:hover {
  border-color: rgba(0, 229, 255, 0.3);
  background: rgba(7, 24, 48, 0.95);
}

.episode-card:hover::before {
  background: rgba(0, 229, 255, 0.4);
}

.episode-card.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.06);
}

.episode-card.active::before {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.ep-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ep-num {
  font-family: 'Bebas Neue', cursive;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.ep-status {
  font-size: 9px;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 2px;
  font-weight: 700;
}

.status-finish {
  background: rgba(176, 255, 0, 0.12);
  color: var(--accent-lime);
  border: 1px solid rgba(176, 255, 0, 0.3);
}

.status-dnf {
  background: rgba(255, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(255, 68, 68, 0.3);
}

.ep-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.ep-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ep-meta span::before {
  content: '›';
  color: var(--accent-cyan);
  opacity: 0.6;
}

.ep-waypoint-bar {
  margin-top: 10px;
  display: flex;
  gap: 3px;
  align-items: center;
}

.wp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.wp-dot.reached {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.wp-dot.finish {
  background: var(--accent-lime);
  border-color: var(--accent-lime);
  box-shadow: 0 0 4px var(--accent-lime);
}

.wp-dash {
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.wp-dash.reached {
  background: rgba(0, 229, 255, 0.4);
}

/* ========== MAIN CONTENT ========== */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== TAB NAVIGATION ========== */
.view-tabs {
  display: flex;
  align-items: center;
  height: 38px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  gap: 2px;
}

.view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
  top: 1px;
  /* align bottom border with container border */
}

.view-tab .tab-icon {
  font-size: 11px;
  opacity: 0.7;
}

.view-tab:hover {
  color: var(--text-primary);
  background: rgba(0, 229, 255, 0.04);
}

.view-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.05);
}

.view-tab.active .tab-icon {
  opacity: 1;
  text-shadow: 0 0 8px var(--accent-cyan);
}

.tab-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 8px;
}

.tab-hint {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ========== TAB PANES ========== */
.tab-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.tab-pane.hidden {
  display: none;
}

/* ========== GLOBE (unchanged, now inside tab-pane) ========== */
.globe-container {
  flex: 1;
  position: relative;
  background: #040d1a;
  min-height: 0;
}

#plotly-globe {
  width: 100%;
  height: 100%;
}

/* ========== STATS PANEL ========== */
.stats-panel {
  height: 110px;
  border-top: 1px solid var(--border);
  background: var(--panel-bg);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 0;
  flex-shrink: 0;
}

.stat-block {
  flex: 1;
  text-align: center;
  padding: 0 20px;
  border-right: 1px solid var(--border);
}

.stat-block:last-child {
  border-right: none;
}

.stat-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  font-family: 'Bebas Neue', cursive;
  font-size: 32px;
  letter-spacing: 2px;
  line-height: 1;
  color: var(--text-primary);
}

.stat-value.highlight {
  color: var(--accent-cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}

.stat-value.good {
  color: var(--accent-lime);
}

.stat-value.warn {
  color: var(--accent-gold);
}

.stat-value.bad {
  color: var(--accent-red);
}

.stat-unit {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: 3px;
}

.gate-indicators {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

.gate-chip {
  font-size: 8px;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.gate-chip.passed {
  background: rgba(0, 229, 255, 0.1);
  border-color: rgba(0, 229, 255, 0.3);
  color: var(--accent-cyan);
}

/* Episode title overlay */
.ep-title-overlay {
  position: absolute;
  top: 16px;
  left: 24px;
  z-index: 10;
  pointer-events: none;
}

.ep-title-label {
  font-family: 'Bebas Neue', cursive;
  font-size: 38px;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
}

.ep-title-sub {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent-cyan);
  opacity: 0.8;
}

/* Loading state */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ocean-deep);
  z-index: 20;
  transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-ring {
  width: 60px;
  height: 60px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Compass decoration */
.compass {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  opacity: 0.2;
  z-index: 10;
  pointer-events: none;
}

/* Season badge */
.season-badge {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 10;
  background: rgba(4, 13, 26, 0.8);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
}

.season-badge span {
  display: block;
  font-family: 'Bebas Neue', cursive;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--accent-gold);
  line-height: 1;
  margin-top: 2px;
}

/* ========== VIDEO CONTAINER ========== */
.video-container {
  flex: 1;
  position: relative;
  background: #040d1a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  /* Tint the native controls to match dark theme on supported browsers */
  color-scheme: dark;
}

/* Season badge variant for video */
.video-season-badge {
  position: absolute;
  top: 16px;
  right: 24px;
  z-index: 10;
  background: rgba(4, 13, 26, 0.8);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.video-season-badge span {
  display: block;
  font-family: 'Bebas Neue', cursive;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--accent-gold);
  line-height: 1;
  margin-top: 2px;
}

/* Video missing overlay */
.video-missing-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--ocean-deep);
  z-index: 30;
  gap: 12px;
  pointer-events: none;
}

.video-missing-overlay.visible {
  display: flex;
}

.video-missing-icon {
  font-size: 48px;
  color: var(--text-muted);
  opacity: 0.3;
}

.video-missing-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--text-muted);
  opacity: 0.6;
}

.video-missing-sub {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  opacity: 0.5;
  text-align: center;
  max-width: 340px;
  line-height: 1.8;
}

.video-missing-sub code {
  color: var(--accent-cyan);
  opacity: 0.8;
  background: rgba(0, 229, 255, 0.07);
  padding: 1px 6px;
  border-radius: 2px;
  font-family: 'Space Mono', monospace;
}