:root {
  --ink: #1d1d1f;
  --ink-soft: rgba(29, 29, 31, 0.62);
  --paper: #f7f3ea;
  --gold: #b48f4a;
  --gold-bright: #d9b671;
  --glass: rgba(26, 25, 24, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #e7dfd1; color: var(--ink);
  font: 14px/1.45 var(--sans); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* map labels */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#labels > * { position: absolute; left: 0; top: 0; white-space: nowrap; transition: opacity 0.25s; will-change: transform; }
#labels > .off { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s, visibility 0s 0.25s; }
.pin { pointer-events: auto; display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 9px; border: 0;
  border-radius: 999px; background: var(--glass); color: #fff; font-weight: 600; font-size: 13px; letter-spacing: 0.01em;
  box-shadow: 0 6px 18px rgba(40, 30, 15, 0.28); backdrop-filter: blur(6px); }
.pin::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1.5px; height: 14px; background: var(--ink); opacity: 0.55; }
.pin:hover, .pin:focus-visible { background: var(--ink); outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.pin.below::after { top: auto; bottom: 100%; height: 8px; }
.pin { z-index: 2; }
.pin.mini { padding: 6px; gap: 0; z-index: 1; }
.pin.mini .pin-name { display: none; }
.pin-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-bright); box-shadow: 0 0 0 3px rgba(217, 182, 113, 0.28); }
.place { color: rgba(74, 62, 46, 0.72); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  text-shadow: 0 0 6px rgba(247, 243, 234, 0.9), 0 0 2px rgba(247, 243, 234, 0.9); }
.place.rank0, .place.rank1 { font-size: 12px; color: rgba(60, 50, 36, 0.82); }

/* title */
.masthead { position: fixed; left: max(20px, env(safe-area-inset-left)); top: max(16px, env(safe-area-inset-top));
  pointer-events: none; text-shadow: 0 1px 12px rgba(247, 243, 234, 0.8); }
.masthead h1, .loader h1 { margin: 0; font: 400 30px/1.1 var(--serif); letter-spacing: -0.01em; }
.masthead h1 em, .loader h1 em { color: var(--gold); font-style: italic; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--ink-soft); }
.hint-touch { display: none; }
@media (pointer: coarse) { .hint-mouse { display: none; } .hint-touch { display: block; } }

/* project card */
.card { position: fixed; left: max(20px, env(safe-area-inset-left)); top: 104px; width: 340px;
  max-height: calc(100% - 200px); overflow-y: auto; padding: 20px 20px 18px; border-radius: 16px;
  background: var(--glass); color: #f3efe6; backdrop-filter: blur(14px); box-shadow: 0 18px 50px rgba(40, 30, 15, 0.35);
  opacity: 0; transition: opacity 0.3s; overscroll-behavior: contain; }
.card.open { opacity: 1; }
.card-close { position: absolute; right: 10px; top: 8px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: #fff; font-size: 24px; line-height: 1; opacity: 0.7; }
.card-close:hover, .card-close:focus-visible { opacity: 1; background: rgba(255, 255, 255, 0.1); outline: none; }
.card-status { display: inline-block; margin: 0 0 10px; padding: 3px 10px; border: 1px solid rgba(217, 182, 113, 0.55);
  border-radius: 999px; color: var(--gold-bright); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.card h2 { margin: 0; padding-right: 30px; font: 400 26px/1.15 var(--serif); color: #fff; }
.card-area { margin: 4px 0 14px; color: rgba(243, 239, 230, 0.66); }
.card figure { margin: 0 0 14px; }
.card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: #333; }
.card figcaption { margin-top: 5px; font-size: 11px; color: rgba(243, 239, 230, 0.55); }
.card dl { display: grid; grid-template-columns: 86px 1fr; gap: 0; margin: 0; }
.card dt, .card dd { margin: 0; padding: 8px 0; border-top: 1px solid var(--line); }
.card dt { color: rgba(243, 239, 230, 0.55); font-size: 12px; padding-top: 9px; }
.card-note { margin: 12px 0 0; font-size: 12px; color: rgba(243, 239, 230, 0.55); }
.card-link { display: block; margin-top: 14px; padding: 11px 14px; border-radius: 10px; background: var(--gold);
  color: #1b1509; font-weight: 600; text-align: center; text-decoration: none; }
.card-link:hover, .card-link:focus-visible { background: var(--gold-bright); outline: none; }

/* bottom strip */
.strip { position: fixed; left: 50%; bottom: max(30px, calc(env(safe-area-inset-bottom) + 26px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; max-width: calc(100% - 24px); padding: 6px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(14px); box-shadow: 0 12px 34px rgba(40, 30, 15, 0.3); }
.chips { position: relative; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 15px; border: 0; border-radius: 999px; background: transparent;
  color: rgba(255, 255, 255, 0.82); font-weight: 600; font-size: 13px; white-space: nowrap; }
.chip:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.chip:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: -2px; }
.chip.active { background: #f3efe6; color: var(--ink); }
.chip.accent { color: var(--gold-bright); }
.chip.accent.active { background: var(--gold); color: #1b1509; }
.chip.quiet { color: rgba(255, 255, 255, 0.5); font-weight: 500; font-size: 12px; }
.rule { flex: none; width: 1px; height: 22px; background: var(--line); }

.credit { position: fixed; left: 0; right: 0; bottom: max(6px, env(safe-area-inset-bottom)); margin: 0; padding: 0 12px;
  text-align: center; font-size: 10.5px; color: rgba(60, 50, 36, 0.7); pointer-events: none; }
.credit a { color: inherit; pointer-events: auto; }

.message { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: min(420px, calc(100% - 40px));
  padding: 18px 22px; border-radius: 14px; background: var(--ink); color: #fff; text-align: center; z-index: 30; }
.loader { position: fixed; inset: 0; display: grid; place-items: center; background: #e7dfd1; text-align: center;
  z-index: 20; transition: opacity 0.6s; }
.loader.done { opacity: 0; pointer-events: none; }
.loader p { margin: 10px 0 0; color: var(--ink-soft); }

/* touch devices: blurring a moving 3D canvas is costly, so use solid panels instead */
@media (pointer: coarse) {
  :root { --glass: rgba(26, 25, 24, 0.93); }
  .pin, .card, .strip { backdrop-filter: none; }
}

/* phones held upright */
@media (max-width: 759px) {
  .masthead h1 { font-size: 24px; }
  .hint { font-size: 11px; }
  .card { left: 10px; right: 10px; top: auto; width: auto; bottom: calc(max(30px, env(safe-area-inset-bottom) + 26px) + 62px);
    max-height: 42%; padding: 16px 16px 14px; }
  .card h2 { font-size: 22px; }
  .card figure { display: none; }
  .strip { left: 10px; right: 10px; transform: none; max-width: none; }
  .chips { flex: 1; }
  .chip { padding: 0 12px; }
  .chip.quiet { display: none; }
  .credit { font-size: 9px; line-height: 1.2; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
