/* WWII Pacific Theater Naval Chart & Command Dossier UI */

:root {
  /* Aged Naval Chart & Brass Command Desk Palette */
  --bg-deep: #c9b793;
  --bg-panel: rgba(245, 236, 214, 0.95);
  --bg-panel-header: #e2d4b1;
  --bg-card: rgba(237, 226, 198, 0.9);
  --bg-card-hover: rgba(226, 211, 176, 0.98);
  --border-main: #4a3823;
  --border-subtle: rgba(74, 56, 35, 0.32);
  --accent-brass: #7a5210;
  --accent-crimson: #8f1d14;
  --accent-navy: #173b5e;
  --text-main: #1f160d;
  --text-muted: #4e3b26;
  --text-dim: #6e573b;
  --shadow-panel: 0 6px 20px rgba(25, 16, 8, 0.36), inset 0 0 14px rgba(139, 105, 50, 0.14);

  /* Clean, Standard, High-Legibility Font Stacks */
  --font-hand: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-hand-zh: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  --font-typewriter: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Georgia', 'Times New Roman', 'Songti SC', 'SimSun', serif;
  --font-mono: 'Consolas', 'Courier New', 'Microsoft YaHei', monospace;
}

body.theme-dark {
  --bg-deep: #0b1520;
  --bg-panel: rgba(20, 30, 42, 0.92);
  --bg-panel-header: #162231;
  --bg-card: rgba(28, 42, 58, 0.85);
  --bg-card-hover: rgba(38, 56, 78, 0.95);
  --border-main: rgba(205, 170, 90, 0.5);
  --border-subtle: rgba(148, 163, 184, 0.25);
  --accent-brass: #e0b84c;
  --accent-crimson: #e0483e;
  --accent-navy: #60a5fa;
  --text-main: #efe6d5;
  --text-muted: #b0a48e;
  --text-dim: #7c7262;
  --shadow-panel: 0 8px 28px rgba(0, 0, 0, 0.7), inset 0 0 14px rgba(0, 0, 0, 0.4);
}

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

body, html {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--bg-deep);
  font-family: var(--font-hand), var(--font-hand-zh);
  color: var(--text-main);
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Map Viewport */
#map-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#map-container:active {
  cursor: grabbing;
}

#map-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Top Commander's Desk Header Bar */
.top-hud {
  position: absolute;
  top: 0px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 50;
  gap: 8px;
}

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

.brand-panel {
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-radius: 4px;
  padding: 5px 10px;
  box-shadow: var(--shadow-panel);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.brand-emblem {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0f1e36;
  border: 1.5px solid #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45), inset 0 0 6px rgba(251, 191, 36, 0.25);
  overflow: hidden;
}

.brand-logo-svg {
  width: 36px;
  height: 36px;
  display: block;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: nowrap;
}

.brand-titles h1 {
  font-family: var(--font-serif);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-main);
  white-space: nowrap;
}

.btn-warship-db {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 7px;
  border-radius: 3px;
  border: 1.5px solid #b45309;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #fde68a;
  font-family: var(--font-mono);
  font-size: 9.8px;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28);
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-warship-db:hover,
.btn-warship-db.active {
  background: linear-gradient(180deg, #b45309 0%, #92400e 100%);
  color: #ffffff;
  border-color: #fbbf24;
  transform: translateY(-0.5px);
}

.db-btn-icon {
  font-size: 11px;
  line-height: 1;
}

.brand-titles p {
  font-family: var(--font-hand);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent-crimson);
  margin-top: 1px;
  white-space: nowrap;
}

/* Top Sides & Factions Legend Bar */
.top-sides-legend {
  position: relative;
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-radius: 4px;
  padding: 5px 10px;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.legend-items-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.legend-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-hand);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.top-power-bar-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
}

.top-power-lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
}

.top-power-lbl.axis {
  color: var(--accent-crimson);
}

.top-power-lbl.allies {
  color: var(--accent-navy);
}

.top-bar-track {
  height: 7px !important;
  flex: 1;
  min-width: 160px;
}

/* Live Remaining Deployable Forces (Carriers & Battleships) in Top Middle Legend */
.top-naval-forces-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding-top: 3px;
  margin-top: 1px;
  border-top: 1px dashed var(--border-subtle);
  cursor: help;
}

.naval-force-group {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.naval-force-group.axis {
  border-left: 3px solid #b82924;
  color: var(--text-main);
}

.naval-force-group.allies {
  border-right: 3px solid #1e4d7b;
  color: var(--text-main);
}

.nf-side-badge {
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.2px;
}

.naval-force-group.axis .nf-side-badge,
.naval-force-group.axis strong {
  color: var(--accent-crimson);
}

.naval-force-group.allies .nf-side-badge,
.naval-force-group.allies strong {
  color: var(--accent-navy);
}

.naval-force-group strong {
  font-size: 11.5px;
  font-weight: 800;
}

.nf-sep {
  opacity: 0.45;
  font-size: 9px;
}

.nf-center-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-brass);
  text-transform: uppercase;
  white-space: nowrap;
}

/* Tab Handle Toggle Button Outside Bottom Edge of Top Box (matches Left/Right Panel Toggle Button Design) */
.naval-compare-btn-row {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: auto;
}

.btn-naval-compare {
  width: 48px;
  height: 22px;
  padding: 0;
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-top: none;
  border-radius: 0 0 5px 5px;
  color: var(--text-main);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-naval-compare:hover,
.btn-naval-compare.active {
  background: var(--bg-card-hover);
  color: var(--accent-crimson);
}

/* Direct Comparison Dropdown Roster Panel */
.naval-compare-dropdown {
  position: absolute;
  top: calc(100% + 25px);
  left: 50%;
  transform: translateX(-50%);
  width: clamp(560px, 68vw, 880px);
  max-height: calc(100vh - 205px);
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
}

.nc-dropdown-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 42px 7px 12px;
  background: var(--bg-panel-header);
  border-bottom: 1.5px solid var(--border-main);
  flex-shrink: 0;
}

.nc-header-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nc-header-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-brass);
  letter-spacing: 0.4px;
}

.nc-header-date {
  font-family: var(--font-hand);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.nc-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nc-filter-tabs {
  display: flex;
  gap: 4px;
}

.nc-tab {
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
}

.nc-tab.active {
  background: var(--accent-crimson);
  border-color: var(--accent-crimson);
  color: #fff8e7;
}

.nc-close-btn {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  border: 1px solid var(--border-main);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nc-close-btn.nc-close-top-right {
  position: absolute;
  top: 7px;
  right: 9px;
  z-index: 6;
}

.nc-close-btn:hover {
  background: var(--accent-crimson);
  color: #fff;
}

.nc-dropdown-body {
  padding: 10px 12px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 720px) {
  .naval-compare-dropdown {
    width: 94vw;
  }
  .nc-dropdown-body {
    grid-template-columns: 1fr;
  }
}

.nc-side-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.nc-side-banner {
  padding: 6px 9px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}

.nc-side-banner.axis {
  background: rgba(184, 41, 36, 0.14);
  border: 1px solid rgba(184, 41, 36, 0.45);
  border-left: 4px solid #b82924;
  color: var(--accent-crimson);
}

.nc-side-banner.allies {
  background: rgba(30, 77, 123, 0.14);
  border: 1px solid rgba(30, 77, 123, 0.45);
  border-left: 4px solid #1e4d7b;
  color: var(--accent-navy);
}

.nc-banner-filters {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nc-banner-filter-pill {
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-main);
  background: rgba(255, 255, 255, 0.55);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.14s ease;
}

.nc-banner-filter-pill:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-brass);
}

.nc-banner-filter-pill.active {
  background: var(--accent-brass);
  color: #fff;
  border-color: var(--accent-brass);
}

.nc-cat-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  color: var(--text-main);
  padding: 3px 6px;
  background: var(--bg-card);
  border-bottom: 1.5px dashed var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.nc-ships-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nc-ship-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  transition: border-color 0.15s ease;
}

.nc-ship-row:hover {
  border-color: var(--border-main);
}

.nc-ship-row.status-sunk {
  opacity: 0.68;
  background: rgba(127, 29, 29, 0.08);
  border-color: rgba(185, 28, 28, 0.35);
}

.nc-ship-row.status-repair {
  background: rgba(180, 83, 9, 0.09);
  border-color: rgba(217, 119, 6, 0.4);
}

.nc-ship-thumb-wrap {
  position: relative;
  width: 78px;
  height: 50px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border-main);
  background: #1e293b;
  flex-shrink: 0;
}

.nc-ship-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: sepia(0.14) contrast(1.06);
}

.nc-ship-row.status-sunk .nc-ship-thumb {
  filter: grayscale(0.85) contrast(1.1);
}

.nc-ship-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nc-ship-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex-wrap: wrap;
}

.nc-ship-name {
  font-family: var(--font-serif);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.nc-ship-badge {
  font-family: var(--font-mono);
  font-size: 8.2px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
}

.nc-ship-badge.deployable {
  background: rgba(21, 128, 61, 0.16);
  color: #15803d;
  border: 1px solid rgba(21, 128, 61, 0.45);
}

.nc-ship-badge.repair {
  background: rgba(180, 83, 9, 0.18);
  color: #b45309;
  border: 1px solid rgba(180, 83, 9, 0.45);
}

.nc-ship-badge.sunk {
  background: rgba(185, 28, 28, 0.18);
  color: #b91c1c;
  border: 1px solid rgba(185, 28, 28, 0.45);
}

.nc-ship-class {
  font-family: var(--font-hand);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.25;
}

.nc-ship-note {
  font-family: var(--font-hand);
  font-size: 9.8px;
  font-weight: 700;
  color: var(--accent-crimson);
  line-height: 1.25;
}

.nc-wiki-thumb-link {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  text-decoration: none;
  cursor: pointer;
}

.nc-wiki-thumb-link::after {
  content: '↗';
  position: absolute;
  right: 2px;
  bottom: 2px;
  background: rgba(15, 23, 42, 0.82);
  color: #fde68a;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1;
  padding: 1.5px 3px;
  border-radius: 2px;
  opacity: 0.78;
  transition: opacity 0.15s, background 0.15s;
}

.nc-wiki-thumb-link:hover::after {
  opacity: 1;
  background: #1d4ed8;
  color: #ffffff;
}

a.nc-wiki-link {
  text-decoration: none;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border-bottom: 1px dashed rgba(30, 64, 175, 0.55);
  transition: color 0.15s, border-color 0.15s;
}

a.nc-wiki-link:hover {
  color: #1d4ed8;
  border-bottom: 1px solid #1d4ed8;
}

.nc-wiki-ext {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 800;
  color: #1e40af;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.35);
  padding: 0 4px;
  border-radius: 2px;
  white-space: nowrap;
}

a.nc-wiki-link:hover .nc-wiki-ext {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1d4ed8;
}

/* Battle Summary Participating Ships Outcome Dropdown */
.battle-summary-dropdown {
  position: fixed;
  z-index: 95;
  width: min(860px, 88vw);
  max-height: 62vh;
  border: 2px solid #d97706;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.72), inset 0 0 0 1px rgba(245, 158, 11, 0.35);
  pointer-events: auto;
}

.bs-pause-btn {
  background: #0f172a;
  color: #fde68a;
  border: 1.5px solid #f59e0b;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  padding: 3px 9px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.bs-pause-btn:hover {
  background: #1e293b;
  color: #ffffff;
  border-color: #fbbf24;
}

.bs-pause-btn.paused {
  background: #15803d;
  color: #ffffff;
  border-color: #4ade80;
}

.bs-skip-btn {
  background: #1d4ed8;
  color: #ffffff;
  border: 1.5px solid #60a5fa;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  padding: 3px 9px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.bs-skip-btn:hover {
  background: #2563eb;
  border-color: #bfdbfe;
}

.bs-role-desc {
  font-family: var(--font-hand);
  font-size: 10px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.28;
  margin-top: 1px;
}

/* Complete WWII Pacific Warship Database Dropdown / Modal */
.warship-db-dropdown {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1040px, 92vw);
  max-height: calc(100vh - 155px);
  z-index: 98;
  border: 2px solid #b45309;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(245, 158, 11, 0.35);
  pointer-events: auto;
}

.db-filter-tabs {
  flex-wrap: wrap;
}

.db-search-wrap {
  display: flex;
  align-items: center;
}

.db-search-input {
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--border-main);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-main);
  font-family: var(--font-hand);
  font-size: 10.5px;
  font-weight: 600;
  width: 195px;
  outline: none;
  user-select: text;
}

.db-search-input:focus {
  border-color: #b45309;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.25);
  background: #ffffff;
}

.db-cat-header {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  color: #fff8e7;
  background: linear-gradient(90deg, #334155 0%, #1e293b 100%);
  border: 1px solid var(--border-main);
  border-left: 4px solid #f59e0b;
  border-radius: 3px;
  padding: 4px 8px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.db-cat-header:hover {
  background: linear-gradient(90deg, #475569 0%, #334155 100%);
}

/* Docked Operational Date & Situation Readout inside Right Panel */
.date-hud-docked {
  background: var(--bg-panel-header);
  border-bottom: 2px solid var(--border-main);
  padding: 7px 11px;
  text-align: center;
  position: relative;
  flex-shrink: 0;
}

.date-stamp-header {
  font-family: var(--font-hand);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.date-display {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-main);
  margin-top: 1px;
}

.phase-badge {
  display: inline-block;
  margin-top: 2px;
  font-family: var(--font-hand);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-crimson);
  line-height: 1.25;
}

/* Right Top Controls */
.hud-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.hud-btn {
  background: var(--bg-panel);
  border: 1.5px solid var(--border-main);
  color: var(--text-main);
  padding: 5px 8px;
  border-radius: 3px;
  font-family: var(--font-typewriter);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-panel);
}

.hud-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-crimson);
}

.hud-btn.active {
  background: var(--bg-panel-header);
  border-color: var(--accent-crimson);
  color: var(--accent-crimson);
}

/* Collapsible Left Commander's Field Notebook Sidebar (Same responsive width as Right Sidebar) */
.left-sidebar {
  position: absolute;
  top: 62px;
  left: 12px;
  width: clamp(288px, 23vw, 342px);
  max-height: calc(100vh - 165px);
  display: flex;
  flex-direction: column;
  z-index: 15;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.left-sidebar.collapsed {
  transform: translateX(calc(-100% - 16px));
}

.left-sidebar > * {
  pointer-events: auto;
}

/* Collapse / Expand Tab Handle on Right Edge of Left Sidebar */
.sidebar-collapse-btn {
  position: absolute;
  top: 8px;
  right: -26px;
  width: 26px;
  height: 48px;
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-left: none;
  border-radius: 0 5px 5px 0;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.28);
  z-index: 20;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-card-hover);
  color: var(--accent-crimson);
}

.sidebar-card {
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-radius: 3px;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Dossier Tab Bar */
.dossier-tabs {
  display: flex;
  background: var(--bg-panel-header);
  border-bottom: 1.5px solid var(--border-main);
}

.dossier-tab {
  flex: 1;
  padding: 6px 3px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-typewriter);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border-right: 1px solid var(--border-subtle);
  transition: all 0.15s;
}

.dossier-tab:last-child {
  border-right: none;
}

.dossier-tab:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.dossier-tab.active {
  background: var(--bg-panel);
  color: var(--accent-crimson);
  box-shadow: inset 0 -2px 0 var(--accent-crimson);
}

.tab-pane {
  display: none;
  padding: 8px 9px;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 215px);
  overflow-y: auto;
}

.tab-pane.active {
  display: flex;
}

.tab-pane::-webkit-scrollbar {
  width: 4px;
}
.tab-pane::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

.card-header {
  font-family: var(--font-typewriter);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--border-subtle);
  padding-bottom: 4px;
}

/* Compact Fleet Cards & Faction Breakdown */
.fleet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fleet-faction-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fleet-faction-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 3px;
  font-family: var(--font-typewriter);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border: 1px solid var(--border-subtle);
}

.fleet-faction-header.japan {
  background: rgba(184, 41, 36, 0.12);
  border-left: 3px solid #b82924;
  color: var(--text-main);
}

.fleet-faction-header.allies {
  background: rgba(30, 77, 123, 0.12);
  border-left: 3px solid #1e4d7b;
  color: var(--text-main);
}

.fleet-faction-count {
  font-family: var(--font-mono);
  font-size: 8.8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}

.fleet-faction-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fleet-card {
  padding: 6px 8px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
  box-sizing: border-box;
}

.fleet-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-main);
}

.fleet-card.selected {
  border-color: var(--accent-crimson);
  background: var(--bg-card-hover);
  box-shadow: inset 3px 0 0 var(--accent-crimson);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.fleet-card-untrack-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: -6px -8px 5px -8px;
  padding: 4px 8px;
  background: rgba(184, 41, 36, 0.14);
  border-bottom: 1px solid rgba(184, 41, 36, 0.35);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
  color: var(--accent-crimson);
}

.fleet-card.selected .fleet-card-untrack-bar {
  display: flex;
}

.fleet-untrack-pill-btn {
  padding: 1.5px 7px;
  border-radius: 3px;
  border: 1px solid var(--accent-crimson);
  background: var(--accent-crimson);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 8.8px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fleet-untrack-pill-btn:hover {
  background: #991b1b;
  border-color: #7f1d1d;
}

.fleet-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.fleet-badge-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-hand);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  min-width: 0;
  flex: 1 1 auto;
}

.fleet-active-pill {
  font-family: var(--font-mono);
  font-size: 8.8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.25;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  box-sizing: border-box;
  flex-shrink: 0;
}

.fleet-insignia {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  color: #fff;
  flex-shrink: 0;
}

.fleet-cmd-line {
  font-family: var(--font-hand);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.fleet-status-line {
  margin-top: 2px;
  font-family: var(--font-hand);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-navy);
}

/* Selected Fleet Trajectory Waypoints Drawer (expands directly below the selected fleet card) */
.fleet-trajectory-detail {
  margin-top: -5px;
  margin-bottom: 5px;
  padding: 7px 8px;
  background: var(--bg-panel);
  border: 1px solid var(--accent-crimson);
  border-top: 1px dashed var(--border-main);
  border-radius: 0 0 3px 3px;
  box-shadow: inset 3px 0 0 var(--accent-crimson);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fleet-summary-box {
  font-family: var(--font-hand);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-main);
  background: var(--bg-card);
  padding: 6px 8px;
  border-radius: 3px;
  border-left: 3px solid var(--accent-brass);
}

.waypoint-timeline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  padding-left: 10px;
  border-left: 1.5px dashed var(--border-main);
  margin-left: 4px;
}

.waypoint-item {
  padding: 4px 6px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  position: relative;
}

.waypoint-item::before {
  content: '';
  position: absolute;
  left: -15px;
  top: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 1.5px solid var(--border-main);
}

.waypoint-item.reached::before {
  background: var(--accent-crimson);
  border-color: var(--accent-crimson);
}

.waypoint-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-main);
}

.wp-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-typewriter);
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-crimson);
}

.wp-title {
  font-family: var(--font-hand);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
}

.wp-detail {
  font-family: var(--font-hand);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Balance of Power Bar & Factions */
.power-bar-container {
  margin-bottom: 4px;
}

.power-bar-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-typewriter);
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 3px;
}

.power-bar-track {
  width: 100%;
  height: 10px;
  background: #2b3a4a;
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  border: 1.5px solid var(--border-main);
}

.power-fill-axis {
  background: repeating-linear-gradient(45deg, #8f1d14, #8f1d14 4px, #b02a20 4px, #b02a20 8px);
  height: 100%;
  transition: width 0.3s ease;
}

.power-fill-allies {
  background: repeating-linear-gradient(45deg, #1b446c, #1b446c 4px, #27598a 4px, #27598a 8px);
  height: 100%;
  flex: 1;
  transition: width 0.3s ease;
}

.faction-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.faction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-hand), var(--font-hand-zh);
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.faction-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.faction-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid var(--border-main);
}

.faction-side-tag {
  font-family: var(--font-typewriter);
  font-size: 8.5px;
  padding: 1px 4px;
  border-radius: 2px;
  font-weight: 700;
}

.tag-axis {
  background: rgba(143, 29, 20, 0.16);
  color: var(--accent-crimson);
  border: 1px solid rgba(143, 29, 20, 0.4);
}

.tag-allies {
  background: rgba(23, 59, 94, 0.16);
  color: var(--accent-navy);
  border: 1px solid rgba(23, 59, 94, 0.4);
}

.tag-neutral {
  background: rgba(100, 116, 139, 0.18);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Event Feed List in Tab */
.event-filter-bar {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 2px 5px;
  font-family: var(--font-typewriter);
  font-size: 9px;
  font-weight: 700;
  border-radius: 2px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
}

.filter-pill.active {
  background: var(--accent-crimson);
  color: #fff;
  border-color: var(--accent-crimson);
}

.event-log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-log-item {
  padding: 5px 6px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-log-item:hover {
  border-color: var(--border-main);
  background: var(--bg-card-hover);
}

.event-log-item.active {
  border-color: var(--accent-crimson);
  background: var(--bg-card-hover);
  box-shadow: inset 3px 0 0 var(--accent-crimson);
}

.event-log-item.future {
  opacity: 0.55;
}

.event-log-icon {
  font-size: 13px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.event-log-info {
  overflow: hidden;
}

.event-log-title {
  font-family: var(--font-hand);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-log-date {
  font-family: var(--font-hand);
  font-size: 10px;
  color: var(--text-muted);
}

/* Map Zoom Controls */
.map-zoom-controls {
  position: absolute;
  bottom: 108px;
  right: calc(clamp(288px, 23vw, 342px) + 22px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 15;
  transition: right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.map-zoom-controls.right-collapsed {
  right: 14px;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  background: var(--bg-panel);
  border: 1.5px solid var(--border-main);
  color: var(--text-main);
  font-family: var(--font-typewriter);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-panel);
}

.zoom-btn:hover {
  background: var(--bg-card-hover);
  color: var(--accent-crimson);
}

/* Docked Right Operational Dispatch Sidebar Panel (Responsive width, collapsible) */
.right-sidebar {
  position: absolute;
  top: 62px;
  right: 12px;
  width: clamp(288px, 23vw, 342px);
  max-height: calc(100vh - 165px);
  display: flex;
  flex-direction: column;
  z-index: 20;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.right-sidebar.collapsed {
  transform: translateX(calc(100% + 16px));
}

.right-sidebar > * {
  pointer-events: auto;
}

.right-sidebar-collapse-btn {
  position: absolute;
  top: 8px;
  left: -26px;
  width: 26px;
  height: 48px;
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-right: none;
  border-radius: 5px 0 0 5px;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.28);
  z-index: 25;
}

.right-sidebar-collapse-btn:hover {
  background: var(--bg-card-hover);
  color: var(--accent-crimson);
}

.right-sidebar-card {
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-radius: 3px;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 152px);
}

.event-popup-docked {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.popup-banner {
  position: relative;
  padding: 8px 12px 7px;
  background: var(--bg-card);
  border-bottom: 1.5px dashed var(--border-main);
  flex-shrink: 0;
}

.popup-type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
  gap: 5px;
}

.popup-type-badge {
  font-family: var(--font-typewriter);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px dashed var(--accent-crimson);
  color: var(--accent-crimson);
}

.popup-scale-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 2px;
  background: rgba(143, 29, 20, 0.14);
  color: var(--accent-crimson);
  border: 1px solid rgba(143, 29, 20, 0.35);
}

.popup-scale-badge.tactical {
  background: rgba(23, 59, 94, 0.14);
  color: var(--accent-navy);
  border-color: rgba(23, 59, 94, 0.35);
}

.popup-title {
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  margin-bottom: 4px;
  word-break: break-word;
}

.popup-meta {
  font-family: var(--font-hand);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

/* Mini Tactical Battle Stage inside Popup (Auto-sizing height & flexible columns so outcome never overflows) */
.popup-tactical-stage {
  background: rgba(74, 56, 35, 0.07);
  height: auto;
  min-height: 76px;
  border-bottom: 1px dashed var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.stage-combatant {
  flex: 1 1 0;
  min-width: 0;
  max-width: 34%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stage-flag {
  font-size: 18px;
  line-height: 1.1;
}

.stage-side-name {
  font-family: var(--font-hand), var(--font-hand-zh);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  word-break: break-word;
}

.stage-commander {
  font-family: var(--font-typewriter);
  font-size: 8.5px;
  color: var(--text-muted);
  line-height: 1.25;
  margin-top: 1px;
  word-break: break-word;
}

.stage-vs-center {
  flex: 1.35 1 0;
  min-width: 96px;
  max-width: 44%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stage-anim-icon {
  font-size: 19px;
  line-height: 1.1;
  animation: clashBounce 1.2s infinite alternate ease-in-out;
}

.stage-outcome-pill {
  margin-top: 3px;
  font-family: var(--font-typewriter);
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.28;
  padding: 3px 6px;
  border-radius: 2px;
  border: 1px solid var(--border-main);
  background: var(--bg-card);
  color: var(--accent-crimson);
  text-align: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: anywhere;
}

@keyframes clashBounce {
  0% { transform: scale(0.92) rotate(-5deg); }
  100% { transform: scale(1.08) rotate(5deg); }
}

.popup-body {
  padding: 10px 13px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popup-body::-webkit-scrollbar {
  width: 4px;
}
.popup-body::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
}

.popup-phases-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 7px 8px;
}

.popup-phases-header {
  font-family: var(--font-typewriter);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-crimson);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
}

.phase-step-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 2px;
  border: 1px solid transparent;
  background: rgba(74, 56, 35, 0.05);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.phase-step-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
}

.phase-step-item.active {
  background: rgba(143, 29, 20, 0.12);
  border-color: var(--accent-crimson);
  box-shadow: inset 2.5px 0 0 var(--accent-crimson);
}

.phase-step-badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--border-main);
  color: #fff8e7;
  flex-shrink: 0;
  margin-top: 1px;
}

.phase-step-item.active .phase-step-badge {
  background: var(--accent-crimson);
}

.phase-step-text {
  font-family: var(--font-hand);
  font-size: 11px;
  line-height: 1.32;
  color: var(--text-main);
  font-weight: 600;
}

/* Key Warships Roster & Ship-to-Ship Strike Log inside Right Dispatch Panel */
.popup-roster-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.popup-roster-subtitle {
  font-family: var(--font-typewriter);
  font-size: 8.8px;
  font-weight: 800;
  color: var(--accent-navy);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.popup-roster-ships {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.popup-roster-ship-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-hand);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  background: rgba(74, 56, 35, 0.06);
  color: var(--text-main);
}

.popup-roster-ship-pill.side-japan {
  border-left: 2.5px solid #dc2626;
}

.popup-roster-ship-pill.side-usa,
.popup-roster-ship-pill.side-uk {
  border-left: 2.5px solid #2563eb;
}

.popup-roster-ship-pill.is-sunk {
  background: rgba(185, 28, 28, 0.12);
  border-color: rgba(185, 28, 28, 0.42);
  color: var(--accent-crimson);
}

.popup-roster-ship-pill.is-damaged {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.42);
}

.popup-duels-list {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
}

.popup-duel-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-hand);
  font-size: 10.2px;
  line-height: 1.28;
  padding: 3.5px 6px;
  border-radius: 2px;
  background: rgba(30, 77, 123, 0.06);
  border-left: 2.5px solid var(--accent-brass);
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s ease;
}

.popup-duel-item:hover {
  background: var(--bg-card-hover);
}

.popup-duel-phase {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 800;
  padding: 1px 3.5px;
  border-radius: 2px;
  background: var(--border-main);
  color: #fff8e7;
  flex-shrink: 0;
}

.popup-description {
  font-family: var(--font-hand);
  font-size: 12.5px;
  line-height: 1.52;
  color: var(--text-main);
}

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

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 6px 8px;
}

.stat-box.axis-box {
  border-left: 3px solid #8f1d14;
}

.stat-box.allies-box {
  border-left: 3px solid #173b5e;
}

.stat-box-label {
  font-family: var(--font-hand);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-box-value {
  font-family: var(--font-hand);
  font-size: 11.5px;
  color: var(--text-main);
  line-height: 1.35;
}

.popup-significance {
  background: rgba(122, 82, 16, 0.1);
  border-left: 3px solid var(--accent-brass);
  padding: 6px 9px;
}

.significance-label {
  font-family: var(--font-hand);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-brass);
  margin-bottom: 2px;
}

.significance-text {
  font-family: var(--font-hand);
  font-size: 12px;
  line-height: 1.42;
  color: var(--text-main);
}

.popup-footer {
  padding: 7px 13px;
  border-top: 1px dashed var(--border-subtle);
  background: var(--bg-panel-header);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.popup-action-btn {
  flex: 1;
  padding: 5px 8px;
  border-radius: 2px;
  border: 1.5px solid var(--border-main);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-typewriter);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.popup-action-btn.primary {
  background: #8f1d14;
  border-color: #5c110c;
  color: #fff8e7;
}

/* Bottom Timeline Control Dock */
.timeline-dock {
  position: fixed;
  bottom: 0px;
  left: 12px;
  right: 12px;
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  border-radius: 3px;
  padding: 7px 14px max(9px, env(safe-area-inset-bottom, 9px));
  box-shadow: var(--shadow-panel);
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.timeline-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.timeline-left-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.timeline-center-date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 3px 13px;
  height: 30px;
  box-sizing: border-box;
  border-radius: 2px;
  border: 1.5px solid var(--border-main);
  background: var(--bg-card);
  color: var(--accent-crimson);
  font-family: var(--font-typewriter);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.timeline-center-date:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-crimson);
}

.timeline-date-icon {
  font-size: 12px;
  line-height: 1;
}

.ctrl-btn {
  background: var(--bg-card);
  border: 1.5px solid var(--border-main);
  color: var(--text-main);
  height: 30px;
  padding: 0 10px;
  border-radius: 2px;
  font-family: var(--font-typewriter);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.ctrl-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-crimson);
}

.play-btn {
  background: #8f1d14;
  border-color: #4a0e09;
  color: #fff8e7;
  padding: 0 14px;
  font-size: 11px;
  min-width: 110px;
}

.speed-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.speed-label {
  font-family: var(--font-typewriter);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.speed-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 3px 7px;
  border-radius: 2px;
  font-family: var(--font-typewriter);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.speed-btn.active {
  background: var(--accent-crimson);
  border-color: var(--accent-crimson);
  color: #fff;
}

.timeline-toggles {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-hand);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-label input {
  accent-color: var(--accent-crimson);
  cursor: pointer;
}

/* Slider & Event Markers Track */
.slider-wrapper {
  position: relative;
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
}

#time-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 7px;
  background: var(--bg-card);
  border-radius: 2px;
  outline: none;
  border: 1.5px solid var(--border-main);
  cursor: pointer;
  z-index: 4;
  position: relative;
}

#time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 20px;
  border-radius: 2px;
  background: var(--accent-crimson);
  border: 1.5px solid #fff8e7;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  cursor: grab;
}

.slider-progress-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 7px;
  background: linear-gradient(90deg, #8f1d14 0%, #9c6b26 45%, #173b5e 100%);
  border-radius: 2px 0 0 2px;
  pointer-events: none;
  z-index: 3;
}

.timeline-markers {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
}

.timeline-event-pip {
  position: absolute;
  top: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translateX(-50%);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease;
  border: 1px solid #24190e;
}

.timeline-event-pip:hover {
  transform: translateX(-50%) scale(1.65);
  z-index: 10;
}

.timeline-event-pip.pip-major {
  width: 9px;
  height: 9px;
  top: 1px;
  border: 1.5px solid #fff8e7;
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-hand);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 2px;
  margin-top: -3px;
}

/* Tooltip on hover (Rich WWII Naval Intelligence & Archival Photo Dossier) */
#map-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--bg-panel);
  border: 2px solid var(--border-main);
  padding: 9px 11px;
  border-radius: 4px;
  font-family: var(--font-hand);
  font-size: 12px;
  line-height: 1.38;
  color: var(--text-main);
  z-index: 110;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 248, 230, 0.35);
  opacity: 0;
  transition: opacity 0.12s ease;
  max-width: 375px;
  min-width: 280px;
  box-sizing: border-box;
  overflow: hidden;
}

#map-tooltip.visible {
  opacity: 1;
}

#map-tooltip img {
  max-width: 100%;
  box-sizing: border-box;
}

/* Individual Battle Warship Hover Tooltip Card (.rt-*) */
.rt-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1.5px solid var(--border-subtle);
  padding-bottom: 7px;
  margin-bottom: 7px;
}

.rt-photo-wrap {
  width: 112px;
  height: 74px;
  border-radius: 3px;
  overflow: hidden;
  border: 1.5px solid var(--border-main);
  background: #1e293b;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
}

.rt-photo {
  width: 112px;
  height: 74px;
  max-width: 112px;
  max-height: 74px;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 2px;
  border: 1.5px solid var(--border-main);
  background: #1e293b;
  flex-shrink: 0;
  filter: sepia(0.12) contrast(1.06);
}

.rt-photo-wrap .rt-photo {
  border: none;
  border-radius: 0;
}

.rt-title-col {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.rt-kicker {
  font-family: var(--font-typewriter);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.25;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.22;
  word-break: break-word;
}

.rt-sub {
  font-size: 10.5px;
  margin-top: 3px;
  line-height: 1.2;
}

.rt-body {
  font-size: 11.5px;
  line-height: 1.38;
  color: var(--text-main);
}

.tt-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1.5px solid var(--border-subtle);
  padding-bottom: 5px;
  margin-bottom: 6px;
}

.tt-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.22;
}

.tt-subtitle {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.tt-badge {
  font-family: var(--font-typewriter);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 2px;
  background: rgba(143, 29, 20, 0.14);
  color: var(--accent-crimson);
  border: 1px solid rgba(143, 29, 20, 0.35);
  white-space: nowrap;
  flex-shrink: 0;
}

.tt-wp-status {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-navy);
  padding: 4px 7px;
  border-radius: 2px;
  font-size: 11px;
  margin-bottom: 7px;
}

.tt-sec-label {
  font-family: var(--font-typewriter);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-crimson);
  margin-bottom: 3px;
}

.tt-commander-box {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 5px 7px;
  margin-bottom: 7px;
}

.tt-cmd-photo {
  width: 52px;
  height: 64px;
  object-fit: cover;
  object-position: top center;
  border-radius: 2px;
  border: 1.5px solid var(--border-main);
  background: #2b2116;
  flex-shrink: 0;
  filter: sepia(0.18) contrast(1.06);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.tt-cmd-info {
  flex: 1;
  min-width: 0;
}

.tt-cmd-name {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.tt-cmd-role {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.25;
}

.tt-ships-flagships {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
  line-height: 1.3;
}

/* Highlighted Flagship Hero Spotlight in Hover Tooltip & Sidebar */
.tt-flagship-spotlight {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.16), rgba(30, 22, 14, 0.08));
  border: 1.5px solid #b45309;
  border-radius: 3px;
  padding: 5px;
  margin-bottom: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.tt-flagship-photo-wrap {
  position: relative;
  width: 132px;
  height: 78px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border-main);
  background: #1e293b;
  flex-shrink: 0;
}

.tt-flagship-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: sepia(0.14) contrast(1.08);
}

.tt-flagship-ribbon {
  position: absolute;
  top: 3px;
  left: 3px;
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fffbeb;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.tt-flagship-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.tt-flagship-badge {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 800;
  color: #b45309;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(180, 83, 9, 0.45);
  padding: 1px 5px;
  border-radius: 2px;
  margin-bottom: 3px;
}

.tt-flagship-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
  word-break: break-word;
}

.tt-flagship-type {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
  word-break: break-word;
}

.fleet-summary-box .tt-flagship-spotlight {
  align-items: center;
  gap: 9px;
  padding: 6px;
}

.fleet-summary-box .tt-flagship-photo-wrap {
  width: 92px;
  height: 60px;
}

.fleet-summary-box .tt-flagship-info {
  flex: 1 1 auto;
  min-width: 0;
}

/* Flagship Mini Strip inside Left Sidebar Fleet Cards */
.fleet-flagship-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  padding: 4px 5px;
  background: rgba(180, 83, 9, 0.10);
  border: 1px solid rgba(180, 83, 9, 0.38);
  border-radius: 3px;
}

.fleet-flagship-thumb {
  width: 58px;
  height: 36px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--border-main);
  background: #1e293b;
  flex-shrink: 0;
  filter: sepia(0.15) contrast(1.06);
}

.fleet-flagship-meta {
  flex: 1;
  min-width: 0;
}

.fleet-flagship-tag {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 800;
  color: #b45309;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fleet-flagship-title {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tt-ships-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 5px;
}

.tt-ship-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tt-ship-photo {
  width: 100%;
  height: 60px;
  object-fit: cover;
  object-position: center;
  background: #1e293b;
  border-bottom: 1px solid var(--border-subtle);
  filter: sepia(0.16) contrast(1.06);
}

.tt-ship-meta {
  padding: 3px 4px;
}

.tt-ship-name {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.18;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tt-ship-type {
  font-size: 8.8px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tt-event-photo-wrap {
  position: relative;
  width: 100%;
  height: 152px;
  border-radius: 3px;
  overflow: hidden;
  border: 1.5px solid var(--border-main);
  background: #1c1610;
  margin-bottom: 6px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

.tt-event-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: sepia(0.15) contrast(1.06);
}

.tt-event-photo-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(15, 10, 6, 0.88));
  color: #f8f1e0;
  font-family: var(--font-typewriter);
  font-size: 8.5px;
  font-weight: 700;
  padding: 10px 6px 3px;
  letter-spacing: 0.04em;
}

.tt-event-outcome {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-crimson);
  padding: 4px 7px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
}

.tt-footer-hint {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  text-align: right;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 3px;
  margin-top: 3px;
}

/* ==================== TABLET & MOBILE RESPONSIVE OPTIMIZATIONS ==================== */
/* Touch-device ergonomics (iPad, Android Tablets, Phones) while preserving desktop 100% */
@media (pointer: coarse) {
  .slider-wrapper {
    height: 32px;
    touch-action: pan-x;
  }

  #time-slider {
    height: 9px;
    touch-action: pan-x;
  }

  #time-slider::-webkit-slider-thumb {
    width: 22px;
    height: 26px;
    border-radius: 3px;
  }

  .timeline-event-pip {
    width: 10px;
    height: 10px;
    top: 1px;
  }

  .timeline-event-pip.pip-major {
    width: 12px;
    height: 12px;
    top: 0px;
  }

  .zoom-btn {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .sidebar-collapse-btn,
  .right-sidebar-collapse-btn {
    width: 30px;
    height: 54px;
    font-size: 14px;
  }
}

/* Tablet Landscape, Touch Devices & Compact Screens (<= 1440px or coarse pointer) */
@media (max-width: 1440px), (pointer: coarse) {
  .top-hud {
    left: 6px;
    right: 6px;
    gap: 5px;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: space-between;
  }

  .brand-panel {
    padding: 4px 7px;
    gap: 6px;
    flex-shrink: 0;
  }

  .brand-emblem {
    width: 28px;
    height: 28px;
  }

  .brand-logo-svg {
    width: 26px;
    height: 26px;
  }

  .brand-titles h1 {
    font-size: 12px;
  }

  .brand-titles p {
    display: none;
  }

  .btn-warship-db {
    padding: 2px 6px;
    font-size: 9px;
  }

  .top-sides-legend {
    padding: 3px 6px;
    gap: 2px;
    flex: 0 1 auto;
    min-width: 0;
  }

  .legend-items-row {
    gap: 4px;
  }

  .legend-chip {
    font-size: 9.2px;
    padding: 1px 4px;
  }

  .naval-force-group {
    font-size: 9.2px;
    padding: 1px 5px;
    gap: 3px;
  }

  .nf-center-tag {
    display: none;
  }

  .hud-actions {
    gap: 4px;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .hud-btn {
    padding: 4px 6px;
    font-size: 9.5px;
  }

  .left-sidebar {
    top: 56px;
    left: 6px;
    width: clamp(256px, 28vw, 310px);
    max-height: calc(100dvh - 154px);
  }

  .left-sidebar.collapsed {
    transform: translateX(calc(-100% - 12px));
  }

  .tab-pane {
    max-height: calc(100dvh - 202px);
  }

  .right-sidebar {
    top: 56px;
    right: 6px;
    width: clamp(256px, 28vw, 310px);
    max-height: calc(100dvh - 154px);
  }

  .right-sidebar-card {
    max-height: calc(100dvh - 154px);
  }

  .map-zoom-controls {
    bottom: 102px;
    right: calc(clamp(256px, 28vw, 310px) + 14px);
  }

  .map-zoom-controls.right-collapsed {
    right: 10px;
  }

  .timeline-dock {
    left: 6px;
    right: 6px;
    padding: 5px 10px max(7px, env(safe-area-inset-bottom, 7px));
    gap: 3px;
  }

  .timeline-controls-row {
    gap: 6px;
  }

  .ctrl-btn {
    height: 27px;
    padding: 0 8px;
    font-size: 10px;
  }

  .play-btn {
    min-width: 92px;
    padding: 0 10px;
  }

  .timeline-toggles {
    gap: 7px;
    font-size: 10.5px;
  }
}

/* Portrait Tablet & Narrow Screens (<= 920px): Pin Language/Battles/Audio to Row 1 Top-Right, Legend on Row 2 */
@media (max-width: 920px) {
  .top-hud {
    left: 5px;
    right: 5px;
    gap: 4px;
    flex-wrap: wrap;
  }

  .brand-panel {
    order: 1;
    padding: 3px 7px;
    flex: 0 1 auto;
    min-width: 0;
  }

  .hud-actions {
    order: 2;
    margin-left: auto;
    gap: 5px;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .hud-btn {
    padding: 4px 7px;
    font-size: 10px;
  }

  .top-sides-legend {
    order: 3;
    flex: 1 1 100%;
    padding: 3px 8px;
  }

  .legend-items-row {
    display: none;
  }

  .left-sidebar {
    top: 84px;
    left: 6px;
    width: clamp(260px, 34vw, 310px);
    max-height: calc(100dvh - 186px);
    z-index: 38;
  }

  .left-sidebar.collapsed {
    transform: translateX(calc(-100% - 8px));
  }

  .right-sidebar {
    top: 84px;
    right: 6px;
    width: clamp(260px, 34vw, 310px);
    max-height: calc(100dvh - 186px);
    z-index: 38;
  }

  .right-sidebar-card {
    max-height: calc(100dvh - 186px);
  }
}

/* Mobile Phones (<= 640px) */
@media (max-width: 640px) {
  .top-hud {
    left: 4px;
    right: 4px;
    gap: 3px;
  }

  .brand-titles h1 {
    font-size: 11px;
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hud-actions {
    gap: 3px;
  }

  .hud-btn {
    padding: 3px 5px;
    font-size: 8.8px;
  }

  .map-zoom-controls {
    bottom: 118px;
    right: 8px !important;
  }

  .timeline-dock {
    left: 4px;
    right: 4px;
    padding: 5px 8px max(7px, env(safe-area-inset-bottom, 7px));
    gap: 3px;
  }

  .timeline-toggles {
    display: none;
  }

  .timeline-ticks {
    font-size: 9.5px;
  }

  .battle-summary-dropdown,
  .warship-db-dropdown {
    width: 96vw !important;
    max-height: 70dvh !important;
  }
}

