:root {
  --void: #140b14;
  --plum: #2a1828;
  --pink: #ff5d8c;
  --peach: #ff9e6d;
  --yellow: #ffea75;
  --mint: #7ceab4;
  --sky: #64c4ff;
  --lavender: #c49aff;
  --text: #f1e6f4;
  --muted: #a894b4;
  --accent: var(--lavender);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-state="ok"] { --accent: var(--mint); }
:root[data-state="wobbly"] { --accent: var(--peach); }
:root[data-state="down"] { --accent: var(--lavender); }
:root[data-state="asleep"] { --accent: var(--lavender); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--void); color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--void);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.sub { margin: 2px 0 0; color: var(--muted); }

.stage {
  position: relative;
  width: min(100%, calc(74vh * 0.9375));
  width: min(100%, calc(74svh * 0.9375));
  aspect-ratio: 6 / 6.4;
  margin-inline: auto;
  border-radius: 20px;
  overflow: hidden;
  background: #0a0614;
  box-shadow: 0 0 0 1px rgba(196, 154, 255, 0.18), 0 18px 60px -20px rgba(0, 0, 0, 0.8);
  transition: box-shadow 0.8s ease;
}
:root[data-state="ok"] .stage { box-shadow: 0 0 0 1px rgba(124, 234, 180, 0.35), 0 18px 60px -20px rgba(124, 234, 180, 0.25); }
:root[data-state="wobbly"] .stage { box-shadow: 0 0 0 1px rgba(255, 158, 109, 0.35), 0 18px 60px -20px rgba(255, 158, 109, 0.2); }
.stage canvas, #flat, .stage .static {
  display: block;
  width: 100%;
  height: 100%;
}
/* the canvas alone owns touch gestures (drag orbits, pinch zooms); the rest of the page scrolls as usual */
.stage canvas {
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.stage canvas.dragging { cursor: grabbing; }
#flat svg, .stage .static { width: 100%; height: 100%; object-fit: cover; }

/* added by xr.js only when the browser can do webxr */
.xr { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: -6px; }
.xr-btn, #xr-ui button {
  font: 0.9rem var(--mono);
  color: var(--accent);
  background: rgba(196, 154, 255, 0.08);
  border: 0;
  border-radius: 999px;
  padding: 9px 20px;
  box-shadow: inset 0 0 0 1px var(--accent);
  cursor: pointer;
}
.xr-btn:hover, #xr-ui button:hover { background: rgba(196, 154, 255, 0.16); }
.xr-btn:focus-visible, #xr-ui button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.xr-note { margin: 0; color: var(--muted); font: 0.85rem var(--mono); }
#xr-ui {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px;
  pointer-events: none;
  color: var(--text);
}
#xr-ui .xr-line { margin: 0; font-size: 1rem; text-shadow: 0 1px 6px #000; }
#xr-ui .xr-bar { display: flex; gap: 10px; pointer-events: auto; }
#xr-ui button { background: rgba(20, 11, 20, 0.75); }

.status { display: flex; flex-direction: column; gap: 10px; }
.line {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.35;
  color: var(--accent);
  transition: color 0.6s ease;
}
.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font: 0.85rem var(--mono);
}
.checks li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: rgba(196, 154, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(196, 154, 255, 0.18);
  color: var(--muted);
}
.checks li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--plum);
  box-shadow: inset 0 0 0 1px var(--muted);
}
.checks li[data-s="ok"] { color: var(--text); }
.checks li[data-s="ok"]::before { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.checks li[data-s="fail"] { color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 158, 109, 0.55); }
.checks li[data-s="fail"]::before { background: var(--peach); box-shadow: 0 0 8px var(--peach); }
.when { margin: 0; min-height: 1.5em; color: var(--muted); font: 0.85rem var(--mono); }

footer { color: var(--muted); font-size: 0.85rem; }
footer p { margin: 0 0 4px; }

@media (max-width: 480px) {
  main { padding-top: 18px; }
  .line { font-size: 1.15rem; }
  .stage { border-radius: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .stage, .line { transition: none; }
}
