:root {
  color-scheme: dark;
  --bg: #0b111a;
  --panel: rgba(18, 27, 39, 0.88);
  --panel-2: rgba(23, 34, 48, 0.88);
  --border: rgba(255, 255, 255, 0.10);
  --text: #f4f0e7;
  --muted: #9eabb9;
  --accent: #d9b06f;
  --accent-2: #f0c984;
  --danger: #cf6d63;
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 0%, rgba(102, 129, 151, .16), transparent 32%),
    radial-gradient(circle at 85% 0%, rgba(182, 137, 82, .11), transparent 34%),
    linear-gradient(160deg, #0a1018 0%, #101925 48%, #0c121b 100%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 2vw, 34px) 18px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
}

h1 { margin: 0; font-size: clamp(25px, 3vw, 42px); letter-spacing: .02em; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: clamp(13px, 1.1vw, 16px); }

.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }
.ghost-btn, .primary-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.ghost-btn {
  padding: 9px 13px;
  background: rgba(255,255,255,.045);
  color: var(--text);
}
.ghost-btn:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); }
.primary-btn {
  padding: 10px 16px;
  background: linear-gradient(135deg, #d4a85f, #b98245);
  color: #15100a;
  font-weight: 850;
  border-color: transparent;
}
.ghost-btn:active, .primary-btn:active { transform: translateY(1px); }

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 360px);
  gap: 16px;
  align-items: stretch;
}

.scene-card, .info-card, .timeline-panel {
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.scene-card {
  min-height: 610px;
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background:
    radial-gradient(circle at 45% 42%, rgba(118, 146, 169, .13), transparent 34%),
    linear-gradient(145deg, rgba(12, 20, 31, .96), rgba(7, 12, 19, .96));
}

#scene { position: absolute; inset: 0; }
#scene canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#scene canvas:active { cursor: grabbing; }

.scene-hints {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: none;
}
.scene-hints span {
  background: rgba(4, 8, 13, .58);
  border: 1px solid rgba(255,255,255,.08);
  color: #bac5cf;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
}

.legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  min-width: 150px;
  border-radius: 12px;
  background: rgba(4, 8, 13, .68);
  border: 1px solid rgba(255,255,255,.09);
  pointer-events: none;
}
.legend-item { display: flex; gap: 8px; align-items: center; font-size: 12px; color: #d4dbe1; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; box-shadow: 0 0 14px currentColor; }

.loading-card {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(360px, calc(100% - 30px));
  padding: 16px;
  border-radius: 15px;
  background: rgba(7, 12, 18, .92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.loading-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.info-card {
  border-radius: 20px;
  padding: 22px;
  background: linear-gradient(160deg, rgba(23,33,46,.94), rgba(14,22,32,.94));
}
.date-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.year-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 72px; min-height: 38px;
  padding: 7px 12px;
  border: 1px solid rgba(217,176,111,.30);
  border-radius: 11px;
  background: rgba(217,176,111,.12);
  color: var(--accent-2);
  font-weight: 900;
  font-size: 19px;
}
.date-text { color: var(--muted); font-size: 14px; }
.info-card h2 { margin: 0 0 12px; font-size: clamp(22px, 2vw, 30px); line-height: 1.25; }
.info-card > p { color: #c9d1d8; font-size: 15px; line-height: 1.72; margin: 0 0 18px; }
.facts { display: grid; gap: 8px; margin: 0 0 18px; }
.fact-item {
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 11px;
  background: rgba(255,255,255,.035);
  color: #d8dee4;
  font-size: 13px;
}
.note-box {
  margin-top: auto;
  padding: 14px;
  border-radius: 12px;
  border-left: 3px solid var(--accent);
  background: rgba(217,176,111,.08);
}
.note-box strong { color: var(--accent-2); font-size: 13px; }
.note-box p { margin: 6px 0 0; color: #c7ced5; font-size: 13px; line-height: 1.65; }

.timeline-panel {
  margin-top: 16px;
  border-radius: 18px;
  background: var(--panel);
  padding: 16px;
}
.timeline-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.timeline-readout { text-align: right; display: grid; gap: 2px; }
.timeline-readout strong { font-size: 15px; color: var(--accent-2); }
.timeline-readout span { color: var(--muted); font-size: 12px; }

.timeline-range {
  width: 100%;
  margin: 18px 0 6px;
  accent-color: var(--accent);
  cursor: pointer;
}
.timeline-ticks {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  color: #8e9aa7;
  font-size: 11px;
  text-align: center;
  margin-bottom: 12px;
}
.timeline-ticks span.active { color: var(--accent-2); font-weight: 800; }

.event-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(105px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.event-card {
  min-width: 105px;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.03);
  cursor: pointer;
  color: #b9c3cc;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.event-card:hover { background: rgba(255,255,255,.06); }
.event-card.active {
  border-color: rgba(217,176,111,.42);
  background: rgba(217,176,111,.10);
  color: #f2dfbf;
  transform: translateY(-2px);
}
.event-card .card-year { display: block; font-size: 11px; color: var(--accent); margin-bottom: 3px; }
.event-card .card-title { display: block; font-size: 12px; font-weight: 750; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 4px 0;
  color: #73808d;
  font-size: 11px;
}

@media (max-width: 980px) {
  .main-layout { grid-template-columns: 1fr; }
  .scene-card { min-height: 560px; }
  .info-card { min-height: auto; }
}

@media (max-width: 640px) {
  .app-shell { padding: 14px 10px 12px; }
  .topbar { align-items: start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: start; }
  .scene-card { min-height: 470px; border-radius: 15px; }
  .info-card, .timeline-panel { border-radius: 15px; }
  .info-card { padding: 17px; }
  .scene-hints span:nth-child(3) { display: none; }
  .timeline-toolbar { align-items: stretch; flex-direction: column; }
  .timeline-readout { text-align: left; }
  .timeline-ticks { font-size: 9px; }
  footer { flex-direction: column; gap: 4px; }
}
