:root {
  --bg: #101418; --fg: #e8ecf1; --dim: #9aa4b1; --card: #1a2028; --line: #2a323d;
  --accent: #3b9eff; --danger: #e0514f; --bar: rgba(10, 13, 17, .72);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.screen { position: fixed; inset: 0; }
.ver { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* home */
#home { overflow: auto; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; align-items: center; }
.homeHead { display: flex; align-items: baseline; gap: 10px; margin-top: 8vh; }
.homeHead .logo { width: 30px; height: 30px; align-self: center; color: var(--accent); }
.homeHead h1 { font-size: 26px; margin: 0; font-weight: 650; }
.card { width: min(440px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { margin: 0; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h2 svg { width: 20px; height: 20px; }
.big { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 18px; border-radius: 12px; background: #262e38; font-weight: 600; font-size: 17px; }
.big svg { width: 22px; height: 22px; }
.big.primary { background: var(--accent); color: #06111c; }
.big:active { filter: brightness(1.15); }
#joinForm { display: flex; gap: 8px; }
#joinForm input { flex: 1; min-width: 0; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #0d1115; color: var(--fg); font-size: 18px; letter-spacing: .06em; text-transform: uppercase; }
#joinForm input::placeholder { text-transform: none; letter-spacing: 0; color: var(--dim); }
.hint { margin: 0; color: var(--dim); font-size: 14px; }
.hint.small { font-size: 13px; }
.msg { min-height: 1.4em; color: #ffb4a8; text-align: center; max-width: 440px; }

/* stage + video (cam preview and viewer share the layout) */
.stage { position: absolute; inset: 0; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage video { position: absolute; left: 50%; top: 50%; object-fit: contain; transform-origin: center center; will-change: transform; background: #000; }
#viewVideo { cursor: grab; }
#stage.panning #viewVideo { cursor: grabbing; }

.top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); pointer-events: none; }
.status { font-size: 14px; color: #dfe6ee; text-shadow: 0 1px 2px rgba(0,0,0,.8); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.7); padding: 14px 18px; border-radius: 12px; text-align: center; max-width: 80vw; }

.bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: stretch; gap: 2px; padding: 6px 4px max(6px, env(safe-area-inset-bottom)); background: var(--bar); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.bar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; padding: 4px 2px; border-radius: 10px; font-size: 11.5px; color: #dfe6ee; }
.bar button svg { width: 24px; height: 24px; }
.bar button:active { background: rgba(255,255,255,.12); }
.bar button[aria-pressed="true"] { color: var(--accent); }
.bar button.danger { color: #ff9a97; }
.bar button[disabled] { opacity: .4; cursor: default; }
body.fs .bar { opacity: .35; transition: opacity .3s; }
body.fs .bar:hover, body.fs .bar:focus-within { opacity: 1; }

/* overlays */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.6); }
.overlay.dim { background: #000; cursor: pointer; }
.overlay.dim p { color: #444; font-size: 15px; text-align: center; margin: 0; }
.qrCard { background: #fff; color: #111; border-radius: 16px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(360px, 100%); }
#qrBox { width: min(280px, 70vw, 50vh); aspect-ratio: 1; }
#qrBox svg { width: 100%; height: 100%; display: block; }
.codeRow { display: flex; align-items: center; gap: 10px; }
.code { font-size: 28px; font-weight: 700; letter-spacing: .18em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.iconBtn { width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #333; background: #eef1f5; }
.iconBtn svg { width: 22px; height: 22px; }
.iconBtn:active { background: #dde3ea; }
.qrCard .hint { color: #555; text-align: center; }
.qrCard .hint.ok { color: #1a7f37; }
.small { padding: 8px 16px; border-radius: 10px; background: #eef1f5; color: #222; font-weight: 600; }
