/* OCTaVIA party relay. Same token names as apps/web (UI_DESIGN_SYSTEM.md): semantic
   colors, readable type floors, and no icons; every control has visible text. */
:root {
  --bg: #07090d;
  --panel: #10141c;
  --panel2: #171d28;
  --line: #263041;
  --text: #eef2f8;
  --muted: #9aa6b8;
  --green: #3ee6a8;
  --glow: rgba(62, 230, 168, 0.14);
  --danger: #ff6b7a;
  --warning: #ffc861;
  --good: #3ee6a8;
  --type-micro: clamp(12px, 0.8vw, 14px);
  --type-compact: clamp(13px, 0.9vw, 15px);
  --type-body-small: clamp(14px, 1vw, 16px);
  --type-body: clamp(16px, 1.2vw, 18px);
  --radius: 14px;
  --stage-glow: #10261d;
  color-scheme: dark;
}

/* Party themes, picked from the host remote. Each swaps the accent and the stage
   glow; accents stay light so dark text on primary buttons keeps its contrast. */
:root[data-theme="sunset"] { --green: #ff9f6b; --glow: rgba(255, 159, 107, 0.16); --stage-glow: #2e1520; --bg: #0d0709; }
:root[data-theme="ocean"]  { --green: #5fd3f5; --glow: rgba(95, 211, 245, 0.15); --stage-glow: #0c2233; --bg: #060a10; }
:root[data-theme="disco"]  { --green: #d29bff; --glow: rgba(210, 155, 255, 0.16); --stage-glow: #24123a; --bg: #09060f; }
:root[data-theme="gold"]   { --green: #ffd166; --glow: rgba(255, 209, 102, 0.15); --stage-glow: #2a2109; --bg: #0b0905; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--type-body)/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel2);
  font-size: var(--type-compact);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--green); border-color: var(--green); color: #04110b; }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 16px; /* 16px stops iOS Safari zooming into the field */
}
input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.eyebrow {
  font-size: var(--type-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.error { color: var(--danger); font-size: var(--type-body-small); min-height: 1.4em; }
[hidden] { display: none !important; }

/* ---- phone pages (guest, host remote) ----------------------------------- */
.page { max-width: 640px; margin: 0 auto; padding: 20px 16px 64px; display: grid; gap: 18px; }
.brand { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.brand h1 { font-size: 22px; letter-spacing: 0.02em; }
.code-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--type-body-small);
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.card h2 { font-size: var(--type-body); }
.row { display: flex; gap: 10px; align-items: center; }
.row > input { flex: 1; }
.stack { display: grid; gap: 10px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.now-title { font-size: 20px; font-weight: 700; line-height: 1.25; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: middle; }
.status-dot.ok { background: var(--good); }
.status-dot.wait { background: var(--warning); }

.song {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  background: var(--panel2);
}
.song img { width: 96px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--bg); }
.song .meta { min-width: 0; }
.song .title { font-size: var(--type-body-small); font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.song .sub { font-size: var(--type-micro); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.song.mine { outline: 1px solid var(--green); background: linear-gradient(var(--glow), var(--glow)), var(--panel2); }
.song.compact { grid-template-columns: 2.2em 1fr auto; }
.position { font-weight: 700; color: var(--muted); text-align: center; font-size: var(--type-body-small); }
.empty { color: var(--muted); font-size: var(--type-body-small); }
@media (max-width: 420px) {
  .song { grid-template-columns: 72px 1fr; }
  .song img { width: 72px; height: 40px; }
  .song .actions { grid-column: 1 / -1; justify-content: stretch; }
  .song .actions button { flex: 1; }
  .song.compact { grid-template-columns: 2.2em 1fr; }
}

/* ---- stage (TV) ---------------------------------------------------------- */
.stage { position: fixed; inset: 0; overflow: hidden; background: #000; }
.stage #player, .stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
  background: radial-gradient(circle at 30% 20%, var(--stage-glow) 0%, var(--bg) 60%);
  text-align: center;
  z-index: 2;
}
.overlay .center { display: grid; gap: 2.4vh; justify-items: center; max-width: 92vw; }
.overlay h1 { font-size: clamp(32px, 6vw, 96px); line-height: 1.05; letter-spacing: -0.01em; }
.overlay h2 { font-size: clamp(20px, 3vw, 48px); font-weight: 600; color: var(--muted); line-height: 1.2; }
.overlay p { font-size: clamp(16px, 1.8vw, 28px); color: var(--muted); }
.join-block { display: flex; gap: 3vw; align-items: center; justify-content: center; flex-wrap: wrap; }
.qr { background: #fff; border-radius: 16px; padding: 8px; width: clamp(160px, 22vw, 360px); aspect-ratio: 1; }
.qr img { width: 100%; height: 100%; display: block; }
.join-text { text-align: left; display: grid; gap: 1vh; }
.join-text .big-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(40px, 7vw, 120px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text);
}
.countdown { font-size: clamp(48px, 9vw, 160px); font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.badge {
  position: absolute;
  top: 2vh;
  right: 2vw;
  z-index: 3;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border-radius: 14px;
  background: rgba(7, 9, 13, 0.78);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.badge .qr { width: clamp(64px, 7vw, 110px); padding: 4px; border-radius: 8px; }
.badge .label { display: grid; text-align: right; }
.badge .label b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(18px, 2vw, 30px); letter-spacing: 0.14em; }
.badge .label span { font-size: var(--type-micro); color: var(--muted); }
.next-ticker {
  position: absolute;
  top: 2vh;
  left: 2vw;
  z-index: 3;
  max-width: 55vw;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(7, 9, 13, 0.78);
  border: 1px solid var(--line);
  font-size: clamp(14px, 1.4vw, 22px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.host-toggle { position: absolute; bottom: 2vh; right: 2vw; z-index: 5; opacity: 0.55; }
.host-toggle:hover, .host-toggle:focus-visible { opacity: 1; }
.controls {
  position: absolute;
  left: 50%;
  bottom: 2vh;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 92vw;
  padding: 12px;
  border-radius: 18px;
  background: rgba(7, 9, 13, 0.9);
  border: 1px solid var(--line);
}
.host-qr-panel { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: rgba(0, 0, 0, 0.85); }
.host-qr-panel .center { display: grid; gap: 16px; justify-items: center; text-align: center; max-width: 90vw; }
.setup-card { width: min(520px, 92vw); display: grid; gap: 14px; text-align: left; }
.setup-card h1 { font-size: clamp(28px, 4vw, 48px); }

/* ---- party title, cheers, spotlight, up-next ----------------------------- */
.party-title { color: var(--green); }
.cheer-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cheer-row button { min-height: 48px; }
.cheer-tally { font-size: var(--type-body-small); color: var(--muted); }
.flash { color: var(--green); font-size: var(--type-body-small); min-height: 1.4em; }
.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  background: linear-gradient(var(--glow), var(--glow)), var(--panel);
  border: 1px solid var(--green);
  font-weight: 700;
  display: grid;
  gap: 4px;
}
.banner .muted { font-weight: 400; }
.name-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.name-row strong { font-size: var(--type-body); }

.spotlight { display: grid; gap: 1.6vh; justify-items: center; max-width: 86vw; }
.spotlight .who { font-size: clamp(26px, 4.2vw, 72px); font-weight: 800; line-height: 1.05; }
.spotlight .chips { display: flex; flex-wrap: wrap; gap: 1vw; justify-content: center; }
.spotlight .chip {
  padding: 0.6vh 1.4vw;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: linear-gradient(var(--glow), var(--glow)), var(--panel);
  font-size: clamp(16px, 1.9vw, 32px);
  font-weight: 700;
}
.spotlight .chip b { color: var(--green); margin-left: 0.4em; }
.spotlight .comments { display: grid; gap: 1vh; width: min(70vw, 1100px); }
.spotlight .comment {
  text-align: left;
  padding: 1vh 1.4vw;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: clamp(16px, 1.7vw, 30px);
}
.spotlight .comment span { color: var(--muted); font-size: 0.8em; margin-left: 0.6em; }
.divider { width: min(40vw, 500px); height: 1px; background: var(--line); }
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
label.check { display: flex; gap: 10px; align-items: center; }
label.check input { width: 22px; min-height: 22px; height: 22px; }
/* During the post-song spotlight, the corner badge already shows the join code. */
.spotlight:not([hidden]) ~ .join-block { display: none; }

/* ---- guest tabs and queue table ------------------------------------------ */
.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 8px 6px; }
.tabs button[aria-selected="true"] { background: var(--green); color: #04110b; }
.tabs .count { font-variant-numeric: tabular-nums; opacity: 0.85; }
.hint { font-size: var(--type-micro); }
.subhead { font-size: var(--type-body-small); color: var(--muted); margin-top: 8px; }
.queue-table { width: 100%; border-collapse: collapse; font-size: var(--type-body-small); }
.queue-table th {
  text-align: left;
  font-size: var(--type-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--line);
}
.queue-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.queue-table td.num { width: 2.2em; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.queue-table td.who { width: 30%; font-weight: 600; overflow-wrap: anywhere; }
.queue-table td.song { overflow-wrap: anywhere; }
.queue-table tr.mine td { background: var(--glow); }
.queue-table tr.mine td.who { color: var(--green); }
.queue-table tr:last-child td { border-bottom: 0; }

/* ---- stage: the line, shown between songs --------------------------------- */
.coming-up { display: grid; gap: 1vh; justify-items: center; width: min(70vw, 1000px); }
.coming-up ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.8vh; width: 100%; counter-reset: line; }
.coming-up li {
  counter-increment: line;
  display: grid;
  grid-template-columns: 2.4em minmax(0, 0.8fr) minmax(0, 1.6fr);
  gap: 1.2vw;
  align-items: baseline;
  text-align: left;
  padding: 0.8vh 1.4vw;
  border-radius: 12px;
  background: rgba(7, 9, 13, 0.6);
  border: 1px solid var(--line);
  font-size: clamp(15px, 1.6vw, 28px);
}
.coming-up li::before { content: counter(line, decimal); color: var(--green); font-weight: 800; }
.coming-up li b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coming-up li span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Arena: ember and gold over charcoal, with a fire glow rising from below. */
:root[data-theme="arena"] { --green: #ff8a3d; --glow: rgba(255, 138, 61, 0.16); --stage-glow: #3a1206; --bg: #0b0605; }
:root[data-theme="arena"] .overlay {
  background:
    radial-gradient(ellipse 90% 45% at 50% 115%, rgba(255, 110, 30, 0.45) 0%, rgba(160, 40, 10, 0.18) 45%, transparent 70%),
    radial-gradient(circle at 30% 20%, var(--stage-glow) 0%, var(--bg) 60%);
}
:root[data-theme="arena"] .overlay h1 { text-shadow: 0 0 28px rgba(255, 120, 40, 0.35); }
/* With the line on screen, tighten the countdown so everything fits on an iPad. */
#interlude .center:has(.coming-up:not([hidden])) { gap: 1.6vh; }
#interlude .center:has(.coming-up:not([hidden])) .countdown { font-size: clamp(36px, 6vw, 110px); line-height: 1; }
#interlude .center:has(.coming-up:not([hidden])) h1 { font-size: clamp(30px, 5vw, 84px); }

/* ---- attribution ---------------------------------------------------------- */
.credit { text-align: center; color: var(--muted); font-size: var(--type-micro); opacity: 0.8; margin-top: 8px; }
.stage-credit { position: absolute; left: 2vw; bottom: 2vh; z-index: 3; margin: 0; text-align: left; font-size: clamp(12px, 1vw, 16px); opacity: 0.6; }

/* ---- party logo and the Arena emblem ------------------------------------- */
.party-logo { max-width: min(40vw, 520px); max-height: 18vh; object-fit: contain; display: block; }
.emblem { display: none; width: auto; height: clamp(70px, 14vh, 150px); filter: drop-shadow(0 0 18px rgba(255, 120, 40, 0.45)); }
:root[data-theme="arena"] .emblem { display: block; }
/* A host-chosen logo replaces the emblem; neither crowds the countdown. */
.center:has(.party-logo:not([hidden])) .emblem { display: none; }
#interlude .center:has(.coming-up:not([hidden])) .party-logo { max-height: 11vh; }
#interlude .center:has(.coming-up:not([hidden])) .emblem { height: clamp(56px, 10vh, 110px); }
.brand-logo { height: 28px; width: auto; max-width: 96px; object-fit: contain; border-radius: 6px; }
.brand .title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* ---- animated reactions ---------------------------------------------------- */
.reaction-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
.cheer-row button.reaction { border-color: var(--green); background: linear-gradient(var(--glow), var(--glow)), var(--panel2); }
