:root {
  --bg: #14160f;
  --bg-raised: #1e2318;
  --ink: #f6f3ea;
  --muted: #b7b2a4;
  --line: rgba(246, 243, 234, 0.12);
  --accent: #d6f25c;
  --accent-ink: #1a2208;
  --danger: #ff5d45;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(214, 242, 92, 0.16), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(255, 93, 69, 0.12), transparent 50%),
    var(--bg);
  color: var(--ink);
}

body { min-height: 100dvh; }

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

button { cursor: pointer; }

[hidden] { display: none !important; }

#toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  background: #fff8ea;
  color: #24180f;
  box-shadow: var(--shadow);
}

#lobby {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.top, .stage-bar, .panel-head, .actions, .stage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; gap: 14px; align-items: center; }

.mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 50%, var(--accent) 0 7px, transparent 8px),
    #2a311c;
  box-shadow: inset 0 0 0 1px var(--line);
}

h1, h2, .eyebrow { margin: 0; }

h1, #stage-title {
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1 { font-size: clamp(2rem, 4vw, 3.2rem); }

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pill, .badge {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #3a241f;
  color: #ffc7bc;
  font-size: 0.86rem;
  white-space: nowrap;
}

.pill.ok {
  background: #243114;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  margin-top: 28px;
}

.panel {
  background: rgba(30, 35, 24, 0.92);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.lead, .muted, .help { color: var(--muted); line-height: 1.5; }

.help {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 93, 69, 0.08);
}

label { display: grid; gap: 8px; margin: 16px 0; font-size: 0.92rem; }

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #12150e;
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
}

input:focus { border-color: var(--accent); }

.actions { justify-content: flex-start; flex-wrap: wrap; }

button.primary, #create-only, .text-btn, .room-list button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
}

button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

#create-only, .room-list button {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

.text-btn { background: transparent; color: var(--muted); padding: 8px 0; }

button:disabled { opacity: 0.55; cursor: wait; }

#room-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

#room-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-radius: 18px;
  background: #14180f;
}

#room-list strong { display: block; }

#room-list span { color: var(--muted); font-size: 0.86rem; }

#stage {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 12px;
}

.stage-bar { align-items: flex-end; }

#stage-title { font-size: clamp(1.6rem, 3vw, 2.4rem); }

#stage-count { margin: 0 0 6px; color: var(--muted); text-align: right; }

.stage-status {
  margin: 8px 0 0;
  color: var(--accent);
}

.grid {
  flex: 1;
  min-height: 0;
  margin-top: 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  align-content: center;
  overflow: auto;
}

.tile {
  position: relative;
  min-height: 220px;
  border-radius: 24px;
  overflow: hidden;
  background: #0d0f0a;
  box-shadow: inset 0 0 0 1px var(--line);
}

.tile .frame, .tile .slot, .tile video {
  width: 100%;
  height: 100%;
}

.tile .frame { position: absolute; inset: 0; }

.tile video {
  object-fit: cover;
  background: #000;
  display: block;
}

.tile.local video { transform: scaleX(-1); }

.tile .avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: Palatino, Georgia, serif;
  font-size: 3rem;
  color: var(--accent);
}

.tile:not(.cam-off) .avatar { visibility: hidden; }

.tile footer {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(12, 14, 9, 0.72);
}

.tile .mic { color: #ffc7bc; font-size: 0.82rem; }

.tile.speaking { box-shadow: inset 0 0 0 3px var(--accent); }

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 8px;
}

.ctrl {
  width: 92px;
  border: 0;
  border-radius: 22px;
  padding: 12px 8px 10px;
  background: #2a311c;
  display: grid;
  justify-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.ctrl svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ctrl.off { background: #3a241f; color: #ffc7bc; }

.ctrl.leave { background: var(--danger); color: #2a0d08; }

@media (max-width: 800px) {
  .layout, .top, .stage-bar { display: block; }
  .pill, .stage-meta { margin-top: 14px; }
  #stage-count { text-align: left; }
  .stage-meta .badge { display: inline-block; margin-top: 8px; }
}
