:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --text: #edf4ef;
  --muted: #b1c3c1;
  --surface: #1b3038;
  --line: #3b525a;
  --focus: #b8e0ea;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { color: var(--text); background: #8ab7c7; font-size: 16px; }
button, select, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, select { font: inherit; }
button { cursor: pointer; }
button, a, select { outline-offset: 4px; }
button:focus-visible, a:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid var(--focus); }
[hidden] { display: none !important; }
svg { display: block; flex-shrink: 0; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.island-app { position: relative; width: 100%; height: 100%; height: 100dvh; isolation: isolate; overflow: hidden; }
#world { display: block; width: 100%; height: 100%; touch-action: none; outline-offset: -4px; }

/* Default HUD: a wordmark, two tools and one destination launcher. */
.topbar { position: absolute; z-index: 5; top: max(24px, env(safe-area-inset-top)); left: max(28px, env(safe-area-inset-left)); right: max(28px, env(safe-area-inset-right)); display: flex; justify-content: space-between; align-items: center; gap: 20px; pointer-events: none; }
.wordmark { flex: 0 1 210px; min-width: 0; margin: 0; line-height: 1; }
.wordmark img { display: block; width: 100%; max-width: 210px; height: auto; filter: drop-shadow(0 2px 4px #10292c4d); }
.view-tools { display: flex; flex-shrink: 0; gap: 8px; pointer-events: auto; }
.icon-button, .close-button { display: grid; place-items: center; width: 48px; height: 48px; padding: 12px; border: 1px solid #ffffff24; border-radius: 7px; background: #20282bd9; color: var(--text); }
.icon-button:hover { background: #20282b; }
.view-tools .icon-button { flex: 0 0 48px; min-width: 48px; min-height: 48px; }
.view-tools .icon-button svg { width: 24px; height: 24px; }
.icon-button:active, .primary-button:active { transform: translateY(1px); }
.icon-button[aria-pressed="true"] { color: #20282b; background: #eef3f3; border-color: #eef3f3; }
.explore-button, .visit-button { position: absolute; z-index: 5; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 12px 20px; border: 1px solid #ffffff70; border-radius: 7px; background: #f1f4f2; color: #20282b; font-size: 16px; line-height: 1.2; font-weight: 600; box-shadow: 0 2px 8px #18303520; }
.explore-button { left: max(28px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom)); min-width: 144px; }
.visit-button { right: max(28px, env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); }
.explore-button:hover, .visit-button:hover { background: #fff; }
.world-controls { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.world-controls button, .move-pad { pointer-events: auto; }
.world-actions { pointer-events: none; }
.move-pad { display: none; }
.move-directions { position: absolute; inset: 0; width: 100%; height: 100%; color: #eef3f3b3; stroke-width: 1.8; }
.move-stick { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 42px; height: 42px; border-radius: 50%; border: 1px solid #ffffffa3; background: #eef3f399; }
.move-pad[data-active="true"] { border-color: #d6ede7; background: #203b42aa; }
.move-pad[data-active="true"] .move-stick { background: #edf5f1; }
.is-loading .world-controls, .is-error .world-controls, .has-modal .world-controls { visibility: hidden; pointer-events: none; }
.has-modal .topbar, .has-modal .world-labels, .is-loading .topbar { visibility: hidden; }

/* Menus carry the detail; the world does not need permanent instruction panels. */
.hub-dialog, .destination-panel { position: fixed; inset: 0; width: min(390px, calc(100% - 32px)); max-height: calc(100dvh - 40px); margin: auto; padding: 22px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: auto; box-shadow: 0 12px 32px #0c171b40; }
.hub-dialog, .destination-panel { overscroll-behavior: contain; scrollbar-gutter: stable; }
.hub-dialog::backdrop, .destination-panel::backdrop { background: #10212640; }
.hub-dialog[open], .destination-panel[open] { animation: menu-in .12s ease-out both; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -8px -8px 14px 0; }
.dialog-heading h2, .destination-panel h2 { margin: 0; font-size: 21px; line-height: 1.3; font-weight: 600; letter-spacing: -.3px; }
.close-button { flex-shrink: 0; border: 0; background: transparent; color: var(--muted); }
.close-button:hover { color: var(--text); background: #ffffff0a; }
.close-button svg { width: 20px; height: 20px; }
.explore-dialog { inset: auto auto 88px 28px; margin: 0; width: 340px; max-height: calc(100dvh - 116px); }
.destination-list { border-top: 1px solid var(--line); }
.destination-button { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; min-height: 74px; padding: 13px 2px; color: var(--text); border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.destination-button:hover { background: #ffffff06; }
.destination-button strong { display: block; font-size: 17px; line-height: 1.3; font-weight: 500; }
.destination-button small { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.3; }
.destination-button > svg { width: 18px; height: 18px; color: var(--muted); }
.destination-button[aria-current="location"] strong { color: #c6e7e9; }
.destination-button[data-walking="true"] small { color: #c6e7e9; }
.setting-row, .menu-button { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 72px; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); color: var(--text); background: transparent; text-align: left; font-size: 16px; font-weight: 400; }
.menu-button:hover { color: #c6e2e6; }
.menu-button svg { width: 20px; height: 20px; color: var(--muted); }
.switch-button { position: relative; flex-shrink: 0; width: 54px; height: 48px; padding: 0; color: var(--text); background: transparent; border: 0; border-radius: 4px; }
.switch-button::before { content: ""; position: absolute; left: 5px; top: 12px; width: 44px; height: 24px; border: 1px solid #738489; border-radius: 14px; background: #374448; }
.switch-button span { position: absolute; left: 9px; top: 16px; width: 16px; height: 16px; border-radius: 50%; background: #bac5c7; transition: transform .12s; }
.switch-button[aria-pressed="true"]::before { background: #58797e; border-color: #83a5ac; }
.switch-button[aria-pressed="true"] span { transform: translateX(20px); background: #eff9f9; }
#quality-select { min-width: 100px; min-height: 48px; padding: 10px; border: 1px solid #5a6b70; border-radius: 5px; color: var(--text); background: #263237; font-size: 16px; }
.prototype-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.help-list { margin: 4px 0 20px; }
.help-list > div { padding: 13px 0; border-top: 1px solid var(--line); }
.help-list dt { font-size: 16px; font-weight: 600; line-height: 1.4; }
.help-list dd { margin: 5px 0 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; padding: 12px 16px; border: 1px solid #e9eeee; border-radius: 6px; color: #20282b; background: #edf2f1; font-family: inherit; font-size: 16px; line-height: 1.3; font-weight: 600; text-decoration: none; }
.primary-button:hover { background: #fff; }
.primary-button svg { width: 19px; height: 19px; }
.destination-panel { inset: auto 28px 26px auto; margin: 0; width: 320px; padding: 22px; }
.destination-panel > .close-button { position: absolute; right: 2px; top: 2px; }
.destination-panel h2 { padding-right: 32px; }
.destination-panel p { margin: 12px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.destination-panel .primary-button { margin-top: 20px; }
.has-destination .visit-button, .has-destination .explore-button, .has-destination .move-pad { visibility: hidden; }

/* Photograph + the same original vector identity used by the in-game HUD. */
.loading-overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; overflow: hidden; background: #103c4a; opacity: 1; transition: opacity .22s ease; }
.loading-overlay::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #09253226, #082c4375 48%, #061e2fe0); }
.loading-overlay.is-leaving { opacity: 0; }
.loading-scene { position: absolute; inset: 0; overflow: hidden; }
.loading-scene img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; animation: coast-drift 16s ease-out both; }
.loading-panel { position: relative; z-index: 1; width: min(480px, calc(100% - 48px)); padding: 0; color: #f2f7ed; text-align: center; transform: translateY(5vh); }
.loading-logo { display: block; width: 100%; height: auto; margin: 0 auto 28px; filter: drop-shadow(0 4px 16px #05233166); }
.loading-panel h2 { margin: 0; font-size: clamp(21px, 3vw, 26px); line-height: 1.35; font-weight: 500; letter-spacing: -.4px; text-shadow: 0 1px 4px #0b283d70; }
.loading-meter { position: relative; width: min(320px, 100%); margin: 24px auto 0; padding-bottom: 44px; }
.loading-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: #e1eee9; font-size: 14px; line-height: 1.5; text-align: left; }
#loading-percent { flex-shrink: 0; font-variant-numeric: tabular-nums; color: #fff9e9; }
#loading-progress { display: block; appearance: none; width: 100%; height: 6px; margin-top: 12px; overflow: hidden; border: 0; border-radius: 6px; accent-color: #cce5cd; background: #b5d5d32e; }
#loading-progress::-webkit-progress-bar { background: #b5d5d32e; border-radius: 6px; }
#loading-progress::-webkit-progress-value { background: linear-gradient(90deg, #89cbbf, #eff0d0); border-radius: 6px; transition: width .18s ease; }
#loading-progress::-moz-progress-bar { background: linear-gradient(90deg, #89cbbf, #eff0d0); border-radius: 6px; }
.loading-orbit { position: absolute; bottom: 0; left: calc(50% - 9px); width: 18px; height: 18px; border: 2px solid #d8e7dd3b; border-top-color: #eaf2da; border-right-color: #a6d9c7; border-radius: 50%; animation: loading-orbit 1.1s linear infinite; }
.loading-panel p { color: #d8e5df; font-size: 15px; line-height: 1.5; }
#loading-actions { width: min(240px, 100%); margin: 20px auto 0; }
.is-error #loading-progress, .is-error #loading-percent, .is-error .loading-orbit { display: none; }
.is-error .loading-meter { padding-bottom: 0; }
.is-error .loading-caption { justify-content: center; text-align: center; }
@keyframes coast-drift { from { transform: scale(1.045); } to { transform: scale(1); } }
@keyframes loading-orbit { to { transform: rotate(360deg); } }

.world-labels { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
body[data-view="explore"] .world-labels { display: none; }
.world-label { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; min-height: 48px; padding: 10px 13px; border: 1px solid #ffffff38; border-radius: 6px; background: #20282bef; color: var(--text); font: 500 15px/1.3 "Segoe UI", system-ui, sans-serif; white-space: nowrap; }
.world-label:hover { background: #354346; }
body[data-view="map"] .move-pad { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@keyframes menu-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 700px) {
  .topbar { top: max(16px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); right: max(18px, env(safe-area-inset-right)); }
  .wordmark { flex-basis: 160px; }
  .view-tools { gap: 7px; }
  .explore-button { left: auto; right: max(20px, env(safe-area-inset-right)); bottom: max(28px, env(safe-area-inset-bottom)); min-width: 140px; }
  .visit-button { right: max(20px, env(safe-area-inset-right)); bottom: max(100px, calc(env(safe-area-inset-bottom) + 72px)); }
  .explore-dialog { inset: auto 14px 96px 14px; width: auto; max-height: calc(100dvh - 116px); }
  .destination-panel { inset: auto 14px 20px 14px; width: auto; max-height: calc(100dvh - 40px); }
  .hub-dialog { padding: 20px; }
  .dialog-heading { margin-bottom: 10px; }
  .destination-button { min-height: 70px; }
}
@media (pointer: coarse), (max-width: 700px) and (orientation: portrait) {
  .move-pad { position: absolute; z-index: 4; display: block; width: 96px; height: 96px; left: max(22px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); border: 1px solid #ffffff6b; border-radius: 50%; background: #233a4438; touch-action: none; user-select: none; }
  .explore-button { left: auto; right: max(22px, env(safe-area-inset-right)); }
  .visit-button { right: max(22px, env(safe-area-inset-right)); bottom: max(100px, calc(env(safe-area-inset-bottom) + 72px)); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { top: 12px; left: 18px; right: 18px; }
  .wordmark { flex-basis: 160px; }
  .explore-button, .visit-button { bottom: 18px; }
  .explore-dialog { inset: 16px 16px 16px auto; width: 330px; max-height: calc(100dvh - 32px); }
  .hub-dialog { max-height: calc(100dvh - 28px); }
  .destination-panel { bottom: 18px; right: 18px; left: auto; width: 310px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  .move-pad { width: 84px; height: 84px; bottom: 18px; }
  .visit-button { bottom: 88px; }
}
/* Portrait is a thumb-first layout, not a shrunken desktop HUD. */
@media (max-width: 700px) and (orientation: portrait) {
  .topbar { top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(16px + env(safe-area-inset-left, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); gap: 12px; }
  .wordmark { flex-basis: 154px; }
  .view-tools .icon-button svg { width: 22px; height: 22px; }
  .view-tools { gap: 8px; }
  .icon-button { background: #203035ef; border-color: #ffffff45; }
  .world-controls {
    inset: auto 0 0; height: calc(176px + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
    padding: 20px calc(18px + env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) calc(18px + env(safe-area-inset-left, 0px));
    background: linear-gradient(transparent, #15333b12 24%, #15333b70);
  }
  .move-pad { position: relative; inset: auto; display: block; flex: 0 0 112px; width: 112px; height: 112px; border: 1px solid #e3f0ef9c; background: #20383fc4; box-shadow: inset 0 0 0 8px #ffffff06, 0 2px 12px #102b3026; -webkit-user-select: none; }
  .move-stick { width: 48px; height: 48px; border-color: #dcece7; background: #dae8e2d9; box-shadow: 0 2px 5px #122e3640; }
  .world-actions { display: flex; flex-direction: column; flex: 0 0 140px; gap: 12px; }
  .world-actions .explore-button, .world-actions .visit-button { position: relative; inset: auto; width: 100%; min-width: 0; min-height: 56px; padding: 14px 16px; font-size: 16px; border-radius: 8px; }
  .world-actions .explore-button { background: #203035f5; border-color: #b9cbc8; color: #f2f5f1; }
  .world-actions .visit-button { background: #e1eee6; border-color: #f0f8f0; color: #193d37; }
  .world-actions button:active { transform: translateY(1px); filter: brightness(.92); }
  body[data-view="map"] .world-controls { height: calc(96px + env(safe-area-inset-bottom, 0px)); justify-content: flex-end; }
  body[data-view="map"] .move-pad { display: none; }
  body[data-view="map"] .visit-button { display: none; }
  .hub-dialog, .destination-panel, .explore-dialog {
    inset: auto calc(12px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
    width: auto; margin: 0; padding: 20px;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    border-radius: 14px; box-shadow: 0 -8px 40px #10252c45; scrollbar-gutter: auto;
  }
  .dialog-heading { position: sticky; top: -20px; z-index: 1; padding-top: 4px; background: var(--surface); }
  .destination-button { min-height: 72px; }
  .setting-row, .menu-button { min-height: 68px; }
  .destination-panel { padding-top: 26px; }
  .primary-button { min-height: 56px; }
}
@media (max-width: 360px) and (orientation: portrait) {
  .topbar { left: 12px; right: 12px; }
  .wordmark { flex-basis: 150px; }
  .world-controls { padding-left: 16px; padding-right: 16px; gap: 20px; }
  .move-pad { flex-basis: 104px; width: 104px; height: 104px; }
  .world-actions { flex-basis: 136px; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .loading-panel { width: min(380px, calc(100% - 40px)); transform: translateY(3vh); }
  .loading-logo { margin-bottom: 24px; }
  .loading-meter { width: min(288px, calc(100% - 20px)); }
  .loading-caption { font-size: 14px; }
}
@media (max-height: 420px) and (orientation: landscape) {
  .loading-panel { width: min(380px, calc(100% - 48px)); transform: none; }
  .loading-logo { width: 260px; margin-bottom: 12px; }
  .loading-panel h2 { font-size: 20px; }
  .loading-meter { margin-top: 12px; padding-bottom: 30px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { animation: none !important; transition: none !important; }
