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

:root {
  --accent:   #5b8cff;
  --accent-2: #38bdf8;
  --danger:   #f87171;

  --bg:       #0a1230;
  --text:     #f3f7ff;
  --text-dim: rgba(233, 240, 255, 0.72);
  --muted:    rgba(233, 240, 255, 0.5);

  /* Glass system */
  --surface:            rgba(255, 255, 255, 0.12);
  --surface-strong:     rgba(255, 255, 255, 0.22);
  --border:             rgba(255, 255, 255, 0.16);
  --border-strong:      rgba(255, 255, 255, 0.28);

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow:    0 24px 60px -12px rgba(15, 30, 80, 0.55);
}

html, body, #app { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* ── Blurred colourful blue backdrop ───────────────────────────────────────── */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(46% 50% at 18% 22%, rgba(80, 140, 255, 0.85) 0%, rgba(80, 140, 255, 0) 60%),
    radial-gradient(40% 44% at 84% 18%, rgba(56, 189, 248, 0.75) 0%, rgba(56, 189, 248, 0) 62%),
    radial-gradient(52% 56% at 78% 82%, rgba(99, 102, 241, 0.80) 0%, rgba(99, 102, 241, 0) 60%),
    radial-gradient(48% 50% at 12% 86%, rgba(45, 212, 255, 0.55) 0%, rgba(45, 212, 255, 0) 60%),
    radial-gradient(60% 60% at 50% 50%, rgba(37, 70, 190, 0.55) 0%, rgba(10, 18, 48, 0) 70%),
    linear-gradient(160deg, #0c1640 0%, #0a1230 50%, #0b1138 100%);
  filter: saturate(1.1);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(80% 80% at 50% 40%, transparent 40%, rgba(6, 12, 36, 0.5) 100%);
  pointer-events: none;
}

/* ── Home screen ───────────────────────────────────────────── */

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 1rem;
}

.home-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  flex: 1;
  width: 100%;
  max-width: 420px;
}

.home h1 {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.home h1 span {
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.join-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.join-form input {
  flex: 1;
  min-width: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 16, 44, 0.4);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  outline: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.18);
  transition: border-color 0.15s;
}
.join-form input::placeholder { color: var(--muted); }
.join-form input:focus { border-color: var(--border-strong); }

.btn {
  padding: 0.8rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.btn:hover { filter: brightness(1.06); }

.btn-primary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  box-shadow: 0 12px 28px -8px rgba(56, 189, 248, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-danger { background: var(--danger); color: #fff; }

.btn-ghost {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn-ghost:hover { background: var(--surface-strong); filter: none; }

.btn-icon {
  padding: 0.8rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  font-weight: 600;
  width: 100%;
  justify-content: center;
}

.notice {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.notice.error { border-left-color: var(--danger); }

/* ── Mode toggle (home) ────────────────────────────────────────────────────── */

.mode-toggle {
  display: flex;
  gap: 0.4rem;
  width: 100%;
  padding: 0.4rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.mode-toggle .btn {
  flex: 1;
  justify-content: center;
  font-size: 0.95rem;
}
.mode-toggle .btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-dim);
}
.mode-toggle .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

/* ── Home footer ───────────────────────────────────────────────────────────── */

.home-footer {
  font-size: 0.8rem;
  padding-bottom: 0.5rem;
}
.home-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: 0.2s;
}
.home-footer a:hover { color: var(--text-dim); border-color: var(--muted); }

/* ── Room / video ──────────────────────────────────────────── */

.room {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(70% 60% at 50% 32%, rgba(120, 170, 255, 0.45), transparent 70%),
    linear-gradient(165deg, #2a4bb0 0%, #1b3486 45%, #122462 100%);
}

video { display: block; background: #0a1230; }

.video-remote {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-local {
  position: absolute;
  bottom: 5rem;
  right: 1.5rem;
  width: 200px;
  height: 150px;
  border-radius: var(--radius-md);
  object-fit: cover;
  z-index: 15;
  border: 1px solid var(--border-strong);
  box-shadow: 0 14px 30px -10px rgba(6, 12, 36, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: grab;
  touch-action: none;
}
.video-local:active { cursor: grabbing; }

.controls {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 0.8rem 1rem;
  border-radius: 99px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.ctrl-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}
.ctrl-btn:hover { background: rgba(255, 255, 255, 0.26); transform: translateY(-2px); }
.ctrl-btn.active {
  background: linear-gradient(150deg, #ff6b6b, #e23b4f);
  border-color: rgba(255, 255, 255, 0.4);
}
.ctrl-btn.btn-danger {
  background: linear-gradient(150deg, #ff6b6b, #e23b4f);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 10px 26px -8px rgba(226, 59, 79, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.ctrl-btn.btn-danger:hover { filter: brightness(1.08); }
.ctrl-btn i { pointer-events: none; }

.room-waiting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 1;
  color: var(--text-dim);
  font-size: 0.95rem;
  background:
    radial-gradient(70% 60% at 50% 32%, rgba(120, 170, 255, 0.45), transparent 70%),
    linear-gradient(165deg, #2a4bb0 0%, #1b3486 45%, #122462 100%);
}

/* When swapped, the fullscreen slot holds your local video, so let it show
   through the waiting overlay instead of being hidden behind it. */
.room.swapped .room-waiting {
  background: transparent;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(6, 12, 36, 0.85);
}

.room-code-badge {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.5rem;
  box-sizing: border-box;
  padding: 0 0.95rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  cursor: pointer;
  user-select: none;
}
.room-code-badge i { color: var(--accent-2); }

/* ── Timer ─────────────────────────────────────────────────────────────────── */

.timer {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 2.5rem;
  box-sizing: border-box;
  padding: 0 0.9rem;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(125, 211, 252, 0.45);
  border-radius: 99px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 24px -8px rgba(56, 189, 248, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}

.timer-warning {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.55);
  color: #ffd9d9;
}

.timer-digits {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.extend-btn {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 99px;
  opacity: 0.9;
}
.extend-btn:hover { opacity: 1; }

.timer-maxed {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ── Audio call UI ─────────────────────────────────────────────────────────── */

.audio-call-ui {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-dim);
  background:
    radial-gradient(70% 60% at 50% 32%, rgba(120, 170, 255, 0.45), transparent 70%),
    linear-gradient(165deg, #2a4bb0 0%, #1b3486 45%, #122462 100%);
}

.audio-call-ui i {
  font-size: 4rem;
  color: var(--accent-2);
  filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.6));
}
.audio-call-ui span { font-size: 0.9rem; }

/* ── Visually hidden (keeps audio playing) ─────────────────────────────────── */

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

/* ── 1-minute warning flash ────────────────────────────────────────────────── */

@keyframes warning-pulse {
  0%   { opacity: 0; }
  12%  { opacity: 0.28; }
  55%  { opacity: 0.18; }
  100% { opacity: 0; }
}

.warning-flash {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: var(--danger);
  animation: warning-pulse 2.5s ease-out forwards;
}

@media (max-width: 600px) {
  .video-local { width: 110px; height: 82px; bottom: 5.5rem; right: 0.75rem; }
  .home h1 { font-size: 2rem; }
  .join-form { flex-direction: column; }
  .controls { gap: 0.5rem; padding: 0.65rem 0.75rem; }
  .ctrl-btn { width: 42px; height: 42px; font-size: 1.15rem; }
  .room-code-badge { left: 1rem; transform: none; }
  .timer { right: 1rem; }
}
