/* ── tokens ─────────────────────────────────────────────────────────────── */
:root {
  --pink: #ff3e7f;
  --violet: #7c3aed;
  --grad: linear-gradient(135deg, var(--pink), var(--violet));
  --bg: #14091f;
  --bg-2: #1d1029;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-line: rgba(255, 255, 255, 0.14);
  --text: #f4eefa;
  --muted: #b5a6c9;
  --danger: #ff4d4d;
  --ok: #3ddc97;
  --warn: #f3c33d;
  --radius: 16px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(124, 58, 237, 0.28), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(255, 62, 127, 0.18), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; }
h1, h2, h3, h4 { letter-spacing: -0.02em; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.muted { color: var(--muted); }
.link {
  background: none;
  border: none;
  color: var(--pink);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link.danger { color: var(--danger); }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.6rem;
  box-shadow: 0 6px 24px rgba(255, 62, 127, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; box-shadow: none; }
.btn-big { font-size: 1.15rem; padding: 1rem 2.4rem; }
.btn-sm { font-size: 0.92rem; padding: 0.5rem 1.1rem; }
.btn-ghost {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  color: var(--text);
  padding: 0.55rem 1.2rem;
}
.btn-ghost:hover { border-color: var(--pink); }
.btn-mini {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.2rem 0.7rem;
}
.btn-mini:hover:not(:disabled) { border-color: var(--pink); }
.btn-mini:disabled { opacity: 0.4; cursor: default; }

/* ── topbar ─────────────────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.1rem;
  padding-top: calc(0.7rem + env(safe-area-inset-top, 0px));
}
.brand {
  font-weight: 800;
  font-size: 1.2rem;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.top-right { display: flex; align-items: center; gap: 0.6rem; }
#ws-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
#ws-dot[data-s="online"] { background: var(--ok); }
#ws-dot[data-s="connecting"] { background: var(--warn); }
#ws-dot[data-s="offline"] { background: var(--danger); }
#btn-profile { font-size: 1.1rem; padding: 0.4rem 0.7rem; }
body[data-screen="landing"] #topbar .brand,
body[data-screen="landing"] #ws-dot,
body[data-screen="call"] #topbar { display: none; }

/* ── screens ────────────────────────────────────────────────────────────── */
main { min-height: calc(100dvh - 60px); }
.screen { display: none; }
body[data-screen="landing"] #screen-landing,
body[data-screen="setup"] #screen-setup,
body[data-screen="searching"] #screen-searching,
body[data-screen="rate"] #screen-rate {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.1rem;
  padding: 1.4rem 1.2rem 3rem;
  max-width: 560px;
  margin: 0 auto;
  animation: screen-in 0.32s ease both;
}
body[data-screen="call"] #screen-call { display: block; animation: screen-in 0.32s ease both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ── landing ────────────────────────────────────────────────────────────── */
.hero-brand {
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  margin: 1.6rem 0 0;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { color: var(--muted); font-size: 1.08rem; margin: 0; max-width: 38ch; }
.gender-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
  max-width: 440px;
  margin-top: 0.6rem;
}
.gender-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  background: var(--glass);
  border: 2px solid var(--glass-line);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.gender-card:hover { transform: translateY(-2px); }
.gender-card.selected {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 62, 127, 0.25), 0 8px 30px rgba(124, 58, 237, 0.3);
}
.gender-emoji { font-size: 2.6rem; }
.match-note { color: var(--muted); font-size: 0.9rem; margin: 0; }
.age-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.age-row input { width: 18px; height: 18px; accent-color: var(--pink); }

/* ── setup ──────────────────────────────────────────────────────────────── */
.preview-wrap { width: 100%; max-width: 440px; overflow: hidden; padding: 0; }
#setup-video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; }
.mirror { transform: scaleX(-1); }
.perm-help { padding: 1.1rem 1.3rem; max-width: 440px; }
.perm-help h3 { margin: 0 0 0.4rem; }
.perm-help p { color: var(--muted); margin: 0 0 0.8rem; }
.device-row {
  display: flex;
  gap: 0.8rem;
  width: 100%;
  max-width: 440px;
  flex-wrap: wrap;
}
.device-row label { flex: 1 1 180px; text-align: left; font-size: 0.85rem; color: var(--muted); }
.device-row select,
.lang-row select,
#report-modal select,
#report-modal textarea,
.modal-card input {
  width: 100%;
  margin-top: 0.25rem;
  background: var(--bg-2);
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  color: var(--text);
  padding: 0.6rem 0.7rem;
}
.modal-card input:focus, .device-row select:focus { outline: 2px solid var(--pink); border-color: transparent; }
.mirror-row { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.95rem; }
.mirror-row input { accent-color: var(--pink); }

/* ── searching ──────────────────────────────────────────────────────────── */
.radar { position: relative; width: 170px; height: 170px; margin-top: 2rem; }
.radar .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--pink);
  opacity: 0;
  animation: ring-pulse 2.4s ease-out infinite;
}
.radar .ring:nth-child(2) { animation-delay: 0.8s; border-color: var(--violet); }
.radar .ring:nth-child(3) { animation-delay: 1.6s; }
@keyframes ring-pulse {
  0% { transform: scale(0.35); opacity: 0.9; }
  100% { transform: scale(1.25); opacity: 0; }
}
.radar-heart {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  animation: heart-beat 1.2s ease-in-out infinite;
}
@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.18); }
  40% { transform: scale(0.96); }
  55% { transform: scale(1.1); }
}
.search-tip { color: var(--muted); min-height: 3em; max-width: 42ch; transition: opacity 0.3s; }

/* ── call screen ────────────────────────────────────────────────────────── */
#screen-call { position: fixed; inset: 0; z-index: 20; }
.stage { position: absolute; inset: 0; background: #000; overflow: hidden; }
#remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  transition: filter 0.6s ease;
}
#remote-video.blurred { filter: blur(26px); }
#local-pip {
  position: absolute;
  right: calc(0.9rem + env(safe-area-inset-right, 0px));
  bottom: calc(6.2rem + env(safe-area-inset-bottom, 0px));
  width: clamp(92px, 24vw, 200px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--glass-line);
  background: var(--bg-2);
  z-index: 6;
  cursor: grab;
  touch-action: none;
}
#local-pip:active { cursor: grabbing; }
#local-pip.cam-off { opacity: 0.25; }
#fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

#peer-bar {
  position: absolute;
  top: calc(0.8rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  z-index: 7;
  max-width: calc(100vw - 1.6rem);
  white-space: nowrap;
}
#peer-handle { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.hearts { color: var(--pink); letter-spacing: 0.08em; }
#q-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
#q-dot[data-q="green"] { background: var(--ok); }
#q-dot[data-q="yellow"] { background: var(--warn); }
#q-dot[data-q="red"] { background: var(--danger); }
#credits-ticker {
  font-size: 0.85rem;
  color: var(--muted);
  border-left: 1px solid var(--glass-line);
  padding-left: 0.7rem;
}
#credits-ticker.low { color: var(--danger); animation: pulse-red 1s ease-in-out infinite; }
@keyframes pulse-red {
  0%, 100% { opacity: 1; text-shadow: none; }
  50% { opacity: 0.55; text-shadow: 0 0 12px rgba(255, 77, 77, 0.8); }
}

#control-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  background: rgba(20, 9, 31, 0.55);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  z-index: 8;
  max-width: calc(100vw - 1rem);
  overflow-x: auto;
  scrollbar-width: none;
}
#control-bar::-webkit-scrollbar { display: none; }
.cbtn {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  font-size: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, border-color 0.2s, background 0.2s;
}
.cbtn:hover { transform: translateY(-2px); border-color: var(--pink); }
.cbtn[data-off="true"] { background: rgba(255, 77, 77, 0.25); border-color: var(--danger); filter: grayscale(0.6); }
.cbtn.primary { background: var(--grad); border-color: transparent; }
.cbtn.danger { background: rgba(255, 77, 77, 0.2); border-color: rgba(255, 77, 77, 0.45); }
.cbtn.active { background: var(--grad); border-color: transparent; }
.cbtn.done { opacity: 0.5; }
.cbtn:disabled { cursor: default; transform: none; }
.badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  min-width: 17px;
  height: 17px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* gift popover */
.popover {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(5.6rem + env(safe-area-inset-bottom, 0px));
  padding: 0.8rem;
  z-index: 9;
  animation: pop-in 0.18s ease both;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
#gift-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; }
.gift-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem 0.9rem;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  transition: border-color 0.15s, transform 0.12s;
}
.gift-item:hover:not(:disabled) { border-color: var(--pink); transform: translateY(-2px); }
.gift-item:disabled { opacity: 0.35; cursor: default; }
.gift-emoji { font-size: 1.7rem; }
.gift-cost { font-size: 0.75rem; color: var(--muted); }

/* chat drawer (internals are chat.js's; shell + slide animation live here) */
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 92vw);
  border-radius: 0;
  border-width: 0 0 0 1px;
  display: flex;
  flex-direction: column;
  z-index: 10;
  transform: translateX(105%);
  transition: transform 0.3s ease;
  background: rgba(20, 9, 31, 0.78);
}
.drawer.open { transform: translateX(0); }
@media (max-width: 640px) {
  .drawer {
    top: auto;
    left: 0;
    width: 100%;
    height: min(62dvh, 480px);
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
  }
  .drawer.open { transform: translateY(0); }
}

/* ── rate ───────────────────────────────────────────────────────────────── */
.rate-with { margin: 0; color: var(--muted); }
.rate-reason { margin: 0; color: var(--muted); font-size: 0.92rem; min-height: 1.4em; }
.rate-thumbs { display: flex; gap: 1.2rem; margin: 0.7rem 0; }
.thumb {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  font-size: 2.2rem;
  background: var(--glass);
  border: 2px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: transform 0.12s, border-color 0.2s;
}
.thumb:hover:not(:disabled) { transform: scale(1.08); border-color: var(--pink); }
.thumb.chosen { border-color: var(--pink); background: rgba(255, 62, 127, 0.2); }
.thumb:disabled { cursor: default; }
.rate-links { display: flex; gap: 1.6rem; }

/* ── profile drawer ─────────────────────────────────────────────────────── */
#profile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 92vw);
  z-index: 40;
  border-radius: 0;
  border-width: 0 0 0 1px;
  padding: 1.1rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  background: rgba(20, 9, 31, 0.88);
  animation: drawer-in 0.25s ease both;
}
@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
#profile-drawer header { display: flex; align-items: center; justify-content: space-between; }
#profile-drawer h3 { margin: 0; }
#profile-drawer h4 { margin: 1.2rem 0 0.5rem; color: var(--muted); }
.p-id { font-size: 1.1rem; }
.p-stats { margin: 0; display: grid; gap: 0.45rem; }
.p-stats div { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.p-stats dt { color: var(--muted); }
.p-stats dd { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
#register-cta { margin-top: 1rem; }
#register-cta .btn-primary { width: 100%; font-size: 0.95rem; }
#friends-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
#friends-list li { display: flex; align-items: center; gap: 0.55rem; }
.friends-empty { color: var(--muted); font-size: 0.88rem; }
.friend-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #4a3a5e; flex: 0 0 auto; }
.online-dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.lang-row { display: block; margin: 1.3rem 0 1rem; font-size: 0.9rem; color: var(--muted); }
#btn-logout { width: 100%; }

/* ── modals ─────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(8, 3, 14, 0.65);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal[hidden], .popover[hidden], #profile-drawer[hidden] { display: none; }
.modal-card {
  position: relative;
  width: min(420px, 100%);
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
  padding: 1.4rem 1.5rem;
  background: rgba(29, 16, 41, 0.92);
  animation: modal-in 0.22s ease both;
  text-align: left;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-card h3 { margin: 0 0 0.8rem; }
.modal-close { position: absolute; top: 0.7rem; right: 0.7rem; padding: 0.3rem 0.65rem; }
.modal-card form { display: grid; gap: 0.8rem; }
.modal-card label { font-size: 0.9rem; color: var(--muted); }
.form-err { color: var(--danger); font-size: 0.9rem; margin: 0; }
.check-row { display: flex; align-items: center; gap: 0.5rem; }
.check-row input { accent-color: var(--pink); }
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid var(--glass-line);
  color: var(--muted);
  padding: 0.5rem;
  font-weight: 600;
}
.tab.active { color: var(--text); border-image: var(--grad) 1; }
.demo-badge {
  display: inline-block;
  vertical-align: middle;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fff;
  background: var(--grad);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
}
#packages { display: grid; gap: 0.7rem; margin-top: 0.6rem; }
.package {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 12px;
}
.terms-list { margin: 0 0 1.1rem; padding-left: 1.2rem; color: var(--muted); }
.terms-list li { margin: 0.5rem 0; }

/* ── toasts ─────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  top: calc(0.9rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(420px, calc(100vw - 1.6rem));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: rgba(29, 16, 41, 0.92);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.95rem;
  pointer-events: auto;
  animation: toast-in 0.25s ease both;
  overflow-wrap: anywhere;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: none; }
}
.toast.out { opacity: 0; transform: translateY(-12px); transition: all 0.3s ease; }
.toast-action {
  flex: 0 0 auto;
  background: var(--grad);
  border: none;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
}

/* ── small screens ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .cbtn { width: 47px; height: 47px; font-size: 1.2rem; }
  #control-bar { gap: 0.4rem; }
  .gender-cards { grid-template-columns: 1fr; }
  #peer-bar { font-size: 0.85rem; gap: 0.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
