:root {
  color-scheme: light dark;
  --hk-graphite: #101820;
  --hk-mineral: #eaede8;
  --hk-current: #b5ecdb;
  --hk-surface: #101820;
  --hk-raised: #1c2731;
  --hk-text: #eaede8;
  --hk-muted: #b5bfc0;
  --hk-line: #3a4752;
  --hk-primary: #b5ecdb;
  --hk-on-primary: #101820;
  --hk-danger: #ffb4ab;
  --hk-focus: #b5ecdb;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Bright sun favors dark text on a light sheet, so light mode is a real field mode. */
@media (prefers-color-scheme: light) {
  :root {
    --hk-surface: #f6f7f3;
    --hk-raised: #ffffff;
    --hk-text: #101820;
    --hk-muted: #47535c;
    --hk-line: #c4cac4;
    --hk-primary: #101820;
    --hk-on-primary: #eaede8;
    --hk-danger: #a3190f;
    --hk-focus: #0b6b57;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--hk-surface); color: var(--hk-text); overscroll-behavior: none; }
button, input { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--hk-focus); outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.noscript { padding: 16px; }

.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.stage { flex: 1; min-height: 0; position: relative; }
.map, .terrain { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; background: #e4e6dc; }

.top { position: absolute; top: calc(env(safe-area-inset-top) + 10px); left: 12px; right: 76px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.chip { margin: 0; padding: 7px 12px; border-radius: 999px; background: var(--hk-graphite); color: var(--hk-mineral); font-size: 15px; font-weight: 600; box-shadow: 0 1px 4px rgb(0 0 0 / 40%); }
.chip[data-state="good"]::before, .chip[data-state="poor"]::before, .chip[data-state="lost"]::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 7px; border-radius: 50%; background: var(--dot); }
.chip[data-state="good"] { --dot: #55e39f; }
.chip[data-state="poor"] { --dot: #ffc247; }
.chip[data-state="lost"] { --dot: #ff6b5e; }

.notice { position: absolute; top: calc(env(safe-area-inset-top) + 54px); left: 12px; right: 76px; margin: 0; padding: 10px 12px; border-radius: 10px; background: #fff3cd; color: #2c2200; font-size: 15px; line-height: 1.35; box-shadow: 0 1px 4px rgb(0 0 0 / 40%); }

/* A second column grows leftward when a short screen can't fit them all above the sheet. */
.rail { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; max-height: calc(100dvh - var(--sheet-height, 240px) - env(safe-area-inset-top) - 20px); display: flex; flex-flow: column wrap-reverse; gap: 8px; }
.round { width: 50px; height: 50px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--hk-graphite); color: var(--hk-mineral); font-size: 26px; line-height: 1; box-shadow: 0 1px 4px rgb(0 0 0 / 40%); cursor: pointer; }
.round-text { font-size: 17px; font-weight: 800; }
.round[aria-pressed="true"] { background: var(--hk-current); color: var(--hk-graphite); }

.scale { position: absolute; left: 12px; bottom: var(--sheet-height, 240px); margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 600; color: #101820; text-shadow: 0 0 3px #fff, 0 0 3px #fff; pointer-events: none; }
.scale-bar { display: block; height: 5px; border: 2px solid #101820; border-top: 0; background: rgb(255 255 255 / 60%); }

.sheet { flex: none; padding: 12px 14px calc(env(safe-area-inset-bottom) + 8px); background: var(--hk-surface); border-top: 1px solid var(--hk-line); }

.arrival { display: block; width: 100%; margin-bottom: 10px; }
.checkpoint-progress { font-size: 18px; font-weight: 700; }
.guide { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 8px 10px; border-radius: 12px; background: var(--hk-raised); }
.guide-arrow { flex: none; color: var(--hk-primary); }
.guide-text { flex: 1; min-width: 0; margin: 0; display: grid; }
.guide-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-text span { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.guide-text small { color: var(--hk-muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0 0 10px; }
.stats dt { color: var(--hk-muted); font-size: 12px; }
.stats dd { margin: 0; font-size: clamp(17px, 5.3vw, 24px); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.actions, .row { display: flex; gap: 8px; }
.actions .button { min-width: 0; padding-inline: 6px; }
.stack { display: grid; gap: 8px; }
.row { margin-block: 12px; }
.wrap { flex-wrap: wrap; }
.button { flex: 1; min-height: 52px; padding: 8px 14px; border: 2px solid var(--hk-line); border-radius: 12px; background: var(--hk-raised); color: var(--hk-text); font-weight: 700; cursor: pointer; }
.button.primary { border-color: var(--hk-primary); background: var(--hk-primary); color: var(--hk-on-primary); }
.button.danger { border-color: var(--hk-danger); color: var(--hk-danger); }
.links { display: flex; justify-content: space-between; margin-top: 4px; }
.links .text-button { padding-inline: 2px; font-size: 15px; white-space: nowrap; }
.text-button { min-height: 44px; padding: 6px 8px; border: 0; background: none; color: var(--hk-text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.credit { margin: 0; color: var(--hk-muted); font-size: 12px; text-align: center; }
.credit a, .fine a { color: inherit; }

.panel { width: min(100vw - 24px, 480px); max-height: 86dvh; padding: 18px; border: 1px solid var(--hk-line); border-radius: 16px; background: var(--hk-surface); color: var(--hk-text); }
.panel::backdrop { background: rgb(0 0 0 / 55%); }
.panel h2 { margin: 0 0 10px; font-size: 22px; }
.panel h3 { margin: 18px 0 6px; font-size: 16px; }
.panel p { line-height: 1.4; }
.coords { display: grid; margin-top: 0; font-size: 21px; font-variant-numeric: tabular-nums; }
.coords small { color: var(--hk-muted); font-size: 14px; }
.fine { color: var(--hk-muted); font-size: 14px; }
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 9px 0; border-top: 1px solid var(--hk-line); }
.list .item-title { flex: 1 1 100%; display: grid; }
.list small { color: var(--hk-muted); }
.list .text-button { min-height: 40px; }
.pill { min-height: 44px; padding: 6px 16px; border: 1px solid var(--hk-line); border-radius: 999px; background: var(--hk-raised); color: var(--hk-text); font-weight: 600; cursor: pointer; }
label { display: block; margin-top: 8px; font-weight: 600; }
input { width: 100%; min-height: 48px; margin-top: 4px; padding: 8px 10px; border: 2px solid var(--hk-line); border-radius: 10px; background: var(--hk-raised); color: var(--hk-text); font-size: 17px; }
progress { width: 100%; height: 12px; }
.thumb { flex: none; width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.photo-full { display: block; width: 100%; max-height: 50dvh; object-fit: contain; border-radius: 10px; background: var(--hk-raised); }
.link-button { display: inline-flex; align-items: center; color: var(--hk-text); }
.hike-note { flex: 1 1 100%; margin: 0; color: var(--hk-muted); font-size: 14px; }
.legend { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.swatch { flex: none; width: 34px; height: 0; border-top: 4px solid #a8320a; }
.swatch-shared { border-top: 4px dashed #7a2fb5; }
.swatch-track { border-top: 3px dashed #6b6b6b; }
.swatch-ski { border-top: 3px dashed #00798c; }

.live-me { width: 18px; height: 18px; border-radius: 50%; background: #0a6cff; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(10, 108, 255, 0.5); }
.live-me-arrow { position: absolute; left: 50%; top: -17px; width: 0; height: 0; margin-left: -7px; border: 7px solid transparent; border-top: 0; border-bottom: 13px solid #0a6cff; }
.live-me[data-heading="none"] .live-me-arrow { display: none; }
.live-photo { width: 42px; height: 42px; padding: 0; border: 2px solid #fff; background: #6b7280 center / cover no-repeat; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.choice { min-height: 44px; padding: 0 14px; border: 2px solid currentColor; border-radius: 22px; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.choice[aria-pressed="true"] { background: #203a31; border-color: #203a31; color: #fff; }
.chip-button { border: 0; font: inherit; cursor: pointer; }
.field { display: grid; gap: 4px; margin: 12px 0; font-weight: 700; }
.field select { min-height: 44px; padding: 0 8px; font: inherit; }
.chip-button { pointer-events: auto; }
.field-label { margin: 12px 0 0; font-weight: 700; }
.directory-note { margin: 4px 0; }
.official-note { display: block; font-weight: 600; }
.plan-section { margin-top: 18px; }
.profile { display: block; width: 100%; height: 40px; margin-top: 6px; overflow: visible; }
.profile path { fill: none; stroke: #203a31; stroke-width: 2; vector-effect: non-scaling-stroke; }
.alert strong { color: #a8320a; }
