:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #131a30;
  --panel-2: #1a2340;
  --line: #27315a;
  --text: #e8ecff;
  --muted: #9aa5cc;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --danger: #ff6b6b;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1d1846 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); }
[hidden] { display: none !important; }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand img { width: 36px; height: 36px; }
.brand span { font-weight: 700; font-size: 20px; letter-spacing: .2px; }
.brand b { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
header.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.pill { font-size: 13px; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }

h1 { font-size: clamp(28px, 5vw, 46px); line-height: 1.1; margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 18px; max-width: 640px; margin: 0 0 32px; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.choice {
  display: block; padding: 24px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); color: var(--text); text-decoration: none; transition: transform .15s, border-color .15s;
}
.choice:hover, .choice:focus-visible { border-color: var(--accent); transform: translateY(-2px); outline: none; }
.choice h2 { margin: 12px 0 6px; font-size: 22px; }
.choice p { margin: 0; color: var(--muted); }
.choice .icon { font-size: 34px; }

.steps { margin-top: 40px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.step strong { display: block; margin-bottom: 4px; }
.step p { margin: 0; color: var(--muted); font-size: 15px; }
footer { margin-top: 40px; color: var(--muted); font-size: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
label.field { display: block; font-weight: 600; margin-bottom: 8px; }
.code-input {
  width: 100%; font: 700 34px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .3em; text-transform: uppercase;
  text-align: center; padding: 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--text);
}
.code-input:focus { border-color: var(--accent); outline: none; }
fieldset { border: 0; padding: 0; margin: 20px 0 0; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { flex: 1 1 140px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); text-align: center;
}
.seg span small { display: block; color: var(--muted); font-size: 13px; }
.seg input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.seg input:disabled + span { opacity: .4; cursor: not-allowed; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  font: 600 17px/1 inherit; font-family: inherit; padding: 16px 22px; border-radius: 12px; color: #fff;
  background: linear-gradient(90deg, var(--accent), #5b7cff); min-height: 52px;
}
.btn:disabled { opacity: .5; cursor: progress; }
.btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.btn.block { width: 100%; margin-top: 24px; }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.error { color: var(--danger); min-height: 1.5em; margin: 12px 0 0; }
.note { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.notice { background: var(--panel); border: 1px solid var(--danger); border-radius: var(--radius); padding: 20px; }

.live-grid { display: grid; gap: 16px; }
.preview { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; object-fit: contain; }
.live-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 14px; }
.status { font-size: 18px; font-weight: 600; margin: 0; }

/* ---------- TV ---------- */
body.tv { overflow: hidden; }
.tv-idle { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4vh 4vw; gap: 3vh; }
.tv-idle .brand img { width: 6vh; height: 6vh; }
.tv-idle .brand span { font-size: 3.6vh; }
.tv-panel { display: flex; align-items: center; gap: 5vw; background: var(--panel); border: 1px solid var(--line); border-radius: 3vh; padding: 4vh 5vw; }
.tv-code-label { color: var(--muted); font-size: 2.6vh; margin: 0 0 1vh; }
.tv-code { font: 800 13vh/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; margin: 0;
  background: linear-gradient(90deg, #fff, #c9d2ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tv-url { font-size: 3vh; margin: 2vh 0 0; }
.tv-url strong { color: var(--accent-2); }
.qr { width: 26vh; height: 26vh; background: #fff; border-radius: 2vh; padding: 1vh; }
.qr svg { width: 100%; height: 100%; display: block; }
.tv-status { color: var(--muted); font-size: 2.6vh; min-height: 3.5vh; margin: 0; }
.tv-footer { display: flex; gap: 2vw; align-items: center; color: var(--muted); font-size: 2vh; }
.tv-footer .btn { font-size: 2vh; padding: 1.4vh 2vw; min-height: 0; }
.stage { position: fixed; inset: 0; background: #000; cursor: none; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.hud { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 16px; padding: 20px 24px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); opacity: 0; transition: opacity .3s; cursor: default; }
.hud.visible { opacity: 1; }
.stage:has(.hud.visible) { cursor: default; }
.hud .grow { flex: 1; color: #cfd6f5; font-size: 15px; }
.unmute { position: absolute; top: 24px; right: 24px; }

@media (max-aspect-ratio: 1/1) {
  .tv-panel { flex-direction: column; }
  .tv-code { font-size: 9vh; }
}
