* {
  box-sizing: border-box;
  margin: 0;
}

/* The hidden attribute must win over any display rule below. */
[hidden] {
  display: none !important;
}

:root {
  --bg: #10141a;
  --surface: #1b222c;
  --text: #eef2f7;
  --muted: #96a0ad;
  --accent: #3b82f6;
  --danger: #dc2626;
  --radius: 14px;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

section[id^="view-"]:not(#view-call) {
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  justify-content: center;
}

h1 {
  font-size: 2.4rem;
  text-align: center;
}

h2 {
  font-size: 1.4rem;
  text-align: center;
}

.tagline {
  color: var(--muted);
  text-align: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label,
.hint {
  color: var(--muted);
  font-size: 0.95rem;
}

input {
  background: var(--surface);
  border: 1px solid #2c3542;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.15rem;
  padding: 14px 16px;
  width: 100%;
}

input.pin {
  text-align: center;
  letter-spacing: 0.6em;
  font-size: 1.6rem;
}

input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

button {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: 12px 16px;
  touch-action: manipulation;
}

button.big {
  font-size: 1.15rem;
  padding: 16px;
}

button.primary {
  background: var(--accent);
  font-weight: 600;
}

button.danger {
  background: var(--danger);
}

button.link {
  background: none;
  color: var(--muted);
  text-decoration: underline;
}

button.chip {
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.divider {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #2c3542;
}

.notice {
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 12px 16px;
  text-align: center;
}

.error {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: var(--radius);
  color: #fca5a5;
  padding: 12px 16px;
  text-align: center;
}

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.12em;
}

#room-list-section h2 {
  font-size: 1rem;
  color: var(--muted);
  text-align: left;
  margin-bottom: 8px;
}

#room-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#room-list li {
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

#room-list .room-code {
  flex: 1;
}

#room-list button {
  font-size: 0.9rem;
  padding: 8px 12px;
}

/* ---------- Call view ---------- */

#view-call {
  position: fixed;
  inset: 0;
  background: #000;
}

#video-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Audio visualization, shown instead of video when the camera is off. */
#eq-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: radial-gradient(ellipse at 50% 50%, #171d29 0%, #0b0e14 70%);
}

#video-local {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 12px;
  width: 28vw;
  max-width: 140px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #111;
  z-index: 2;
}

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

.call-top {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
  right: calc(28vw + 24px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}

#call-status {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  font-size: 0.9rem;
  padding: 6px 14px;
  width: fit-content;
}

.call-room {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  font-size: 0.9rem;
  padding: 6px 14px;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pin-note {
  color: var(--muted);
}

#tap-to-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  font-size: 1.1rem;
  padding: 16px 24px;
  z-index: 3;
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  padding: 0 12px;
  z-index: 2;
}

/* Round icon buttons with a small label underneath. */
button.ctl {
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  min-width: 60px;
}

.ctl .icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}

.ctl svg {
  width: 24px;
  height: 24px;
}

.ctl .icon-off {
  display: none;
}

.ctl.off .icon-on {
  display: none;
}

.ctl.off .icon-off {
  display: block;
}

.ctl.off .icon-wrap {
  background: var(--danger);
}

.ctl.hangup .icon-wrap {
  background: var(--danger);
}

.ctl.danger .icon-wrap {
  background: rgba(220, 38, 38, 0.45);
}

.ctl:disabled {
  opacity: 0.4;
}

.ctl-label {
  font-size: 0.72rem;
  color: #cbd5e1;
}

/* Centered pills (mute reminder, call timer) just above the controls. */
.bottom-stack {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 106px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2;
  pointer-events: none;
}

/* "Your microphone is off" reminder. */
.muted-banner {
  background: rgba(220, 38, 38, 0.92);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.92rem;
  white-space: nowrap;
}

/* Big centered share action, shown while waiting for the other person. */
#share-cta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 24px;
  text-align: center;
  z-index: 1;
}

#share-cta .hint {
  line-height: 1.5;
}

#btn-share-big {
  display: flex;
  align-items: center;
  gap: 10px;
}

#btn-share-big svg {
  width: 20px;
  height: 20px;
}

/* Peer-state note (e.g. their mic is off) under the status pill. */
.mini-pill {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  font-size: 0.85rem;
  padding: 6px 14px;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fca5a5;
}

.mini-pill svg {
  width: 16px;
  height: 16px;
}

.mini-pill.timer {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
