:root {
  --bg: #09090c;
  --card: #121218;
  --soft: #1b1b24;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f7;
  --muted: #a2a2b3;
  --accent: #7c5cff;
  --accent-2: #fe4f82;
  --danger: #ff6b6b;
  --ok: #48d2a0;
  --radius: 22px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: radial-gradient(circle at top, #151522 0%, var(--bg) 45%); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; min-height: 100%; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.brand {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.screen { display: flex; flex-direction: column; gap: 14px; }
.card, .hero-card, .duel-card, .chat-screen {
  background: rgba(18, 18, 24, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card, .card, .ended-card, .preview-card, .form-card, .duel-card, .chat-screen {
  padding: 18px;
}

.hero-card h1, .ended-card h2 { margin: 8px 0; font-size: 30px; line-height: 1.05; letter-spacing: -0.045em; }
.eyebrow { color: #cbbcff; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); }

.field-label { display: block; margin: 12px 0 8px; color: var(--muted); font-size: 14px; }
.input-file, .textarea, .chat-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  border-radius: 16px;
}

.input-file { padding: 14px; }
.textarea { min-height: 84px; padding: 14px; resize: vertical; }
.chat-input { padding: 14px 16px; }

.photo-preview, .preview-photo-wrap, .duel-photo-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(180deg, #1d1d28, #121218);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.photo-preview.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.photo-preview img, .preview-photo, .duel-photo { width: 100%; height: 100%; object-fit: cover; display: block; }

.legal-box {
  margin-top: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  border: 1px solid var(--line);
}
.checkbox-line { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.checkbox-line input { margin-top: 3px; }

.primary-button, .secondary-button, .ghost-button {
  border: 0;
  min-height: 52px;
  border-radius: 18px;
  font-weight: 700;
  transition: transform .15s ease, opacity .15s ease;
}
.primary-button:active, .secondary-button:active, .ghost-button:active { transform: scale(0.98); }
.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}
.secondary-button {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--line);
}
.ghost-button {
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  min-width: 40px;
}
.ghost-button.small { min-height: 36px; min-width: 36px; }
.ghost-button.danger { color: var(--danger); font-size: 26px; }
.wide { width: 100%; }
.large { min-height: 58px; font-size: 18px; }

.row { display: flex; gap: 10px; }
.two-buttons > * { flex: 1; }

.preview-caption, .duel-caption {
  margin-top: 12px;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 650;
}
.preview-meta, .duel-distance { margin-top: 8px; color: var(--muted); font-size: 14px; }

.radar-zone {
  min-height: calc(100dvh - 110px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.radar {
  position: relative;
  width: 240px;
  height: 240px;
  display: grid;
  place-items: center;
}
.pulse {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(124, 92, 255, 0.3);
  animation: pulse 2.6s ease-out infinite;
}
.pulse-a { width: 90px; height: 90px; }
.pulse-b { width: 150px; height: 150px; animation-delay: 0.4s; }
.pulse-c { width: 220px; height: 220px; animation-delay: 0.8s; }
.core {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  box-shadow: 0 0 36px rgba(124, 92, 255, 0.8);
}
@keyframes pulse {
  0% { transform: scale(0.92); opacity: 0.15; }
  60% { opacity: 0.55; }
  100% { transform: scale(1.06); opacity: 0.08; }
}
.searching-title { font-size: 26px; font-weight: 800; letter-spacing: -0.04em; text-align: center; }

.duel-card { display: flex; flex-direction: column; gap: 12px; }
.duel-topline { color: #e3dbff; font-weight: 700; }
.timer { font-size: 42px; font-weight: 900; letter-spacing: -0.05em; }
.duel-actions { margin-top: 8px; }

.chat-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 110px);
  gap: 12px;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-avatar { width: 50px; height: 50px; border-radius: 16px; object-fit: cover; }
.chat-title { font-size: 20px; font-weight: 800; letter-spacing: -0.04em; }
.chat-subtitle { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.chat-messages {
  flex: 1;
  min-height: 260px;
  max-height: 52dvh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
}
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble-row.theirs { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.35;
  word-break: break-word;
}
.bubble.mine { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; }
.bubble.theirs { background: rgba(255,255,255,0.07); color: var(--text); border: 1px solid var(--line); }
.quick-row {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 2px;
}
.quick-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
}
.chat-form { display: flex; gap: 10px; }
.send-button { min-width: 92px; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: #111118;
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  padding: 18px;
  z-index: 10;
  box-shadow: var(--shadow);
}
.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sheet-title { font-size: 24px; font-weight: 800; letter-spacing: -0.04em; }
.sheet-subtitle { color: var(--muted); font-size: 14px; margin-top: 2px; }
.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
#genderGroup.segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented button {
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
}
.segmented button.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.25), rgba(254, 79, 130, 0.25));
  border-color: rgba(124, 92, 255, 0.6);
}
.sheet-actions { margin-top: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,28,0.98);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 481px) {
  .app-shell { padding-top: 22px; }
}
