:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #e8ecf3;
  background: #101318;
  --amber: #f6bb65;
  --muted: #a6afbd;
  --edge: #303640;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; background: #222832; border: 1px solid var(--edge); border-radius: 8px; padding: .68em 1.05em; cursor: pointer; }
button:hover { filter: brightness(1.14); }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, .script-list:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.loading { padding: 8vw; color: var(--muted); }
.primary { background: var(--amber); border-color: var(--amber); color: #201b14; font-weight: 700; }
.lobby { width: 100%; height: 100%; overflow: auto; display: flex; flex-direction: column; padding: 0 clamp(18px,5.5vw,96px); background: radial-gradient(ellipse at 73% 46%, #212830 0, transparent 49%), #101318; }
.lobby header, .lobby footer, .remote header, .remote-meta, .qr-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lobby header { padding: 24px 0; border-bottom: 1px solid var(--edge); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 660; letter-spacing: -.04em; white-space: nowrap; }
.wordmark i { width: 28px; height: 28px; border-radius: 7px; display: grid; align-content: center; gap: 3px; padding-left: 6px; background: var(--amber); }
.wordmark b { height: 2px; background: #201b14; width: 15px; }
.wordmark b:nth-child(2) { width: 11px; }
.wordmark b:last-child { width: 7px; }
.lobby-actions { display: flex; align-items: center; gap: 14px; }
.full { font-size: 14px; background: transparent; }
.full span { margin-left: 8px; }
.stage-screen, .join { width: 100%; height: 100vh; height: 100dvh; position: relative; }
.stage-host, .pairing { position: absolute; inset: 0; }
.stage-tools { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; gap: 12px; border-radius: 12px; padding: 6px 12px 6px 6px; background: #131820ec; opacity: 0; transition: opacity .2s; }
.stage-tools.disconnected, .stage-tools:hover, .stage-tools:focus-within { opacity: 1; }
.stage-tools .pair-toggle { font-size: 13px; }
.pair-body { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(220px, .82fr); align-items: center; gap: clamp(32px,8vw,140px); width: min(1020px,100%); margin: auto; padding: clamp(24px,6vh,64px) 0; }
.deck-name { color: var(--amber); letter-spacing: .05em; font-size: 15px; margin: 0 0 15px; }
h1 { font-size: clamp(36px,5vw,76px); letter-spacing: -.055em; line-height: 1.15; margin: 0; }
.instructions { margin: 18px 0 30px; line-height: 1.7; color: var(--muted); font-size: clamp(14px,1.4vw,18px); }
.room-label { color: var(--muted); font-size: 13px; }
.digits { display: flex; gap: clamp(5px, .7vw, 12px); margin: 10px 0 24px; }
.digits span { display: grid; place-items: center; width: clamp(39px, 4.8vw, 74px); aspect-ratio: .84; background: #20252d; border: 1px solid #373e48; border-radius: 8px; font: 540 clamp(29px,3.5vw,54px)/1 var(--mono); }
.primary span { margin-left: 18px; }
.qr-card { background: #f3f0e8; border-radius: 17px; padding: clamp(15px,2vw,28px); color: #1d2023; box-shadow: 0 16px 55px #0004; }
.qr-top { margin-bottom: 12px; font-size: 14px; font-weight: 650; }
.qr-top i { font: 24px/1 var(--mono); }
.qr { display: block; width: 100%; background: white; fill: #101317; shape-rendering: crispEdges; border-radius: 4px; }
.qr-bottom { margin-top: 14px; font: 13px var(--mono); color: #52565b; overflow-wrap: anywhere; }
.lobby footer { padding: 16px 0 20px; border-top: 1px solid var(--edge); font-size: 13px; color: var(--muted); }
.keys { display: flex; align-items: center; gap: 6px; }
kbd { font: 12px var(--mono); border: 1px solid #414753; border-radius: 4px; padding: 2px 5px; color: #cfd6df; }
.keys kbd:last-child { margin-left: 10px; }
.join-card { display: grid; gap: 16px; width: min(100%,370px); margin: auto; padding: 28px 0; }
.join-card h1 { font-size: clamp(36px,5vw,52px); margin-bottom: 12px; }
.join-card label, .notice { font-size: 14px; color: var(--muted); }
.join-card input { background: #1a1f27; color: #fff; border: 1px solid #535c6b; padding: 14px; font: 30px var(--mono); letter-spacing: .15em; width: 100%; border-radius: 8px; }
.notice { margin: 0; color: #f3bd82; }
.notice:empty { display: none; }

.stage-host, .preview-host { overflow: hidden; background: #0b0e14; }
.virtual-stage { position: absolute; top: 50%; left: 50%; width: 1280px; height: 720px; overflow: hidden; background: #0b0e14; color: #e8ecf3; transform-origin: center; pointer-events: none; }
.scene-item { position: absolute; width: max-content; white-space: pre-wrap; overflow-wrap: break-word; line-height: 1.35; transition: left .38s ease, top .38s ease, width .38s ease, height .38s ease, transform .38s ease, opacity .32s ease, font-size .38s ease, color .38s ease, background-color .38s ease, border-color .38s ease; }
.scene-title { font-weight: 720; letter-spacing: -.035em; line-height: 1.16; }
.scene-chip { line-height: 1; padding: 11px 18px; background: color-mix(in srgb,var(--accent) 13%,#0b0e14); border: 1px solid color-mix(in srgb,var(--accent) 55%,transparent); border-radius: 999px; }
.scene-image img { width: 100%; object-fit: contain; display: block; transition: height .38s ease; }
.scene-item small { display: block; font-size: 22px; color: #abb6c6; }
.scene-image small { margin-top: 10px; font-size: 18px; }
.scene-kpi strong { transition: color .38s ease; display: block; color: var(--accent); font-size: 104px; line-height: 1.08; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.scene-kpi small { margin-top: 10px; }
.scene-path svg, .scene-arrow > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.scene-path path { transition: stroke .38s ease, stroke-dashoffset .38s ease, stroke-width .38s ease; }
.scene-bar { display: flex; flex-direction: column; gap: 10px; }
.scene-bar > div { flex: 1; min-height: 16px; background: #242a34; border-radius: 6px; overflow: hidden; }
.scene-bar i { display: block; width: 100%; height: 100%; min-height: inherit; transform-origin: left; background: var(--accent); transition: transform .38s ease, background-color .38s ease; }
.scene-arrow { transform-origin: left center; color: #4da3ff; }
.scene-highlight { border: 3px solid var(--accent); border-radius: 10px; animation: breathe 2.2s ease-in-out infinite alternate; }
.scene-highlight.tracking { transition-property: opacity, transform, border-color; }
@keyframes breathe { from { box-shadow: 0 0 0 1px transparent; } to { box-shadow: 0 0 16px 2px color-mix(in srgb,var(--accent) 42%,transparent); } }

.remote { width: min(100%,760px); margin: 0 auto; height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto auto auto minmax(0,min(29dvh,330px)) minmax(0,1fr) auto; background: #13171d; }
.remote header, .remote-meta { padding: 10px 18px; }
.remote header { border-bottom: 1px solid var(--edge); }
.remote .wordmark { font-size: 16px; }
.switch-room { font: 14px var(--mono); color: #e3e6eb; border: 1px solid var(--edge); border-radius: 6px; padding: 7px 10px; }
.remote-meta { font-size: 13px; padding-bottom: 4px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.status.online i { background: #74d5a5; }
.progress { font: 14px var(--mono); }
.tabs { display: flex; overflow-x: auto; gap: 6px; padding: 8px 18px 10px; scrollbar-width: thin; }
.tabs button { white-space: nowrap; background: transparent; color: var(--muted); border-radius: 20px; font-size: 13px; padding: 6px 12px; }
.tabs button[aria-current] { background: #332c23; color: var(--amber); border-color: #69553a; }
.preview { padding: 0 16px 12px; min-height: 0; }
.preview-host { width: 100%; height: 100%; position: relative; border-radius: 8px; outline: 1px solid #303641; }
.reader { position: relative; min-height: 0; border-block: 1px solid var(--edge); }
.reading-line { position: absolute; top: 35%; left: 0; width: 10px; height: 2px; background: var(--amber); z-index: 1; pointer-events: none; }
.script-list { height: 100%; position: relative; padding: 0 16px; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; scrollbar-width: thin; }
.script-list::before, .script-list::after { content: ""; display: block; }
.script-list::before { height: var(--before,0); }
.script-list::after { height: var(--after,0); }
.script-row { display: flex; align-items: baseline; gap: 12px; width: 100%; padding: 14px; background: transparent; border: 1px solid transparent; text-align: left; line-height: 1.65; font-size: clamp(17px, 3.6vw, 23px); color: #acb4bf; }
.script-row small { font: 13px var(--mono); color: #878f9c; }
.script-row[aria-current] { color: #faf4eb; background: #28251f; border-color: #584b39; }
.script-row[aria-current] small { color: var(--amber); }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px max(12px,env(safe-area-inset-bottom)); }
.controls button { min-height: 48px; }
@media (max-width: 620px) {
  .pair-body { grid-template-columns: 1fr; gap: 22px; width: min(100%,400px); }
  .pair-copy { text-align: center; }
  .digits { justify-content: center; margin-bottom: 14px; }
  .instructions { margin: 10px 0 14px; }
  .qr-card { width: min(58vw,245px); justify-self: center; }
  .lobby header { padding: 14px 0; }
  .deck-name { margin-bottom: 8px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .lobby header, .lobby footer { padding-block: 8px; }
  .pair-body { padding-block: 10px; grid-template-columns: 1.5fr .8fr; }
  .qr-card { max-width: 200px; }
  .digits { margin-block: 4px 8px; }
  .instructions { margin: 4px 0 8px; }
  .remote { grid-template: auto auto auto 1fr auto / 38% 1fr; }
  .remote header, .remote-meta, .remote .tabs { grid-column: 1 / -1; }
  .remote .reader { grid-row: 4; grid-column: 2; }
  .controls { grid-column: 1 / -1; padding-block: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
