/* ═════════════════════════════════════════════
   Bombeo Mini App — design system
   Colours come from Telegram theme vars so the app follows
   the user's light/dark setting automatically.
   ═════════════════════════════════════════════ */

:root {
  --bg: var(--tg-theme-bg-color, #0d0f14);
  --bg-soft: var(--tg-theme-secondary-bg-color, #161922);
  --bg-elev: rgba(255, 255, 255, 0.055);
  --text: var(--tg-theme-text-color, #f4f5f7);
  --hint: var(--tg-theme-hint-color, #8b90a0);
  --link: var(--tg-theme-link-color, #4ea8ff);
  --accent: var(--tg-theme-button-color, #ff4d6d);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --like: #2ee08a;
  --nope: #ff4d6d;
  --super: #ffc531;
  --radius: 24px;
  --radius-sm: 14px;
  --shadow-lg: 0 22px 48px rgba(0, 0, 0, 0.42);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.28);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Author `display` rules would otherwise beat the UA rule for [hidden],
   leaving empty states stacked on top of real content. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 8px;
  flex-shrink: 0;
  z-index: 3;
}

.brand { display: flex; align-items: center; gap: 8px; }

.brand-logo {
  font-size: 19px;
  line-height: 1;
  animation: bob 3.2s var(--ease-soft) infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-6deg); }
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  background: var(--bg-elev);
  padding: 5px 11px;
  border-radius: 999px;
  transition: opacity 0.2s ease;
}
.counter:empty { opacity: 0; }

/* ── Main ── */
#main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  padding: 2px 16px 0;
}

.view { display: none; }
.view.active {
  display: block;
  animation: viewIn 0.42s var(--ease) both;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#view-feed.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#view-matches.active,
#view-profile.active {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
  scrollbar-width: none;
}
#view-matches::-webkit-scrollbar,
#view-profile::-webkit-scrollbar { display: none; }

/* ── Deck ── */
.deck {
  position: relative;
  flex: 1;
  min-height: 0;
  perspective: 1200px;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow-lg);
  transform-origin: 50% 120%;
  will-change: transform, opacity;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.card.front {
  animation: cardIn 0.45s var(--ease) both;
  z-index: 2;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card.behind {
  z-index: 1;
  transform: translateY(12px) scale(0.94);
  opacity: 0.55;
  filter: saturate(0.7) brightness(0.75);
  pointer-events: none;
}

.card.photo {
  background-size: cover;
  background-position: center 22%;
}

.card.no-photo {
  background: radial-gradient(120% 90% at 30% 0%, #2a3040 0%, #12151d 62%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card .initial {
  font-size: 104px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.09);
  letter-spacing: -0.04em;
}

.card .scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(4, 6, 10, 0.92) 0%, rgba(4, 6, 10, 0.55) 30%, rgba(4, 6, 10, 0) 58%),
    linear-gradient(to bottom, rgba(4, 6, 10, 0.35) 0%, rgba(4, 6, 10, 0) 22%);
  pointer-events: none;
}

.card .info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px 20px 22px;
  color: #fff;
  pointer-events: none;
}

.card .name {
  font-size: 27px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}

.card .meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  white-space: nowrap;
}

.card .bio {
  margin-top: 11px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Swipe stamps */
.stamp {
  position: absolute;
  top: 26px;
  padding: 7px 14px;
  border: 3px solid;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.12s linear;
  pointer-events: none;
  z-index: 3;
}
.stamp-like { left: 22px; color: var(--like); border-color: var(--like); transform: rotate(-14deg); }
.stamp-nope { right: 22px; color: var(--nope); border-color: var(--nope); transform: rotate(14deg); }

/* Exit animations */
.card.gone-left { transition: transform 0.4s var(--ease), opacity 0.4s ease; transform: translateX(-135%) rotate(-18deg); opacity: 0; }
.card.gone-right { transition: transform 0.4s var(--ease), opacity 0.4s ease; transform: translateX(135%) rotate(18deg); opacity: 0; }
.card.gone-up { transition: transform 0.45s var(--ease), opacity 0.45s ease; transform: translateY(-125%) scale(0.9); opacity: 0; }

/* ── Action buttons ── */
.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px 0 calc(8px + var(--safe-bottom));
  flex-shrink: 0;
}

.act {
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-soft);
  box-shadow: var(--shadow-md);
  transition: transform 0.16s var(--ease), box-shadow 0.16s ease;
  position: relative;
  overflow: hidden;
}

.act svg {
  width: 46%;
  height: 46%;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.act::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  transform: scale(0.4);
  transition: transform 0.4s var(--ease), opacity 0.4s ease;
}
.act:active::after { opacity: 0.14; transform: scale(1); transition: none; }
.act:active { transform: scale(0.9); }
.act:disabled { opacity: 0.4; }

.act-dislike { width: 62px; height: 62px; color: var(--nope); }
.act-super { width: 52px; height: 52px; color: var(--super); }
.act-like { width: 62px; height: 62px; color: var(--like); }

/* ── States ── */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 44px 26px;
  color: var(--hint);
  animation: viewIn 0.45s var(--ease) both;
}

.state-icon {
  font-size: 52px;
  margin-bottom: 14px;
  animation: float 3.4s var(--ease-soft) infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

.state h2 { margin: 0 0 8px; font-size: 19px; font-weight: 700; color: var(--text); }
.state p { margin: 0 0 20px; font-size: 14px; line-height: 1.55; max-width: 300px; }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s var(--ease), opacity 0.15s;
}
.btn:active { transform: scale(0.96); opacity: 0.9; }

.btn-primary {
  background: linear-gradient(135deg, #ff5c7a 0%, #ff3d6e 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 61, 110, 0.34);
}

/* ── Page head ── */
.page-head { padding: 10px 2px 16px; }
.page-head h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.page-sub { margin: 5px 0 0; font-size: 13.5px; color: var(--hint); }

/* ── Matches list ── */
.matches { display: flex; flex-direction: column; gap: 10px; }

.match-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px;
  border-radius: 18px;
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.18s var(--ease), background 0.18s;
  animation: rowIn 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.match-row:active { transform: scale(0.975); background: var(--bg-elev); }

.match-avatar {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  object-fit: cover;
  background: var(--bg-elev);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 23px;
  font-weight: 700;
  color: var(--hint);
}

.match-info { flex: 1; min-width: 0; }
.match-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.match-sub {
  font-size: 13px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.match-cta {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  padding: 9px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff5c7a, #ff3d6e);
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(255, 61, 110, 0.3);
}

/* ── Profile ── */
.profile-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 262px;
  display: flex;
  align-items: flex-end;
  background: var(--bg-soft);
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
  animation: cardIn 0.5s var(--ease) both;
}

.profile-hero .hero-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
}

.profile-hero .hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(4, 6, 10, 0.95) 0%, rgba(4, 6, 10, 0.45) 42%, rgba(4, 6, 10, 0.08) 100%);
}

.profile-hero .hero-body {
  position: relative;
  padding: 20px;
  color: #fff;
  width: 100%;
}

.profile-name {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.profile-bio {
  margin: 7px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.88);
}

.hero-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.profile-card {
  background: var(--bg-soft);
  border-radius: 20px;
  padding: 6px 18px;
  margin-bottom: 12px;
  animation: viewIn 0.45s var(--ease) both;
  animation-delay: 60ms;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(140, 148, 165, 0.13);
}
.profile-row:last-child { border-bottom: 0; }
.profile-row span:first-child { color: var(--hint); flex-shrink: 0; }
.profile-row span:last-child { font-weight: 600; text-align: right; }

.profile-strip {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 2px 12px;
  scrollbar-width: none;
  margin-bottom: 4px;
}
.profile-strip::-webkit-scrollbar { display: none; }
.profile-strip img {
  width: 104px;
  height: 136px;
  object-fit: cover;
  border-radius: 16px;
  flex-shrink: 0;
  scroll-snap-align: start;
  box-shadow: var(--shadow-md);
  animation: cardIn 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

/* ── Bottom nav ── */
.tabbar {
  position: relative;
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  padding: 6px 10px calc(6px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid rgba(140, 148, 165, 0.14);
}

.nav-pill {
  position: absolute;
  top: 8px;
  bottom: calc(8px + var(--safe-bottom));
  left: 10px;
  width: calc((100% - 20px) / 3);
  border-radius: 16px;
  background: rgba(255, 77, 109, 0.14);
  transition: transform 0.38s var(--ease);
  pointer-events: none;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--hint);
  padding: 9px 4px;
  font-size: 10.5px;
  font-weight: 650;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.25s ease;
}

.tab svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: transform 0.32s var(--ease);
}

.tab.active { color: var(--accent); }
.tab.active svg { transform: translateY(-1px) scale(1.1); }

/* ── Match overlay ── */
.match-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(6, 8, 13, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 24px;
  animation: fadeIn 0.3s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.match-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  text-align: center;
  color: #fff;
  animation: popIn 0.55s var(--ease) both;
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.8) translateY(24px); }
  60% { opacity: 1; transform: scale(1.03) translateY(0); }
  100% { opacity: 1; transform: scale(1); }
}

.match-badge {
  font-size: 58px;
  line-height: 1;
  animation: heartBeat 1.1s var(--ease-soft) infinite;
  filter: drop-shadow(0 10px 26px rgba(255, 61, 110, 0.5));
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.16); }
  28% { transform: scale(1); }
  42% { transform: scale(1.1); }
  56% { transform: scale(1); }
}

.match-title {
  margin: 12px 0 6px;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffd0da, #ff6d92);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.match-sub { margin: 0 0 22px; font-size: 14px; color: rgba(255, 255, 255, 0.72); }

.match-photos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.match-photo {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  animation: popIn 0.6s var(--ease) both;
}
.match-photo:nth-child(1) { animation-delay: 80ms; }
.match-photo:nth-child(2) { animation-delay: 160ms; }

.match-card .btn { width: 100%; }

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: fall var(--dur, 2.4s) linear var(--delay, 0s) forwards;
}

@keyframes fall {
  0% { opacity: 0; transform: translateY(-20px) rotate(0deg); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translateY(105vh) rotate(540deg); }
}

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translate(-50%, -160%);
  background: rgba(18, 21, 29, 0.96);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 120;
  transition: transform 0.42s var(--ease);
  box-shadow: var(--shadow-md);
  max-width: 88vw;
  text-align: center;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }

/* ── Skeletons ── */
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--bg-soft) 28%, rgba(255, 255, 255, 0.07) 46%, var(--bg-soft) 64%);
  background-size: 220% 100%;
  animation: shimmer 1.25s linear infinite;
  height: 100%;
}

@keyframes shimmer {
  from { background-position: 180% 0; }
  to { background-position: -180% 0; }
}

.skeleton-row {
  height: 82px;
  border-radius: 18px;
  margin-bottom: 10px;
  background: linear-gradient(100deg, var(--bg-soft) 28%, rgba(255, 255, 255, 0.07) 46%, var(--bg-soft) 64%);
  background-size: 220% 100%;
  animation: shimmer 1.25s linear infinite;
}

/* ── Accessibility ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
