:root {
  color-scheme: dark;
  --ink: #f6f3ea;
  --muted: #c0beb7;
  --line: rgba(246, 243, 234, 0.22);
  --panel: rgba(19, 22, 26, 0.92);
  --accent: #89c2c7;
  --gold: #d6b45f;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #111418;
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
button,
a,
select,
input {
  font: inherit;
}
button,
select,
.wall-pass {
  min-height: 44px;
}
button,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button {
  touch-action: manipulation;
}
button:hover,
a:hover {
  border-color: var(--accent);
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}
.scene,
.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.scene canvas {
  touch-action: none;
}
.walk-mode .scene canvas {
  cursor: grab;
}
.walk-mode .scene canvas:active {
  cursor: grabbing;
}
.scene canvas:focus {
  outline: none;
}
.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}
.walk-mode.pointer-locked .reticle {
  opacity: 0.8;
}
.topbar {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
  text-shadow: 0 2px 12px #111;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: auto;
}
.mode-switch,
.level-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.mode-switch button,
.level-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}
.mode-switch button.active {
  background: var(--accent);
  color: #152323;
}
.level-switch button.active {
  background: var(--gold);
  color: #231d10;
}
.mode-switch svg,
.actions svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.status {
  align-self: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
.status.ready {
  color: var(--accent);
}
.status.error {
  color: #ffb5a5;
}
.panel {
  position: absolute;
  left: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(460px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}
dd {
  margin: 0;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.actions {
  display: flex;
  gap: 8px;
}
.actions button,
.actions a {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
.walk-mode .panel {
  display: none;
}
/* Keep the view open; secondary controls live in the settings popover. */
.walk-tools, .walk-stick, .walk-hint { display: none; }
.walk-mode .walk-tools { display: flex; }
.walk-tools {
  position: absolute;
  z-index: 3;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
  font-size: 13px;
}
.walk-tools > button, .walk-settings { pointer-events: auto; }
.walk-tools > button { padding: 0 14px; }
.walk-settings { position: relative; }
summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; margin-left: 10px; color: var(--accent); }
details[open] > summary::after { content: '−'; }
summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.settings-content {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: 300px;
  max-height: calc(100dvh - 180px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 40px #0006;
}
.settings-title { margin: 0 0 8px; color: var(--ink); font-size: 12px; font-weight: 700; }
.settings-title:not(:first-child) { margin-top: 18px; }
.settings-help { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.wall-pass, .speed-label { display: flex; align-items: center; gap: 8px; }
.wall-pass { cursor: pointer; }
.wall-pass input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.speed-label { justify-content: space-between; margin-top: 6px; }
select { padding: 0 8px; }
#walk-feedback {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}
.button-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.walk-pad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); gap: 4px; }
.look-pad { display: grid; grid-template-columns: 44px; gap: 4px; }
.pad-label { display: none; }
[data-move] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
[data-move] span { font-size: 10px; font-weight: 600; }
[data-move].pressed, [data-move]:active { background: var(--accent); color: #152323; border-color: var(--accent); }
[data-move='forward'] { grid-column: 2; grid-row: 1; }
[data-move='left'] { grid-column: 1; grid-row: 2; }
[data-move='backward'] { grid-column: 2; grid-row: 2; }
[data-move='right'] { grid-column: 3; grid-row: 2; }
.walk-pad svg { width: 16px; height: 16px; fill: currentColor; }
.look-pad button { font-size: 20px; }
.walk-hint {
  position: absolute;
  top: 90px;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(19, 22, 26, .8);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  pointer-events: none;
}
.walk-mode .walk-hint { display: block; }
.touch-hint { display: none; }
.walk-stick {
  position: absolute;
  z-index: 2;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(110px, calc(env(safe-area-inset-bottom) + 98px));
  width: 124px;
  height: 124px;
  border: 1px solid rgba(246, 243, 234, .4);
  border-radius: 50%;
  background: rgba(19, 22, 26, .4);
  box-shadow: inset 0 0 0 14px rgba(246, 243, 234, .025);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stick-label {
  position: absolute;
  left: 0;
  right: 0;
  top: -25px;
  font-size: 11px;
  text-align: center;
  color: var(--muted);
  text-shadow: 0 1px 5px #000;
  pointer-events: none;
}
.stick-track { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.stick-thumb {
  width: 42px;
  height: 42px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: rgba(137, 194, 199, .5);
  box-shadow: 0 2px 10px #0005;
}
.walk-stick.pressed .stick-thumb { background: var(--accent); }
@media (pointer: coarse), (max-width: 850px) {
  .topbar { gap: 8px; }
  .topbar > div:first-child { display: none; }
  .top-actions { width: 100%; justify-content: center; }
  .walk-mode .walk-stick { display: block; }
  .desktop-hint { display: none; }
  .touch-hint { display: inline; }
}
@media (pointer: coarse) {
  #pointer-lock { display: none; }
}
@media (max-width: 600px) {
  .topbar {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }
  .top-actions { gap: 6px; }
  .mode-switch button, .level-switch button { padding-inline: 9px; font-size: 12px; }
  .mode-switch svg { display: none; }
  .status { position: absolute; top: 62px; right: 0; padding: 6px 8px; }
  .walk-hint { top: max(112px, calc(env(safe-area-inset-top) + 102px)); font-size: 11px; }
  .walk-tools { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); gap: 6px; }
  .walk-tools > button { padding-inline: 10px; }
  #pointer-lock { display: none; }
  .settings-content {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(90px, calc(env(safe-area-inset-bottom) + 78px));
    width: auto;
  }
  .panel { left: max(10px, env(safe-area-inset-left)); width: calc(100% - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)); gap: 10px; }
  .panel dl { grid-template-columns: 1fr 1fr; }
  .panel dl > div:first-child { grid-column: 1 / -1; }
}
@media (max-height: 540px) and (orientation: landscape) {
  .topbar { top: max(8px, env(safe-area-inset-top)); }
  .topbar > div:first-child, .walk-hint, .panel { display: none !important; }
  .top-actions { justify-content: flex-end; }
  .status { position: static; }
  .walk-tools { left: 154px; right: max(12px, env(safe-area-inset-right)); justify-content: flex-end; }
  .walk-stick { left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); width: 112px; height: 112px; }
  #walk-feedback { text-align: right; }
  .settings-content { max-height: calc(100dvh - 160px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
