:root {
  --pink: #ff4d8d;
  --pink-2: #ff2d6a;
  --purple: #8b5cff;
  --violet: #5b2bd6;
  --gold: #ffd166;
  --mint: #3dffb0;
  --coral: #ff6b5a;
  --ink: #1a0524;
  --ink-2: #3a1848;
  --cream: #fff7fb;
  --card: #fffaf6;
  --muted: #7a5a86;
  --shadow: 0 18px 40px rgba(26, 5, 36, 0.28);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Nunito", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, #5b1a6a 0%, transparent 50%),
    radial-gradient(900px 500px at 110% 10%, #ff4d8d55 0%, transparent 45%),
    linear-gradient(165deg, #14041c 0%, #2a0838 45%, #1a0524 100%);
  color: var(--ink);
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.device { width: 100%; height: 100%; display: grid; place-items: center; padding: 0; }

.phone {
  position: relative;
  width: 100%;
  height: 100%;
  background: #120317;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  isolation: isolate;
}

.phone-shine { display: none; }

@media (min-width: 480px) and (min-height: 780px) {
  .device { padding: 16px; }
  .phone {
    width: min(390px, 100%);
    height: min(844px, 100dvh - 32px);
    border-radius: 42px;
    border: 10px solid #0a020f;
    box-shadow:
      var(--shadow),
      0 0 0 1px #3a1848,
      inset 0 0 0 2px #2a102f;
  }
  .phone-shine {
    display: block;
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 120px; height: 18px;
    background: #0a020f;
    border-radius: 0 0 14px 14px;
    z-index: 20;
    pointer-events: none;
  }
}

.screen { position: absolute; inset: 0; }

/* ——— Splash ——— */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 28px calc(28px + var(--safe-b));
  color: #fff;
  background:
    radial-gradient(circle at 20% 20%, #ff4d8d55, transparent 40%),
    radial-gradient(circle at 85% 80%, #8b5cff66, transparent 42%),
    linear-gradient(180deg, #2a0838, #120317);
  z-index: 5;
  transition: opacity .45s ease, transform .45s ease;
}
.splash[hidden] { display: none; }
.splash.is-leaving { opacity: 0; transform: scale(1.04); pointer-events: none; }

.splash-orb {
  position: absolute; border-radius: 50%; filter: blur(40px); opacity: .7; pointer-events: none;
}
.splash-orb-a { width: 220px; height: 220px; background: #ff4d8d; top: -40px; left: -50px; animation: floaty 8s ease-in-out infinite; }
.splash-orb-b { width: 260px; height: 260px; background: #8b5cff; bottom: -60px; right: -70px; animation: floaty 10s ease-in-out infinite reverse; }
@keyframes floaty { 50% { transform: translate(16px, -18px) scale(1.08); } }

.splash-mark { position: relative; animation: popin .7s cubic-bezier(.2,1.4,.3,1) both; filter: drop-shadow(0 10px 20px #ff4d8d66); }
@keyframes popin { from { transform: scale(.4) rotate(-12deg); opacity: 0; } }

.brand {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 2.6rem;
  letter-spacing: -0.03em;
  margin-top: 14px;
  position: relative;
}
.brand span, .brand-mini span { color: var(--gold); }
.tagline {
  margin-top: 8px;
  font-weight: 800;
  font-size: 1.05rem;
  max-width: 16rem;
  line-height: 1.35;
  position: relative;
}
.tagline-sub {
  margin: 10px 0 28px;
  color: #f3d6ff;
  font-size: .92rem;
  max-width: 20rem;
  line-height: 1.45;
  position: relative;
}
.splash-legal { margin-top: 16px; font-size: .72rem; color: #c9a8d8; position: relative; }

/* ——— Buttons ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px; border-radius: 999px; font-weight: 800;
  transition: transform .15s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink) 0%, var(--purple) 100%);
  color: #fff;
  box-shadow: 0 10px 24px #ff4d8d55;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 2px solid #f0d4ea;
  margin-top: 8px;
}
.btn-xl { padding: 15px 26px; font-size: 1.05rem; position: relative; }
.btn-full { width: 100%; }

/* ——— App shell ——— */
.app {
  display: flex; flex-direction: column;
  background:
    linear-gradient(180deg, #3a0a4a 0%, #1a0524 28%, #1a0524 100%);
  color: #fff;
}
.app[hidden] { display: none; }

.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: calc(14px + var(--safe-t)) 18px 8px;
  flex: 0 0 auto;
}
.brand-mini {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
}
.mini-heart { color: var(--pink); margin-right: 2px; }
.stats { font-size: .75rem; color: #e9c8f5; font-weight: 700; }
.stats b { color: var(--gold); font-weight: 800; }
.dot { opacity: .5; margin: 0 4px; }

.pages { flex: 1; min-height: 0; position: relative; }
.page {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: 0 16px 8px;
}
.page[hidden] { display: none; }

/* ——— Deck ——— */
.deck-wrap {
  flex: 1; min-height: 0;
  position: relative;
  display: flex;
}
.deck {
  position: relative;
  flex: 1;
  max-height: 100%;
  touch-action: none;
  user-select: none;
}
.card {
  position: absolute; inset: 0;
  border-radius: 26px;
  background: var(--card);
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  will-change: transform;
  cursor: grab;
}
.card:active { cursor: grabbing; }
.card.is-front { z-index: 3; }
.card.is-mid { z-index: 2; transform: scale(.97) translateY(10px); }
.card.is-back { z-index: 1; transform: scale(.94) translateY(20px); opacity: .92; }
.card.is-leaving { pointer-events: none; transition: transform .45s ease, opacity .45s ease; }

.card-art {
  position: relative;
  height: 48%;
  min-height: 180px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-art svg { width: min(72%, 220px); height: auto; filter: drop-shadow(0 12px 16px rgba(0,0,0,.18)); }
.card-badge {
  position: absolute; top: 14px; left: 14px;
  background: rgba(26,5,36,.72);
  color: #fff;
  backdrop-filter: blur(8px);
  font-size: .7rem;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
}
.stamp {
  position: absolute; top: 22px; z-index: 4;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: .08em;
  padding: 4px 12px;
  border: 5px solid;
  border-radius: 12px;
  transform: rotate(-18deg);
  opacity: 0;
  pointer-events: none;
  text-transform: uppercase;
}
.stamp-like { left: 18px; color: var(--mint); border-color: var(--mint); }
.stamp-nope { right: 18px; color: var(--coral); border-color: var(--coral); transform: rotate(16deg); }

.card-body {
  flex: 1; min-height: 0;
  padding: 12px 16px 14px;
  overflow: auto;
  background: linear-gradient(180deg, #fffaf6 0%, #ffeef7 100%);
}
.card-name { font-family: "Fredoka", sans-serif; font-size: 1.45rem; font-weight: 650; line-height: 1.1; }
.card-name span { font-family: "Nunito", sans-serif; font-weight: 800; color: var(--muted); font-size: 1.15rem; }
.card-meta { color: var(--muted); font-weight: 700; font-size: .82rem; margin: 4px 0 8px; }
.card-bio { font-size: .92rem; line-height: 1.4; margin-bottom: 8px; }
.pickup {
  font-style: italic;
  background: #fff;
  border-left: 4px solid var(--pink);
  padding: 8px 10px;
  border-radius: 0 12px 12px 0;
  font-size: .88rem;
  margin: 8px 0;
  color: var(--ink-2);
}
.hobby-row, .flag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill {
  font-size: .72rem; font-weight: 800;
  padding: 4px 8px; border-radius: 999px;
  background: #f3e2ff; color: #5b2bd6;
}
.pill.flag { background: #ffe3ea; color: #c9184a; }
.section-label {
  font-size: .68rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-top: 8px;
}

.actions {
  display: flex; justify-content: center; align-items: center; gap: 18px;
  padding: 10px 0 4px;
  flex: 0 0 auto;
}
.fab {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 10px 22px rgba(0,0,0,.28);
  transition: transform .15s ease;
}
.fab:active { transform: scale(.92); }
.fab-nope { background: #fff; color: var(--coral); }
.fab-like { background: #fff; color: #ff2d6a; }
.fab-super { width: 50px; height: 50px; background: #fff; color: #4ea8de; }
.hint { text-align: center; font-size: .72rem; color: #d7b4e6; padding-bottom: 4px; }

.empty-deck {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: linear-gradient(180deg, #3a0a4a, #1a0524);
  border-radius: 26px;
}
.empty-deck[hidden] { display: none; }
.empty-emoji { font-size: 3.4rem; margin-bottom: 8px; }
.empty-deck h2 { font-family: "Fredoka", sans-serif; margin-bottom: 8px; }
.empty-deck p { color: #f3d6ff; margin-bottom: 18px; max-width: 20rem; }

/* ——— Lines & profile ——— */
.panel {
  flex: 1; min-height: 0; overflow: auto;
  background: var(--cream);
  color: var(--ink);
  border-radius: 24px 24px 16px 16px;
  padding: 20px 18px 18px;
  -webkit-overflow-scrolling: touch;
}
.kicker {
  font-size: .72rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--pink-2);
}
.panel h2 { font-family: "Fredoka", sans-serif; font-size: 1.55rem; margin: 4px 0 8px; }
.panel-lead { color: var(--muted); font-weight: 700; margin-bottom: 14px; }
.line-box {
  background: #fff;
  border: 2px solid #f3d4ea;
  border-radius: 18px;
  padding: 18px 16px;
  font-size: 1.12rem;
  line-height: 1.4;
  font-weight: 700;
  min-height: 8rem;
  display: flex; align-items: center;
  margin-bottom: 14px;
  box-shadow: 0 8px 0 #ffd6ea;
}
.copy-status { text-align: center; margin-top: 8px; font-weight: 800; color: #2b8a5a; font-size: .85rem; }

.you-hero { text-align: center; margin-bottom: 14px; }
.you-avatars { display: flex; justify-content: center; align-items: end; gap: 8px; margin-bottom: 8px; }
.you-avatars .av { width: 112px; height: 112px; }
.you-avatars .av-teddy { width: 84px; height: 84px; }
.you-avatars svg { width: 100%; height: 100%; display: block; }
.you-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff; font-weight: 800; font-size: .72rem;
  padding: 4px 10px; border-radius: 999px; margin-bottom: 6px;
}
.you-handle, .you-loc { color: var(--muted); font-weight: 700; font-size: .88rem; }
.bio-card, .teddy-card {
  background: #fff; border-radius: 16px; padding: 12px 14px; margin: 10px 0;
  border: 1px solid #f3d4ea;
}
.bio-card h3, .teddy-card h3, .flag-list dt {
  font-size: .78rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--pink-2); margin-bottom: 6px;
}
.bio-card p, .teddy-card p { font-size: .92rem; line-height: 1.45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span {
  background: #f3e2ff; color: #5b2bd6; font-weight: 800;
  font-size: .75rem; padding: 6px 10px; border-radius: 999px;
}
.flag-list { margin: 12px 0; }
.flag-list dd {
  background: #ffe3ea; color: #9b1b3a;
  font-weight: 700; font-size: .85rem;
  padding: 8px 10px; border-radius: 10px; margin: 6px 0;
}
.teddy-card { display: flex; gap: 10px; align-items: center; }
.teddy-pic { width: 72px; height: 72px; flex: 0 0 auto; }
.teddy-pic svg { width: 100%; height: 100%; display: block; }

/* ——— Tabs ——— */
.tabbar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px 10px calc(10px + var(--safe-b));
  background: #120317;
  border-top: 1px solid #3a1848;
  flex: 0 0 auto;
}
.tab {
  color: #c9a8d8; font-weight: 800; font-size: .75rem;
  padding: 6px 4px 4px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-ico { font-size: 1.15rem; line-height: 1; }
.tab.is-on { color: #fff; background: #2a0838; }

/* ——— Match overlay ——— */
.match-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 28px 22px;
  background: radial-gradient(circle at 50% 30%, #ff4d8d, #5b2bd6 55%, #120317 100%);
  color: #fff;
  animation: matchIn .35s ease;
}
.match-overlay[hidden] { display: none; }
.match-overlay.is-reject {
  background: radial-gradient(circle at 50% 40%, #4a1020, #120317 70%);
}
@keyframes matchIn { from { opacity: 0; transform: scale(1.06); } }

.match-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
  animation: fall 1.6s linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(240deg); opacity: .2; } }

.match-kicker {
  font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 6px; position: relative;
  font-size: .8rem;
}
.match-title {
  font-family: "Fredoka", sans-serif;
  font-size: 2.1rem; line-height: 1.1;
  max-width: 16ch; position: relative;
}
.match-faces {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 22px 0; position: relative;
}
.match-faces .av { width: 108px; height: 108px; }
.match-faces svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 8px 16px rgba(0,0,0,.3)); }
.match-heart {
  font-size: 2rem; animation: beat .8s ease-in-out infinite;
}
@keyframes beat { 50% { transform: scale(1.2); } }
.match-sub { position: relative; font-weight: 700; max-width: 22rem; margin-bottom: 22px; color: #ffe6f3; }
.match-overlay .btn { position: relative; }

.match-overlay.is-reject .match-kicker { color: #ff8fa3; }
.match-overlay.is-reject .match-heart { animation: none; filter: grayscale(1); opacity: .55; }
.match-overlay.is-glitch .match-title { animation: glitch .4s linear; }
@keyframes glitch {
  0%, 100% { transform: none; }
  25% { transform: translate(-3px, 1px); color: #3dffb0; }
  50% { transform: translate(3px, -2px); color: #ff4d8d; }
  75% { transform: translate(-2px, 2px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
