:root {
  color-scheme: light;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  color: #253e34;
  background: #f5f2e9;
  font-synthesis: none;
  --paper: #f5f2e9;
  --ink: #253e34;
  --muted: #687269;
  --line: #dcded2;
  --accent: #86643a;
  --focus: #906627;
}

* { box-sizing: border-box; }

html { min-width: 280px; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

button, input, output, select { font: inherit; }
button, summary, select, input[type="range"] { -webkit-tap-highlight-color: transparent; }
button, summary, select { touch-action: manipulation; }
button { color: inherit; }
p, h1, h2 { margin: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 12px max(24px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 32px; height: 38px; flex: none; stroke: var(--ink); stroke-width: 1.4; }
.eyebrow { color: var(--muted); font-size: 10px; line-height: 1.8; }
h1 { font-size: 21px; font-weight: 700; line-height: 1.65; }
.prototype-badge {
  padding: 3px 11px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.theme-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-inline-start: auto;
}
.theme-control label { color: var(--muted); font-size: 10px; white-space: nowrap; }
#theme {
  width: 132px;
  min-width: 0;
  min-height: 44px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
#theme:disabled { opacity: .55; cursor: not-allowed; }

body[data-theme="neon"] :where(.site-header, .control-panel) {
  color-scheme: dark;
  --paper: #171827;
  --ink: #edf0ff;
  --muted: #bcc3dc;
  --line: #656b86;
  --accent: #e7a5ff;
  --focus: #7de5ed;
  background: var(--paper);
  color: var(--ink);
}
body[data-theme="neon"] .control-panel :where(.button, kbd) {
  border-color: var(--line);
  background: #292d43;
  color: var(--ink);
}
body[data-theme="neon"] .control-panel .button-primary {
  border-color: #7de5ed;
  background: #7de5ed;
  color: #171827;
}
body[data-theme="neon"] .control-panel .button-quiet { background: transparent; color: var(--muted); }
@media (hover: hover) {
  body[data-theme="neon"] .control-panel .button:hover:not(:disabled) { border-color: var(--accent); background: #3b405b; }
  body[data-theme="neon"] .control-panel .button-primary:hover:not(:disabled) { background: #a9f0f5; }
}

.walk-shell {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(180px, 1fr) auto;
}

#viewport {
  position: relative;
  min-width: 0;
  min-height: 180px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(ellipse at 50% 36%, #e9dfca 0%, #c6b79c 70%, #a99e87 100%);
  touch-action: none;
  overscroll-behavior: contain;
}

#viewport:focus-visible { outline-offset: -5px; }
#viewport canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.viewport-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  text-align: center;
  font-size: 14px;
  background: linear-gradient(140deg, #f0ebdf, #ded5c1);
}

.overlay-message { max-width: 380px; }
.overlay-message > p { font-weight: 700; }
.overlay-caption { display: block; margin-top: 8px; color: #656b60; font-size: 12px; }
.loading-mark {
  display: block;
  width: 30px;
  height: 40px;
  margin: 0 auto 20px;
  border: 1px solid #8c977f;
  border-bottom: 3px solid var(--ink);
  border-radius: 18px 18px 0 0;
  box-shadow: inset 0 0 0 6px #e5dfcf, inset 0 0 0 7px #a1a992;
}
.error-overlay { background: #f2e9dd; color: #743d2d; }

.control-panel {
  min-width: 0;
  padding: 12px max(24px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.journey-bar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(130px, 1.5fr) auto;
  align-items: center;
  gap: 26px;
}

.journey-status { min-width: 0; font-size: 11px; }
#status { color: var(--muted); overflow-wrap: anywhere; }
.distance-label { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: 10px; }
#distance { color: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.progress-control { min-width: 0; }
#progress {
  display: block;
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  accent-color: var(--ink);
  cursor: pointer;
  direction: ltr;
}

#progress::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: #c8cfc1; }
#progress::-moz-range-track { height: 3px; border-radius: 3px; background: #c8cfc1; }
#progress::-moz-range-progress { height: 3px; background: var(--ink); }
#progress::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  margin-top: -6.5px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
#progress::-moz-range-thumb {
  height: 10px;
  width: 10px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
.progress-labels { display: flex; justify-content: space-between; direction: ltr; color: var(--muted); font-size: 9px; line-height: 1.4; }

.utility-controls, .control-row, .movement-controls, .look-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}
.control-row { justify-content: center; gap: 16px; }
.control-divider { width: 1px; height: 24px; background: var(--line); }
.button {
  min-height: 40px;
  padding: 7px 15px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 1px solid #ced4c7;
  border-radius: 7px;
  background: #fbf9f3;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.button-primary { border-color: var(--ink); background: var(--ink); color: #fffdf7; }
.button-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.button-soft { background: #e8ecdf; }
.movement-controls .button { min-width: 80px; }
.look-controls .button { min-width: 85px; }
.button > span[aria-hidden] { font-size: 17px; line-height: 1; }

@media (hover: hover) {
  .button:hover:not(:disabled) { border-color: #99a78e; background: #e9edde; }
  .button-primary:hover:not(:disabled) { border-color: #3d5849; background: #3d5849; }
  summary:hover { color: var(--ink); }
  #shop-list :where(button, a):hover { border-color: #99a78e; background: #e9edde; }
}
.button:active:not(:disabled) { border-color: var(--accent); }
.button:disabled { opacity: .45; cursor: not-allowed; }

.panel-notes {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 20px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}
#interaction-help { line-height: 1.9; }
.technical-notes { margin-inline-start: auto; min-width: 0; }
.technical-notes[open] { flex-basis: 100%; }
summary { padding-block: 3px; cursor: pointer; width: fit-content; }
summary::marker { color: var(--accent); font-size: 9px; }
.notes-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  margin-top: 7px;
  padding: 10px 0 2px;
  border-top: 1px dashed var(--line);
  line-height: 2;
}
kbd {
  display: inline-block;
  min-width: 19px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fbf9f3;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 10px;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
}
#metrics { grid-column: 1 / -1; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

dialog {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  margin: auto;
  padding: 24px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #cbd0c1;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 90px #17291f40;
}
dialog::backdrop { background: #14291fcc; }
.dialog-heading { margin-bottom: 16px; }
h2 { font-size: 20px; line-height: 1.8; overflow-wrap: anywhere; }
#shop-photo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 38dvh;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e3ddce;
  color: var(--muted);
  font-size: 12px;
}
#shop-photo:not([src]), #shop-photo[src=""] { visibility: hidden; }
.shop-meta { margin-top: 14px; font-size: 13px; overflow-wrap: anywhere; }
.dialog-note { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 2; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
#shop-list { display: grid; gap: 8px; }
#shop-list :where(button, a) {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbf9f3;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: start;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}
#shop-list :where(ul, ol) { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

@media (max-width: 640px) {
  .site-header { gap: 10px; padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .brand { gap: 10px; min-width: 0; }
  .brand-mark { width: 27px; height: 34px; }
  h1 { font-size: 19px; }
  .prototype-badge { display: none; }
  .theme-control { display: grid; gap: 2px; flex: 0 0 128px; }
  .theme-control label { line-height: 1.4; }
  #theme { width: 100%; }
  .control-panel { padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); gap: 8px; }
  .journey-bar { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; }
  .journey-status { font-size: 10px; }
  .progress-control { grid-column: 1 / -1; grid-row: 2; }
  .utility-controls { gap: 4px; }
  .utility-controls .button { min-height: 40px; padding-inline: 9px; font-size: 10px; }
  #progress { height: 28px; }
  .progress-labels { font-size: 8px; }
  .control-row { gap: 8px; }
  .movement-controls { flex: 1; gap: 5px; }
  .look-controls { flex: 1.8; gap: 5px; }
  .movement-controls .button, .look-controls .button { flex: 1; min-width: 0; padding-inline: 7px; font-size: 11px; gap: 5px; min-height: 44px; }
  .control-divider { display: none; }
  .panel-notes { gap: 3px; padding-top: 6px; font-size: 9px; }
  .technical-notes { margin-inline-start: 0; }
  .notes-content { grid-template-columns: 1fr; font-size: 11px; }
  dialog { padding: 18px; }
  .dialog-actions .button { width: 100%; min-height: 44px; }
}

@media (max-height: 500px) and (min-width: 641px) {
  .site-header { padding-top: calc(5px + env(safe-area-inset-top, 0px)); padding-bottom: 5px; }
  .brand > div { display: flex; align-items: baseline; gap: 12px; }
  .brand-mark { width: 24px; height: 30px; }
  h1 { font-size: 18px; }
  .eyebrow { font-size: 9px; }
  .control-panel { gap: 5px; padding-top: 6px; padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px)); }
  .journey-bar { gap: 15px; }
  .journey-status { font-size: 10px; }
  .button { min-height: 34px; padding-block: 5px; font-size: 11px; }
  .panel-notes { padding-top: 4px; font-size: 9px; }
  .dialog-heading { margin-bottom: 10px; }
}

@media (max-width: 359px) {
  .site-header, .control-panel { padding-inline: 10px; }
  .brand-mark { display: none; }
  .control-row { flex-wrap: wrap; }
  .movement-controls, .look-controls { flex-basis: 100%; }
  .journey-bar { grid-template-columns: 1fr; }
  .utility-controls { justify-content: flex-end; }
  .progress-control { grid-row: 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .button, .prototype-badge, dialog { border: 1px solid ButtonText; }
  #progress { appearance: auto; -webkit-appearance: auto; }
  .loading-mark { border-color: CanvasText; }
}
