:root {
  --pink: #f7b2c4;
  --pink-deep: #e8809b;
  --blue: #a9d3f0;
  --blue-deep: #6db0e0;
  --bg: #fff6f8;
  --card: #ffffff;
  --ink: #2c2230;
  --muted: #8a7d88;
  --like: #28c76f;
  --dislike: #ff5b6e;
  --shadow: 0 10px 30px rgba(80, 40, 60, 0.16);
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fff6f8 0%, #f1f7fd 100%);
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--dislike); font-weight: 600; }

/* ---------- LOGIN ---------- */
#login-view { align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-emoji { font-size: 56px; line-height: 1; }
.login-card h1 { margin: 12px 0 2px; font-size: 28px; }
.login-card p { margin: 0 0 22px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
input, select {
  font-size: 16px;
  padding: 14px 16px;
  border: 1.5px solid #ecdfe5;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus { border-color: var(--pink-deep); }
.btn-primary {
  margin-top: 6px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--pink-deep), var(--blue-deep));
  cursor: pointer;
}
.btn-primary:active { transform: scale(0.98); }

/* ---------- TOP BAR ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #f0e3e8;
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { flex: 0 0 auto; }
.hi { font-weight: 700; font-size: 14px; text-transform: capitalize; }
.tabs { flex: 1; display: flex; justify-content: center; gap: 6px; }
.tab {
  border: none; background: transparent; font-size: 15px; font-weight: 700;
  color: var(--muted); padding: 8px 12px; border-radius: 999px; cursor: pointer;
}
.tab.active { color: var(--ink); background: #ffe7ee; }
.badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 2px;
  font-size: 12px; color: #fff; background: var(--pink-deep); border-radius: 999px;
}
.icon-btn {
  border: none; background: transparent; font-size: 20px; color: var(--muted);
  cursor: pointer; padding: 6px;
}

.tab-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 12px 14px 18px; }

/* ---------- FILTERS ---------- */
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.seg { display: flex; background: #fff; border-radius: 12px; padding: 3px; box-shadow: var(--shadow); }
.seg-btn {
  border: none; background: transparent; padding: 8px 14px; border-radius: 10px;
  font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer;
}
.seg-btn.active { background: linear-gradient(135deg, var(--pink), var(--blue)); color: #3a2b35; }
.region-select { flex: 1; padding: 10px 12px; font-size: 14px; box-shadow: var(--shadow); border-color: transparent; }

/* ---------- DECK ---------- */
.deck {
  position: relative;
  flex: 1;
  min-height: 320px;
  margin: 4px 0 12px;
  display: flex; align-items: center; justify-content: center;
}
.card {
  position: absolute;
  width: min(86vw, 380px);
  height: min(56vh, 460px);
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  text-align: center;
  will-change: transform;
  touch-action: pan-y;
  user-select: none;
}
.card.boy  { background: linear-gradient(170deg, #ffffff 55%, #eaf4fd 100%); }
.card.girl { background: linear-gradient(170deg, #ffffff 55%, #ffeef4 100%); }
.card .gender-pill {
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px; margin-bottom: 14px;
}
.card.boy  .gender-pill { background: #e3f1fc; color: var(--blue-deep); }
.card.girl .gender-pill { background: #ffe4ec; color: var(--pink-deep); }
.card .name { font-size: clamp(34px, 11vw, 56px); font-weight: 800; line-height: 1.05; margin: 0; }
.card .regions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.region-tag {
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 10px;
  background: #f4eef1; color: #5d4f57;
}
.region-tag b { color: var(--ink); }

/* swipe choice stamps */
.stamp {
  position: absolute; top: 26px; font-size: 26px; font-weight: 900; letter-spacing: 0.05em;
  padding: 6px 14px; border-radius: 12px; border: 3px solid; opacity: 0; transform: rotate(-12deg);
  pointer-events: none;
}
.stamp.like { left: 22px; color: var(--like); border-color: var(--like); transform: rotate(-16deg); }
.stamp.nope { right: 22px; color: var(--dislike); border-color: var(--dislike); transform: rotate(16deg); }

.deck-empty { text-align: center; color: var(--muted); font-size: 17px; padding: 0 24px; }
.deck-empty .big { font-size: 46px; display: block; margin-bottom: 8px; }

/* ---------- ACTIONS ---------- */
.actions { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 4px 0; }
.round {
  width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); background: #fff; transition: transform 0.08s ease;
}
.round:active { transform: scale(0.9); }
.round.like { color: var(--like); font-size: 30px; }
.round.dislike { color: var(--dislike); }
.round.undo { width: 50px; height: 50px; font-size: 22px; color: var(--muted); }

.progress { text-align: center; font-size: 13px; margin: 8px 0 0; }

/* ---------- MATCHES ---------- */
#matches-tab h2 { margin: 6px 0 14px; font-size: 22px; text-align: center; }
.matches-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.match-item {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.match-item .m-name { font-size: 20px; font-weight: 800; }
.match-item .m-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.match-item .m-dot.boy { background: var(--blue-deep); }
.match-item .m-dot.girl { background: var(--pink-deep); }
.match-item .m-match { font-size: 15px; }
.match-item .m-regions { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, var(--pink-deep), var(--blue-deep));
  color: #fff; font-weight: 800; font-size: 16px;
  padding: 14px 22px; border-radius: 999px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
