/* Squad Theater 2.0 — Grand Opening cinematic theme */
:root {
  --velvet: #6b1e2e;
  --velvet-dark: #4a1420;
  --velvet-deep: #2d0a12;
  --gold: #d4af37;
  --gold-light: #e8c96a;
  --gold-dim: #9a7b2c;
  --wood: #3d2314;
  --wood-dark: #1e1008;
  --bg-top: #3d1518;
  --bg-mid: #1a080c;
  --bg-bot: #0a0406;
  --text: #f5e6d3;
  --muted: rgba(245, 230, 211, 0.62);
  --line: rgba(212, 175, 55, 0.28);
  --danger: #e85d5d;
  --ok: #5dce8a;
  --warn: #e8b84a;
  --panel: rgba(18, 8, 12, 0.82);
  --radius: 16px;
  --font-display: "Cinzel", "Palatino Linotype", Palatino, serif;
  --font-body: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  --font-italic: "Playfair Display", Georgia, serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-hc="1"] {
  --text: #fff8ef;
  --muted: rgba(255, 248, 239, 0.8);
  --line: rgba(232, 201, 106, 0.55);
  --gold: #f0d78c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-bot);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(120, 40, 55, 0.45), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(40, 15, 25, 0.5), transparent),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 45%, var(--bg-bot));
  overflow-x: hidden;
}

body.theater-live {
  background: #050203;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ——— Screens ——— */
.screen {
  display: none;
  min-height: 100dvh;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ——— Landing ——— */
#screen-landing {
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem calc(2rem + var(--safe-bottom));
  position: relative;
}

.curtain-side {
  pointer-events: none;
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(18vw, 140px);
  background: linear-gradient(90deg, #3a0c16, #6b1e2e 40%, #4a1420);
  opacity: 0.55;
  z-index: 0;
}
.curtain-side.left {
  left: 0;
  box-shadow: inset -20px 0 40px rgba(0, 0, 0, 0.35);
}
.curtain-side.right {
  right: 0;
  transform: scaleX(-1);
}

.card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: linear-gradient(165deg, rgba(45, 18, 24, 0.94), rgba(12, 5, 8, 0.97));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
  backdrop-filter: blur(12px);
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
  margin: 0 0 0.75rem;
}

.card h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.35rem, 4.2vw, 1.75rem);
  color: var(--gold-light);
  letter-spacing: 0.04em;
  margin: 0 0 0.5rem;
  line-height: 1.25;
}

.tagline {
  font-family: var(--font-italic);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.field {
  text-align: left;
  margin-bottom: 0.85rem;
}
.field label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.35rem;
}
.field input {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
}
.field input::placeholder {
  color: rgba(245, 230, 211, 0.35);
}
.field input:focus {
  border-color: var(--gold);
  outline: none;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0.75rem 1.1rem;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #1a0c10;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--gold-light);
}
.btn-ghost {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: none;
  min-height: 40px;
}
.btn-danger {
  background: rgba(232, 93, 93, 0.15);
  border: 1px solid rgba(232, 93, 93, 0.4);
  color: #ffb4b4;
}

.fine-links {
  margin-top: 1.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  font-size: 0.78rem;
}
.fine-links a {
  color: var(--gold-dim);
  text-decoration: none;
}
.fine-links a:hover {
  color: var(--gold-light);
}

.recent {
  margin-top: 1.25rem;
  text-align: left;
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}
.recent h2 {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin: 0 0 0.5rem;
  font-weight: 500;
}
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.recent-list button {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 0.85rem;
}
.recent-list button:hover {
  border-color: var(--line);
}
.recent-list .meta {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-bottom: 0.85rem;
}
.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}
.status-pill.live .dot {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

/* ——— Theater stage ——— */
#screen-theater {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.theater-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.55);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 5;
}
.theater-top .brand {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--gold);
}
.theater-top .room-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.chip {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--gold-light);
}
.chip.director {
  background: rgba(212, 175, 55, 0.15);
}
.top-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.icon-btn {
  min-width: 40px;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--gold-light);
  font-size: 0.85rem;
  padding: 0 0.55rem;
}
.icon-btn:hover {
  background: rgba(212, 175, 55, 0.12);
}
.icon-btn.active {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.2);
}

.theater-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}
@media (min-width: 900px) {
  .theater-body {
    grid-template-columns: 1fr 300px;
  }
  .side-panel {
    border-left: 1px solid var(--line);
  }
}

.stage-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #000;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
}

#film-video {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}

.stage-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
}

.film-grain {
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.5s steps(2) infinite;
}
@keyframes grain {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(-2%, 2%);
  }
}

.house-lights {
  background: radial-gradient(ellipse at 50% 0%, rgba(120, 40, 50, 0.35), transparent 55%);
  transition: opacity 1.2s ease;
  opacity: 1;
}
body.show-started .house-lights {
  opacity: 0.08;
}

/* Curtains */
.curtains {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  display: flex;
}
.curtain {
  flex: 1;
  background: linear-gradient(90deg, #2a0a12, #6b1e2e 30%, #4a1420 70%, #2a0a12);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
  transition: transform 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.curtain.left {
  transform-origin: left center;
}
.curtain.right {
  transform-origin: right center;
}
.curtains.open .curtain.left {
  transform: translateX(-102%);
}
.curtains.open .curtain.right {
  transform: translateX(102%);
}

.lobby-message {
  position: absolute;
  z-index: 3;
  text-align: center;
  padding: 1.5rem;
  max-width: 28rem;
}
.lobby-message h2 {
  font-family: var(--font-display);
  color: var(--gold-light);
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
}
.lobby-message p {
  color: var(--muted);
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.lobby-message.hidden {
  display: none;
}

.reactions-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}
.reaction-float {
  position: absolute;
  bottom: 12%;
  font-size: 1.75rem;
  animation: floatUp 2.2s ease-out forwards;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}
@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.6);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-120px) scale(1.15);
  }
}

.sync-badge {
  position: absolute;
  left: 0.65rem;
  bottom: 0.65rem;
  z-index: 6;
  font-size: 0.68rem;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--line);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stats-hud {
  position: absolute;
  right: 0.65rem;
  top: 0.65rem;
  z-index: 6;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.65rem;
  line-height: 1.4;
  white-space: pre;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid var(--line);
  color: #b8d4a8;
  max-width: min(280px, 90%);
  display: none;
}
.stats-hud.show {
  display: block;
}

/* Controls */
.transport {
  flex-shrink: 0;
  padding: 0.55rem 0.75rem calc(0.55rem + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(20, 8, 12, 0.95), rgba(8, 3, 5, 0.98));
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.transport.audience-limited .host-only {
  display: none;
}

.seek-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.seek-row input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
}

.ctrl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.ctrl-row .spacer {
  flex: 1;
}

.emoji-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.emoji-bar button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
}
.emoji-bar button:hover {
  border-color: var(--line);
  background: rgba(212, 175, 55, 0.1);
}

/* Side panel */
.side-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  max-height: 40vh;
}
@media (min-width: 900px) {
  .side-panel {
    max-height: none;
  }
}

.side-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.side-tabs button {
  flex: 1;
  padding: 0.65rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.side-tabs button.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
}

.side-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.side-pane.active {
  display: flex;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.85rem;
}
.chat-msg .who {
  color: var(--gold);
  font-weight: 600;
  margin-right: 0.35rem;
}
.chat-msg.system {
  color: var(--muted);
  font-style: italic;
  font-size: 0.78rem;
}
.chat-msg .when {
  font-size: 0.65rem;
  color: rgba(245, 230, 211, 0.35);
  margin-left: 0.35rem;
}

.chat-form {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem;
  border-top: 1px solid var(--line);
}
.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
}

.roster {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem;
  list-style: none;
  margin: 0;
}
.roster li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
  font-size: 0.85rem;
}
.roster .role {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.roster .q {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  margin-left: auto;
}
.roster .q.fair {
  background: var(--warn);
}
.roster .q.poor {
  background: var(--danger);
}
.roster .q.unknown {
  background: #666;
}

.host-tools {
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
  flex: 1;
}
.host-tools .dropzone {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s, background 0.15s;
}
.host-tools .dropzone.drag {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
}
.playlist {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
}
.playlist li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.08);
}
.playlist li.active {
  color: var(--gold-light);
}
.playlist li button {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--muted);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open {
  display: flex;
}
.modal {
  width: min(520px, 100%);
  max-height: min(88dvh, 720px);
  overflow: auto;
  background: linear-gradient(165deg, #2a1218, #12080c);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.modal h2 {
  font-family: var(--font-display);
  color: var(--gold-light);
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}
.modal p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin: 0 0 0.75rem;
}
.modal .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.doctor-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.doctor-list li {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
  font-size: 0.85rem;
}
.doctor-list .mark {
  flex-shrink: 0;
  width: 1.2rem;
  text-align: center;
}
.doctor-list .ok {
  color: var(--ok);
}
.doctor-list .fail {
  color: var(--danger);
}
.doctor-list .run {
  color: var(--warn);
}

/* Onboarding steps */
.onboard-steps {
  text-align: left;
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.onboard-steps li {
  margin-bottom: 0.4rem;
}

/* Toast */
#toasts {
  position: fixed;
  bottom: calc(1rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
  width: min(360px, 92vw);
}
.toast {
  background: rgba(20, 10, 12, 0.94);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  font-size: 0.85rem;
  text-align: center;
  animation: toastIn 0.25s ease;
  box-shadow: var(--shadow);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Album visualizer */
#visualizer {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  background: radial-gradient(circle at 50% 60%, #2d0a12, #050203);
}
body.mode-album #visualizer {
  display: block;
}
body.mode-album #film-video {
  opacity: 0.15;
}

/* Mobile transport collapse */
@media (max-width: 599px) {
  .theater-top .brand {
    display: none;
  }
  .card {
    padding: 1.35rem 1.15rem 1.2rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .film-grain,
  .curtain,
  .reaction-float,
  .house-lights {
    animation: none !important;
    transition: none !important;
  }
  .curtains.open .curtain.left,
  .curtains.open .curtain.right {
    transform: translateX(0);
    opacity: 0;
  }
}

/* Fullscreen stage */
.stage-wrap:fullscreen,
.stage-wrap:-webkit-full-screen {
  background: #000;
}
.stage-wrap:fullscreen .transport,
.stage-wrap:-webkit-full-screen .transport {
  opacity: 0.95;
}
