:root {
  --bg: #04060f;
  --ink: rgba(255, 255, 255, 0.9);
  --ink-2: rgba(255, 255, 255, 0.58);
  --ink-3: rgba(255, 255, 255, 0.36);
  --gold: #f2c46d;
  --gold-2: #ffd98a;
  --ember: #ff8a5c;
  --glass: rgba(9, 12, 26, 0.58);
  --glass-2: rgba(14, 18, 36, 0.78);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --display: 'Cinzel', 'Cormorant Garamond', serif;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse 70% 60% at 50% 42%, #0e1536 0%, #070a1c 45%, #02030a 100%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.hidden { display: none !important; }

#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#globe.grab { cursor: grabbing; }
#globe.pick { cursor: pointer; }
#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 75% 75% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ---------- labels on the globe ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-family: var(--serif); font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 0 10px rgba(0, 0, 0, 1), 0 0 3px rgba(0, 0, 0, 1), 0 1px 1px rgba(0, 0, 0, 0.9);
  will-change: transform, opacity;
  opacity: 0;
}
.lbl.sub { font-weight: 500; letter-spacing: 0.2em; color: rgba(255, 255, 255, 0.62); }
.lbl.muted { color: rgba(255, 255, 255, 0.5); font-weight: 500; font-style: italic; text-transform: none; letter-spacing: 0.06em; }
.lbl.battle {
  font-family: var(--sans); font-weight: 500; font-size: 11px;
  letter-spacing: 0.08em; text-transform: none;
  color: var(--gold-2);
  transform: translate(-50%, calc(-100% - 9px));
  text-shadow: 0 0 8px rgba(0, 0, 0, 1), 0 0 2px #000;
}
.lbl.battle::before { content: '⚔ '; opacity: 0.8; }

/* ---------- glass chrome ---------- */
.chrome { z-index: 10; }
.glass, #card, #era, #search, .tool, .modal-box, #tooltip, #search-results, .speed, .play {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#brand { position: fixed; top: 26px; left: 30px; pointer-events: none; }
.wordmark {
  font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: 0.44em; text-transform: uppercase;
  color: #fff; text-shadow: 0 0 30px rgba(120, 160, 255, 0.45), 0 0 2px rgba(255, 255, 255, 0.4);
}
.tagline { margin-top: 7px; font-size: 11.5px; letter-spacing: 0.1em; color: var(--ink-2); }

#toolbar { position: fixed; top: 26px; right: 30px; display: flex; align-items: center; gap: 12px; }
#search { position: relative; display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 14px; border-radius: 999px; color: var(--ink-2); width: 330px; transition: border-color .2s, width .3s; }
#search:focus-within { border-color: rgba(242, 196, 109, 0.45); color: var(--gold-2); width: 380px; }
#search input { flex: 1; background: none; border: 0; outline: 0; color: var(--ink); font: 13px var(--sans); letter-spacing: 0.01em; }
#search input::placeholder { color: var(--ink-3); }
#search-results {
  position: absolute; top: 46px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  border-radius: 14px; max-height: 60vh; overflow: auto; background: var(--glass-2);
}
#search-results li { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; border-radius: 9px; cursor: pointer; color: var(--ink); }
#search-results li:hover, #search-results li.sel { background: rgba(255, 255, 255, 0.07); }
#search-results .kind { font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); width: 46px; flex: none; }
#search-results .kind.battle { color: var(--gold); }
#search-results .kind.war { color: var(--ember); }
#search-results .nm { flex: 1; font-size: 13px; }
#search-results .yr { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tools { display: flex; gap: 8px; }
.tool { height: 38px; padding: 0 16px; border-radius: 999px; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-2); transition: all .2s; }
.tool:hover { color: var(--ink); border-color: var(--line-2); }
.tool[data-toggle]:not(.active) { opacity: 0.45; text-decoration: line-through; }
.tool.active { color: var(--gold-2); border-color: rgba(242, 196, 109, 0.4); box-shadow: 0 0 18px rgba(242, 196, 109, 0.12), inset 0 0 12px rgba(242, 196, 109, 0.06); }

/* ---------- info card ---------- */
#card {
  position: fixed; right: 30px; top: 86px; width: 380px; max-height: calc(100vh - 300px);
  overflow: auto; border-radius: var(--radius); padding: 26px 26px 22px;
  transition: transform .4s cubic-bezier(.2,.8,.2,1), opacity .35s;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
#card.hidden { display: block !important; opacity: 0; transform: translateX(28px); pointer-events: none; }
.close { position: absolute; top: 12px; right: 14px; width: 30px; height: 30px; border-radius: 50%; font-size: 20px; line-height: 1; color: var(--ink-2); }
.close:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.card-kicker { font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card-kicker .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; box-shadow: 0 0 10px currentColor; }
.card-title { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.08; margin: 0 0 10px; color: #fff; letter-spacing: 0.01em; }
.card-meta { font-size: 12px; color: var(--ink-2); line-height: 1.6; margin-bottom: 14px; }
.card-meta b { color: var(--ink); font-weight: 500; }
.card-meta .row { display: flex; gap: 10px; }
.card-meta .k { color: var(--ink-3); width: 68px; flex: none; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; padding-top: 2px; }
.card-meta .link { color: var(--gold-2); cursor: pointer; }
.card-meta .link:hover { text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--ink); }
.card-body { font-size: 13.2px; line-height: 1.62; color: rgba(255, 255, 255, 0.8); }
.card-body p { margin: 0 0 10px; }
.card-body img.thumb { width: 100%; max-height: 210px; object-fit: cover; border-radius: 10px; margin: 4px 0 14px; display: block; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); }
.card-body .more { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; }
.card-body .loading { color: var(--ink-3); font-style: italic; }
.card-body .list { list-style: none; margin: 8px 0 0; padding: 0; }
.card-body .list li { display: flex; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; }
.card-body .list li:hover .nm { color: var(--gold-2); }
.card-body .list .yr { color: var(--gold); font-variant-numeric: tabular-nums; width: 64px; flex: none; font-size: 12px; }
.card-body .list .nm { flex: 1; font-size: 12.5px; }

/* ---------- era panel ---------- */
#era {
  position: fixed; left: 30px; bottom: 214px; width: 320px; max-height: 36vh;
  border-radius: var(--radius); padding: 14px 6px 8px 18px; display: flex; flex-direction: column;
  transition: opacity .3s, transform .3s;
}
#era.empty { opacity: 0; pointer-events: none; transform: translateY(8px); }
.era-head { display: flex; flex-direction: column; gap: 2px; padding-right: 12px; margin-bottom: 8px; }
.era-range { font-family: var(--serif); font-size: 17px; font-weight: 500; color: #fff; }
.era-count { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); }
#era-list { list-style: none; margin: 0; padding: 0 12px 0 0; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
#era-list li { display: flex; gap: 10px; align-items: baseline; padding: 5px 6px; margin-left: -6px; border-radius: 7px; cursor: pointer; transition: background .15s; }
#era-list li:hover, #era-list li.sel { background: rgba(255, 255, 255, 0.07); }
#era-list li { opacity: 0.55; transition: opacity .25s; }
#era-list li.now, #era-list li:hover, #era-list li.sel { opacity: 1; }
#era-list li.now .yr { color: var(--gold-2); text-shadow: 0 0 8px rgba(242,196,109,.5); }
#era-list li.now .nm { color: #fff; }
#era-list .yr { color: var(--gold); font-size: 11.5px; width: 58px; flex: none; font-variant-numeric: tabular-nums; }
#era-list .nm { flex: 1; font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#era-list .war { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
#era-list li.more { color: var(--ink-3); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none;
  padding: 9px 13px; border-radius: 10px; max-width: 300px;
  font-size: 12.5px; line-height: 1.45; color: var(--ink);
  opacity: 0; transition: opacity .12s; transform: translate(16px, 18px);
}
#tooltip.on { opacity: 1; }
#tooltip .t { font-family: var(--serif); font-size: 17px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 8px; }
#tooltip .t i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 8px currentColor; }
#tooltip .s { color: var(--ink-2); font-size: 11.5px; margin-top: 2px; }
#tooltip .s b { color: var(--gold-2); font-weight: 500; }

/* ---------- timeline ---------- */
#timeline {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  width: min(1560px, calc(100vw - 60px));
}
.tl-readout { display: flex; align-items: flex-end; gap: 20px; margin-bottom: 8px; padding-left: 4px; }
.play { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--gold-2); transition: all .2s; margin-bottom: 8px; }
.play:hover { border-color: rgba(242, 196, 109, 0.5); box-shadow: 0 0 22px rgba(242, 196, 109, 0.18); }
.play .ico-pause { display: none; }
.play.on .ico-pause { display: block; }
.play.on .ico-play { display: none; }
.year { display: flex; align-items: baseline; gap: 10px; line-height: 1; }
#year-num { font-family: var(--serif); font-weight: 300; font-size: 74px; color: #fff; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; text-shadow: 0 0 40px rgba(120, 160, 255, 0.35); }
#year-era { font-family: var(--serif); font-weight: 500; font-size: 20px; letter-spacing: 0.24em; color: var(--gold); }
.tl-hint { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px; }
.speed { margin-left: auto; margin-bottom: 8px; display: flex; border-radius: 999px; overflow: hidden; height: 34px; }
.speed button { padding: 0 13px; font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; }
.speed button.active { color: var(--gold-2); background: rgba(255, 255, 255, 0.06); }

.tl-slider { position: relative; height: 112px; cursor: pointer; }
.tl-eras { position: absolute; left: 0; right: 0; top: 0; height: 18px; }
.tl-eras div {
  position: absolute; top: 0; height: 100%; border-left: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-3); padding-left: 7px; line-height: 16px;
  white-space: nowrap; overflow: hidden;
}
.tl-eras div:nth-child(even) { background: linear-gradient(to bottom, rgba(255,255,255,0.025), transparent); }
.tl-track { position: absolute; left: 0; right: 0; top: 30px; height: 2px; background: rgba(255, 255, 255, 0.14); box-shadow: 0 0 12px rgba(120,160,255,.15); }
.tl-track::after { content: ''; position: absolute; left: 0; top: -14px; bottom: -14px; right: 0; }
.tl-ticks { position: absolute; left: 0; right: 0; top: 24px; height: 40px; pointer-events: none; }
.tl-ticks i { position: absolute; top: 3px; width: 1px; height: 8px; background: rgba(255, 255, 255, 0.32); }
.tl-ticks i.major { height: 12px; top: 1px; background: rgba(255, 255, 255, 0.55); }
.tl-ticks span { position: absolute; top: 18px; transform: translateX(-50%); font-size: 10px; color: var(--ink-2); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-wars { position: absolute; left: 0; right: 0; top: 62px; height: 50px; }
.tl-wars div {
  position: absolute; height: 5px; border-radius: 3px; min-width: 3px;
  background: rgba(242, 196, 109, 0.28); transition: background .15s, box-shadow .15s;
}
.tl-wars div:hover, .tl-wars div.sel { background: var(--gold-2); box-shadow: 0 0 10px var(--gold); z-index: 2; }
.tl-wars div.in { background: rgba(255, 138, 92, 0.75); }
.tl-handle { position: absolute; top: 18px; bottom: 0; width: 2px; margin-left: -1px; pointer-events: none;
  background: linear-gradient(to bottom, var(--gold-2), rgba(242, 196, 109, 0.0)); box-shadow: 0 0 14px rgba(242, 196, 109, 0.6); }
.tl-handle .knob {
  position: absolute; left: 50%; top: 12px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff2c8, var(--gold) 60%, #b98a2c);
  box-shadow: 0 0 0 4px rgba(242, 196, 109, 0.18), 0 0 22px rgba(242, 196, 109, 0.7);
  pointer-events: auto; cursor: grab;
}
.tl-slider.dragging .knob { cursor: grabbing; transform: scale(1.15); }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; z-index: 50; background: #02030a; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; transition: opacity 1s ease; }
#loader.done { opacity: 0; pointer-events: none; }
.loader-mark { font-family: var(--display); font-size: 30px; letter-spacing: 0.5em; text-transform: uppercase; color: #fff; padding-left: 0.5em; text-shadow: 0 0 40px rgba(120,160,255,.5); animation: breathe 2.4s ease-in-out infinite; }
.loader-bar { width: 280px; height: 1px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: var(--gold); box-shadow: 0 0 12px var(--gold); transition: width .3s; }
.loader-msg { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }
@keyframes breathe { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(2, 3, 10, 0.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal-box { position: relative; width: 560px; max-width: calc(100vw - 40px); max-height: 85vh; overflow: auto; border-radius: 20px; padding: 34px 38px; background: var(--glass-2); font-size: 13.5px; line-height: 1.65; color: rgba(255, 255, 255, 0.82); }
.modal-box h4 { margin: 20px 0 8px; font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold); }
.modal-box p { margin: 0 0 10px; }
.help { margin: 0; padding-left: 18px; }
.help li { margin: 4px 0; }
.help b { color: #fff; font-weight: 500; }
kbd { font: 11px var(--sans); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-2); background: rgba(255,255,255,.06); color: #fff; }

/* ---------- entrance ---------- */
.reveal { animation: rise 1.1s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
#timeline.reveal { animation-name: rise-tl; }
@keyframes rise-tl { from { opacity: 0; transform: translate(-50%, 18px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 1100px) {
  #search { width: 220px; }
  #era { display: none; }
  #year-num { font-size: 54px; }
}

body.nofx * { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
body.nolabels #labels { display: none; }

@media (max-width: 700px) {
  #brand { top: 14px; left: 16px; }
  .wordmark { font-size: 15px; letter-spacing: 0.3em; }
  .tagline { display: none; }
  #toolbar { top: 12px; right: 16px; left: auto; gap: 6px; }
  #search { width: 44px; padding: 0 13px; }
  #search:focus-within { width: calc(100vw - 32px); position: fixed; left: 16px; top: 58px; }
  #search input { min-width: 0; }
  .tools { display: none; }
  #search:focus-within ~ .tools { display: none; }
  #card { left: 16px; right: 16px; width: auto; top: auto; bottom: 168px; max-height: 42vh; padding: 18px; }
  #card.hidden { transform: translateY(20px); }
  .card-title { font-size: 22px; }
  #timeline { width: calc(100vw - 32px); bottom: 12px; }
  #year-num { font-size: 40px; }
  #year-era { font-size: 14px; }
  .tl-hint { display: none; }
  .play { width: 36px; height: 36px; margin-bottom: 4px; }
  .speed { display: none; }
  .tl-slider { height: 90px; }
  .tl-wars { top: 58px; height: 32px; }
  .tl-ticks span { font-size: 9px; }
  .tl-eras div { font-size: 8px; letter-spacing: 0.12em; }
  #tooltip { max-width: 220px; }
  .modal-box { padding: 24px 20px; }
}
.sides { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.side { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #fff; cursor: pointer; }
.side i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; box-shadow: 0 0 8px currentColor; }
.side:hover { text-decoration: underline; }
.vs { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }
#tooltip .sides { margin: 4px 0 2px; }
#era-list .dots { display: inline-flex; gap: 3px; flex: none; }
#era-list .dots i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
#search-results .kind.state { color: #8fb8ff; }
#search-results .kind.region { color: var(--ink-3); }

/* music: the YouTube player sits behind the globe canvas (YouTube will not play in a tiny player) */
#music-frame { position: fixed; left: 0; top: 0; width: 320px; height: 240px; z-index: -1; opacity: 0; pointer-events: none; }
#music-frame iframe { width: 320px; height: 240px; border: 0; display: block; }

#about .note { color: var(--ink-3); font-size: 12px; margin: 0 0 8px; }
#about .basis { color: var(--ink-3); }
