/* bO.-Universum overlay: bO.craft style - dark surfaces #0E1014-#262B36, accent #FD5D03,
   calm and futuristic. Large targets (>= 88 px for always-visible controls) for eye tracking,
   head pointers and touch; visible focus and scan highlight; high contrast and large text modes. */
:root {
  --bg: #0E1014;
  --surface: #14171D;
  --surface-2: #1A1E26;
  --surface-3: #262B36;
  --line: #3A4152;
  --text: #E9ECF2;
  --muted: #A9B1C2;
  --accent: #FD5D03;
  --accent-soft: #FF8A47;
  --focus: #FFD27A;
  --target: 88px;
  --radius: 14px;
  color-scheme: dark;
  font: 18px/1.45 system-ui, "Segoe UI", sans-serif;
}
:root.large-text { font-size: 23px; }
:root.high-contrast { --bg: #000; --surface: #000; --surface-2: #0a0a0a; --surface-3: #1a1a1a; --line: #fff; --text: #fff; --muted: #fff; --focus: #ffff00; }
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after { transition: none !important; animation: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: grid; grid-template-rows: auto 1fr auto auto; min-height: 100dvh; overflow: hidden; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -200px; z-index: 50; background: var(--accent); color: #000; padding: 14px 18px; border-radius: var(--radius); font-weight: 700; }
.skip:focus { top: 12px; }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 16px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border-bottom: 1px solid var(--line);
}
.bar h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.02em; display: flex; gap: 8px; align-items: baseline; }
.logo { color: var(--accent); font-weight: 800; }
.sep { color: var(--muted); }
.status { color: var(--muted); font-size: 0.9rem; flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar, .toolbar .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

button, .button-link {
  min-width: var(--target); min-height: var(--target); padding: 10px 18px;
  font: inherit; font-weight: 650; color: var(--text); cursor: pointer;
  background: var(--surface-3); border: 2px solid var(--line); border-radius: var(--radius);
  position: relative; overflow: hidden; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
button:hover { border-color: var(--accent-soft); }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); }
button.primary:hover { background: var(--accent-soft); }
button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
/* Dwell progress: fills from the left while the pointer rests. */
button::after { content: ""; position: absolute; inset: auto 0 0 0; height: 6px; background: var(--focus); transform-origin: left; transform: scaleX(var(--dwell, 0)); pointer-events: none; }

:focus-visible, .scan-focus { outline: 4px solid var(--focus) !important; outline-offset: 3px; }
.scan-focus { box-shadow: 0 0 0 9px rgba(253, 93, 3, 0.45) !important; }

#stage { position: relative; min-height: 0; outline: none; background: var(--bg); }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#stage:focus-visible { outline: 4px solid var(--focus); outline-offset: -4px; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid rgba(255,255,255,0.7); border-radius: 50%; pointer-events: none; z-index: 2; }
.no-3d-note { position: absolute; inset: 30% 10% auto; text-align: center; color: var(--muted); }

.pad { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.pad .group { display: flex; gap: 10px; }
.pad .group[hidden] { display: none; }
.glyph { font-size: 1.8rem; line-height: 1; }
.legal { margin: 0; padding: 6px 16px 10px; font-size: 0.72rem; color: var(--muted); background: var(--surface); }

dialog {
  width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  background: var(--surface-2); color: var(--text); border: 2px solid var(--accent); border-radius: 18px; padding: 20px 24px;
}
dialog::backdrop { background: rgba(5, 6, 8, 0.72); }
dialog h2 { margin: 0 0 8px; }
dialog button { min-height: 56px; min-width: 56px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.note { color: var(--muted); font-size: 0.9rem; min-height: 1em; }
.places { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 10px; }
.places li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.places h3 { margin: 0 0 4px; font-size: 1.05rem; }
.places p { margin: 0 0 8px; color: var(--muted); }
.places .row { display: flex; flex-wrap: wrap; gap: 8px; }
.kind { display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; padding: 10px 14px; }
legend { padding: 0 6px; font-weight: 700; color: var(--accent-soft); }
.field { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.field input[type="checkbox"] { width: 32px; height: 32px; accent-color: var(--accent); }
.field select, .field input[type="range"] { min-height: 48px; font: inherit; flex: 1 1 220px; background: var(--surface-3); color: var(--text); border: 2px solid var(--line); border-radius: 10px; accent-color: var(--accent); }
table.bindings { width: 100%; border-collapse: collapse; margin: 12px 0; }
table.bindings caption { text-align: left; font-weight: 700; padding: 6px 0; }
table.bindings th, table.bindings td { border-top: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: middle; }
table.bindings td button { margin: 2px 4px 2px 0; }

@media (max-width: 640px) {
  :root { --target: 72px; font-size: 17px; }
  .bar { padding: 8px 10px; }
  .toolbar button { padding: 8px 12px; }
}

/* Crosshair (Minecraft-like plus, bO accent on lock) and touch stick. */
.crosshair { border: 0; border-radius: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: rgba(233, 236, 242, 0.9); box-shadow: 0 0 0 1px rgba(14, 16, 20, 0.6); border-radius: 1px; }
.crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
.crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }
.pointer-locked .crosshair::before, .pointer-locked .crosshair::after { background: var(--accent-soft); }
.touch-stick { position: absolute; width: 112px; height: 112px; border-radius: 50%; border: 2px solid rgba(233, 236, 242, 0.35); background: rgba(14, 16, 20, 0.35); display: none; z-index: 3; pointer-events: none; }
.touch-stick.on { display: block; }
.touch-knob { position: absolute; left: 34px; top: 34px; width: 44px; height: 44px; border-radius: 50%; background: rgba(253, 93, 3, 0.75); }
.panels { position: absolute; right: 16px; top: 96px; display: grid; gap: 10px; z-index: 4; max-width: min(360px, 45vw); }
.panel { background: rgba(20, 23, 29, 0.92); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.panel h2 { margin: 0 0 6px; font-size: 1rem; color: var(--accent-soft); }

/* ---- Immersive start (default): the 3D view fills the viewport, no bars, no pad. The accessible
   controls appear with an accessibility profile (html.ui-full); the skip link, the menu, Alt+B and
   the gamepad combination always reach them. ---- */
html, body { width: 100%; height: 100dvh; overflow: hidden; }
:root:not(.ui-full) body { display: block; }
:root:not(.ui-full) .bar,
:root:not(.ui-full) #pad,
:root:not(.ui-full) .legal,
:root:not(.ui-full) .skip-places { display: none !important; }
:root:not(.ui-full) #stage { position: fixed; inset: 0; width: 100vw; height: 100dvh; }
:root:not(.ui-full) .panels { top: 72px; }

.menu-button {
  position: fixed; z-index: 6; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  width: 48px; height: 48px; min-width: 48px; min-height: 48px; padding: 0;
  border-radius: 12px; border: 1px solid rgba(233, 236, 242, 0.16); background: rgba(14, 16, 20, 0.42);
  color: var(--accent); font-weight: 800; font-size: 0.9rem; letter-spacing: 0.01em;
  backdrop-filter: blur(6px); opacity: 0.72; transition: opacity 0.2s, border-color 0.2s;
}
.menu-button:hover, .menu-button:focus-visible { opacity: 1; border-color: var(--accent-soft); }
.pointer-locked .menu-button { opacity: 0.28; }
.menu-button::after { display: none; }
:root.ui-full .menu-button { display: none; }

.start-hint {
  position: fixed; z-index: 4; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(92vw, 640px); display: grid; justify-items: center; gap: 10px; text-align: center; pointer-events: none;
  animation: hint-in 0.8s ease-out both;
}
.start-hint[hidden], :root.ui-full .start-hint { display: none; }
.start-hint .pill {
  padding: 10px 20px; border-radius: 999px; font-size: 0.86rem; letter-spacing: 0.03em; color: var(--text);
  background: rgba(14, 16, 20, 0.55); border: 1px solid rgba(233, 236, 242, 0.14); backdrop-filter: blur(8px);
}
.start-hint .fine { font-size: 0.62rem; line-height: 1.35; color: var(--muted); opacity: 0.75; max-width: 56ch; }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Touch: faint stick hint bottom left, only when touch is detected and nothing else is shown. */
:root.touch:not(.ui-full) #stage::after {
  content: ""; position: absolute; left: max(28px, env(safe-area-inset-left)); bottom: max(72px, env(safe-area-inset-bottom));
  width: 96px; height: 96px; border-radius: 50%; border: 2px solid rgba(233, 236, 242, 0.18); pointer-events: none; z-index: 1;
}

/* Menu and profile dialogs. */
dialog.menu { width: min(520px, calc(100vw - 24px)); }
.menu .logo { color: var(--accent); }
.menu-items { display: grid; gap: 10px; margin: 12px 0; }
.menu-items button { width: 100%; justify-content: flex-start; min-height: 56px; }
.menu h3 { margin: 14px 0 0; font-size: 0.95rem; color: var(--accent-soft); }
.legal-note { margin: 16px 0 0; font-size: 0.72rem; color: var(--muted); }
.legal-note a { color: var(--focus); display: inline-block; min-height: 24px; padding: 2px 0; }
.profiles { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 10px; }
.profiles li { display: grid; gap: 4px; }
.profiles button { width: 100%; justify-content: flex-start; }
.profiles .hint { font-size: 0.85rem; color: var(--muted); padding-left: 4px; }
