@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg-deep: #10121c;
  --bg-card: #1a1d2e;
  --bg-card-2: #20243a;
  --border-subtle: #2b2f47;
  --text-primary: #eef0f7;
  --text-muted: #9aa0ba;
  --accent: #ff8659;
  --accent-dark: #e06a3f;
  --accent-soft: rgba(255, 134, 89, 0.14);
  --online: #4fd1a5;
  --danger: #ff5c72;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: radial-gradient(circle at 20% 0%, #191d31 0%, var(--bg-deep) 55%);
  color: var(--text-primary);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ================= AD SLOTS ================= */
.ad-slot {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    #191c2b,
    #191c2b 10px,
    #1d2033 10px,
    #1d2033 20px
  );
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.ad-bottom {
  border-top: 1px solid var(--border-subtle);
  border-bottom: none;
}

.ad-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ================= LAYOUT ================= */
.app-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.screen {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ================= HOME SCREEN ================= */
.home-screen {
  display: flex;
  justify-content: center;
}

.home-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-muted);
  margin: 4px 0 20px;
  font-size: 14.5px;
  line-height: 1.5;
}

.online-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(79, 209, 165, 0.1);
  border: 1px solid rgba(79, 209, 165, 0.3);
  color: var(--online);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 24px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 0 0 rgba(79, 209, 165, 0.6);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 209, 165, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(79, 209, 165, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 209, 165, 0); }
}

.filter-block {
  margin-bottom: 22px;
}

.filter-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 14px 0 8px;
}

.filter-label:first-child {
  margin-top: 0;
}

.chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  flex: 1;
  min-width: 80px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-2);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #17131a;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 10px 24px rgba(255, 134, 89, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(255, 134, 89, 0.32);
}

.btn-primary:active {
  transform: translateY(0);
}

.safety-note {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  background: rgba(255, 92, 114, 0.08);
  border: 1px solid rgba(255, 92, 114, 0.25);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

/* ================= SEARCH SCREEN ================= */
.search-screen {
  display: flex;
  justify-content: center;
}

.search-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  text-align: center;
}

.spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#searchStatusText {
  color: var(--text-primary);
  font-size: 15px;
  margin: 0 0 8px;
}

.timeout-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.timeout-box p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 14px;
}

.timeout-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-secondary {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 13.5px;
}

.btn-outline {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  font-size: 13.5px;
}

.btn-text {
  margin-top: 22px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

/* ================= CHAT SCREEN ================= */
.chat-screen {
  display: flex;
  justify-content: center;
}

.chat-container {
  width: 100%;
  max-width: 560px;
  height: 78vh;
  min-height: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card-2);
  flex-shrink: 0;
}

.chat-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
}

.status-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.status-dot {
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 50%;
  background: var(--online);
  flex-shrink: 0;
}

.status-dot.offline {
  background: var(--danger);
}

/* Compact top-bar buttons: Report / Skip / Stop */
.btn-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
  transition: filter 0.12s ease;
}

.btn-header:hover {
  filter: brightness(1.1);
}

.btn-icon {
  flex-shrink: 0;
  line-height: 1;
}

.btn-label {
  flex-shrink: 0;
}

.btn-report {
  background: rgba(255, 92, 114, 0.1);
  border: 1px solid rgba(255, 92, 114, 0.3);
  color: var(--danger);
}

.btn-skip {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-stop {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

/* Gender badge shown next to "Connected with a stranger" */
.gender-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 17px;
  padding: 0 5px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.gender-badge.badge-male {
  background: rgba(79, 157, 255, 0.16);
  border: 1px solid rgba(79, 157, 255, 0.45);
  color: #6fb2ff;
}

.gender-badge.badge-female {
  background: rgba(255, 111, 165, 0.16);
  border: 1px solid rgba(255, 111, 165, 0.45);
  color: #ff8fbb;
}

.safety-strip {
  font-size: 11.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 18px;
  margin: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.msg.me {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #17131a;
  border-bottom-right-radius: 4px;
}

.msg.stranger {
  align-self: flex-start;
  background: var(--bg-card-2);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
}

.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  text-align: center;
}

.typing-indicator {
  padding: 0 18px 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}

.message-form {
  display: flex;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card-2);
}

.message-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
}

.message-input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-send {
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #17131a;
  font-weight: 700;
  cursor: pointer;
  font-size: 13.5px;
}

.btn-send:disabled,
.message-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================= TOAST ================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 999;
  max-width: 90%;
  text-align: center;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 520px) {
  .app-wrapper {
    padding: 14px 10px;
  }

  .home-card, .search-card {
    padding: 24px 18px;
  }

  .chat-container {
    height: 86vh;
    border-radius: var(--radius-md);
  }

  .chat-header {
    padding: 6px 8px;
    gap: 4px;
  }

  .btn-header {
    height: 27px;
    padding: 0 8px;
    font-size: 11px;
  }

  .chat-status {
    font-size: 12.5px;
    gap: 4px;
  }

  .msg {
    max-width: 88%;
  }
}

/* Very narrow phones: shrink header buttons to icon-only so the center
   status text + gender badge always has enough room and never gets clipped */
@media (max-width: 400px) {
  .chat-header {
    padding: 6px 6px;
  }

  .btn-header {
    padding: 0 7px;
    min-width: 30px;
  }

  .btn-label {
    display: none;
  }

  .chat-status {
    font-size: 12px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pulse-dot, .spinner, .btn-primary {
    animation: none !important;
    transition: none !important;
  }
}
