/* hud.css — the visitor interface: tools, title cards, minimap, overlays.
   Owned by Agent E. Everything reuses the custom properties from gallery.css
   so the gallery reads as one building. Restraint is the brief: dark glass,
   gold hairlines, serif for anything that names a thing. */

:root {
  --hud-glass: rgba(13, 12, 18, 0.72);
  --hud-glass-strong: rgba(12, 11, 17, 0.92);
  --hud-line: rgba(233, 226, 208, 0.14);
  --hud-line-strong: rgba(201, 162, 39, 0.42);
  --hud-blur: blur(18px) saturate(150%);
  --hud-shadow: 0 20px 60px -18px rgba(0, 0, 0, 0.85);
  --hud-gap: 12px;
  --hud-inset-top: max(16px, env(safe-area-inset-top));
  --hud-inset-right: max(16px, env(safe-area-inset-right));
  --hud-inset-bottom: max(16px, env(safe-area-inset-bottom));
  --hud-inset-left: max(16px, env(safe-area-inset-left));
}

/* The navigation agent parks its hint and touch controls at z-index 6 and its
   teleport fade at 40; the HUD belongs between them. */
#hud-root {
  z-index: 7;
}

/* ------------------------------------------------------------------ tools */

.hud-cluster {
  position: fixed;
  top: var(--hud-inset-top);
  right: var(--hud-inset-right);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.hud-tools {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: var(--hud-glass);
  border: 1px solid var(--hud-line);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.9);
  pointer-events: auto;
}

.hud-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(244, 241, 234, 0.72);
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.hud-btn:hover { color: var(--paper); background: rgba(244, 241, 234, 0.08); }
.hud-btn.is-active { color: var(--gold-soft); background: rgba(201, 162, 39, 0.16); }
.hud-btn[aria-pressed='true'] { color: var(--gold-soft); }
.hud-btn:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
  color: var(--paper);
}

.hud-progress {
  margin: 0;
  padding: 4px 10px;
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, 0.44);
  border-radius: 999px;
  background: rgba(13, 12, 18, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.hud-progress b { font-weight: 600; color: var(--gold-soft); }

/* ------------------------------------------------------------- room card */

/* Top-left, at every size. The bottom band belongs to the guide's speech card
   (bottom-centre) and the minimap (bottom-right); a bottom-left title card
   collides with the guide panel as soon as the viewport narrows. */
.hud-room {
  position: fixed;
  left: var(--hud-inset-left);
  top: calc(var(--hud-inset-top) + 6px);
  max-width: min(46vw, 420px);
  pointer-events: none;
  opacity: 0;
  translate: 0 10px;
  transition: opacity 0.7s var(--ease), translate 0.7s var(--ease);
}
.hud-room.is-in { opacity: 1; translate: 0 0; }

.hud-room-rule {
  display: block;
  width: 34px;
  height: 1px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--gold), transparent);
}
.hud-room-name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.4rem, 3.2vw, 2.05rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75);
}
.hud-room-sub {
  margin: 6px 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, 0.5);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}

/* --------------------------------------------------------- artwork prompt */

/* Sits just under the reticle rather than along the bottom edge: it refers to
   whatever you are aiming at, and the bottom-centre band is the guide's. */
.hud-prompt {
  position: fixed;
  left: 50%;
  top: calc(50% + 54px);
  bottom: auto;
  translate: -50% 8px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  /* Interactive only while it is actually showing, so the hidden prompt never
     swallows a click meant for the artwork behind it. */
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(90vw, 560px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--hud-glass);
  border: 1px solid var(--hud-line);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: var(--hud-shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.28s var(--ease), translate 0.28s var(--ease);
}
.hud-prompt.is-in { opacity: 1; translate: -50% 0; pointer-events: auto; }
.hud-prompt.is-in:hover { border-color: var(--hud-line-strong); }
.hud-prompt:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }

.hud-prompt-title {
  font-family: var(--serif);
  font-size: 1.12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-prompt-hint {
  flex: none;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, 0.52);
  border-left: 1px solid var(--hud-line);
  padding-left: 14px;
}
.hud-prompt-hint kbd {
  font-size: 0.68rem;
  padding: 1px 6px;
  color: var(--gold-soft);
  border-color: rgba(201, 162, 39, 0.4);
}

/* ---------------------------------------------------------------- toasts */

.hud-toasts {
  position: fixed;
  top: var(--hud-inset-top);
  left: 50%;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  max-width: min(92vw, 460px);
}

.hud-toast {
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  text-align: center;
  color: var(--paper);
  background: var(--hud-glass-strong);
  border: 1px solid var(--hud-line-strong);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: var(--hud-shadow);
  opacity: 0;
  translate: 0 -8px;
  transition: opacity 0.3s var(--ease), translate 0.3s var(--ease);
}
.hud-toast.is-in { opacity: 1; translate: 0 0; }

/* --------------------------------------------------------- corner minimap */

.hud-map-slot { display: contents; }

.hud-map {
  position: fixed;
  right: var(--hud-inset-right);
  bottom: var(--hud-inset-bottom);
  width: 168px;
  height: 168px;
  padding: 0;
  pointer-events: auto;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(9, 8, 13, 0.62);
  border: 1px solid var(--hud-line);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: var(--hud-shadow);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.hud-map:hover { border-color: var(--hud-line-strong); }
.hud-map:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }
.hud-map-canvas { display: block; width: 100%; height: 100%; }
.hud-map-n {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: rgba(244, 241, 234, 0.4);
}

/* ------------------------------------------------------------- overlays */

.hud-dialog {
  /* Required. #hud-root is pointer-events:none so the 3D world stays clickable
     through it, and a <dialog> promoted to the top layer still inherits that
     from its DOM parent — without this the panel renders but every control
     inside it is dead to real clicks. Programmatic .click() still fires, which
     makes it an easy one to miss when testing. */
  pointer-events: auto;
  width: min(94vw, 760px);
  max-height: min(88svh, 900px);
  margin: auto;
  padding: 0;
  color: var(--paper);
  background: linear-gradient(180deg, rgba(20, 18, 27, 0.94), rgba(11, 10, 16, 0.96));
  border: 1px solid var(--hud-line);
  border-radius: var(--radius);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.95);
  overflow: hidden;
  /* `display` MUST be none while closed. It is animated discretely below, so
     the open/close transition still runs — but a closed dialog that keeps
     `display: flex` stays in layout at opacity 0 and silently swallows every
     pointer event on the page, which breaks clicking into the artworks. */
  display: none;
  flex-direction: column;

  opacity: 0;
  scale: 0.97;
  transition-property: opacity, scale, display, overlay;
  transition-duration: 0.28s;
  transition-timing-function: var(--ease);
  transition-behavior: allow-discrete;
}
.hud-dialog[open] {
  display: flex;
  opacity: 1;
  scale: 1;
  @starting-style {
    opacity: 0;
    scale: 0.97;
  }
}

.hud-dialog::backdrop {
  background: rgba(4, 4, 7, 0);
  backdrop-filter: blur(0px);
  transition:
    background-color 0.3s var(--ease),
    backdrop-filter 0.3s var(--ease),
    display 0.3s allow-discrete,
    overlay 0.3s allow-discrete;
}
.hud-dialog[open]::backdrop {
  background: rgba(4, 4, 7, 0.62);
  backdrop-filter: blur(6px);
  @starting-style {
    background: rgba(4, 4, 7, 0);
    backdrop-filter: blur(0px);
  }
}

.hud-dialog *::-webkit-scrollbar { width: 8px; height: 8px; }
.hud-dialog *::-webkit-scrollbar-thumb {
  background: rgba(244, 241, 234, 0.18);
  border-radius: 999px;
}
.hud-dialog *::-webkit-scrollbar-track { background: transparent; }
.hud-dialog * { scrollbar-width: thin; scrollbar-color: rgba(244, 241, 234, 0.22) transparent; }

.panel-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--hud-line);
}
.panel-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  line-height: 1.1;
}
.panel-sub {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.panel-close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -6px -6px 0 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(244, 241, 234, 0.6);
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.panel-close:hover { color: var(--paper); background: rgba(244, 241, 234, 0.08); }
.panel-close:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

.panel-foot {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hud-line);
}
.panel-primary {
  font: inherit;
  font-size: 0.9rem;
  min-height: 44px;
  padding: 0 26px;
  border-radius: 999px;
  color: var(--paper);
  cursor: pointer;
  border: 1px solid rgba(201, 162, 39, 0.5);
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.24), rgba(201, 162, 39, 0.09));
  transition: background 0.22s var(--ease);
}
.panel-primary:hover {
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.38), rgba(201, 162, 39, 0.16));
}
.panel-primary:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }

/* ------------------------------------------------------------- full map */

/* The plan is tall and narrow (roughly 92 m by 160 m), so the panel is too, and
   it needs a real height for the canvas row to have anything to expand into. */
.map-dialog {
  width: min(94vw, 620px);
  height: min(86svh, 860px);
}

.map-full-wrap {
  flex: 1 1 auto;
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
}
.map-full-canvas { display: block; cursor: pointer; }

.map-legend {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 0 24px 12px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-item::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.legend-seen::before { background: var(--gold-soft); }
.legend-unseen::before { border: 1px solid rgba(244, 241, 234, 0.6); }
.legend-you::before {
  width: 0;
  height: 0;
  border-radius: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--paper);
}

.map-rooms {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 24px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hud-line);
}
.map-room-chip,
.dir-chip {
  font: inherit;
  font-size: 0.78rem;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  cursor: pointer;
  color: rgba(244, 241, 234, 0.78);
  background: rgba(244, 241, 234, 0.05);
  border: 1px solid var(--hud-line);
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.map-room-chip { border-left: 3px solid var(--chip, var(--gold)); }
.map-room-chip:hover,
.dir-chip:hover { color: var(--paper); background: rgba(244, 241, 234, 0.1); }
.map-room-chip:focus-visible,
.dir-chip:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }
.dir-chip.is-on {
  color: var(--ink);
  background: var(--chip, var(--gold-soft));
  border-color: transparent;
  font-weight: 600;
}

/* ------------------------------------------------------------- directory */

.dir-dialog { width: min(96vw, 1000px); }

.dir-controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px 10px;
}
.dir-search-wrap {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}
.dir-search-icon {
  position: absolute;
  left: 14px;
  display: grid;
  place-items: center;
  color: rgba(244, 241, 234, 0.4);
  pointer-events: none;
}
.dir-search {
  font: inherit;
  font-size: 0.95rem;
  width: 100%;
  min-height: 44px;
  padding: 0 16px 0 44px;
  color: var(--paper);
  background: rgba(244, 241, 234, 0.05);
  border: 1px solid var(--hud-line);
  border-radius: 999px;
}
.dir-search::placeholder { color: rgba(244, 241, 234, 0.35); }
.dir-search:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 1px; }

.dir-count {
  flex: none;
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}

.dir-chips {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 24px 14px;
}

.dir-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 24px calc(24px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.dir-section { margin-bottom: 26px; }
.dir-section[hidden] { display: none; }
.dir-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.25rem;
  position: sticky;
  top: 0;
  padding: 8px 0;
  background: linear-gradient(180deg, rgba(13, 12, 19, 0.98), rgba(13, 12, 19, 0.9) 70%, transparent);
  z-index: 1;
}
.dir-section-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent, var(--gold));
}
.dir-section-title small {
  font-family: var(--font);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, 0.38);
}

.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.dir-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 15px 13px;
  border-radius: 10px;
  background: rgba(244, 241, 234, 0.035);
  border: 1px solid var(--hud-line);
  border-left: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.dir-card[hidden] { display: none; }
.dir-card:hover { background: rgba(244, 241, 234, 0.07); }

.card-head { display: flex; align-items: center; gap: 9px; }
.card-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--accent);
}
.dir-card.is-seen .card-dot { background: var(--accent); }
.card-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.08rem;
  line-height: 1.2;
}
.card-desc {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: rgba(244, 241, 234, 0.58);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.card-cat { color: rgba(244, 241, 234, 0.36); }
.card-seen { color: var(--gold-soft); }

.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.card-btn {
  font: inherit;
  font-size: 0.76rem;
  min-height: 38px;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  color: rgba(244, 241, 234, 0.82);
  background: rgba(244, 241, 234, 0.06);
  border: 1px solid var(--hud-line);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.card-btn svg { width: 15px; height: 15px; }
.card-btn:hover { color: var(--paper); background: rgba(244, 241, 234, 0.13); }
.card-btn:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }
.card-walk { border-color: rgba(201, 162, 39, 0.32); color: var(--gold-soft); }
.card-walk:hover { background: rgba(201, 162, 39, 0.18); color: var(--paper); }

.dir-empty {
  padding: 0 24px 24px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ help */

.help-dialog { width: min(94vw, 820px); }
.help-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 24px 6px;
}
.help-intro {
  margin: 0 0 22px;
  max-width: 62ch;
  font-size: 0.92rem;
  line-height: 1.75;
  color: rgba(244, 241, 234, 0.74);
}

.help-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px 30px;
}
.help-col-title {
  margin: 0 0 10px;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.help-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(233, 226, 208, 0.06);
}
.help-keys {
  flex: none;
  width: 108px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.help-lhs {
  font-size: 0.72rem;
  color: rgba(244, 241, 234, 0.6);
}
.help-label {
  font-size: 0.8rem;
  color: rgba(244, 241, 234, 0.72);
  line-height: 1.4;
}
.help-credit {
  margin: 26px 0 0;
  font-size: 0.74rem;
  color: rgba(244, 241, 234, 0.4);
}
.help-credit a { color: var(--gold-soft); }

/* -------------------------------------------------------------- settings */

.set-dialog { width: min(94vw, 560px); }
.set-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 24px calc(24px + env(safe-area-inset-bottom));
}

.set-group { padding: 18px 0; border-bottom: 1px solid rgba(233, 226, 208, 0.07); }
.set-group:last-child { border-bottom: 0; }
.set-group-title {
  margin: 0 0 12px;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
}
.set-row.is-disabled { opacity: 0.4; }
.set-label { font-size: 0.88rem; }
.set-control { display: flex; align-items: center; gap: 10px; }
.set-value {
  min-width: 46px;
  text-align: right;
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.set-note {
  margin: 10px 0 0;
  font-size: 0.74rem;
  line-height: 1.6;
  color: rgba(244, 241, 234, 0.44);
}

.set-segment {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(244, 241, 234, 0.05);
  border: 1px solid var(--hud-line);
}
.set-seg-btn {
  font: inherit;
  font-size: 0.82rem;
  flex: 1 1 0;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(244, 241, 234, 0.62);
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.set-seg-btn:hover { color: var(--paper); }
.set-seg-btn.is-on {
  color: var(--ink);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  font-weight: 600;
}
.set-seg-btn:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

.set-range {
  width: min(46vw, 200px);
  accent-color: var(--gold);
  height: 24px;
}
.set-range:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 4px; }

.set-toggle {
  width: 56px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.set-toggle-track {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(244, 241, 234, 0.14);
  border: 1px solid var(--hud-line);
  position: relative;
  transition: background-color 0.22s var(--ease);
}
.set-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  transition: translate 0.22s var(--ease);
}
.set-toggle.is-on .set-toggle-track { background: var(--gold); }
.set-toggle.is-on .set-toggle-track::after { translate: 20px 0; }
.set-toggle:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; border-radius: 999px; }

.set-danger {
  font: inherit;
  font-size: 0.8rem;
  min-height: 40px;
  margin-top: 12px;
  padding: 0 18px;
  border-radius: 999px;
  cursor: pointer;
  color: rgba(244, 241, 234, 0.7);
  background: transparent;
  border: 1px solid var(--hud-line);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.set-danger:hover { color: var(--paper); border-color: rgba(255, 134, 134, 0.5); }
.set-danger.is-armed {
  color: #ff9a9a;
  border-color: rgba(255, 134, 134, 0.7);
  background: rgba(255, 134, 134, 0.1);
}
.set-danger:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

/* ------------------------------------------------------- small screens */

@media (pointer: coarse), (max-width: 720px) {
  /* The navigation agent owns both bottom corners on touch (joystick left,
     interact button right), so the HUD vacates them: the map joins the
     top-right stack and the transient labels stay clear of the thumbs. */
  .hud-map {
    position: relative;
    inset: auto;
    width: 124px;
    height: 124px;
  }
  .hud-cluster { gap: 6px; }
  /* The tool cluster spans most of the width on a phone, so the title card
     drops below it instead of running underneath. */
  .hud-room {
    top: calc(var(--hud-inset-top) + 62px);
    max-width: min(52vw, 280px);
  }
  .hud-prompt {
    top: calc(50% + 76px);
    flex-direction: column;
    gap: 4px;
    padding: 10px 18px;
    text-align: center;
    max-width: min(74vw, 360px);
  }
  .hud-prompt-hint { border-left: 0; padding-left: 0; }
  .hud-toasts {
    top: auto;
    bottom: calc(var(--hud-inset-bottom) + 215px);
    max-width: min(80vw, 380px);
  }
  .hud-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92svh;
    border-radius: 16px 16px 0 0;
    margin: auto auto 0;
  }
  .panel-head { padding: 18px 18px 14px; }
  .dir-controls,
  .dir-chips,
  .dir-body,
  .set-body,
  .help-body,
  .map-legend,
  .map-rooms { padding-left: 18px; padding-right: 18px; }
  .dir-grid { grid-template-columns: 1fr; }
  .help-keys { width: 92px; }
}

@media (max-width: 480px) {
  .hud-map { width: 104px; height: 104px; }
  .dir-controls { flex-wrap: wrap; }
  .set-range { width: 42vw; }
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .hud-dialog,
  .hud-dialog::backdrop,
  .hud-room,
  .hud-prompt,
  .hud-toast,
  .set-toggle-track::after {
    transition-duration: 0.01ms;
  }
}
.is-reduced-motion .hud-dialog,
.is-reduced-motion .hud-dialog::backdrop,
.is-reduced-motion .hud-room,
.is-reduced-motion .hud-prompt,
.is-reduced-motion .hud-toast {
  transition-duration: 0.01ms;
}
