:root {
  --bg: #fbf6f1;
  --ink: #3a2a2e;
  --muted: #9a8a8d;
  --rose: #d9667b;
  --rose-deep: #c24d64;
  --rose-soft: #f6dde1;
  --card: #fffdfb;
  --line: #eadfd8;
  --shadow: 0 10px 30px -12px rgba(120, 60, 70, 0.25);

  --font-love: "Caveat", "Segoe Print", cursive;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  /* faint graph paper, to match the drawings */
  background:
    linear-gradient(rgba(217, 102, 123, 0.06) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(217, 102, 123, 0.06) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

main {
  position: relative;
  height: 100%;
}

/* ---------- Screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  text-align: center;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.screen.is-active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

h1,
h2 {
  font-family: var(--font-love);
  font-weight: 700;
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  max-width: 16ch;
  line-height: 1.15;
}

h2 {
  font-size: clamp(2rem, 5.5vw, 3rem);
}

.hint {
  color: var(--muted);
  margin: 8px 0 32px;
  min-height: 1.5em;
  transition: color 0.3s;
}

/* ---------- Question screen ---------- */

.doodle {
  --tilt: -3deg;
  position: relative;
  margin: 0 0 28px;
  padding: 8px;
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt));
  animation: drop-in 0.8s var(--ease-spring) 0.1s backwards;
}

/* A strip of washi tape holding the drawing */
.doodle::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 84px;
  height: 24px;
  background: rgba(217, 102, 123, 0.35);
  transform: translateX(-50%) rotate(-4deg);
  border-radius: 2px;
}

.doodle img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
}

.doodle-ask {
  width: min(220px, 52vw);
  animation: drop-in 0.8s var(--ease-spring) 0.1s backwards,
    sway 5s ease-in-out 1s infinite;
}

.doodle-prizes {
  --tilt: 2deg;
  width: min(260px, 64vw);
  margin-bottom: 20px;
}

@keyframes drop-in {
  from { opacity: 0; transform: translateY(-24px) rotate(calc(var(--tilt) - 8deg)) scale(0.9); }
}

@keyframes sway {
  0%, 100% { transform: rotate(var(--tilt)); }
  50% { transform: rotate(calc(var(--tilt) + 4deg)); }
}

.buttons {
  display: flex;
  gap: 16px;
  margin-top: 40px;
  min-height: 56px;
  align-items: center;
}

.btn {
  --scale: 1;
  font: inherit;
  font-weight: 500;
  font-size: 1rem;
  padding: 14px 34px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transform: scale(var(--scale));
  transition: transform 0.35s var(--ease-spring), background 0.2s, box-shadow 0.2s;
}

.btn-yes {
  background: var(--rose);
  color: #fff;
  box-shadow: var(--shadow);
}

.btn-yes:hover {
  background: var(--rose-deep);
}

.btn-yes:focus-visible {
  outline: 2px solid var(--rose-deep);
  outline-offset: 3px;
}

.btn-no {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  white-space: nowrap;
}

.btn-no.is-loose {
  position: fixed;
  z-index: 10;
  transform-origin: top left;
  transition:
    left 0.4s var(--ease-out),
    top 0.4s var(--ease-out),
    transform 0.35s var(--ease-spring),
    opacity 0.3s;
}

.btn-no.is-gone {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Cards ---------- */

.cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  perspective: 1200px;
}

.card {
  --i: 0;
  width: 180px;
  height: 250px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  /* "backwards" so the animation releases transform/opacity once dealt */
  animation: deal 0.7s var(--ease-out) backwards;
  animation-delay: calc(0.15s + var(--i) * 0.12s);
  transition: transform 0.4s var(--ease-out), opacity 0.4s;
}

@keyframes deal {
  from { opacity: 0; transform: translateY(40px) rotate(-4deg); }
  to   { opacity: 1; transform: none; }
}

.cards:not(.has-pick) .card:hover {
  transform: translateY(-8px);
}

.card:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 6px;
  border-radius: 16px;
}

.card:disabled {
  cursor: default;
}

.cards.has-pick .card:not(.is-picked) {
  opacity: 0.55;
  transform: scale(0.94);
}

.cards.has-pick .card.is-picked {
  transform: translateY(-10px) scale(1.04);
}

.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s var(--ease-out);
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}

.card-back {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.25), transparent 60%),
    var(--rose);
  color: rgba(255, 255, 255, 0.9);
  font-size: 2.5rem;
  border: 6px solid var(--card);
}

.card-front {
  background: var(--card);
  border: 1px solid var(--line);
  transform: rotateY(180deg);
  padding: 20px;
}

.card.is-best .card-front {
  background: var(--rose-soft);
  border-color: transparent;
}

.prize {
  font-family: var(--font-love);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

/* ---------- "What else" button ---------- */

.btn-more {
  margin-top: 36px;
  background: var(--card);
  color: var(--rose-deep);
  border-color: var(--rose-soft);
  box-shadow: var(--shadow);
  animation: rise 0.6s var(--ease-out) backwards;
}

.btn-more:hover {
  background: var(--rose-soft);
}

.btn-more[hidden] {
  display: none;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
}

/* ---------- Locked popup ---------- */

.modal {
  width: min(380px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 60px -20px rgba(120, 60, 70, 0.4);
  text-align: center;
}

.modal[open] {
  animation: pop 0.45s var(--ease-spring);
}

.modal::backdrop {
  background: rgba(58, 42, 46, 0.35);
  backdrop-filter: blur(4px);
  animation: fade 0.3s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
}

@keyframes fade {
  from { opacity: 0; }
}

.modal-body {
  padding: 32px 24px 24px;
}

.lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--rose-soft);
  color: var(--rose-deep);
  margin-bottom: 16px;
}

.modal:not(.is-unlocked) .lock svg {
  animation: wiggle 2.4s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(-10deg); }
  88% { transform: rotate(8deg); }
  92% { transform: rotate(-5deg); }
}

h3 {
  font-family: var(--font-love);
  font-weight: 700;
  font-size: 2.1rem;
  margin: 0;
}

.modal-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 6px 0 20px;
}

.secret {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.secret li {
  font-family: var(--font-love);
  font-size: 1.4rem;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  filter: blur(7px);
  user-select: none;
  transition: filter 1s var(--ease-out);
}

.modal.is-unlocked .secret li {
  filter: none;
  user-select: auto;
}

.countdown {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}

.countdown div {
  min-width: 62px;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--rose-soft);
}

.countdown span {
  display: block;
  font-size: 1.5rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--rose-deep);
}

.countdown small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.modal.is-unlocked .countdown {
  display: none;
}

.btn-close {
  background: var(--rose);
  color: #fff;
}

.btn-close:hover {
  background: var(--rose-deep);
}

/* ---------- Heart burst ---------- */

.particle {
  position: fixed;
  z-index: 20;
  color: var(--rose);
  font-size: 14px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: burst 0.9s var(--ease-out) forwards;
}

@keyframes burst {
  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.6);
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 620px) {
  .cards {
    gap: 12px;
  }

  .card {
    width: 30vw;
    max-width: 150px;
    height: calc(30vw * 1.4);
    max-height: 210px;
  }

  .prize {
    font-size: 1.2rem;
  }

  .card-front {
    padding: 10px;
  }
}

/* Short screens (phones in landscape, small phones) */
@media (max-height: 700px) {
  .doodle-ask { width: min(150px, 40vw); margin-bottom: 18px; }
  .doodle-prizes { width: min(170px, 50vw); margin-bottom: 12px; }
  .hint { margin-bottom: 20px; }
  .btn-more { margin-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
