:root {
  --bg: #0b0d12;
  --fg: #f4f5f7;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-fg: #ffffff;
  --panel: #171a22;
  --danger: #e5484d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#stage { position: relative; width: 100vw; height: 100vh; }

.layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}
.layer.active { opacity: 1; pointer-events: auto; }

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg);
}

.fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: 20vmin;
  font-weight: 700;
  color: var(--panel);
  background: radial-gradient(circle at 50% 40%, #232838, var(--bg) 70%);
}
.fallback.show { display: grid; }

.cta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

#startBtn {
  font-size: clamp(22px, 4vmin, 40px);
  font-weight: 600;
  padding: 0.8em 1.8em;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  box-shadow: 0 10px 40px rgb(79 140 255 / 0.45);
  animation: pulse 2.4s ease-in-out infinite;
}
#startBtn:disabled { opacity: 0.6; animation: none; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.hint { margin: 0; color: var(--muted); font-size: clamp(14px, 2.2vmin, 22px); }

.status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(20px, 3.5vmin, 36px);
  color: var(--muted);
}
.status[hidden] { display: none; }

.caption {
  position: absolute;
  left: 50%;
  bottom: 14vh;
  transform: translateX(-50%);
  width: min(90vw, 1100px);
  margin: 0;
  text-align: center;
  font-size: clamp(18px, 3vmin, 32px);
  line-height: 1.35;
  text-shadow: 0 2px 8px rgb(0 0 0 / 0.8);
}

.stop {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 12px 22px;
  font-size: 18px;
  border: 1px solid rgb(255 255 255 / 0.25);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.45);
  color: var(--fg);
  cursor: pointer;
}

#admin {
  position: absolute;
  top: 16px;
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  padding: 20px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.5);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}
#admin[hidden] { display: none; }
#admin h2 { margin: 0; font-size: 18px; }
#admin label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
#admin select, #admin button {
  font-size: 16px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgb(255 255 255 / 0.15);
  background: var(--bg);
  color: var(--fg);
}
.admin-note { margin: 0; font-size: 13px; color: var(--muted); }
#admin select:disabled { opacity: 0.5; }
#admin option:disabled { color: var(--muted); }
.admin-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-actions a { color: var(--muted); font-size: 14px; }

/* ---------- вхід ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; margin: 0; padding: 16px; }
.login {
  display: flex; flex-direction: column; gap: 16px;
  width: min(360px, 100%); padding: 28px;
  background: var(--panel); border-radius: 16px;
}
.login h1 { margin: 0; font-size: 22px; }
.login label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.login input, .login button {
  font: inherit; padding: 12px 14px; border-radius: 10px;
  border: 1px solid #2a2f3c; background: var(--bg); color: var(--fg);
}
.login button { background: var(--accent); color: var(--accent-fg); border: 0; cursor: pointer; font-weight: 600; }
.login-error { margin: 0; color: var(--danger); font-size: 14px; }

/* ---------- тестова панель на стартовому екрані ---------- */
.testpanel {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-bottom: 12px; padding: 12px 16px; max-width: 100%;
  border-radius: 14px; background: rgb(23 26 34 / 0.85);
  border: 1px solid rgb(255 255 255 / 0.08);
}
.testpanel[hidden] { display: none; }
.testpanel-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.testpanel-label { color: var(--muted); font-size: 14px; }
.testpanel select {
  font: inherit; font-size: 15px; padding: 8px 10px; border-radius: 8px; max-width: 100%;
  border: 1px solid rgb(255 255 255 / 0.15); background: var(--bg); color: var(--fg);
}
.testpanel select:disabled { opacity: 0.5; }
.testpanel-note { margin: 0; font-size: 13px; color: #f5b94a; text-align: center; }
.testpanel-note[hidden] { display: none; }

/* ---------- модель і таймер під час розмови ---------- */
.liveinfo {
  position: absolute; top: 16px; left: 16px; z-index: 5;
  display: flex; gap: 12px; align-items: center;
  padding: 8px 14px; border-radius: 999px;
  background: rgb(0 0 0 / 0.5); font-size: 15px; color: var(--fg);
}
.liveinfo[hidden] { display: none; }
.liveinfo #liveModel:empty { display: none; }
.liveinfo-timer { font-variant-numeric: tabular-nums; color: var(--muted); }
.liveinfo-timer.warn { color: #f5b94a; font-weight: 600; }

.admin-check { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 14px; }
