:root {
  --parchment: #efe6d0;
  --parchment-dark: #e2d4b6;
  --ink: #3a2e22;
  --ink-soft: #6b5b45;
  --accent: #8c3b2b;      /* 朱砂红 */
  --accent-soft: #b5654a;
  --gold: #b08d3e;
  --water: #3b6ea5;
  --water-fill: rgba(59, 110, 165, 0.38);
  --north: #7a4a2b;
  --south: #4a6b3a;
  --panel-bg: rgba(247, 240, 224, 0.94);
  --shadow: rgba(58, 46, 34, 0.28);
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--serif);
  color: var(--ink);
  background: #2a2118;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  /* 羊皮纸底纹 */
  background:
    radial-gradient(circle at 20% 15%, rgba(176, 141, 62, 0.12), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(140, 59, 43, 0.10), transparent 50%),
    linear-gradient(160deg, #efe6d0, #e6d8ba);
}

/* ---------- 顶部标题 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 26px;
  border-bottom: 2px solid var(--parchment-dark);
  box-shadow: 0 2px 10px var(--shadow);
  background: linear-gradient(180deg, rgba(247, 240, 224, 0.9), rgba(226, 212, 182, 0.6));
  z-index: 500;
}
.title-block h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--ink-soft);
}
.music-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--gold);
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  font-family: var(--serif);
  padding: 7px 14px;
  border-radius: 22px;
  cursor: pointer;
  letter-spacing: 2px;
  font-size: 14px;
  transition: all 0.25s;
}
.music-btn:hover { background: var(--gold); color: #fff; }
.music-btn.playing { background: var(--accent); border-color: var(--accent); color: #fff; }
.music-btn.playing .music-icon { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- 主体 ---------- */
.stage {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 16px;
  gap: 16px;
}

.panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border: 1px solid var(--parchment-dark);
  border-radius: 8px;
  box-shadow: 0 6px 22px var(--shadow);
  padding: 22px 22px 18px;
  overflow-y: auto;
  position: relative;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(176, 141, 62, 0.35);
  border-radius: 5px;
  pointer-events: none;
}

.panel-era {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.era-badge {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 4px;
}
.era-year {
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 1px;
}

.width-block { margin-bottom: 18px; }
.width-number {
  font-size: 30px;
  color: var(--ink);
  letter-spacing: 2px;
}
.width-number b { color: var(--accent); font-size: 40px; }
.width-bar-wrap {
  margin: 10px 0 6px;
  height: 12px;
  background: rgba(59, 110, 165, 0.12);
  border-radius: 6px;
  overflow: hidden;
}
.width-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--water), #6fa0cf);
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.width-hint { font-size: 13px; color: var(--ink-soft); }

.era-quote {
  margin: 16px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--gold);
  background: rgba(176, 141, 62, 0.08);
  font-size: 15px;
  line-height: 1.8;
  color: var(--accent);
  font-style: normal;
}
.era-quote:empty { display: none; }

.era-narrative {
  font-size: 15px;
  line-height: 2;
  color: var(--ink);
  text-align: justify;
}

.legend {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--parchment-dark);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.dot.north { background: var(--north); }
.dot.south { background: var(--south); }
.dot.water { background: var(--water-fill); border: 1px solid var(--water); }

/* ---------- 地图 ---------- */
.map-wrap {
  flex: 1;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 22px var(--shadow);
  border: 1px solid var(--parchment-dark);
}
#map { position: absolute; inset: 0; background: #dfe4e0; }
/* 让底图偏做旧、低饱和，呼应仿古气质 */
.leaflet-tile-pane { filter: sepia(0.35) saturate(0.85) contrast(0.95) brightness(1.02); }

.map-note {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 500;
  font-size: 11px;
  color: #4a4238;
  background: rgba(247, 240, 224, 0.8);
  padding: 3px 8px;
  border-radius: 4px;
}

/* 地名标签 */
.place-label {
  background: rgba(247, 240, 224, 0.92);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 0 1px 4px var(--shadow);
}
.place-label.faint { opacity: 0.62; border-color: rgba(176, 141, 62, 0.4); font-size: 11px; }
.place-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 3px var(--shadow);
}
.place-dot.faint { background: var(--gold); }

.bank-tip {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 2px;
}

/* ---------- 时间轴 ---------- */
.timeline {
  padding: 14px 26px 20px;
  border-top: 2px solid var(--parchment-dark);
  background: linear-gradient(0deg, rgba(247, 240, 224, 0.9), rgba(226, 212, 182, 0.5));
  box-shadow: 0 -2px 10px var(--shadow);
}
.timeline-head { display: flex; align-items: center; gap: 14px; }
.nav-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: rgba(255, 255, 255, 0.4);
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.nav-btn:hover { background: var(--gold); color: #fff; }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

.timeline-track-wrap { flex: 1; }
.time-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--water) 0%, var(--accent) 100%);
  outline: none;
  cursor: pointer;
}
.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff5e0, var(--accent));
  border: 2px solid #fff;
  box-shadow: 0 2px 6px var(--shadow);
  cursor: pointer;
}
.time-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff5e0, var(--accent));
  border: 2px solid #fff;
  cursor: pointer;
}

.tick-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}
.tick {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 1px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s;
  white-space: nowrap;
}
.tick:hover { color: var(--accent); }
.tick.active {
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.credits {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.5px;
}
.credits a { color: var(--accent-soft); text-decoration: none; }
.credits a:hover { text-decoration: underline; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .stage { flex-direction: column; padding: 10px; gap: 10px; }
  .panel { width: auto; max-height: 34vh; }
  .title-block h1 { font-size: 20px; letter-spacing: 3px; }
  .subtitle { font-size: 11px; }
  .tick { font-size: 10px; }
  .tick-labels { overflow-x: auto; }
}
