:root {
  --bg-top: #2e2e2e;
  --bg-bottom: #0c0c0c;
  /* warm cream instead of white, to sit with the lantern light */
  --ink: #221b11;
  --ink-soft: #66584a;
  --card: #fbf2d9;
  --card-in: #fffaea;
  --card-line: #e8d7ab;
  --accent: #2c2216;
  --accent-ink: #fff3d6;
  --focus: #b8964f;
  --tag-bg: #f3e4bd;
  --glass: rgba(251, 242, 217, 0.93);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(ellipse at 50% 20%, var(--bg-top), var(--bg-bottom) 70%);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* title logo: warm, glowing like the lantern; a dark brown edge keeps it readable on the night sky and the haze */
.brand { position: fixed; top: 12px; left: 16px; pointer-events: none; }
.brand-name {
  margin: 0; font-family: "Darumadrop One", "Nunito", system-ui, sans-serif; font-weight: 400;
  font-size: 40px; line-height: 1; letter-spacing: 0.01em; color: #ffe7b0;
  text-shadow: 0 2px 0 #7a3f12, 0 3px 0 #5c2c0a, 0 0 18px rgba(255, 160, 60, 0.55), 0 6px 14px rgba(0, 0, 0, 0.45);
}

/* region buttons: a row at the bottom centre (the ? button stays top right) */
.nav {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: calc(100vw - 32px);
}
.nav button {
  font: inherit; font-weight: 800; font-size: 14px;
  border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer;
  background: var(--glass); color: var(--ink); box-shadow: var(--shadow);
  transition: transform .15s ease, background .15s ease;
}
.nav button:hover { transform: translateY(-2px); }
.nav button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.nav button:focus-visible, .panel a:focus-visible, .panel-close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.panel {
  position: fixed; right: 16px; top: 76px;
  width: min(360px, calc(100vw - 32px)); max-height: calc(100vh - 160px);
  display: flex; flex-direction: column; overflow: hidden;   /* title stays; only the body scrolls */
  padding: 20px 0 0; border-radius: 20px;
  background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--card-line);
  animation: pop .25s ease-out;
}
.panel[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.panel-title { flex: none; margin: 0 54px 10px 22px; font-size: 22px; font-weight: 800; }
.panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 22px 22px; font-size: 15px; line-height: 1.55; color: var(--ink-soft); }
.panel-body p { margin: 0 0 10px; }
.panel-body strong { color: var(--ink); }
.panel-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
  border: 0; border-radius: 50%; background: var(--card-line); color: var(--ink);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.panel-body .highlight { margin: -4px 0 10px; font-weight: 800; color: var(--ink); }
.panel-body h3 { margin: 14px 0 6px; font-size: 14px; color: var(--ink); }
.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: 9px 12px; margin-bottom: 6px; border-radius: 12px; background: var(--card-in); border: 1px solid var(--card-line); font-size: 14px; line-height: 1.4; }
.events b { display: block; color: var(--ink); }
.events .when { float: right; margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.impacts { margin: 0 0 10px; padding-left: 18px; font-size: 14px; }
.panel-body .total { font-weight: 700; color: var(--ink); }
.panel-body .source { font-size: 12px; line-height: 1.45; }

.labels { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.brand, .nav, .panel, .hint, .info-btn { z-index: 1; }
.label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%);
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--glass); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  font-weight: 800; font-size: 13px; transition: opacity .2s;
}
.label::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--glass); }
.isle {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font-weight: 800; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92); text-shadow: 0 1px 3px rgba(0, 40, 80, 0.85), 0 0 10px rgba(0, 40, 80, 0.5);
  transition: opacity .3s;
}

/* "?" button (top right) and its dialog: developer, 3D model credits, data sources */
.info-btn {
  position: fixed; top: 16px; right: 16px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--glass); color: var(--ink); box-shadow: var(--shadow); cursor: pointer;
  font: inherit; font-weight: 800; font-size: 19px; line-height: 1; transition: transform .15s ease;
}
.info-btn:hover { transform: translateY(-2px); }
.info-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.info {
  width: min(440px, calc(100vw - 32px)); max-height: min(78vh, 680px); padding: 20px 0 0;
  border: 1px solid var(--card-line); border-radius: 20px; background: var(--card); color: var(--ink);
  box-shadow: var(--shadow); flex-direction: column; overflow: hidden;
}
.info[open] { display: flex; animation: pop .25s ease-out; }
.info::backdrop { background: rgba(0, 0, 0, 0.45); }
.info .panel-close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.info h3:first-child { margin-top: 0; }
.info a { color: var(--ink); }
.credits, .sources { margin: 0 0 8px; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.credits li, .sources li { margin-bottom: 4px; }
.credits .what { display: block; font-weight: 800; color: var(--ink); }
.hint {
  position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%);   /* above the region buttons */
  margin: 0; padding: 10px 16px; border-radius: 14px; width: max-content; max-width: calc(100vw - 32px);
  background: var(--glass); box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700; color: var(--ink-soft); text-align: center;
  transition: opacity .4s;
}
.hint kbd { display: inline-block; min-width: 20px; padding: 1px 5px; margin: 0 1px; border-radius: 5px; background: var(--card-in); border: 1px solid var(--card-line); font: inherit; font-size: 12px; color: var(--ink); }

/* opening screen */
.intro {
  position: fixed; inset: 0; z-index: 3; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 26, 10, 0.55), rgba(8, 6, 3, 0.85) 75%);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  transition: opacity .6s ease;
}
.intro.done { opacity: 0; pointer-events: none; }
.intro:not(.done) ~ .loader { visibility: hidden; }   /* the loading card waits behind the opening screen */
.intro-card { max-width: 560px; text-align: center; animation: pop .6s ease-out; }
.intro-headline {
  margin: 0 0 14px; font-family: "Darumadrop One", "Nunito", system-ui, sans-serif; font-weight: 400;
  font-size: clamp(30px, 6vw, 46px); line-height: 1.15; color: #ffe7b0;
  text-shadow: 0 2px 0 #7a3f12, 0 3px 0 #5c2c0a, 0 0 22px rgba(255, 160, 60, 0.5), 0 8px 18px rgba(0, 0, 0, 0.5);
}
.intro-text { margin: 0 0 26px; font-size: clamp(16px, 3.6vw, 19px); font-weight: 700; line-height: 1.5; color: #f3e2bd; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.intro-go {
  font: inherit; font-weight: 800; font-size: 19px; padding: 12px 44px; border: 0; border-radius: 999px; cursor: pointer;
  background: #c9902f; color: #2a1a08; box-shadow: 0 0 0 3px rgba(255, 220, 150, 0.25), 0 10px 26px rgba(0, 0, 0, 0.45);
  transition: transform .15s ease, background .15s ease;
}
.intro-go:hover { background: #d9a13d; transform: translateY(-2px); }
.intro-go:focus-visible { outline: 3px solid #ffe7b0; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .intro, .intro-card { transition: none; animation: none; } }

.loader { position: fixed; inset: 0; display: grid; place-items: center; transition: opacity .5s; }
.loader.done { opacity: 0; pointer-events: none; }
.loader-card { padding: 18px 22px; border-radius: 18px; background: var(--glass); box-shadow: var(--shadow); width: 240px; }
.loader-title { font-weight: 800; margin-bottom: 10px; }
.loader-bar { height: 8px; border-radius: 99px; background: var(--card-line); overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

@media (max-width: 640px) {
  .brand { top: 10px; left: 12px; }
  .info-btn { top: 12px; right: 12px; }
  .brand-name { font-size: 32px; }
  /* six regions: a 3 x 2 grid of buttons at the bottom; hint and panel sit above it */
  .nav { bottom: 12px; right: 12px; left: 12px; transform: none; width: auto; max-width: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .nav button { padding: 8px 4px; font-size: 12px; white-space: nowrap; }
  .hint { bottom: 106px; font-size: 12px; }
  .panel { top: auto; bottom: 106px; right: 12px; left: 12px; width: auto; max-height: 48vh; }
}
@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  .nav button { transition: none; }
}
