:root {
  --primary: #7C3AED;
  --primary-light: #A78BFA;
  --primary-dark: #5B21B6;
  --accent: #F59E0B;
  --accent-light: #FCD34D;
  --green: #10B981;
  --red: #EF4444;
  --pink: #EC4899;
  --blue: #3B82F6;
  --bg: #0F0F1A;
  --bg-card: #1A1A2E;
  --bg-surface: #16162A;
  --text: #F1F1F6;
  --text-muted: #9CA3AF;
  --text-dim: #6B7280;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: -apple-system, 'SF Pro', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Screens --- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* --- Loading --- */
#screen-loading {
  align-items: center;
  justify-content: center;
}
.loading-logo { text-align: center; }
.logo-img { width: 80px; height: 80px; border-radius: 20px; }
.logo-large { width: 120px; height: 120px; border-radius: 28px; }
.loading-text { color: var(--text-muted); margin-top: 16px; font-size: 15px; }

/* --- Buttons --- */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { transform: scale(0.97); }
.btn-full { width: 100%; }
.btn-text {
  background: none; border: none; color: var(--text-muted);
  font-size: 15px; padding: 12px; cursor: pointer;
  display: block; margin: 0 auto;
}
.btn-back {
  background: rgba(255,255,255,0.1); border: none; color: var(--text);
  width: 36px; height: 36px; border-radius: 12px; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* --- Onboarding --- */
.onboard-step {
  padding: 24px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.onboard-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}
.onboard-hero h1 { font-size: 36px; font-weight: 800; }
.subtitle { color: var(--text-muted); font-size: 18px; line-height: 1.4; }

.onboard-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 32px;
}
.progress-bar {
  flex: 1; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px; transition: width 0.3s ease;
}
.step-count { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

.onboard-step h2 { font-size: 24px; margin-bottom: 20px; }
.hint { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

/* --- Forms --- */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; color: var(--text-muted);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group input, textarea {
  width: 100%; background: var(--bg-surface); border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm); padding: 14px 16px; color: var(--text);
  font-size: 16px; outline: none; transition: border-color 0.2s;
}
.form-group input:focus, textarea:focus {
  border-color: var(--primary-light);
}
textarea { resize: none; font-family: inherit; }
.city-input-wrap { display: flex; gap: 8px; }
.city-input-wrap input { flex: 1; }
.btn-geo {
  width: 48px; flex-shrink: 0; background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-sm);
  font-size: 20px; cursor: pointer; transition: background 0.2s;
}
.btn-geo:active { background: rgba(124,58,237,0.2); }
.btn-geo.detecting { animation: pulse 1s infinite; }
.geo-status { font-size: 12px; color: var(--green); margin-top: 4px; min-height: 16px; }
.char-count { text-align: right; font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* --- Choice buttons --- */
.choice-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.choice-btn {
  background: var(--bg-surface); border: 2px solid transparent;
  border-radius: var(--radius); padding: 20px; font-size: 16px;
  color: var(--text); cursor: pointer; transition: all 0.2s;
  text-align: center;
}
.choice-btn:active, .choice-btn.selected {
  border-color: var(--primary); background: rgba(124,58,237,0.15);
}
.choice-wide { grid-column: span 2; }

/* --- Question card --- */
.question-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 24px;
  margin-bottom: 24px; flex: 1;
}
.question-text {
  font-size: 22px; font-weight: 600; margin-bottom: 20px; line-height: 1.3;
}

/* --- Photo upload --- */
.photo-upload-area { display: flex; flex-direction: column; align-items: center; margin: 20px 0; cursor: pointer; }
.photo-cropper-area { display: flex; flex-direction: column; align-items: center; margin: 20px 0; }
.photo-select {
  width: 200px; height: 200px; border-radius: 50%; cursor: pointer;
  border: 3px dashed rgba(255,255,255,0.15); transition: border-color 0.2s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.photo-select:active { border-color: var(--primary); }
.photo-select span { font-size: 48px; margin-bottom: 8px; }
.photo-cropper { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crop-controls { width: 100%; max-width: 260px; text-align: center; margin-top: 8px; }
.crop-slider {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: rgba(255,255,255,0.15); border-radius: 2px; outline: none;
}
.crop-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: var(--primary); cursor: pointer;
}
.crop-hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* --- Voice recorder --- */
.voice-recorder { text-align: center; margin: 24px 0; }
.btn-record {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--pink));
  border: none; color: white; font-size: 32px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; flex-direction: column; gap: 4px;
  transition: transform 0.2s;
}
.btn-record.recording {
  animation: pulse 1s infinite;
  background: linear-gradient(135deg, #DC2626, var(--red));
}
#record-text { font-size: 10px; font-weight: 600; }
.record-timer { color: var(--text-muted); margin-top: 12px; font-variant-numeric: tabular-nums; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* --- Done animation --- */
.done-animation { font-size: 80px; animation: zap 0.6s ease-out; }
@keyframes zap {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.spinner {
  width: 32px; height: 32px; border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 16px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Main App --- */
.tab-content { display: none; flex: 1; padding: 16px 16px 80px; }
.tab-content.active { display: flex; flex-direction: column; }
.tab-title { font-size: 22px; margin-bottom: 16px; }

/* Discover */
.discover-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.discover-header h2 { font-size: 22px; }
.sparks-badge {
  background: linear-gradient(135deg, var(--accent), #D97706);
  padding: 6px 14px; border-radius: 20px; font-size: 14px; font-weight: 700;
}

/* Card stack */
.card-stack {
  flex: 1; position: relative; display: flex;
  align-items: center; justify-content: center;
}
.match-card {
  position: absolute; width: 100%; max-width: 360px;
  background: var(--bg-card); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s;
  cursor: grab; user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.match-card.swiping { transition: none; }
.match-card.gone { transition: transform 0.3s ease-out; pointer-events: none; }

.card-top { display: flex; justify-content: space-between; align-items: start; margin-bottom: 16px; }
.card-name { font-size: 24px; font-weight: 700; }
.card-age { font-size: 20px; font-weight: 400; color: var(--text-muted); margin-left: 8px; }
.card-city { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.compatibility-badge {
  background: linear-gradient(135deg, var(--green), #059669);
  padding: 6px 14px; border-radius: 16px; font-size: 16px; font-weight: 700;
  white-space: nowrap;
}
.compatibility-badge.low { background: linear-gradient(135deg, var(--accent), #D97706); }

.card-reasons { margin: 12px 0; }
.card-reason {
  display: inline-block; background: rgba(255,255,255,0.06);
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
  color: var(--text-muted); margin: 4px 4px 4px 0;
}

.card-answers { margin-top: 16px; }
.card-answer {
  background: var(--bg-surface); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 10px;
}
.card-answer-q { font-size: 12px; color: var(--primary-light); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px; }
.card-answer-a { font-size: 15px; line-height: 1.4; }

/* Swipe indicators */
.swipe-indicator {
  position: absolute; top: 20px; padding: 8px 16px;
  border-radius: 8px; font-size: 18px; font-weight: 800;
  opacity: 0; transition: opacity 0.1s; pointer-events: none;
  text-transform: uppercase;
}
.swipe-like { right: 20px; color: var(--green); border: 3px solid var(--green); }
.swipe-nope { left: 20px; color: var(--red); border: 3px solid var(--red); }

/* Action buttons */
.action-buttons {
  display: flex; justify-content: center; gap: 20px;
  padding: 16px 0;
}
.action-btn {
  width: 60px; height: 60px; border-radius: 50%;
  border: none; font-size: 24px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s;
}
.action-btn:active { transform: scale(0.9); }
.action-btn.skip { background: rgba(239,68,68,0.15); color: var(--red); }
.action-btn.like { background: rgba(16,185,129,0.15); color: var(--green); }
.action-btn.superlike { background: rgba(245,158,11,0.15); color: var(--accent); }

/* Spark of day */
.spark-of-day {
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(236,72,153,0.1));
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.spark-day-badge {
  font-size: 14px; font-weight: 700; color: var(--accent); margin-bottom: 8px;
}

/* --- Matches list --- */
.matches-list { overflow-y: auto; }
.match-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; background: var(--bg-card); border-radius: var(--radius-sm);
  margin-bottom: 8px; cursor: pointer; transition: background 0.2s;
}
.match-item:active { background: var(--bg-surface); }
.match-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0; overflow: hidden;
}
.match-avatar img { width: 100%; height: 100%; object-fit: cover; }
.match-info { flex: 1; min-width: 0; }
.match-name { font-weight: 600; font-size: 16px; }
.match-preview { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-compat { font-size: 13px; color: var(--green); font-weight: 600; }

/* --- Chat --- */
.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.chat-header .btn-back { margin-right: 4px; }
.chat-header-name { font-weight: 600; }
.chat-header-compat { font-size: 12px; color: var(--green); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 0;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-bubble {
  max-width: 80%; padding: 12px 16px; border-radius: 18px;
  font-size: 15px; line-height: 1.4; word-break: break-word;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: var(--bg-card);
  border-bottom-left-radius: 4px;
}
.chat-bubble.icebreaker {
  align-self: center; background: rgba(245,158,11,0.1);
  color: var(--accent); font-size: 13px; text-align: center;
  border-radius: var(--radius-sm); max-width: 90%;
}
.chat-time { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.chat-input-bar {
  display: flex; gap: 10px; padding: 12px 0;
  padding-bottom: calc(12px + var(--safe-bottom));
}
.chat-input-bar input {
  flex: 1; background: var(--bg-card); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px; padding: 12px 18px; color: var(--text);
  font-size: 15px; outline: none;
}
.btn-send {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); border: none; color: white;
  font-size: 20px; cursor: pointer;
}

/* --- Profile --- */
.profile-card { text-align: center; padding-top: 20px; display: flex; flex-direction: column; align-items: center; }
.profile-photo {
  width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; overflow: hidden;
}
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-edit-badge {
  position: absolute; bottom: 4px; right: 4px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center;
  justify-content: center; font-size: 14px;
  border: 2px solid var(--bg); z-index: 1;
}
.profile-cropper-wrap {
  margin: 16px 0; display: flex; flex-direction: column; align-items: center;
}
.profile-name { font-size: 24px; font-weight: 700; text-align: center; }
.profile-meta { color: var(--text-muted); font-size: 14px; margin-top: 4px; text-align: center; }
.profile-tier {
  display: inline-block; margin-top: 12px; padding: 6px 16px;
  border-radius: 20px; font-size: 13px; font-weight: 700;
  text-align: center; align-self: center;
}
.profile-tier.free { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.profile-tier.plus { background: rgba(124,58,237,0.2); color: var(--primary-light); }
.profile-tier.pro { background: rgba(245,158,11,0.2); color: var(--accent); }

.profile-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
  margin: 24px 0; text-align: center;
}
.stat-num { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.profile-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.profile-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: var(--bg-card); border-radius: var(--radius-sm);
  border: none; color: var(--text); font-size: 15px; cursor: pointer;
  text-align: left; width: 100%; transition: background 0.2s;
}
.profile-btn:active { background: var(--bg-surface); }
.profile-btn-icon { font-size: 20px; width: 28px; text-align: center; }
.profile-btn-danger { color: var(--red); }

/* --- Bottom nav --- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-surface); border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; padding: 8px 0;
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 100;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; padding: 4px;
  transition: color 0.2s;
}
.nav-btn small { font-size: 10px; }
.nav-btn.active { color: var(--primary-light); }

/* --- Popups --- */
.popup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 24px;
}
.match-popup-content {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 32px 24px; text-align: center; max-width: 320px; width: 100%;
}
.match-hearts { font-size: 48px; margin-bottom: 12px; }
.match-popup-content h2 { font-size: 28px; margin-bottom: 8px; }
.match-icebreaker {
  background: rgba(245,158,11,0.1); border-radius: var(--radius-sm);
  padding: 12px; margin: 16px 0; font-size: 14px; color: var(--accent);
}

/* --- Card gift button --- */
.card-bottom-row { display: flex; gap: 8px; margin-top: 12px; }
.card-gift-btn {
  flex: 1; padding: 10px;
  background: rgba(236,72,153,0.1); border: 1px solid rgba(236,72,153,0.2);
  border-radius: var(--radius-sm); color: var(--pink); font-size: 14px;
  cursor: pointer; transition: background 0.2s; text-align: center;
}
.card-gift-btn:active { background: rgba(236,72,153,0.2); }
.card-report-btn {
  width: 44px; flex-shrink: 0; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06); border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; cursor: pointer;
}
.card-report-btn:active { background: rgba(239,68,68,0.1); color: var(--red); }

/* --- Profile sections --- */
.profile-section-title {
  font-size: 14px; font-weight: 700; color: var(--text-muted);
  margin: 12px 0 8px; text-transform: uppercase; letter-spacing: 0.5px;
  text-align: left;
}
.sparks-info {
  background: var(--bg-card); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 16px; text-align: left;
}
.spark-use {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-muted); padding: 4px 0;
}
.spark-use span { font-size: 16px; width: 24px; text-align: center; }

/* --- Waitlist --- */
.waitlist-container {
  flex: 1; padding: 24px 20px 100px; text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.waitlist-container h1 { font-size: 24px; margin-bottom: 20px; }

.waitlist-position {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
  width: 100%; max-width: 280px;
}
.position-number { font-size: 48px; font-weight: 900; }
.position-city { font-size: 14px; color: rgba(255,255,255,0.7); margin-top: 4px; }

.waitlist-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: 100%; margin-bottom: 20px;
}
.wl-stat {
  background: var(--bg-card); border-radius: var(--radius-sm); padding: 14px 8px;
}
.wl-stat-num { font-size: 22px; font-weight: 700; }
.wl-stat-label { font-size: 10px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.3px; }

.wl-sparks-earned {
  background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(245,158,11,0.05));
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm); padding: 10px 16px; margin-bottom: 16px;
  font-size: 15px; font-weight: 700; color: var(--accent); width: 100%;
}

.waitlist-early-bird {
  background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px;
  font-size: 13px; color: var(--accent); width: 100%;
}

.waitlist-referral {
  background: var(--bg-card); border-radius: var(--radius); padding: 20px;
  width: 100%; margin-bottom: 16px; text-align: center;
}
.waitlist-referral h3 { font-size: 16px; margin-bottom: 6px; }

.referral-score {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; color: var(--text-muted); margin: 14px 0;
}
.referral-score strong { color: var(--accent); }

.btn-share-copy {
  display: block; width: 100%; background: none; border: none;
  color: var(--primary-light); font-size: 13px; padding: 10px;
  cursor: pointer; text-decoration: underline;
}

.share-buttons {
  display: flex; gap: 8px; margin-top: 10px; justify-content: center;
}
.share-btn {
  background: var(--bg-surface); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px; padding: 8px 16px; color: var(--text);
  font-size: 13px; cursor: pointer; transition: background 0.2s;
}
.share-btn:active { background: rgba(255,255,255,0.08); }

.waitlist-tease {
  background: rgba(124,58,237,0.1); border-radius: var(--radius-sm);
  padding: 12px; font-size: 14px; color: var(--primary-light); width: 100%;
}

/* --- Empty state --- */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state p:first-child { font-size: 18px; margin-bottom: 8px; }

/* --- Responsive --- */
@media (min-width: 420px) {
  .match-card { max-width: 380px; }
}
