:root {
  color-scheme: dark;
  --bg: #080b0d;
  --surface: #101518;
  --surface-2: #161d20;
  --line: rgba(255,255,255,.12);
  --muted: #89969b;
  --text: #f6f6f1;
  --yellow: #ffd21c;
  --red: #d71724;
  --green: #72d69c;
  --mono: "SFMono-Regular", Consolas, ui-monospace, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); letter-spacing: 0; }
body { background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 48px 48px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
em { color: var(--yellow); font-style: normal; }

.topbar { height: 68px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(8,11,13,.94); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 18px; letter-spacing: .08em; }
.brand small { color: var(--muted); font-family: var(--mono); font-size: 9px; }
.brand-mark { width: 30px; height: 24px; display: flex; align-items: stretch; gap: 3px; transform: skew(-12deg); }
.brand-mark i { flex: 1; background: var(--yellow); }
.brand-mark i:nth-child(2) { background: var(--red); }
.live-state, .network-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 10px var(--mono); }
.live-state i, .online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.is-connected .live-state i, .online-dot { background: var(--green); box-shadow: 0 0 10px rgba(114,214,156,.55); }

.dashboard { width: min(1540px, calc(100% - 48px)); margin: 0 auto; padding: 32px 0 56px; }
.command-band, .section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.command-band { margin-bottom: 26px; }
.eyebrow { margin: 0 0 9px; color: var(--yellow); font: 10px var(--mono); letter-spacing: .12em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 38px; line-height: 1; }
h2 { margin-bottom: 0; font-size: 28px; }
.mono { margin: 0; color: var(--muted); font: 10px var(--mono); }
.operator-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: var(--text); font: 10px var(--mono); }
.button:hover { border-color: rgba(255,210,28,.5); }
.button:disabled { opacity: .5; cursor: wait; }
.button--primary { border-color: var(--yellow); background: var(--yellow); color: #171408; font-weight: 700; }
.button--danger { color: #ff8790; }

.overview-grid { display: grid; grid-template-columns: 290px 320px minmax(400px, 1fr); border: 1px solid var(--line); background: var(--surface); }
.overview-grid > article { min-width: 0; padding: 18px; border-right: 1px solid var(--line); }
.overview-grid > article:last-child { border-right: 0; }
.panel-heading { min-height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font: 9px var(--mono); }
.panel-heading b { color: var(--yellow); font-weight: 500; text-align: right; }
.qr-box { width: min(100%, 218px); aspect-ratio: 1; margin: 16px auto 14px; padding: 9px; background: #fff; }
.qr-box img { display: block; width: 100%; height: 100%; }
.join-url { margin: 0; overflow: hidden; color: var(--muted); font: 8px/1.5 var(--mono); text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.countdown-panel { display: flex; flex-direction: column; }
.countdown { flex: 1; min-height: 150px; display: grid; place-content: center; text-align: center; }
.countdown strong { color: var(--yellow); font: 500 54px/1 var(--mono); }
.countdown span { margin-top: 10px; color: var(--muted); font: 8px var(--mono); }
.schedule-row { min-height: 34px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font: 9px var(--mono); }
.schedule-row b { color: var(--text); font-weight: 500; }
.visual-panel { position: relative; min-height: 320px; overflow: hidden; }
.stadium-visual { position: absolute; inset: 42px 0 0; }
.stadium-visual canvas { width: 100%; height: 100%; }
.visual-fallback { padding: 80px 40px; color: var(--muted); text-align: center; }
.effect-name { position: absolute; right: 18px; bottom: 16px; padding: 7px 10px; border: 1px solid var(--line); background: rgba(8,11,13,.8); color: var(--yellow); font: 9px var(--mono); }
.sync-lock-banner { position: absolute; z-index: 3; top: 54px; left: 18px; width: min(310px, calc(100% - 36px)); padding: 12px 14px; border: 1px solid rgba(255,210,28,.55); background: rgba(8,11,13,.92); box-shadow: 0 0 24px rgba(255,210,28,.1); }
.sync-lock-banner[hidden] { display: none; }
.sync-lock-banner span, .sync-lock-banner strong { display: block; font-family: var(--mono); }
.sync-lock-banner span { margin-bottom: 6px; color: var(--yellow); font-size: 8px; }
.sync-lock-banner strong { font-size: 11px; font-weight: 500; }
.sync-lock-banner > div, .show-sync-lock > div { height: 2px; margin-top: 10px; overflow: hidden; background: rgba(255,255,255,.12); }
.sync-lock-banner i, .show-sync-lock i { display: block; width: 0; height: 100%; background: var(--yellow); box-shadow: 0 0 8px var(--yellow); transition: width 120ms linear; }

.metric-grid { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 12px; border: 1px solid var(--line); background: var(--surface); }
.metric-grid article { min-height: 90px; padding: 16px 18px; display: flex; align-items: flex-end; justify-content: space-between; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border-right: 0; }
.metric-grid span { color: var(--muted); font: 9px var(--mono); }
.metric-grid strong { color: var(--yellow); font: 500 34px var(--mono); }

.sync-telemetry { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 12px; border: 1px solid var(--line); background: #0c1113; }
.sync-telemetry article { min-width: 0; min-height: 82px; padding: 14px 18px; display: grid; grid-template-columns: 1fr auto; align-content: center; gap: 5px 12px; border-right: 1px solid var(--line); }
.sync-telemetry article:last-child { border-right: 0; }
.sync-telemetry span, .sync-telemetry small { color: var(--muted); font: 8px var(--mono); }
.sync-telemetry strong { color: var(--green); font: 500 20px var(--mono); }
.sync-telemetry small { grid-column: 1 / -1; }

.participants-section { margin-top: 30px; }
.section-heading { margin-bottom: 13px; }
.simulation-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 9px var(--mono); }
.simulation-control input { width: 58px; height: 38px; padding: 0 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--text); }
.participant-table-wrap { overflow: auto; border: 1px solid var(--line); }
.participant-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 12px; }
.participant-table th { height: 38px; padding: 0 14px; color: var(--muted); font: 9px var(--mono); text-align: left; }
.participant-table td { height: 68px; padding: 8px 14px; border-top: 1px solid var(--line); white-space: nowrap; transition: color 90ms linear, background-color 90ms linear; }
.participant-table td b, .participant-table td small { display: block; }
.participant-table td small { margin-top: 4px; color: var(--muted); font: 8px var(--mono); }
.participant-table tr.is-offline { opacity: .48; }
.participant-table tr.is-lit { opacity: 1; }
.participant-table tr.is-lit td { border-color: rgba(255,255,255,.45); background: #fffbe8; color: #111617; }
.participant-table tr.is-lit td small, .participant-table tr.is-lit .device-cell small { color: #495254; }
.participant-table tr.is-lit .state-pill { border-color: #527563; color: #205937; }
.participant-table tr.is-lit .online-dot { background: #15934e; box-shadow: none; }
.participant-table tr.is-lit .device-icon { border-color: #1b2325; }
.device-cell { display: flex; align-items: center; gap: 10px; }
.device-cell p { margin: 0; }
.device-icon { position: relative; width: 16px; height: 26px; flex: 0 0 auto; border: 1px solid #8d999d; border-radius: 3px; }
.device-icon::after { position: absolute; bottom: 2px; left: 50%; width: 3px; height: 1px; background: currentColor; transform: translateX(-50%); content: ""; }
.device-icon--iphone, .device-icon--ipad { border-color: #dce5e7; }
.device-icon--android { border-color: var(--green); }
.light-state { color: var(--yellow); font: 500 9px var(--mono); }
.state-pill { display: inline-block; padding: 5px 7px; border: 1px solid var(--line); color: var(--muted); font: 8px var(--mono); }
.state-pill.is-ready { border-color: rgba(114,214,156,.35); color: var(--green); }
.online-dot { display: inline-block; margin-right: 7px; }
.online-dot.is-offline { background: #697176; box-shadow: none; }
.empty-row td { height: 110px; color: var(--muted); text-align: center; }

/* Participant phone */
.join-page { height: 100%; overflow: hidden; background: #090b0c; }
.phone-shell { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(circle at 50% 35%, rgba(215,23,36,.16), transparent 43%), #090b0c; }
.phone-header { position: absolute; z-index: 10; top: 0; right: 0; left: 0; height: calc(64px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 20px 0; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.phone-header .brand strong { font-size: 14px; }
.phone-header .brand-mark { width: 24px; height: 19px; }
.network-state { color: var(--green); }
.network-state.is-offline { color: #ff9298; }
.join-notification { position: absolute; z-index: 20; top: calc(76px + env(safe-area-inset-top)); right: 14px; left: 14px; padding: 13px 15px; border: 1px solid rgba(114,214,156,.55); background: rgba(11,24,18,.97); box-shadow: 0 12px 36px rgba(0,0,0,.36); opacity: 0; transform: translateY(-8px); transition: opacity .24s ease, transform .24s ease; }
.join-notification[hidden] { display: none; }
.join-notification.is-visible { opacity: 1; transform: translateY(0); }
.join-notification span, .join-notification strong, .join-notification small { display: block; font-family: var(--mono); }
.join-notification span { margin-bottom: 5px; color: var(--green); font-size: 7px; }
.join-notification strong { font-size: 12px; font-weight: 600; }
.join-notification small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.phone-step { position: absolute; inset: calc(64px + env(safe-area-inset-top)) 0 0; display: none; overflow-y: auto; padding: 38px max(22px, env(safe-area-inset-left)) calc(26px + env(safe-area-inset-bottom)); }
.phone-step.is-active { display: block; }
.phone-step h1 { max-width: 410px; margin-bottom: 20px; font-size: clamp(42px, 12vw, 66px); line-height: .98; }
.phone-step h2 { margin-bottom: 18px; font-size: clamp(32px, 9vw, 48px); line-height: 1.03; }
.lead { max-width: 440px; margin-bottom: 27px; color: #a9b1b4; font-size: 15px; line-height: 1.55; }
.location-fields { display: grid; gap: 12px; max-width: 520px; }
.location-fields label { display: grid; gap: 8px; color: var(--muted); font: 9px var(--mono); }
.location-fields label span { display: flex; justify-content: space-between; }
.location-fields small { color: var(--yellow); }
.location-fields select { width: 100%; height: 52px; padding: 0 13px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); color: var(--text); }
.location-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.phone-primary, .phone-secondary { width: min(100%, 520px); min-height: 58px; border-radius: 3px; font: 700 12px var(--mono); }
.phone-primary { border: 0; background: var(--yellow); color: #141106; box-shadow: 0 0 30px rgba(255,210,28,.12); }
.phone-secondary { border: 1px solid rgba(255,210,28,.5); background: rgba(255,210,28,.07); color: var(--yellow); }
.phone-primary:disabled { opacity: .55; }
.privacy-copy { max-width: 520px; margin: 14px 0 0; color: #667175; font: 8px/1.5 var(--mono); text-align: center; }
.error-message { min-height: 20px; margin: 13px 0 3px; color: #ff7f88; font-size: 12px; }

.capability-list { max-width: 520px; margin: 28px 0; border: 1px solid var(--line); background: var(--surface); }
.capability-list > div { min-height: 66px; padding: 10px 14px; display: flex; align-items: center; gap: 13px; border-bottom: 1px solid var(--line); }
.capability-list > div:last-child { border-bottom: 0; }
.capability-list p { display: grid; gap: 4px; margin: 0; }
.capability-list b { font: 10px var(--mono); }
.capability-list small { color: var(--muted); font-size: 11px; }
.cap-dot { width: 10px; height: 10px; flex: 0 0 auto; border: 2px solid #596267; border-radius: 50%; }
.cap-dot.is-ready { border-color: var(--green); background: var(--green); box-shadow: 0 0 10px rgba(114,214,156,.5); }
.cap-dot.is-fallback { border-color: var(--yellow); background: var(--yellow); }
.mini-countdown { width: min(100%, 520px); margin: 0 0 18px; display: flex; align-items: baseline; justify-content: space-between; color: var(--muted); font: 9px var(--mono); }
.mini-countdown strong { color: var(--yellow); font-size: 32px; font-weight: 500; }

.phone-step--center { padding-top: 0; display: none; place-content: center; justify-items: center; text-align: center; }
.phone-step--center.is-active { display: grid; }
#raise-step { overflow-y: auto; padding: 24px max(18px, env(safe-area-inset-left)) calc(20px + env(safe-area-inset-bottom)); text-align: left; }
#raise-step.is-active { display: block; }
.orientation-panel { width: min(100%, 560px); min-height: 172px; margin: 0 auto; display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 17px; padding: 18px; border: 1px solid rgba(255,210,28,.35); background: #111719; transition: border-color .2s ease, background .2s ease; }
.orientation-panel.is-warning { border-color: rgba(255,80,91,.72); background: #271114; }
.orientation-panel.is-good { border-color: rgba(114,214,156,.68); background: #0f2119; }
.orientation-visual { position: relative; width: 88px; height: 124px; display: grid; place-items: center; border-right: 1px solid var(--line); }
.orientation-visual span { width: 40px; height: 76px; display: block; border: 2px solid var(--yellow); border-radius: 5px; background: linear-gradient(180deg, rgba(255,210,28,.18), transparent); box-shadow: 0 0 20px rgba(255,210,28,.12); transition: transform .18s ease, border-color .18s ease; }
.orientation-panel.is-warning .orientation-visual span { border-color: #ff6570; box-shadow: 0 0 24px rgba(255,60,75,.24); }
.orientation-panel.is-good .orientation-visual span { border-color: var(--green); box-shadow: 0 0 24px rgba(114,214,156,.26); }
.orientation-visual span::before { display: block; width: 13px; height: 2px; margin: 5px auto; background: currentColor; content: ""; }
.orientation-visual i { position: absolute; right: 5px; bottom: 9px; left: 5px; height: 1px; background: rgba(255,255,255,.15); }
.orientation-copy p { margin: 0; color: var(--muted); font: 9px/1.5 var(--mono); }
.orientation-copy > p:first-child { margin-bottom: 8px; color: var(--yellow); letter-spacing: .1em; }
.orientation-panel.is-warning .orientation-copy > p:first-child { color: #ff7c85; }
.orientation-panel.is-good .orientation-copy > p:first-child { color: var(--green); }
.orientation-copy h2 { margin: 0 0 9px; font-size: clamp(25px, 7.4vw, 38px); }
.sensor-readout { width: min(100%, 560px); margin: 10px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: #0c1113; }
.sensor-readout div { min-height: 53px; padding: 9px 11px; display: grid; gap: 4px; border-right: 1px solid var(--line); }
.sensor-readout div:last-child { border-right: 0; }
.sensor-readout span { color: var(--muted); font: 7px var(--mono); }
.sensor-readout b { color: var(--text); font: 500 15px var(--mono); }
.preparation-feed { position: relative; width: min(100%, 560px); min-height: 150px; margin: 10px auto 0; overflow: hidden; padding: 18px; border: 1px solid var(--line); background: rgba(14,19,21,.96); }
.preparation-feed::before { position: absolute; inset: 0; opacity: .2; background-image: linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 28px 100%; content: ""; }
.feed-scan { position: absolute; z-index: 0; top: 0; bottom: 0; left: -15%; width: 12%; background: linear-gradient(90deg, transparent, rgba(255,210,28,.12), transparent); animation: feed-scan 3.8s linear infinite; }
.preparation-feed > :not(.feed-scan) { position: relative; z-index: 1; }
.preparation-feed > p:first-of-type { margin: 0 0 8px; color: var(--yellow); font: 8px var(--mono); letter-spacing: .11em; }
.preparation-feed h3 { margin: 0 0 8px; font-size: 19px; line-height: 1.2; }
.preparation-feed > p:last-of-type { min-height: 36px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.preparation-feed.is-changing h3, .preparation-feed.is-changing > p { animation: feed-copy .32s ease both; }
.feed-progress { height: 2px; margin-top: 15px; overflow: hidden; background: rgba(255,255,255,.1); }
.feed-progress span { display: block; width: 20%; height: 100%; background: var(--yellow); box-shadow: 0 0 9px var(--yellow); transition: width .5s ease; }
#raise-step .phone-secondary { width: min(100%, 560px); min-height: 46px; margin: 10px auto 0; display: block; }
#raise-step .phone-secondary[hidden] { display: none; }
.waiting-footer { width: min(100%, 560px); margin: 14px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sync-quality { margin: 0; color: var(--muted); font: 8px/1.5 var(--mono); }
.compact-countdown { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.compact-countdown span { color: var(--muted); font: 7px var(--mono); }
.compact-countdown strong { color: var(--yellow); font: 500 20px var(--mono); }
.participant-badge { margin-top: 20px; padding: 12px 18px; border: 1px solid var(--yellow); color: var(--yellow); font: 18px var(--mono); }
@keyframes feed-scan { to { left: 110%; } }
@keyframes feed-copy { from { opacity: .35; transform: translateY(5px); } }

.phone-step--show { inset: 0; padding: 0; overflow: hidden; background: #000; }
.show-light { --light-level: 0; position: absolute; inset: 0; background: rgb(255 214 34); opacity: var(--light-level); transition: opacity 80ms linear; }
.show-light.is-lit { background: #fff9d8; }
.show-sync-lock { position: absolute; z-index: 3; top: calc(78px + env(safe-area-inset-top)); right: 20px; left: 20px; padding: 14px 15px; border: 1px solid rgba(255,210,28,.6); background: rgba(8,11,13,.88); color: #fff; }
.show-sync-lock[hidden] { display: none; }
.show-sync-lock span, .show-sync-lock strong { display: block; font-family: var(--mono); }
.show-sync-lock span { margin-bottom: 7px; color: var(--yellow); font-size: 8px; }
.show-sync-lock strong { font-size: 12px; font-weight: 500; }
.show-status { position: absolute; z-index: 2; right: 20px; bottom: max(24px, env(safe-area-inset-bottom)); left: 20px; display: flex; align-items: flex-end; justify-content: space-between; color: rgba(255,255,255,.86); font: 9px var(--mono); mix-blend-mode: difference; }
.show-status strong { font-size: 18px; }
#torch-video { position: fixed; width: 1px; height: 1px; opacity: .001; pointer-events: none; }

@media (max-width: 1050px) {
  .overview-grid { grid-template-columns: 260px 290px 1fr; }
  .dashboard { width: min(100% - 28px, 1540px); }
}

@media (max-width: 820px) {
  .dashboard-page { overflow-x: hidden; }
  .topbar { padding: 0 16px; }
  .dashboard { width: calc(100% - 24px); padding-top: 20px; }
  .command-band, .section-heading { align-items: flex-start; flex-direction: column; }
  .operator-actions { justify-content: flex-start; }
  .overview-grid { grid-template-columns: 1fr; }
  .overview-grid > article { border-right: 0; border-bottom: 1px solid var(--line); }
  .overview-grid > article:last-child { border-bottom: 0; }
  .visual-panel { min-height: 320px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid article { border-bottom: 1px solid var(--line); }
  .metric-grid article:nth-child(2n) { border-right: 0; }
  .metric-grid article:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .sync-telemetry { grid-template-columns: repeat(2, 1fr); }
  .sync-telemetry article:nth-child(2n) { border-right: 0; }
  .sync-telemetry article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 390px), (max-height: 700px) {
  .phone-step { padding-top: 24px; }
  .phone-step h1 { font-size: 39px; }
  .phone-step h2 { font-size: 31px; }
  .lead { margin-bottom: 18px; font-size: 13px; }
  .location-fields select { height: 46px; }
  .phone-primary, .phone-secondary { min-height: 52px; }
  .capability-list { margin: 16px 0; }
  .capability-list > div { min-height: 57px; }
  .orientation-panel { grid-template-columns: 82px minmax(0, 1fr); min-height: 150px; padding: 14px; }
  .orientation-visual { width: 70px; height: 104px; }
  .orientation-copy h2 { font-size: 25px; }
  .preparation-feed { min-height: 134px; padding: 14px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
