:root {
  --ink: #1d2327;
  --paper: #f3f1ec;
  --mist: rgba(243, 241, 236, 0.72);
  --line: rgba(29, 35, 39, 0.14);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #cfd8dd; color: var(--ink); font-family: 'Manrope', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.screen[hidden] { display: none; }
#loading { background: linear-gradient(180deg, #dfe6ea 0%, #eae6dc 100%); transition: opacity 0.8s; }
.load-inner { text-align: center; }
.wordmark { font-weight: 300; font-size: clamp(2.4rem, 6vw, 4rem); letter-spacing: 0.32em; text-transform: lowercase; padding-left: 0.32em; }
.load-bar { width: 220px; height: 1px; background: var(--line); margin: 2rem auto 1rem; overflow: hidden; }
.load-bar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.3s; }
.load-note { font-size: 0.78rem; letter-spacing: 0.14em; opacity: 0.55; }
#boot-fail .card { max-width: 420px; padding: 2rem; background: var(--paper); border-radius: 14px; }
#boot-fail h1 { font-weight: 300; letter-spacing: 0.2em; margin-bottom: 1rem; }
#boot-fail p { line-height: 1.6; margin-bottom: 1.2rem; }
#boot-fail a { color: var(--ink); }

/* ── the overlay ────────────────────────────────────────────────────── */
#loading.gone { opacity: 0; pointer-events: none; }
.ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.ui button, .ui a, .ui input { pointer-events: auto; }
.title { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 1.6s ease; background: radial-gradient(ellipse at 50% 45%, rgba(18, 22, 26, 0) 0%, rgba(18, 22, 26, 0.34) 100%); }
.title.show { opacity: 1; pointer-events: auto; }
.title-inner { text-align: center; color: #fff; text-shadow: 0 2px 26px rgba(0, 0, 0, 0.35); }
.title .wordmark { font-size: clamp(3rem, 8vw, 5.6rem); }
.tagline { font-weight: 300; letter-spacing: 0.1em; opacity: 0.92; margin: 0.5rem 0 2.6rem; }
.title-actions { display: flex; flex-direction: column; gap: 0.6rem; width: min(340px, 86vw); margin: 0 auto; }
.btn { font: inherit; font-size: 0.95rem; font-weight: 500; letter-spacing: 0.02em; padding: 0.85rem 1.2rem; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.42); background: rgba(250, 249, 246, 0.14); color: #fff; backdrop-filter: blur(14px) saturate(1.15); -webkit-backdrop-filter: blur(14px) saturate(1.15); cursor: pointer; text-align: left; transition: background 0.2s, transform 0.2s; text-shadow: none; }
.btn span { display: block; font-size: 0.74rem; font-weight: 400; opacity: 0.78; margin-top: 0.15rem; }
.btn:hover { background: rgba(250, 249, 246, 0.28); transform: translateY(-1px); }
.btn.primary { background: rgba(250, 249, 246, 0.92); color: var(--ink); border-color: transparent; }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.28); }
.btn.small { padding: 0.45rem 0.95rem; font-size: 0.82rem; }
.keys { margin-top: 2.4rem; font-size: 0.78rem; opacity: 0.88; letter-spacing: 0.02em; line-height: 2; max-width: 38rem; padding: 0 1rem; }
kbd { font-family: inherit; font-size: 0.72rem; padding: 0.08rem 0.42rem; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 5px; white-space: nowrap; }
.back { position: absolute; left: 1.4rem; top: 1.2rem; color: #fff; opacity: 0.8; text-decoration: none; font-size: 0.85rem; letter-spacing: 0.06em; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4); }
.back:hover { opacity: 1; }

.hud { position: absolute; inset: 0; color: #fff; text-shadow: 0 1px 14px rgba(0, 0, 0, 0.45), 0 0 2px rgba(0, 0, 0, 0.25); transition: opacity 0.6s; }
.hud.hidden { opacity: 0; }
.dist { position: absolute; left: 1.6rem; bottom: 1.4rem; opacity: 0; transition: opacity 1.4s ease; }
.dist.show { opacity: 0.92; }
.dist b { display: inline-block; font-weight: 300; font-size: 1.7rem; letter-spacing: 0.02em; line-height: 1; font-variant-numeric: tabular-nums; margin-right: 0.35rem; }
.dist .where { display: block; font-style: normal; font-size: 0.78rem; letter-spacing: 0.06em; opacity: 0.85; margin-top: 0.25rem; }
.dist .pace { display: none; margin-top: 0.4rem; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; padding: 0.22rem 0.55rem; border-radius: 999px; background: rgba(250, 249, 246, 0.9); color: var(--ink); text-shadow: none; }
.dist .pace.on { display: inline-block; }
.dist .pace.wandering { margin-left: 0.35rem; background: rgba(250, 249, 246, 0.6); }
.dist small { font-size: 0.7rem; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0.85; }
.dist em { display: block; font-style: normal; font-size: 0.78rem; opacity: 0.72; margin-top: 0.2rem; }
.place { position: absolute; left: 50%; top: 60%; transform: translate(-50%, 0.6rem); text-align: center; opacity: 0; transition: opacity 2.4s ease, transform 2.4s ease; width: 90vw; }
.place.show { opacity: 1; transform: translate(-50%, 0); }
.place small { font-size: 0.7rem; letter-spacing: 0.42em; text-transform: uppercase; opacity: 0.85; padding-left: 0.42em; }
.place h2 { font-weight: 300; font-size: clamp(1.8rem, 4.4vw, 3.1rem); letter-spacing: 0.06em; margin: 0.35rem 0 0.25rem; }
.place em { font-weight: 300; font-size: 0.98rem; opacity: 0.88; letter-spacing: 0.04em; }
.note { position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%); font-size: 0.95rem; letter-spacing: 0.05em; opacity: 0; transition: opacity 1.2s; text-align: center; width: 90vw; }
.note.show { opacity: 0.95; }
.prompt { position: absolute; left: 50%; top: 57%; transform: translateX(-50%); font-size: 0.9rem; letter-spacing: 0.04em; opacity: 0; transition: opacity 0.3s; }
.prompt.show { opacity: 1; }
.fps { position: absolute; right: 1rem; top: 0.8rem; font-size: 0.75rem; opacity: 0.72; font-variant-numeric: tabular-nums; }

.pause, .settings { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.35s; background: rgba(26, 30, 34, 0.26); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.pause.show, .settings.show { opacity: 1; pointer-events: auto; }
.card { background: rgba(247, 246, 242, 0.88); color: var(--ink); border-radius: 18px; padding: 2rem 2rem 1.6rem; width: min(380px, 90vw); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.2); text-shadow: none; }
.card h2 { font-weight: 400; letter-spacing: 0.1em; margin-bottom: 0.4rem; }
.card .btn { color: var(--ink); border-color: var(--line); background: rgba(255, 255, 255, 0.55); backdrop-filter: none; -webkit-backdrop-filter: none; }
.card .btn:hover { background: #fff; }
.card .btn.primary { background: var(--ink); color: var(--paper); }
.card .btn.ghost { background: transparent; }
.pause-info { font-size: 0.85rem; opacity: 0.7; margin-bottom: 1.3rem; line-height: 1.5; }
.back-inline { display: block; margin-top: 1.3rem; font-size: 0.8rem; color: var(--ink); opacity: 0.6; text-decoration: none; }
.back-inline:hover { opacity: 0.9; }
.card.wide { width: min(640px, 94vw); max-height: 86vh; display: flex; flex-direction: column; padding: 1.6rem 1.8rem 1.2rem; }
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.settings-body { overflow-y: auto; padding-right: 0.4rem; }
.settings section { margin-bottom: 1.3rem; }
.settings h3 { font-size: 0.68rem; letter-spacing: 0.26em; text-transform: uppercase; opacity: 0.5; font-weight: 500; margin-bottom: 0.3rem; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.row label { font-size: 0.9rem; }
.row label small { display: block; font-size: 0.72rem; opacity: 0.55; margin-top: 0.1rem; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: inherit; font-size: 0.78rem; padding: 0.42rem 0.72rem; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.seg button:hover { background: rgba(29, 35, 39, 0.06); }
.seg button.on { background: var(--ink); color: var(--paper); }
.slider { display: flex; align-items: center; gap: 0.6rem; }
.slider input { width: 150px; accent-color: #1d2327; }
.slider output { font-size: 0.78rem; width: 3.2rem; text-align: right; font-variant-numeric: tabular-nums; opacity: 0.75; }
.toggle { font: inherit; font-size: 0.78rem; padding: 0.36rem 0.9rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; min-width: 3.6rem; }
.toggle.on { background: var(--ink); color: var(--paper); }
@media (max-width: 640px) {
  .row { flex-direction: column; align-items: flex-start; }
  .dist { left: 1.2rem; bottom: 1.2rem; }
  .keys { display: none; }
}
/* hidden panels take no clicks, once their fade is done */
.title, .pause, .settings { visibility: hidden; }
.title { transition: opacity 1.6s ease, visibility 0s linear 1.6s; }
.pause, .settings { transition: opacity 0.35s, visibility 0s linear 0.35s; }
.title.show, .pause.show, .settings.show { visibility: visible; transition-delay: 0s; }

/* journey and travel panels share the settings sheet */
.journey .tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin: 0.4rem 0 1.2rem; }
.journey .tally b { display: block; font-weight: 300; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.journey .tally small { font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.6; }
.journey table.where { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.journey table.where td { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.journey table.where td:last-child { text-align: right; font-variant-numeric: tabular-nums; opacity: 0.8; }
.journey .quiet { font-size: 0.85rem; opacity: 0.6; }
.travel .places { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.5rem; overflow-y: auto; }
.travel .places .btn.here { opacity: 0.55; }
@media (max-width: 520px) { .journey .tally { grid-template-columns: repeat(2, 1fr); } }

/* the veil over a long journey, lifted when the new country has grown in */
.veil { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #f4f2ec; color: var(--ink); opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.9s ease, visibility 0s linear 0.9s; text-shadow: none; }
.veil.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.5s ease, visibility 0s; }
.veil p { font-size: 1rem; letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.7; }

/* binoculars: two overlapping fields of view, soft at the rim */
.binoc { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.25s; }
.binoc.show { opacity: 1; }
.binoc::before { content: ''; position: absolute; inset: 0; background: #07080a;
  -webkit-mask: radial-gradient(circle at 37% 50%, transparent 0 31vmin, #000 34vmin), radial-gradient(circle at 63% 50%, transparent 0 31vmin, #000 34vmin);
  -webkit-mask-composite: source-in; mask: radial-gradient(circle at 37% 50%, transparent 0 31vmin, #000 34vmin), radial-gradient(circle at 63% 50%, transparent 0 31vmin, #000 34vmin);
  mask-composite: intersect; }

/* the pin set on the map, kept in the corner of the eye */
.pin { position: absolute; left: 50%; top: 1.1rem; transform: translateX(-50%); display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; letter-spacing: 0.04em; opacity: 0; transition: opacity 0.6s; pointer-events: none; }
.pin.show { opacity: 0.92; }
.pin svg { color: #fff; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.45)); transition: transform 0.12s linear; }
.pin b { font-weight: 600; }
.pin span { opacity: 0.85; font-variant-numeric: tabular-nums; }

/* the map in your hand: lifted out of the pocket, unfolded, held up */
.held { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; pointer-events: none;
  background: radial-gradient(ellipse at 50% 60%, rgba(20, 24, 28, 0.05), rgba(20, 24, 28, 0.42)); transition: opacity 0.35s ease, visibility 0s linear 0.6s; color: #2b2622; text-shadow: none; }
.held.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.3s ease, visibility 0s; }
.paper { position: relative; width: min(1000px, 95vw); height: min(720px, 92vh); display: flex; flex-direction: column; padding: 1rem 1.3rem 0.9rem; border-radius: 3px;
  background:
    linear-gradient(90deg, transparent 49.6%, rgba(90, 70, 40, 0.09) 50%, rgba(255, 255, 255, 0.35) 50.4%, transparent 51%),
    linear-gradient(0deg, transparent 49.4%, rgba(90, 70, 40, 0.07) 50%, rgba(255, 255, 255, 0.3) 50.6%, transparent 51.2%),
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(160, 130, 80, 0.12), transparent 55%),
    #f3eddc;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.6) inset, 0 30px 90px rgba(0, 0, 0, 0.38), 0 6px 18px rgba(0, 0, 0, 0.18);
  transform: perspective(1500px) translateY(70vh) rotateX(24deg) rotateZ(4deg) scale(0.9); transition: transform 0.6s cubic-bezier(0.2, 0.75, 0.25, 1); }
.held.show .paper { transform: perspective(1500px) translateY(1.5vh) rotateX(5deg) rotateZ(-0.7deg); animation: held-sway 7s ease-in-out 0.6s infinite; }
@keyframes held-sway { 0%, 100% { translate: 0 0; rotate: 0deg; } 35% { translate: 2px -3px; rotate: 0.25deg; } 70% { translate: -2px 1px; rotate: -0.2deg; } }
@media (prefers-reduced-motion: reduce) { .held.show .paper { animation: none; } .paper { transition: none; } }
.paper-head { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.paper-title { flex: 1; min-width: 12rem; }
.paper-title h2 { font-weight: 300; font-size: 1.55rem; letter-spacing: 0.08em; line-height: 1.1; }
.paper-title small { display: block; font-size: 0.78rem; letter-spacing: 0.06em; opacity: 0.62; margin-top: 0.15rem; font-style: italic; }
.paper-tabs { display: flex; border: 1px solid rgba(43, 38, 34, 0.25); border-radius: 999px; overflow: hidden; }
.paper-tabs button, .paper-put, .local-zoom button, .dial-presets button { font: inherit; color: inherit; background: transparent; border: 0; cursor: pointer; }
.paper-tabs button { font-size: 0.8rem; padding: 0.42rem 0.95rem; letter-spacing: 0.03em; }
.paper-tabs button.on { background: #2b2622; color: #f3eddc; }
.paper-put { font-size: 0.78rem; opacity: 0.7; padding: 0.4rem 0.2rem; }
.paper-put:hover { opacity: 1; }
.paper-put kbd, .paper kbd { border-color: rgba(43, 38, 34, 0.35); }
.paper-page { display: none; position: relative; flex: 1; min-height: 0; }
.paper-page.show { display: block; }
.paper-page.here { border: 1px solid rgba(60, 46, 30, 0.35); box-shadow: 0 0 0 3px #f3eddc, 0 0 0 4px rgba(60, 46, 30, 0.2); overflow: hidden; }
.paper-page.world { overflow-y: auto; }
.paper-note { font-size: 0.82rem; opacity: 0.68; margin: 0 0 0.6rem; }
canvas.local { display: block; width: 100%; height: 100%; cursor: crosshair; }
.local-zoom { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; border: 1px solid rgba(43, 38, 34, 0.3); border-radius: 8px; overflow: hidden; background: rgba(250, 247, 238, 0.85); }
.local-zoom button { width: 28px; height: 26px; font-size: 1rem; line-height: 1; }
.local-zoom button + button { border-top: 1px solid rgba(43, 38, 34, 0.2); }
.local-zoom button:hover { background: #fff; }
.local-legend { position: absolute; right: 10px; bottom: 8px; font-size: 0.68rem; font-style: italic; opacity: 0.7; background: rgba(250, 247, 238, 0.75); padding: 0.1rem 0.4rem; border-radius: 4px; pointer-events: none; }
.local-tip { position: absolute; pointer-events: none; background: rgba(252, 250, 244, 0.95); border: 1px solid rgba(43, 38, 34, 0.2); border-radius: 8px; padding: 0.35rem 0.6rem; font-size: 0.78rem; opacity: 0; transition: opacity 0.15s; white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.local-tip.show { opacity: 1; }
.local-tip b { display: block; font-weight: 600; }
.local-tip small { display: block; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.5; margin-top: 0.1rem; }
.paper-watch { margin-top: 0.8rem; }
.dial-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.35rem; }
.dial-label { font-size: 0.66rem; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0.6; }
.dial-time { font-size: 0.95rem; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.dial { position: relative; height: 14px; margin: 0 8px; }
.dial-track { position: absolute; inset: 0; border-radius: 999px; box-shadow: 0 0 0 1px rgba(43, 38, 34, 0.25) inset; }
.dial-gold { position: absolute; top: -4px; bottom: -4px; border: 1.5px solid #d9902f; border-radius: 6px; pointer-events: none; }
.dial-sun { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: #fff7dc; border: 2px solid #2b2622; transform: translate(-50%, -50%); box-shadow: 0 0 0 4px rgba(255, 220, 140, 0.35); pointer-events: none; }
.dial input { position: absolute; left: -8px; right: -8px; top: -8px; bottom: -8px; width: calc(100% + 16px); opacity: 0; cursor: pointer; margin: 0; }
.dial-hours { display: flex; justify-content: space-between; font-size: 0.62rem; opacity: 0.5; margin: 0.25rem 2px 0.5rem; font-variant-numeric: tabular-nums; }
.dial-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.dial-presets button { font-size: 0.76rem; padding: 0.32rem 0.75rem; border: 1px solid rgba(43, 38, 34, 0.25); border-radius: 999px; }
.dial-presets button:hover { background: rgba(255, 255, 255, 0.7); }
.dial-presets button.gold { border-color: #d9902f; color: #8a5414; font-weight: 600; }
.dial-presets button.hold { margin-left: auto; }
.dial-presets button.hold.on { background: #2b2622; color: #f3eddc; border-color: #2b2622; }
@media (max-width: 640px) { .paper { padding: 0.8rem; } .paper-title h2 { font-size: 1.2rem; } .dial-presets button.hold { margin-left: 0; } }

/* the controls, along the bottom: always there, so nobody has to guess */
.controls { position: absolute; left: 50%; bottom: 0.8rem; transform: translateX(-50%); width: min(1000px, calc(100vw - 500px)); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.35rem 0.85rem; font-size: 0.72rem; letter-spacing: 0.03em; line-height: 1.2; opacity: 0.8; pointer-events: none; }
.controls .c { display: inline-flex; align-items: center; gap: 0.28rem; white-space: nowrap; transition: opacity 0.3s; }
.controls kbd { font-size: 0.66rem; padding: 0.1rem 0.4rem; background: rgba(20, 24, 28, 0.28); border-color: rgba(255, 255, 255, 0.55); }
.controls .c kbd + kbd { margin-left: 0.05rem; }
.controls .c kbd:last-of-type { margin-right: 0.2rem; }
.controls .c.on kbd { background: rgba(250, 249, 246, 0.95); color: var(--ink); border-color: transparent; text-shadow: none; }
.controls .c.on { font-weight: 600; }
/* the controls are for a keyboard: on a phone, or when the window is narrow, there is no room for them */
@media (max-width: 900px), (pointer: coarse) { .controls { display: none !important; } }
.note { bottom: max(13%, 5.2rem); }
