:root {
  color-scheme: dark;
  --bg: #14120e;
  --bg-raise: #1e1b16;
  --line: #3a342b;
  --text: #f4efe6;
  --muted: #b3a898;
  --accent: #ff5a1f;
  --accent-ink: #1c0c05;
  --danger: #d4644e;
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--text); overflow-wrap: break-word; }
img, video { max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.lobby {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(255, 90, 31, 0.2), transparent 60%),
    var(--bg);
}
.card {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  padding: 32px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.eyebrow { margin: 0; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; }
.intro { display: grid; gap: 10px; }
h1 { margin: 0; font-size: 42px; line-height: 1.02; font-weight: 700; letter-spacing: -0.03em; }
.lead, .hint, .sync, .empty p { color: var(--muted); line-height: 1.5; }
.lead { margin: 0; }
a { color: var(--accent); }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); }
.links { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.links a, button.quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.join {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}
.join button, #lobby-form button, #form > button[type="submit"] { width: 100%; }
.sub { display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.sub h2 { margin: 0; font-size: 18px; }
.card.wide { width: min(980px, 100%); }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th, .users td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.users input { width: 88px; padding: 8px 10px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions button, .danger { border: 0; border-radius: 999px; padding: 8px 12px; background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.danger { background: var(--danger); color: white; }
.muted { color: var(--muted); }
.nav { color: var(--text); text-decoration: none; }
label { display: grid; gap: 8px; font-size: 14px; }
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #12100d;
}
button[type="submit"], .mic, #copy-link, .tap {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
.mic.off, #copy-link, button.quiet { background: transparent; color: var(--text); border: 1px solid var(--line); }
.mic.live { background: var(--danger); color: white; }

.theater { min-height: 100vh; min-height: 100dvh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 60px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}
.logo { display: block; width: min(250px, 100%); height: auto; }
.topbar .logo { width: 150px; flex: none; }
.room-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
}
.room-chip .kicker {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.room-chip strong { font-size: 15px; letter-spacing: 0.04em; }
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.top-actions .nav,
.topbar #copy-link {
  height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.connection { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.connection.ok { color: #9dcc8a; }

.layout { display: grid; grid-template-columns: 1fr 320px; grid-template-rows: minmax(280px, 1fr); min-height: 0; height: 100%; }
.stage { position: relative; background: #090807; height: 100%; min-height: 0; overflow: hidden; }
#mount { position: absolute; inset: 0; z-index: 1; }
#mount iframe, #mount video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
  border: 0;
}
#screen.hidden, #screen-frame.hidden { display: none !important; }
#screen:not(.hidden), #screen-frame:not(.hidden) {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.screen-label {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 3;
  max-width: 420px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(20, 18, 14, 0.88);
}
#mount video { object-fit: contain; }
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 48px;
  max-width: 640px;
}
.empty h2 { margin: 0 0 8px; }
.tap { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 5; max-width: calc(100% - 32px); text-align: center; }
.player-tools { display: flex; gap: 8px; }
.stage-dock {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 7;
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-log {
  position: absolute;
  left: 14px;
  bottom: 64px;
  z-index: 6;
  width: min(340px, calc(100% - 120px));
  max-height: 42%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  overflow: hidden;
  pointer-events: none;
}
.stage.chat-open .chat-log { bottom: 168px; }
.chat-line {
  align-self: flex-start;
  max-width: 100%;
  margin: 0;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(20, 18, 14, 0.58);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  animation: chat-in 0.35s ease;
}
.chat-line.leaving { animation: chat-out 0.4s ease forwards; }
.chat-line .who { color: var(--accent); font-weight: 650; margin-right: 6px; }
.chat-form {
  position: absolute;
  left: 14px;
  bottom: 64px;
  z-index: 7;
  width: min(320px, calc(100% - 28px));
  display: grid;
  gap: 8px;
}
.chat-form input { background: rgba(20, 18, 14, 0.86); }
.emoji-row { display: flex; flex-wrap: nowrap; gap: 6px; }
.emoji-row button {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(244, 239, 230, 0.16);
  background: rgba(20, 18, 14, 0.72);
  font-size: 18px;
  line-height: 1;
}
.fx { position: absolute; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
.burst {
  position: absolute;
  top: 38%;
  font-size: 76px;
  animation: burst 1.25s ease-out;
  animation-fill-mode: forwards;
  pointer-events: none;
}
@keyframes chat-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes chat-out { to { opacity: 0; transform: translateY(-12px); } }
@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.4); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -36px) scale(1.4); }
}
.round {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(244, 239, 230, 0.16);
  background: rgba(20, 18, 14, 0.82);
  color: var(--text);
}
.round svg { width: 20px; height: 20px; display: block; }
.round.off { color: var(--muted); }
.round:hover { background: rgba(20, 18, 14, 0.84); }
.full {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 7;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(20, 18, 14, 0.88);
  color: var(--text);
  border: 1px solid var(--line);
}
.stage:fullscreen,
.stage:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #090807;
}
.stage:fullscreen #mount,
.stage:-webkit-full-screen #mount,
.stage:fullscreen #screen,
.stage:-webkit-full-screen #screen,
.stage:fullscreen #screen-frame,
.stage:-webkit-full-screen #screen-frame,
.stage.stage-fill,
.stage.stage-fill #mount,
.stage.stage-fill #screen,
.stage.stage-fill #screen-frame {
  height: 100%;
}
body.stage-open { overflow: hidden; }
.stage.stage-fill {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100dvh;
  min-height: 0;
}

aside {
  padding: 18px;
  border-left: 1px solid var(--line);
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
}
aside h2 { margin: 8px 0 0; font-size: 15px; }
#media-form, #join-form, #lobby-form { display: grid; gap: 10px; }
#people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#people li {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-raise);
  border-radius: 10px;
  outline: 1px solid transparent;
}
#people li.talking { outline-color: #9dcc8a; }
.person-mic { color: var(--muted); font-size: 13px; }
.person-mic.on { color: #9dcc8a; }
.person-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.person-actions button { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: transparent; color: var(--text); font-size: 13px; }
#role {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 90, 31, 0.14);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 860px) {
  h1 { font-size: 28px; }
  .lobby { padding: 16px 12px; }
  .card { padding: 20px 16px; }
  .layout { grid-template-columns: 1fr; }
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 12px;
    padding: 8px 12px;
  }
  .topbar .logo { width: 128px; }
  .room-chip { grid-column: 1 / -1; width: 100%; }
  .top-actions { margin-left: 0; justify-self: end; }
  .connection { margin-left: auto; }
  button, #copy-link { white-space: normal; }
  .topbar #copy-link,
  .top-actions .nav { white-space: nowrap; }
  aside { border-left: 0; border-top: 1px solid var(--line); padding: 14px 12px; min-width: 0; }
  .theater { height: auto; }
  .layout, .layout > * { min-width: 0; }
  .layout { height: auto; grid-template-rows: auto; }
  .stage { height: 56vw; min-height: 220px; }
  .full { top: 12px; right: 12px; bottom: auto; z-index: 7; }
  .empty { padding: 20px; }
}
