:root {
  color-scheme: dark;
  --ink: #f7f0df;
  --muted: #a6acb5;
  --soft: #75818d;
  --night: #07111f;
  --night-deep: #040a12;
  --blue: #002eff;
  --yellow: #ffd100;
  --red: #ff4b45;
  --line: rgba(247, 240, 223, 0.2);
  --line-strong: rgba(247, 240, 223, 0.38);
  --panel: rgba(6, 16, 29, 0.9);
  --shadow: 0 18px 64px rgba(0, 0, 0, 0.5);
  --ease: 150ms ease;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: "Tw Cen MT", "Avenir Next", Avenir, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-width: 280px;
}

button,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--night);
}

.topbar {
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 12px 20px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--night-deep);
}

.brand-lockup,
.top-actions,
.current-heading,
.stage-tools,
.details-head,
.mode-toggle {
  display: flex;
  align-items: center;
}

.brand-lockup {
  min-width: 0;
  gap: 22px;
}

.wordmark {
  flex: 0 0 auto;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.current-heading {
  min-width: 0;
  gap: 10px;
}

.eyebrow {
  color: var(--yellow);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(15px, 1.5vw, 20px);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 8px;
}

.status-line {
  max-width: 20vw;
  overflow: hidden;
  color: var(--soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button,
.icon-button,
.round-button,
.tool-button,
.timeline-arrow,
.timeline-item,
.mode-toggle button,
.caption-detail {
  cursor: pointer;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}

.text-button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.text-button:hover,
.text-button:active {
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--night-deep);
}

.icon-button,
.round-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(247, 240, 223, 0.05);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  text-decoration: none;
}

.icon-button:hover,
.round-button:hover {
  border-color: var(--yellow);
  background: rgba(255, 209, 0, 0.16);
  color: var(--yellow);
}

.link-button {
  font-size: 20px;
}

.timeline-bar {
  z-index: 35;
  display: flex;
  align-items: stretch;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.96);
}

.timeline {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.timeline::-webkit-scrollbar {
  display: none;
}

.timeline-arrow {
  z-index: 2;
  flex: 0 0 48px;
  min-height: 48px;
  border-right: 1px solid var(--line);
  background: var(--night-deep);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.timeline-arrow:last-child {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.timeline-arrow:hover {
  background: var(--blue);
  color: var(--yellow);
}

.timeline-item {
  position: relative;
  flex: 1 0 92px;
  min-height: 48px;
  padding: 7px 12px 6px;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.timeline-item:hover {
  background: rgba(255, 209, 0, 0.09);
  color: var(--ink);
}

.timeline-item[aria-selected="true"] {
  background: var(--yellow);
  color: var(--night-deep);
}

.timeline-item[aria-selected="true"]::after {
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  content: "";
}

.timeline-year,
.timeline-era {
  display: block;
}

.timeline-year {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.05;
}

.timeline-era {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #111923;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.viewport.dragging {
  cursor: grabbing;
}

.tile-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.tile {
  position: absolute;
  display: block;
  image-rendering: auto;
  pointer-events: none;
  background: #1a2530;
}

.loading-screen {
  z-index: 30;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #101a25;
  color: var(--muted);
  pointer-events: none;
  text-align: center;
  transition: opacity 180ms ease;
}

.loading-screen[hidden] {
  display: none;
}

.loading-copy {
  display: grid;
  justify-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.loading-copy strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.loading-mark,
.loading-dot {
  display: block;
  border: 2px solid rgba(255, 209, 0, 0.3);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.loading-mark {
  width: 26px;
  height: 26px;
}

.loading-badge {
  z-index: 26;
  position: absolute;
  top: 16px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(4, 10, 18, 0.86);
  color: var(--muted);
  font-size: 11px;
  transform: translateX(-50%);
}

.loading-badge[hidden] {
  display: none;
}

.loading-dot {
  width: 11px;
  height: 11px;
}

.stage-label {
  z-index: 12;
  position: absolute;
  top: 22px;
  left: 22px;
  display: grid;
  gap: 4px;
  pointer-events: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75);
}

.stage-year {
  color: var(--ink);
  font-size: clamp(44px, 8vw, 112px);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 0.85;
}

.stage-label-text {
  color: var(--yellow);
  font-size: clamp(10px, 1vw, 14px);
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.stage-tools {
  z-index: 16;
  position: absolute;
  top: 18px;
  right: 18px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  background: rgba(4, 10, 18, 0.83);
  box-shadow: var(--shadow);
}

.tool-button,
.zoom-readout,
.mode-toggle button {
  height: 40px;
  border: 1px solid var(--line);
  background: rgba(247, 240, 223, 0.05);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.tool-button {
  padding: 0 11px;
}

.tool-button:hover {
  border-color: var(--yellow);
  background: rgba(255, 209, 0, 0.16);
  color: var(--yellow);
}

.zoom-readout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 0 7px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mode-toggle {
  gap: 2px;
  padding-right: 3px;
}

.mode-toggle button {
  min-width: 64px;
  padding: 0 10px;
}

.mode-toggle button[aria-pressed="true"] {
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--night-deep);
}

.map-caption {
  z-index: 15;
  position: absolute;
  bottom: 45px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(560px, calc(100% - 36px));
  padding: 8px 10px;
  border-left: 3px solid var(--yellow);
  background: rgba(4, 10, 18, 0.78);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
}

.caption-detail {
  padding: 0;
  background: transparent;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.minimap {
  z-index: 15;
  position: absolute;
  right: 18px;
  bottom: 45px;
  width: 148px;
  height: 184px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: rgba(4, 10, 18, 0.9);
  box-shadow: var(--shadow);
  cursor: crosshair;
}

.minimap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.92;
  pointer-events: none;
}

.mini-view {
  position: absolute;
  min-width: 9px;
  min-height: 9px;
  border: 2px solid var(--yellow);
  background: rgba(255, 209, 0, 0.11);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.map-hint {
  z-index: 14;
  position: absolute;
  right: 18px;
  bottom: 12px;
  left: 18px;
  color: rgba(247, 240, 223, 0.7);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

kbd {
  display: inline-block;
  min-width: 17px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  background: rgba(4, 10, 18, 0.78);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.details-panel {
  z-index: 28;
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(390px, calc(100% - 36px));
  padding: 22px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px);
  transition: opacity 160ms ease, transform 160ms ease;
  visibility: hidden;
}

.details-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  visibility: visible;
}

.details-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.details-head h2 {
  margin-top: 7px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
}

.details-note {
  padding: 18px 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.details-list {
  display: grid;
  gap: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

.details-list > div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.details-list dt {
  color: var(--soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.details-list dd,
.details-provenance {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.breakable {
  overflow-wrap: anywhere;
}

.details-provenance {
  padding: 18px 0;
}

.welcome-modal-backdrop {
  z-index: 70;
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 10, 18, 0.86);
  backdrop-filter: blur(8px);
}

.welcome-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 26px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.welcome-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.welcome-modal h2 {
  max-width: 12ch;
  margin: 24px 0 12px;
  color: var(--ink);
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.98;
}

.welcome-modal-body {
  max-width: 42ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.welcome-modal-instructions {
  display: grid;
  gap: 12px;
  margin: 24px 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.welcome-modal-instructions p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.welcome-modal-instructions p > strong:first-child {
  display: inline-block;
  min-width: 64px;
  color: var(--yellow);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.welcome-start {
  width: 100%;
}

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

@media (max-width: 840px) {
  .topbar {
    gap: 12px;
    padding-inline: 12px;
  }

  .brand-lockup {
    gap: 14px;
  }

  .wordmark {
    font-size: 9px;
  }

  .status-line {
    display: none;
  }

  .timeline-item {
    flex-basis: 84px;
  }

  .stage-label {
    top: 16px;
    left: 14px;
  }

  .stage-tools {
    top: 12px;
    right: 12px;
    max-width: calc(100% - 24px);
  }

  .map-caption {
    bottom: 34px;
    left: 12px;
  }

  .minimap {
    right: 12px;
    bottom: 35px;
    width: 98px;
    height: 126px;
  }

  .map-hint {
    right: 12px;
    bottom: 8px;
    left: 12px;
    font-size: 10px;
  }
}

@media (max-width: 600px) {
  .topbar {
    align-items: flex-start;
    min-height: 86px;
    padding-block: 10px;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .current-heading {
    display: block;
  }

  .current-heading .eyebrow {
    display: block;
    margin-bottom: 4px;
  }

  h1 {
    max-width: 48vw;
    font-size: 14px;
  }

  .top-actions {
    gap: 5px;
  }

  .text-button {
    min-height: 36px;
    padding-inline: 9px;
    font-size: 11px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .timeline-arrow {
    flex-basis: 38px;
    min-height: 45px;
  }

  .timeline-item {
    flex-basis: 76px;
    min-height: 45px;
    padding-inline: 9px;
  }

  .timeline-year {
    font-size: 14px;
  }

  .timeline-era {
    font-size: 9px;
  }

  .stage-tools {
    top: auto;
    right: 9px;
    bottom: 78px;
    left: 9px;
    justify-content: flex-end;
    padding: 4px;
  }

  .tool-button,
  .zoom-readout,
  .mode-toggle button,
  .round-button {
    height: 36px;
  }

  .round-button {
    width: 36px;
  }

  .mode-toggle button {
    min-width: 56px;
  }

  .map-caption {
    right: 12px;
    bottom: 42px;
    max-width: calc(100% - 24px);
    font-size: 11px;
  }

  .minimap {
    display: none;
  }

  .details-panel {
    top: 8px;
    right: 8px;
    bottom: 8px;
    width: calc(100% - 16px);
    padding: 18px;
  }

  .details-head h2 {
    font-size: 21px;
  }

  .map-hint {
    display: none;
  }

  .welcome-modal-backdrop {
    align-items: end;
    padding: 12px;
  }

  .welcome-modal {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 20px;
  }

  .welcome-modal h2 {
    margin-top: 20px;
    font-size: 30px;
  }

  .welcome-modal-instructions {
    gap: 10px;
    margin: 18px 0;
    padding: 14px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
