:root {
  --glass: rgba(252, 250, 246, 0.74);
  --glass-strong: rgba(252, 250, 246, 0.92);
  --glass-border: rgba(255, 255, 255, 0.7);
  --ink: #1c2230;
  --ink-soft: #5d6679;
  --ink-faint: rgba(28, 34, 48, 0.12);
  --accent: #b9832f;
  --accent-soft: rgba(185, 131, 47, 0.14);
  --shadow: 0 12px 34px rgba(18, 26, 44, 0.16), 0 2px 6px rgba(18, 26, 44, 0.08);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

body.night {
  --glass: rgba(14, 18, 30, 0.62);
  --glass-strong: rgba(14, 18, 30, 0.88);
  --glass-border: rgba(255, 255, 255, 0.09);
  --ink: #edf0f7;
  --ink-soft: #a4adc1;
  --ink-faint: rgba(237, 240, 247, 0.14);
  --accent: #f1c46f;
  --accent-soft: rgba(241, 196, 111, 0.16);
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1020;
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.panel {
  position: fixed;
  z-index: 10;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background-color 0.8s ease, color 0.8s ease, border-color 0.8s ease, opacity 0.6s ease, transform 0.6s ease;
}

body.is-loading .panel, body.is-loading .attrib { opacity: 0; transform: translateY(8px); pointer-events: none; }

/* ------------------------------------------------------------------ loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 110%, #2b4a6b 0%, #152238 45%, #0a0f1c 100%);
  color: #eef2f8;
  transition: opacity 1.2s ease, visibility 1.2s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-inner { text-align: center; width: min(360px, 80vw); }
.loader-mark { width: 64px; height: 64px; fill: none; stroke: #d8e6f2; stroke-width: 2.4; stroke-linecap: round; opacity: 0.9; }
.loader-mark path:nth-child(-n+2) { stroke: #f3e2bf; animation: jet 1.8s ease-in-out infinite; transform-origin: 32px 44px; }
@keyframes jet { 0%, 100% { transform: scaleY(0.92); } 50% { transform: scaleY(1.04); } }
#loader h1 { font-family: var(--serif); font-weight: 500; font-size: 34px; letter-spacing: 0.02em; margin: 10px 0 18px; }
#loader h1 em, .brand-title em { font-style: italic; color: #e9c27a; }
.loader-step { font-size: 13px; color: #9fb0c8; margin: 0 0 12px; min-height: 1.3em; }
.loader-bar { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6fc3d6, #e9c27a); transition: width 0.4s ease; }
.loader-error { color: #ffb4a8; font-size: 13px; line-height: 1.5; margin-top: 16px; }

/* ------------------------------------------------------------------ brand */
.brand { top: 18px; left: 18px; padding: 12px 18px 11px; }
.brand-title { font-family: var(--serif); font-size: 22px; letter-spacing: 0.01em; line-height: 1.1; }
.brand-title em { color: var(--accent); }
.brand-sub { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.04em; margin-top: 3px; }

/* ------------------------------------------------------------------ side panel */
.side {
  top: 18px;
  right: 18px;
  width: 248px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding: 14px 14px 12px;
  scrollbar-width: thin;
}
.side section + section { margin-top: 14px; }
.side h2 {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin: 0 0 8px 2px;
}
.side-toggle { display: none; top: 18px; right: 18px; width: 42px; height: 42px; border-radius: 12px; cursor: pointer; font-size: 18px; }

.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 3px; border-radius: 11px; background: var(--ink-faint); }
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 560;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--glass-strong); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }

.places { display: flex; flex-direction: column; gap: 1px; max-height: 32vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.places button {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
}
.places button small { color: var(--ink-soft); font-size: 10.5px; white-space: nowrap; }
.places button:hover, .places button.on { background: var(--accent-soft); }


.follow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.follow button {
  border: 1px solid var(--ink-faint);
  background: transparent;
  border-radius: 9px;
  padding: 6px 2px;
  font-size: 12px;
  cursor: pointer;
}
.follow button:hover { background: var(--ink-faint); }
.follow button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ time bar */
.timebar {
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px 10px 10px;
  width: min(860px, calc(100vw - 36px));
}
body.is-loading .timebar { transform: translate(-50%, 8px); }
.play {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s, background 0.6s;
}
.play:hover { transform: scale(1.06); }
.play svg { width: 18px; height: 18px; fill: currentColor; }
.play .icon-pause, .play.on .icon-play { display: none; }
.play.on .icon-pause { display: block; }

.clock { display: flex; flex-direction: column; min-width: 92px; }
.clock span { font-size: 26px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1; }
.clock small { font-size: 11px; color: var(--ink-soft); margin-top: 3px; white-space: nowrap; }

.slider-wrap { flex: 1; position: relative; padding-top: 4px; }
#time {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
#time::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 8px;
  background: linear-gradient(90deg, #0d1530 0%, #1b2550 20%, #d98a7a 27%, #f5cf9a 31%, #9cc8ec 40%, #7fb6e8 50%, #9cc8ec 72%, #f6c48a 80%, #d9776a 84%, #2a2c58 90%, #0d1530 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
#time::-moz-range-track {
  height: 8px;
  border-radius: 8px;
  background: linear-gradient(90deg, #0d1530 0%, #1b2550 20%, #d98a7a 27%, #f5cf9a 31%, #9cc8ec 40%, #7fb6e8 50%, #9cc8ec 72%, #f6c48a 80%, #d9776a 84%, #2a2c58 90%, #0d1530 100%);
}
#time::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
#time::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.sun-marks { position: absolute; left: 11px; right: 11px; top: 0; height: 30px; pointer-events: none; }
.sun-marks i { position: absolute; top: 0; width: 1px; height: 26px; background: var(--ink-soft); opacity: 0.35; }
.ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-soft); padding: 0 4px; margin-top: 1px; }

.presets { display: flex; gap: 4px; flex: none; }
.presets button {
  border: 1px solid var(--ink-faint);
  background: transparent;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.presets button:hover { background: var(--ink-faint); }

/* ------------------------------------------------------------------ info card */
.card {
  left: 18px;
  bottom: 104px;
  width: min(360px, calc(100vw - 36px));
  padding: 18px 20px 16px;
  animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.card[hidden] { display: none; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.card-kicker { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 650; }
.card h3 { font-family: var(--serif); font-weight: 500; font-size: 23px; line-height: 1.15; margin: 5px 26px 8px 0; }
.card p { font-size: 13.2px; line-height: 1.55; margin: 0 0 12px; color: var(--ink); opacity: 0.92; }
.card p:empty { display: none; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12px; margin: 0 0 12px; }
.card dt { color: var(--ink-soft); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
.card-close { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--ink-faint); cursor: pointer; font-size: 17px; line-height: 1; }
.card-actions { display: flex; align-items: center; gap: 14px; }
.card-actions button { border: 0; background: var(--accent); color: #fff; border-radius: 999px; padding: 7px 14px; font-size: 12.5px; cursor: pointer; }
.card-actions a { font-size: 12px; color: var(--ink-soft); text-decoration: none; }
.card-actions a:hover { color: var(--ink); }

/* ------------------------------------------------------------------ compass, hint, attribution */
.compass { right: 18px; bottom: 26px; width: 50px; height: 50px; border-radius: 50%; padding: 5px; cursor: pointer; }
.compass svg { width: 100%; height: 100%; overflow: visible; }
.compass .n { fill: #d0503c; }
.compass .s { fill: var(--ink-soft); opacity: 0.6; }
.compass text { font-size: 6px; font-weight: 700; fill: var(--ink); }
.hint { left: 50%; bottom: 102px; transform: translateX(-50%); padding: 7px 14px; font-size: 12px; color: var(--ink-soft); border-radius: 999px; white-space: nowrap; }
.hint.gone { opacity: 0; pointer-events: none; }
.attrib { position: fixed; z-index: 9; left: 20px; bottom: 6px; font-size: 10.5px; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); transition: opacity 0.6s; }
.attrib a { color: inherit; }

/* ------------------------------------------------------------------ labels */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.label {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  will-change: transform, opacity;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.label.lm { pointer-events: auto; cursor: pointer; }
.label.lm .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 6px;
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.9);
  color: #2a2418;
  font-size: 11.5px;
  font-weight: 560;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, calc(-100% - 22px));
  transition: background 0.3s, transform 0.2s;
}
.label.lm .pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #c9953c; box-shadow: 0 0 0 2px rgba(201, 149, 60, 0.25); }
.label.lm::after {
  content: "";
  position: absolute;
  left: 0;
  top: -22px;
  width: 1px;
  height: 22px;
  background: linear-gradient(rgba(255, 252, 245, 0.9), rgba(255, 252, 245, 0));
}
.label.lm:hover .pill { transform: translate(-50%, calc(-100% - 24px)) scale(1.05); }
.label.lm.sel .pill { background: #c9953c; color: #fff; }
.label.lm.sel .pill::before { background: #fff; }
body.night .label.lm .pill { background: rgba(20, 24, 38, 0.86); color: #f3ead6; }
body.night .label.lm::after { background: linear-gradient(rgba(243, 234, 214, 0.7), rgba(243, 234, 214, 0)); }

.label.place span {
  display: block;
  transform: translate(-50%, -50%);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.55), 0 1px 8px rgba(0, 0, 0, 0.35);
}
.label.place.r4 span { font-size: 9.5px; letter-spacing: 0.1em; opacity: 0.85; }
.label.water span { display: block; transform: translate(-50%, -50%); font-family: var(--serif); font-style: italic; font-size: 15px; letter-spacing: 0.08em; color: rgba(225, 244, 255, 0.95); text-shadow: 0 1px 6px rgba(0, 40, 70, 0.6); }
.label.peak span { display: block; transform: translate(-50%, -100%); font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.label.peak span::before { content: "▲ "; font-size: 8px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 820px) {
  /* menu ends above the compass and scrolls as a single block (dvh follows the visible height) */
  .side { display: none; top: 70px; max-height: calc(100vh - 228px); max-height: calc(100dvh - 228px); }
  .places { max-height: none; }
  .side.open { display: block; }
  .side-toggle { display: grid; place-items: center; }
  .presets { display: none; }
  .hint { display: none; }
  .brand-sub { display: none; }
  /* compass above the time bar, info card above the compass */
  .compass { bottom: 96px; }
  .card { bottom: 158px; max-height: calc(100dvh - 240px); overflow-y: auto; }
}

/* phones held horizontally: too little height for an open panel, so the menu stays behind its
   button, and the compass moves to the right of the time bar instead of covering it */
@media (orientation: landscape) and (max-height: 500px) {
  .side { display: none; top: 70px; max-height: calc(100vh - 168px); max-height: calc(100dvh - 168px); }
  .side.open { display: block; }
  .places { max-height: none; }
  .side-toggle { display: grid; place-items: center; }
  .presets { display: none; }
  .hint { display: none; }
  .brand-sub { display: none; }
  .timebar { left: calc(50% - 31px); width: min(860px, calc(100vw - 98px)); }
  .compass { bottom: 29px; }
  .card { bottom: 104px; max-height: calc(100vh - 176px); max-height: calc(100dvh - 176px); overflow-y: auto; }
}
