:root {
  color-scheme: dark;
  --ink: #f2eee5;
  --muted: #9ca7b5;
  --faint: #697687;
  --gold: #d7b67a;
  --gold-bright: #f0d59f;
  --line: rgba(189, 205, 224, 0.14);
  --panel: rgba(10, 16, 25, 0.78);
  --range-progress: 0%;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #05080e;
}

body {
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

button:disabled {
  cursor: default;
  opacity: 0.28;
}

#globe {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#globe canvas {
  display: block;
  touch-action: none;
}

.space-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 54% 46%, transparent 25%, rgba(3, 7, 13, 0.12) 58%, rgba(3, 6, 11, 0.68) 100%),
    linear-gradient(180deg, rgba(4, 8, 14, 0.48) 0%, transparent 25%, transparent 62%, rgba(4, 8, 14, 0.9) 100%);
}

.site-header {
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 26px 36px 38px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 9, 15, 0.82), transparent);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  color: var(--gold);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1.15;
}

.brand-mark .brand-star {
  fill: var(--gold-bright);
  stroke: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.34em;
}

h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

h1 span {
  margin: 0 4px;
  color: var(--gold);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.interactive-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #b6c1cd;
  background: rgba(9, 15, 24, 0.4);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.interactive-badge span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8fbda7;
  box-shadow: 0 0 8px rgba(143, 189, 167, 0.8);
}

.era-panel {
  position: fixed;
  z-index: 3;
  top: 136px;
  left: 38px;
  width: min(520px, 39vw);
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.85);
}

.era-kicker {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.era-kicker i {
  width: 22px;
  height: 1px;
  background: rgba(215, 182, 122, 0.5);
}

#era-sequence {
  color: var(--muted);
  font-weight: 400;
}

.era-panel h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(34px, 3.5vw, 54px);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: 0.04em;
}

.era-panel p {
  max-width: 500px;
  margin: 15px 0 0;
  color: #b4bdc7;
  font-size: 12px;
  line-height: 1.9;
  letter-spacing: 0.035em;
}

.polity-panel {
  position: fixed;
  z-index: 4;
  top: 244px;
  right: 32px;
  width: 208px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(15, 23, 34, 0.8), rgba(7, 12, 20, 0.65));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.panel-heading span {
  color: var(--faint);
  font-size: 9px;
}

.polity-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  max-height: min(230px, calc(100dvh - 550px));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(215, 182, 122, 0.25) transparent;
}

.polity-button {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  padding: 7px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #b8c2cd;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  font-size: 10px;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.polity-button:hover,
.polity-button.is-focused {
  border-color: rgba(215, 182, 122, 0.28);
  color: #fff5e3;
  background: rgba(215, 182, 122, 0.08);
}

.polity-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--polity-color);
  box-shadow: 0 0 7px color-mix(in srgb, var(--polity-color) 60%, transparent);
}

.polity-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-hint {
  margin: 11px 0 0;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.globe-tools {
  position: fixed;
  z-index: 4;
  right: 32px;
  bottom: 248px;
}

.icon-button,
.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 50%;
  color: #aeb9c5;
  background: rgba(12, 19, 29, 0.72);
  backdrop-filter: blur(10px);
}

.icon-button svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:not(:disabled):hover,
.play-button:hover {
  border-color: rgba(215, 182, 122, 0.55);
  transform: translateY(-1px);
}

.experience-footer {
  position: fixed;
  z-index: 5;
  right: 24px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 24px;
  max-width: 1480px;
  margin: 0 auto;
}

.timeline-card {
  padding: 16px 20px 14px;
  border: 1px solid rgba(189, 205, 224, 0.16);
  border-radius: 15px;
  background: linear-gradient(120deg, rgba(14, 21, 31, 0.93), rgba(7, 13, 22, 0.88));
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.42), inset 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(22px);
}

.timeline-topline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

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

.step-button {
  width: 30px;
  height: 30px;
  padding: 7px;
  background: transparent;
}

.play-button {
  min-width: 82px;
  height: 34px;
  gap: 5px;
  padding: 0 13px 0 10px;
  border-color: rgba(215, 182, 122, 0.4);
  border-radius: 999px;
  color: #17150f;
  background: linear-gradient(135deg, #ead29f, #c9a666);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.play-button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: currentColor;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.play-button.is-playing svg {
  fill: none;
  stroke-width: 2.2;
}

.timeline-position {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.timeline-position strong {
  min-width: 58px;
  color: var(--gold-bright);
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
  font-weight: 500;
  text-align: right;
}

.timeline-position > span {
  color: var(--faint);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.timeline-position b {
  color: #b7c2cd;
  font-size: 12px;
  font-weight: 500;
}

.timeline-hint {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.timeline-hint span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
}

.range-wrap {
  margin: 11px 0 10px;
}

#timeline-range {
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: ew-resize;
  touch-action: pan-y;
}

#timeline-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--gold) 0 var(--range-progress), rgba(155, 172, 192, 0.2) var(--range-progress) 100%);
  box-shadow: 0 1px rgba(255, 255, 255, 0.025);
}

#timeline-range::-moz-range-track {
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--gold) 0 var(--range-progress), rgba(155, 172, 192, 0.2) var(--range-progress) 100%);
}

#timeline-range::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border: 3px solid #e8d4aa;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: #5b4b31;
  box-shadow: 0 0 0 4px rgba(215, 182, 122, 0.12), 0 0 18px rgba(215, 182, 122, 0.35);
}

#timeline-range::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 3px solid #e8d4aa;
  border-radius: 50%;
  background: #5b4b31;
  box-shadow: 0 0 0 4px rgba(215, 182, 122, 0.12), 0 0 18px rgba(215, 182, 122, 0.35);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -1px;
  color: #738092;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.range-labels span:nth-child(2) {
  color: #515f70;
  font-family: inherit;
}

.dynasty-nav {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-top: 11px;
  border-top: 1px solid rgba(189, 205, 224, 0.09);
}

.nav-label {
  flex: 0 0 auto;
  color: #8592a2;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.dynasty-buttons {
  display: flex;
  flex: 1;
  gap: 5px;
  min-width: 0;
  padding: 1px 2px 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.dynasty-buttons::-webkit-scrollbar {
  display: none;
}

.dynasty-button {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #8997a7;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.dynasty-button:hover {
  color: #e4d5b7;
  background: rgba(215, 182, 122, 0.06);
}

.dynasty-button.is-active {
  border-color: rgba(215, 182, 122, 0.25);
  color: #eed7aa;
  background: rgba(215, 182, 122, 0.1);
}

.dynasty-button.is-utility {
  border-right-color: rgba(189, 205, 224, 0.14);
  border-radius: 5px 0 0 5px;
  color: #a8b5c2;
}

.source-line {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 4px 0;
  color: rgba(135, 149, 165, 0.64);
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.025em;
}

.controls-tip {
  flex: 0 0 auto;
}

.loading-screen {
  position: fixed;
  z-index: 6;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 22px 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(6, 11, 18, 0.88);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  transform: translate(-50%, -50%);
  transition: opacity 400ms ease, visibility 400ms ease;
}

.loading-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loading-screen.is-error {
  width: min(420px, calc(100vw - 40px));
  text-align: center;
}

.loading-screen p {
  margin: 0;
  color: #aab6c3;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.08em;
}

.loading-orbit {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(215, 182, 122, 0.25);
  border-radius: 50%;
  animation: orbit-spin 1.6s linear infinite;
}

.loading-orbit::before {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(215, 182, 122, 0.45);
  border-radius: 50%;
  content: "";
}

.loading-orbit span {
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 10px var(--gold);
}

.polity-tooltip {
  min-width: 118px;
  padding: 10px 12px;
  border: 1px solid rgba(215, 182, 122, 0.35);
  border-radius: 8px;
  color: #eaf0f6;
  background: rgba(6, 11, 18, 0.92);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.32);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  text-align: left;
  backdrop-filter: blur(10px);
}

.polity-tooltip strong {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #fff3dc;
  font-size: 13px;
  font-weight: 600;
}

.polity-tooltip strong::before {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--tooltip-color);
  content: "";
}

.polity-tooltip span {
  display: block;
  margin-top: 5px;
  color: #8795a5;
  font-size: 9px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

@media (max-width: 900px) {
  .site-header {
    padding: 20px 22px 30px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: 17px;
  }

  .interactive-badge {
    display: none;
  }

  .era-panel {
    top: 122px;
    left: 24px;
    width: min(500px, calc(100vw - 48px));
  }

  .era-panel h2 {
    font-size: 38px;
  }

  .polity-panel {
    top: 238px;
    right: 20px;
    width: 184px;
  }

  .polity-list {
    max-height: 125px;
  }

  .experience-footer {
    right: 14px;
    left: 14px;
  }

  .timeline-hint {
    font-size: 8px;
  }

  .globe-tools {
    right: 20px;
    bottom: 246px;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 16px 16px 24px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .eyebrow {
    font-size: 7px;
  }

  h1 {
    font-size: 15px;
    letter-spacing: 0.04em;
  }

  .subtitle {
    margin-top: 4px;
    font-size: 9px;
  }

  .era-panel {
    top: 105px;
    left: 18px;
    width: calc(100vw - 36px);
  }

  .era-kicker {
    margin-bottom: 8px;
    font-size: 8px;
  }

  .era-panel h2 {
    font-size: 31px;
  }

  .era-panel p {
    display: -webkit-box;
    margin-top: 10px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.75;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .polity-panel {
    top: 224px;
    right: 14px;
    left: 14px;
    width: auto;
    padding: 8px 10px;
    border-radius: 9px;
  }

  .panel-heading,
  .panel-hint {
    display: none;
  }

  .polity-list {
    display: flex;
    gap: 5px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .polity-list::-webkit-scrollbar {
    display: none;
  }

  .polity-button {
    flex: 0 0 auto;
    padding: 5px 8px;
    font-size: 9px;
  }

  .experience-footer {
    right: 8px;
    bottom: max(7px, env(safe-area-inset-bottom));
    left: 8px;
  }

  .timeline-card {
    padding: 12px 12px 10px;
    border-radius: 12px;
  }

  .timeline-topline {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .timeline-hint {
    display: none;
  }

  .playback-controls {
    gap: 5px;
  }

  .play-button {
    min-width: 70px;
    height: 32px;
    padding-right: 10px;
    font-size: 10px;
  }

  .timeline-position {
    gap: 7px;
  }

  .timeline-position strong {
    min-width: 46px;
    font-size: 17px;
  }

  .timeline-position > span {
    font-size: 8px;
  }

  .range-wrap {
    margin: 8px 0 7px;
  }

  #timeline-range {
    height: 30px;
  }

  #timeline-range::-webkit-slider-thumb {
    width: 19px;
    height: 19px;
    margin-top: -8px;
  }

  #timeline-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
  }

  .dynasty-nav {
    gap: 0;
    padding-top: 8px;
  }

  .nav-label {
    display: none;
  }

  .dynasty-button {
    padding: 6px 9px;
    font-size: 9px;
  }

  .source-line {
    display: block;
    padding: 6px 3px 0;
    font-size: 7px;
    text-align: center;
  }

  .controls-tip {
    display: none;
  }

  .globe-tools {
    right: 14px;
    bottom: 237px;
  }

  .globe-tools .icon-button {
    width: 32px;
    height: 32px;
  }
}

@media (max-height: 690px) and (min-width: 641px) {
  .era-panel {
    top: 116px;
  }

  .era-panel h2 {
    font-size: 36px;
  }

  .polity-panel {
    top: 195px;
  }

  .polity-list {
    max-height: 90px;
  }
}

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

.polity-tooltip-float {
  position: fixed;
  z-index: 60;
  display: none;
  min-width: 118px;
  padding: 10px 12px;
  border: 1px solid rgba(215, 182, 122, 0.35);
  border-radius: 8px;
  color: #eaf0f6;
  background: rgba(6, 11, 18, 0.92);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.32);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  text-align: left;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.polity-tooltip-float strong {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}

.polity-tooltip-float span {
  display: block;
  margin-top: 5px;
  color: #8795a5;
  font-size: 9px;
}
