:root {
  --ink: #fff;
  --muted: rgba(255, 255, 255, 0.75);
  --accent: #ff5d8f;
  --yes: #2bd67b;
  --nope: #ff4d5e;
  --glass: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.28);
  --bg: #111;
  --display: "Fraunces", Georgia, serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
  --top: calc(84px + env(safe-area-inset-top));
  --bottom: calc(118px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* Blurred copy of the top card's photo fills the page behind the deck. */
.backdrop {
  position: fixed;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  object-fit: cover;
  filter: blur(30px) brightness(0.45) saturate(1.2);
  transition: opacity 0.4s;
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
}
.heading { flex: 1; min-width: 0; }
.eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar h1 {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.count { flex: none; font-size: 14px; color: var(--muted); }
.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 20px;
  display: grid;
  place-items: center;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- card stack ---------- */
.stack {
  position: fixed;
  top: var(--top);
  bottom: var(--bottom);
  left: 50%;
  width: min(100% - 24px, 520px);
  transform: translateX(-50%);
}

.card {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 24px;
  background: #222;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  touch-action: none;
  will-change: transform;
}
.card.top { cursor: grab; }
.card.top:active { cursor: grabbing; }
.card.under { transform: scale(0.94) translateY(14px); transition: transform 0.3s; }
.card.under2 { transform: scale(0.88) translateY(28px); opacity: 0.6; }
.card.enter { animation: deal 0.35s ease-out; }
@keyframes deal {
  from { transform: scale(0.94) translateY(14px); }
}

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
.shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 40%, transparent 65%);
}

.card-body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 20px 22px;
}
.card-emoji { font-size: 48px; line-height: 1; }
.card h2 {
  margin: 8px 0 4px;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(36px, 10vw, 56px);
  line-height: 1;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  overflow-wrap: anywhere;
}
.card .meta { margin: 0 0 12px; color: var(--muted); font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
}

/* YES / NOPE stamps that fade in while dragging */
.stamp {
  position: absolute;
  top: 28px;
  padding: 4px 14px;
  border: 5px solid;
  border-radius: 12px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 44px;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
}
.stamp.yes { left: 22px; color: var(--yes); transform: rotate(-14deg); }
.stamp.nope { right: 22px; color: var(--nope); transform: rotate(14deg); }

/* ---------- controls ---------- */
.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
}
.round {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 30px;
  line-height: 1;
  transition: transform 0.15s, background 0.15s;
}
.round.undo { width: 50px; height: 50px; font-size: 22px; color: #ffc94d; }
.round.nope { color: var(--nope); }
.round.yes { color: var(--yes); }
.round:active { transform: scale(0.88); }
.round:disabled { opacity: 0.3; pointer-events: none; }
@media (hover: hover) {
  .round.nope:hover { background: var(--nope); color: #fff; border-color: var(--nope); }
  .round.yes:hover { background: var(--yes); color: #fff; border-color: var(--yes); }
}

.hint {
  position: fixed;
  left: 50%;
  top: calc(var(--top) + 16px);
  z-index: 6;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.4s;
}
.hint.gone { opacity: 0; }

.credit {
  position: fixed;
  right: 12px;
  bottom: calc(6px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}

/* ---------- out of cards ---------- */
.empty {
  position: fixed;
  top: var(--top);
  bottom: var(--bottom);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}
.empty-emoji { font-size: 72px; }
.empty h2 { margin: 0; font-family: var(--display); font-size: 30px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 26px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 30px rgba(255, 93, 143, 0.45);
}
.btn.ghost { background: transparent; }
.btn:active { transform: scale(0.95); }

/* ---------- result ---------- */
.result {
  position: fixed;
  inset: 0;
  z-index: 20;
  animation: fade 0.5s ease-out;
}
@keyframes fade { from { opacity: 0; transform: scale(1.04); } }
.result .shade { background: rgba(0, 0, 0, 0.55); }
.result-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.result-emoji { font-size: 84px; animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
.result h2 {
  margin: 8px 0 4px;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(44px, 13vw, 96px);
  line-height: 1;
  overflow-wrap: anywhere;
}
.result-cat { margin: 0 0 28px; color: var(--muted); font-size: 17px; }
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 320px);
}
@keyframes pop {
  from { transform: scale(0.2); opacity: 0; }
}

.confetti {
  position: fixed;
  top: -40px;
  z-index: 21;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); }
}

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