:root {
  color-scheme: dark;
  --bg: #101827;
  --card: rgba(255,255,255,0.10);
  --card-strong: rgba(255,255,255,0.16);
  --text: #f8fafc;
  --muted: #b8c2d6;
  --line: rgba(255,255,255,0.16);
  --primary: #7c9cff;
  --primary-2: #d76dff;
  --danger: #ff5f7a;
  --success: #48d597;
  --shadow: 0 24px 80px rgba(0,0,0,0.38);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(124,156,255,0.34), transparent 36%),
    radial-gradient(circle at 90% 20%, rgba(215,109,255,0.25), transparent 35%),
    linear-gradient(145deg, #0b1020 0%, #101827 52%, #17213b 100%);
  overflow: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; border: 0; }
button:disabled { opacity: .45; cursor: not-allowed; }

.app-shell {
  min-height: 100dvh;
  width: 100%;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
}

.screen {
  display: none;
  width: min(100%, 520px);
  min-height: calc(100dvh - 36px);
}
.screen.active { display: flex; flex-direction: column; }

.glass {
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.hero-card, .call-card {
  width: 100%;
  margin: auto;
  padding: 26px;
  border-radius: 34px;
}

.brand-badge, .eyebrow {
  display: inline-flex;
  color: #dbeafe;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(124,156,255,0.15);
  border: 1px solid rgba(124,156,255,0.28);
  padding: 7px 11px;
  border-radius: 999px;
}

h1, h2, h3 { margin: 14px 0 8px; line-height: 1.05; }
h1 { font-size: clamp(40px, 11vw, 68px); }
h2 { font-size: clamp(32px, 8vw, 48px); }
p { color: var(--muted); line-height: 1.75; }

.join-form { display: grid; gap: 14px; margin-top: 24px; }
label { color: #e5e7eb; font-size: 14px; display: grid; gap: 8px; }
input {
  width: 100%;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px 16px;
  outline: none;
}
input:focus { border-color: rgba(124,156,255,.85); box-shadow: 0 0 0 4px rgba(124,156,255,.12); }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .call-btn {
  border-radius: 18px;
  color: white;
  min-height: 52px;
  padding: 0 18px;
  font-weight: 800;
}
.primary-btn, .call-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 20px 38px rgba(124,156,255,.26);
}
.call-btn {
  width: 100%;
  height: 74px;
  border-radius: 24px;
  font-size: 20px;
  margin: 20px 0 10px;
}
.secondary-btn {
  background: rgba(255,255,255,.10);
  border: 1px solid var(--line);
}
.ghost-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  min-height: 44px;
}
.danger-btn {
  background: rgba(255,95,122,.15);
  border: 1px solid rgba(255,95,122,.32);
  min-height: 44px;
}
.action-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
.status-text { min-height: 28px; font-size: 14px; }
.hidden { display: none !important; }

.topbar, .room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.topbar strong, .room-header strong { display: block; margin-top: 6px; font-size: 18px; }

.call-card { text-align: center; }
.pulse-orb {
  width: 120px;
  height: 120px;
  border-radius: 999px;
  margin: 14px auto;
  background: radial-gradient(circle at 30% 25%, #fff, var(--primary) 30%, var(--primary-2) 70%);
  box-shadow: 0 0 0 18px rgba(124,156,255,.08), 0 0 80px rgba(215,109,255,.45);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(.96); } 50% { transform: scale(1.04); } }

.room-screen {
  width: 100%;
  max-width: 920px;
}
.video-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-content: center;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  padding-bottom: 132px;
}
.video-tile {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-radius: 24px;
  min-height: 220px;
  aspect-ratio: 3 / 4;
}
.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #0b1020;
}
.name-pill {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 7px 10px;
  background: rgba(0,0,0,.46);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  font-size: 13px;
}
.empty-room {
  text-align: center;
  grid-column: 1 / -1;
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: 28px;
  background: rgba(255,255,255,.04);
}
.avatar-placeholder { font-size: 60px; }
.participant-strip {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  display: flex;
  gap: 9px;
  overflow-x: auto;
  max-width: 920px;
  margin: auto;
}
.participant-chip {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.10);
  color: var(--muted);
  font-size: 13px;
}
.controls {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  padding: 12px;
  border-radius: 26px;
  max-width: 620px;
  margin: auto;
}
.control-btn {
  min-height: 64px;
  border-radius: 20px;
  background: rgba(255,255,255,.11);
  border: 1px solid var(--line);
  color: white;
  font-size: 20px;
  display: grid;
  place-items: center;
  gap: 2px;
}
.control-btn span { font-size: 11px; color: var(--muted); font-weight: 700; }
.control-btn.active { outline: 2px solid rgba(72,213,151,.55); }
.control-btn.off { outline: 2px solid rgba(255,95,122,.55); }
.toast {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: 118px;
  max-width: 520px;
  margin: auto;
  background: rgba(15,23,42,.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  color: white;
  box-shadow: var(--shadow);
  z-index: 30;
}

@media (orientation: landscape) and (max-height: 580px) {
  .video-tile { aspect-ratio: 16 / 9; min-height: 180px; }
  .controls { grid-template-columns: repeat(4, minmax(84px, 1fr)); max-width: 520px; }
}
