:root {
  color-scheme: dark;
  --bg: #091016;
  --panel: #111a20;
  --panel-2: #16232b;
  --line: rgba(255, 255, 255, 0.14);
  --text: #f3f7f8;
  --muted: #a9b8bd;
  --accent: #42d6a4;
  --accent-2: #f0c85a;
  --danger: #ff6f61;
  --politics: #7cc4ff;
  --people: #d59cff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  padding-bottom: 118px;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
}

.globe-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(66, 214, 164, 0.15), transparent 34%),
    linear-gradient(160deg, #081015 0%, #10202a 52%, #05080b 100%);
}

#globe {
  position: absolute;
  inset: 0;
}

.hud {
  position: absolute;
  left: clamp(18px, 4vw, 54px);
  top: clamp(18px, 4vw, 42px);
  width: min(520px, calc(100% - 36px));
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-row span {
  border: 1px solid var(--line);
  background: rgba(7, 13, 17, 0.68);
  padding: 8px 10px;
  border-radius: 6px;
  backdrop-filter: blur(12px);
}

.control-panel {
  min-height: 100vh;
  padding: 24px 24px 140px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.year-readout {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

#yearLabel {
  font-size: clamp(2.3rem, 7vw, 4.1rem);
  font-weight: 800;
  line-height: 0.9;
  color: var(--accent-2);
}

#eraLabel {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

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

.timeline-bar {
  position: fixed;
  z-index: 12;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 10px;
  padding: 16px clamp(18px, 4vw, 54px) 18px;
  border-top: 1px solid var(--line);
  background: rgba(9, 16, 22, 0.94);
  box-shadow: 0 -18px 45px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
}

.timeline-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.year-stepper {
  display: inline-flex;
  gap: 6px;
}

.step-button {
  width: 42px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.step-button:hover:not(:disabled) {
  border-color: rgba(66, 214, 164, 0.8);
  background: rgba(66, 214, 164, 0.14);
}

.step-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

#yearSlider {
  width: 100%;
  accent-color: var(--accent);
}

.timeline-ticks {
  position: relative;
  height: 18px;
  color: var(--muted);
  font-size: 0.74rem;
}

.timeline-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.timeline-ticks span:first-child {
  transform: translateX(0);
}

.timeline-ticks span:last-child {
  transform: translateX(-100%);
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.filter {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
}

.filter.active,
.filter:hover {
  color: var(--text);
  border-color: rgba(66, 214, 164, 0.8);
  background: rgba(66, 214, 164, 0.14);
}

.event-search {
  display: grid;
  gap: 7px;
}

.search-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.search-input {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.search-input::placeholder {
  color: rgba(178, 190, 196, 0.72);
}

.search-input:focus {
  border-color: rgba(66, 214, 164, 0.8);
  outline: none;
}

.search-clear {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 0 10px;
  font-weight: 800;
  cursor: pointer;
}

.search-clear:hover:not(:disabled),
.search-clear:focus-visible {
  color: var(--text);
  border-color: rgba(66, 214, 164, 0.8);
  outline: none;
}

.search-clear:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.panel-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.panel-section h2 {
  margin: 0 0 12px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.event-list {
  display: grid;
  gap: 9px;
}

.event-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 11px;
}

.event-item {
  cursor: pointer;
}

.event-item:hover,
.event-item:focus-visible {
  border-color: rgba(66, 214, 164, 0.8);
  background: rgba(66, 214, 164, 0.1);
  outline: none;
}

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  font-weight: 750;
}

.item-year {
  color: var(--accent-2);
  font-size: 0.82rem;
}

.item-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.event-chip {
  display: inline-flex;
  margin-top: 8px;
  color: var(--text);
  font-size: 0.72rem;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.event-source {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
}

.map-marker {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 50%;
  background: rgba(9, 16, 22, 0.82);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.map-marker svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-marker:hover,
.map-marker:focus-visible {
  z-index: 2;
  outline: none;
  border-color: var(--accent);
  transform: translate(-50%, -50%) scale(1.12);
}

.marker-conflict {
  color: var(--danger);
}

.marker-politics {
  color: var(--politics);
}

.marker-people {
  color: var(--people);
}

.marker-voyage {
  color: var(--accent);
}

.marker-ship,
.marker-crown,
.marker-flag {
  color: var(--accent-2);
}

.tooltip {
  position: fixed;
  z-index: 10;
  width: min(300px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 16, 22, 0.94);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  opacity: 0;
  transform: translate(12px, 12px);
  transition: opacity 120ms ease;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip h3 {
  margin: 0 0 5px;
  font-size: 0.98rem;
}

.tooltip-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.tooltip p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.38;
}

.tooltip-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tooltip-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.tooltip-link:hover,
.tooltip-link:focus-visible {
  border-color: rgba(66, 214, 164, 0.8);
  outline: none;
}

.tooltip-link svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .globe-stage {
    min-height: 62vh;
  }

  .control-panel {
    min-height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-bottom: 140px;
  }

  h1 {
    max-width: 11ch;
  }
}

@media (max-width: 560px) {
  .control-panel {
    padding: 18px;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter:last-child {
    grid-column: span 2;
  }
}
