:root {
  color-scheme: dark;
  --bg: #000;
  --surface: rgba(30, 30, 32, .72);
  --surface-strong: rgba(28, 28, 30, .94);
  --surface-light: rgba(255,255,255,.11);
  --line: rgba(255,255,255,.12);
  --text: #fff;
  --muted: rgba(235,235,245,.62);
  --blue: #0a84ff;
  --green: #30d158;
  --red: #ff453a;
  --warning: #ffd60a;
  --ease: cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.app-shell { width: 100%; min-height: 100vh; min-height: 100dvh; }
.lobby {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(34px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 50% -10%, rgba(10,132,255,.13), transparent 38rem),
    #000;
}
.lobby-panel { width: min(410px, 100%); }
.brand-mark {
  width: 54px; height: 54px; display: grid; place-items: center;
  margin-bottom: 24px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.15), rgba(255,255,255,.045));
  border: 1px solid rgba(255,255,255,.11);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 16px 40px rgba(0,0,0,.4);
  font-size: 29px;
}
h1 { margin: 0; font-size: clamp(34px, 9vw, 48px); letter-spacing: -.045em; line-height: 1.02; }
.subtitle { margin: 9px 0 30px; color: var(--muted); font-size: 17px; letter-spacing: -.01em; }
.field-group { margin-top: 14px; }
.field-group label, .section-label { display: block; margin: 0 0 8px 3px; color: var(--muted); font-size: 13px; font-weight: 600; }
.field-group input, .custom-duration input {
  width: 100%; height: 54px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 16px;
  outline: none; background: rgba(255,255,255,.075); color: var(--text);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.field-group input:focus, .custom-duration input:focus {
  border-color: rgba(10,132,255,.8); background: rgba(255,255,255,.095);
  box-shadow: 0 0 0 4px rgba(10,132,255,.14);
}
.remember-row {
  display: flex; gap: 11px; align-items: flex-start; margin: 16px 2px 0;
  color: var(--text); cursor: pointer; user-select: none;
}
.remember-row input { appearance: none; width: 21px; height: 21px; flex: 0 0 auto; margin: 1px 0 0; border: 1px solid rgba(255,255,255,.25); border-radius: 7px; background: rgba(255,255,255,.06); }
.remember-row input:checked { background: var(--blue); border-color: var(--blue); }
.remember-row input:checked::after { content: "✓"; display: grid; place-items: center; height: 100%; color: #fff; font-size: 14px; font-weight: 800; }
.remember-row span { display: grid; gap: 2px; font-size: 14px; }
.remember-row small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.duration-section { margin-top: 27px; }
.duration-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.duration-chip {
  min-height: 45px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255,255,255,.065); cursor: pointer; font-weight: 650;
  transition: background .18s, border-color .18s, transform .12s;
}
.duration-chip:active { transform: scale(.97); }
.duration-chip.selected { background: rgba(10,132,255,.2); border-color: rgba(10,132,255,.7); color: #cfe7ff; }
.duration-chip small { display: block; color: var(--muted); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.custom-duration { margin-top: 9px; }
.lobby-actions { display: grid; gap: 10px; margin-top: 28px; }
.button { height: 52px; border: 0; border-radius: 16px; cursor: pointer; font-weight: 700; letter-spacing: -.01em; transition: transform .12s, filter .18s, opacity .18s; }
.button:active { transform: scale(.985); }
.button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--blue); color: #fff; }
.secondary { background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.06); }
.status { min-height: 20px; margin: 14px 3px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.status.error { color: #ff9f98; }
.text-button { display: block; margin: 12px auto 0; padding: 6px 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }

.call-screen { position: fixed; inset: 0; background: #050505; overflow: hidden; touch-action: manipulation; }
.remote-stage { position: absolute; inset: 0; display: grid; place-items: center; background: #070707; }
.remote-stage video {
  display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  object-fit: contain; object-position: center center; background: #070707;
}
.remote-stage::after { content: ""; pointer-events: none; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.28), transparent 23%, transparent 68%, rgba(0,0,0,.28)); opacity: .7; }
.waiting-state { position: relative; z-index: 2; display: grid; place-items: center; text-align: center; padding: 28px; }
.waiting-orb { width: 92px; height: 92px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.15), rgba(255,255,255,.035) 65%); border: 1px solid rgba(255,255,255,.08); box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: breathe 3s var(--ease) infinite; }
.waiting-orb span { font-size: 40px; opacity: .9; }
.waiting-state h2 { margin: 23px 0 5px; font-size: 25px; letter-spacing: -.03em; }
.waiting-state p { margin: 0; color: var(--muted); font-size: 14px; }
.ready-line { margin-top: 18px; display: flex; align-items: center; gap: 7px; color: rgba(235,235,245,.72); font-size: 12px; }
.ready-line i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px rgba(48,209,88,.55); }
@keyframes breathe { 50% { transform: scale(1.045); opacity: .75; } }

.local-stage {
  position: absolute; z-index: 5; top: max(88px, calc(env(safe-area-inset-top) + 68px)); right: 16px;
  width: clamp(104px, 25vw, 190px); aspect-ratio: 3/4;
  overflow: hidden; border-radius: 22px; border: 1px solid rgba(255,255,255,.22); background: #161616;
  box-shadow: 0 18px 55px rgba(0,0,0,.45); transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.local-stage video { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center center; background: #111; transform: scaleX(-1); }
.local-label { position: absolute; z-index: 2; left: 8px; bottom: 8px; padding: 4px 7px; border-radius: 999px; background: rgba(0,0,0,.52); backdrop-filter: blur(12px); font-size: 10px; font-weight: 650; }

/* Odada tek kisi varken kendi kamera goruntusu ana ekrani doldurur.
   Karsi tarafin videosu geldiginde JS bu sinifi kaldirir ve goruntu PiP'e doner. */
.local-stage.solo {
  inset: 0; top: 0; right: 0; bottom: 0; left: 0;
  width: 100%; max-width: none; height: 100%; aspect-ratio: auto;
  border: 0; border-radius: 0; box-shadow: none; z-index: 3;
}
.local-stage.solo .local-label { display: none; }
.local-stage.solo video { object-fit: contain; object-position: 50% 50%; background: #070707; }

.top-chrome {
  position: absolute; z-index: 10; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.room-status { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 8px 13px; border-radius: 18px; background: rgba(20,20,22,.48); backdrop-filter: blur(24px) saturate(1.3); border: 1px solid rgba(255,255,255,.08); }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 14px rgba(255,214,10,.35); }
.connection-dot.ok { background: var(--green); box-shadow: 0 0 14px rgba(48,209,88,.42); }
.connection-dot.bad { background: var(--red); box-shadow: 0 0 14px rgba(255,69,58,.42); }
.room-status div { display: grid; line-height: 1.15; }
.room-status strong { font-size: 13px; font-weight: 700; }
.room-status span:last-child { margin-top: 3px; color: var(--muted); font-size: 10px; }
.timer-pill { height: 48px; display: flex; align-items: center; gap: 7px; padding: 0 15px; border: 1px solid rgba(255,255,255,.08); border-radius: 18px; background: rgba(20,20,22,.48); backdrop-filter: blur(24px) saturate(1.3); cursor: pointer; font-variant-numeric: tabular-nums; font-weight: 700; }

.controls {
  position: absolute; z-index: 12; left: 50%; bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 11px; padding: 9px; border-radius: 30px;
  background: rgba(28,28,30,.58); border: 1px solid rgba(255,255,255,.09); backdrop-filter: blur(28px) saturate(1.3);
  box-shadow: 0 18px 55px rgba(0,0,0,.32); transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.round-control { width: 52px; height: 52px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); cursor: pointer; transition: transform .12s, background .2s, opacity .2s; }
.round-control:active { transform: scale(.92); }
.round-control.off { background: rgba(255,255,255,.92); color: #111; }
.round-control.hangup { background: var(--red); color: #fff; }
.round-control svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.call-screen.ui-hidden .call-ui { opacity: 0; pointer-events: none; }
.call-screen.ui-hidden .top-chrome { transform: translateY(-12px); }
.call-screen.ui-hidden .controls { transform: translate(-50%, 14px); }
.call-screen.ui-hidden .local-stage { opacity: .82; }

.reconnect-overlay { position: absolute; z-index: 8; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; background: rgba(0,0,0,.26); backdrop-filter: blur(15px); text-align: center; }
.reconnect-overlay strong { font-size: 21px; letter-spacing: -.02em; }
.reconnect-overlay span { color: var(--muted); font-size: 13px; }
.spinner { width: 30px; height: 30px; margin-bottom: 8px; border: 2px solid rgba(255,255,255,.22); border-top-color: #fff; border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.timer-popover {
  position: absolute; z-index: 14; top: max(72px, calc(env(safe-area-inset-top) + 60px)); right: 12px;
  width: min(320px, calc(100vw - 24px)); padding: 16px; border-radius: 22px;
  background: rgba(28,28,30,.88); border: 1px solid rgba(255,255,255,.11); backdrop-filter: blur(34px) saturate(1.35); box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.popover-handle { display: none; width: 36px; height: 4px; margin: -4px auto 14px; border-radius: 999px; background: rgba(255,255,255,.22); }
.timer-popover > strong { font-size: 14px; }
.timer-big { margin-top: 8px; font-size: 34px; font-weight: 750; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.timer-popover p { margin: 4px 0 18px; color: var(--muted); font-size: 12px; }
.mic-status { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 11px; border-radius: 13px; background: rgba(255,255,255,.055); color: var(--muted); font-size: 12px; }
.mic-status i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--warning); box-shadow: 0 0 12px rgba(255,214,10,.28); }
.mic-status[data-state="ok"] i { background: var(--green); box-shadow: 0 0 14px rgba(48,209,88,.52); }
.mic-status[data-state="off"] i { background: var(--red); box-shadow: 0 0 14px rgba(255,69,58,.35); }
.round-control.speaking { box-shadow: 0 0 0 4px rgba(48,209,88,.22), 0 0 24px rgba(48,209,88,.22); }
.end-night { width: 100%; height: 44px; border: 0; border-radius: 13px; background: rgba(255,69,58,.16); color: #ff9f98; cursor: pointer; font-weight: 700; }

.audio-unlock { position: absolute; z-index: 13; left: 50%; bottom: max(100px, calc(env(safe-area-inset-bottom) + 92px)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 9px 11px 9px 14px; border-radius: 18px; background: rgba(28,28,30,.82); backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,.1); font-size: 12px; }
.audio-unlock span { color: var(--muted); }
.audio-unlock button { border: 0; border-radius: 11px; background: var(--blue); padding: 8px 11px; font-weight: 700; cursor: pointer; }

.toast { position: absolute; z-index: 20; left: 50%; top: max(78px, calc(env(safe-area-inset-top) + 68px)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 30px); padding: 11px 15px; border-radius: 15px; background: rgba(36,36,38,.88); border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(26px); box-shadow: 0 18px 50px rgba(0,0,0,.32); font-size: 13px; text-align: center; }
#audioBucket { position: fixed; width: 1px; height: 1px; left: -9999px; overflow: hidden; }

@media (max-width: 600px) {
  .lobby { place-items: start center; padding-top: max(58px, calc(env(safe-area-inset-top) + 40px)); }
  .duration-grid { grid-template-columns: repeat(3, 1fr); }
  .local-stage { right: 10px; width: min(31vw, 132px); max-height: 32vh; border-radius: 17px; }
  .top-chrome { left: 8px; right: 8px; }
  .room-status { min-height: 44px; padding: 7px 10px; border-radius: 16px; }
  .timer-pill { height: 44px; border-radius: 16px; padding: 0 12px; }
  .controls { gap: 8px; padding: 8px; }
  .round-control { width: 48px; height: 48px; }
  .timer-popover { position: absolute; top: auto; right: 8px; left: 8px; bottom: max(92px, calc(env(safe-area-inset-bottom) + 82px)); width: auto; }
  .popover-handle { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
