:root {
  --black: #090806;
  --black-soft: #15110c;
  --gold: #d4af37;
  --gold-light: #f5df9a;
  --champagne: #f6e7c1;
  --cream: #fffaf0;
  --danger: #ff6b6b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--black); }
body { font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--cream); touch-action: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; }

.app-shell { position: relative; width: 100%; height: 100dvh; min-height: 560px; overflow: hidden; isolation: isolate; background: radial-gradient(circle at top, #2b2113 0%, #0b0906 60%); }
.background-layer { position: absolute; inset: 0; z-index: -3; overflow: hidden; }
.background-layer img {
  opacity: .50;
  filter: brightness(.92);
  transition: opacity .18s ease, filter .18s ease;
}
.background-layer img.reaction-flash {
  opacity: .72;
  filter:
    brightness(1.08)
    saturate(1.0)
    contrast(1.02);
}
.background-shade { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(8,7,5,.35), rgba(8,7,5,.6) 58%, rgba(8,7,5,.9)); }

.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }

.start-screen, .win-screen { display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom)); }
.start-card, .win-card { width: min(92vw, 440px); text-align: center; padding: 30px 24px; border: 1px solid rgba(245,223,154,.28); border-radius: 28px; background: rgba(10,8,5,.78); backdrop-filter: blur(10px); box-shadow: 0 24px 80px rgba(0,0,0,.42); }
.age-badge { width: 82px; height: 82px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--gold-light); color: var(--gold-light); font-size: 36px; font-weight: 900; background: radial-gradient(circle, rgba(212,175,55,.26), rgba(212,175,55,.06)); }
.eyebrow { margin: 0 0 8px; color: var(--gold-light); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.05; }
h1 { font-size: clamp(36px, 9vw, 52px); }
h2 { font-size: clamp(30px, 8vw, 46px); color: var(--champagne); }
.subtitle { margin: 14px 0 8px; font-size: 20px; line-height: 1.35; }
.objective { margin: 8px 0 18px; color: rgba(255,250,240,.78); }
.rules { display: flex; justify-content: center; gap: 12px; margin-bottom: 22px; }
.rules span { padding: 9px 12px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); font-size: 14px; }
.rules strong { color: var(--gold-light); }
.primary-button { width: 100%; min-height: 54px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #f7e4a3, #c99620); color: #171006; font-weight: 900; font-size: 17px; box-shadow: 0 10px 28px rgba(212,175,55,.28); }
.primary-button:active { transform: scale(.985); }
.drag-tip { margin: 14px 0 0; color: rgba(255,250,240,.64); font-size: 13px; }

.game-screen { padding-top: var(--safe-top); }
.hud { position: absolute; top: calc(10px + var(--safe-top)); left: 14px; right: 14px; z-index: 20; padding: 12px 14px; border: 1px solid rgba(245,223,154,.24); border-radius: 18px; background: rgba(8,7,5,.72); backdrop-filter: blur(8px); }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hud-label { color: rgba(255,250,240,.65); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.score-text { margin-top: 2px; font-size: 22px; font-weight: 900; color: var(--champagne); }
.sound-button { border: 1px solid rgba(245,223,154,.3); background: rgba(255,255,255,.06); color: var(--cream); border-radius: 999px; padding: 8px 11px; font-size: 12px; font-weight: 800; }
.meter-track { height: 10px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.meter-fill { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b88518, #f7e4a3); transition: width .22s ease; }

.game-area { position: absolute; inset: 0; overflow: hidden; }
.falling-layer, .feedback-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.falling-layer { z-index: 8; }
.feedback-layer { z-index: 16; }

.falling-heart {
  position: absolute;
  top: -120px;
  width: clamp(62px, 17vw, 88px);
  aspect-ratio: 1 / 1;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .32));
}

.heart-frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(145deg, #f7e6aa, #b88117);

  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='black' d='M50 91C44 85 15 66 7 48C-2 28 9 8 29 8C40 8 47 15 50 22C53 15 60 8 71 8C91 8 102 28 93 48C85 66 56 85 50 91Z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;

  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='black' d='M50 91C44 85 15 66 7 48C-2 28 9 8 29 8C40 8 47 15 50 22C53 15 60 8 71 8C91 8 102 28 93 48C85 66 56 85 50 91Z'/%3E%3C/svg%3E");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.heart-frame::after {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, .62);

  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='none' stroke='black' stroke-width='5' d='M50 91C44 85 15 66 7 48C-2 28 9 8 29 8C40 8 47 15 50 22C53 15 60 8 71 8C91 8 102 28 93 48C85 66 56 85 50 91Z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;

  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='none' stroke='black' stroke-width='5' d='M50 91C44 85 15 66 7 48C-2 28 9 8 29 8C40 8 47 15 50 22C53 15 60 8 71 8C91 8 102 28 93 48C85 66 56 85 50 91Z'/%3E%3C/svg%3E");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.heart-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  transform: scale(1.08);
}
.falling-heart.wobble { animation: wobble .55s ease-in-out infinite alternate; }
@keyframes wobble { from { rotate: -6deg; } to { rotate: 6deg; } }

.catcher { position: absolute; z-index: 12; bottom: calc(-12vh + var(--safe-bottom)); left: 50%; width: clamp(190px, 52vw, 270px); transform: translateX(-50%); will-change: left; pointer-events: none; }
.catcher img { display: block; width: 100%; height: auto; filter: drop-shadow(0 12px 14px rgba(0,0,0,.4)); }
.catch-zone { position: absolute; z-index: 2; left: 12%; top: 0; width: 76%; height: 23%; border-radius: 0 0 48% 48%; }

.banner { position: absolute; z-index: 18; top: calc(118px + var(--safe-top)); left: 50%; transform: translate(-50%, -14px); opacity: 0; padding: 10px 16px; white-space: nowrap; border: 1px solid rgba(245,223,154,.45); border-radius: 999px; background: rgba(8,7,5,.82); color: var(--gold-light); font-weight: 900; transition: .2s ease; }
.banner.show { transform: translate(-50%, 0); opacity: 1; }
.float-text { position: absolute; transform: translate(-50%, -50%); font-weight: 1000; font-size: 26px; text-shadow: 0 4px 12px rgba(0,0,0,.6); animation: floatAway .8s ease forwards; }
.float-text.good { color: var(--gold-light); }
.float-text.bad { color: var(--danger); }
@keyframes floatAway { from { opacity: 1; translate: 0 0; scale: .8; } to { opacity: 0; translate: 0 -60px; scale: 1.2; } }
.spark { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--gold-light); animation: sparkle .58s ease-out forwards; }
@keyframes sparkle { to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.25); } }

.win-screen { z-index: 30; background: radial-gradient(circle at center, rgba(66,47,13,.54), rgba(5,4,3,.96)); }
#confettiCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.win-card {
  position: relative;
  z-index: 2;
  max-height: 94vh;
  overflow: auto;
}

.win-portrait {
  position: relative;
  width: min(68vw, 290px);
  margin: -8px auto 12px;
}

.win-portrait::before {
  content: "";
  position: absolute;
  inset: 10% 8% 4%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(212, 175, 55, .25),
    rgba(212, 175, 55, .08) 48%,
    transparent 72%
  );
  filter: blur(14px);
}

.win-image {
  position: relative;
  display: block;
  width: 100%;
  max-height: 39vh;
  object-fit: contain;
  margin: 0 auto;
  filter:
    drop-shadow(0 8px 12px rgba(0, 0, 0, .52))
    drop-shadow(0 0 14px rgba(212, 175, 55, .18));
}
.joke { margin: 14px 0 22px; color: var(--gold-light); font-size: 18px; font-style: italic; }

@media (max-height: 680px) {
  .hud { top: calc(6px + var(--safe-top)); }
  .catcher { width: clamp(170px, 46vw, 225px); bottom: calc(-15vh + var(--safe-bottom)); }
  .falling-heart { width: clamp(58px, 15vw, 76px); }
  .start-card, .win-card { padding: 22px 20px; }
}


/* Single changing faded reaction background */
.background-layer img {
  opacity: .50;
  filter: brightness(.92);
  transition: opacity .18s ease, filter .18s ease;
}

.background-layer img.reaction-flash {
  opacity: .72;
  filter:
    brightness(1.08)
    saturate(1.0)
    contrast(1.02);
}

@media (max-height: 720px) {
  .win-portrait {
    width: min(55vw, 235px);
    margin-bottom: 7px;
  }

  .win-image {
    max-height: 31vh;
  }

  .win-card {
    padding-top: 18px;
    padding-bottom: 18px;
  }
}

/* Restore centred reaction background sizing */
.background-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.background-layer img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  opacity: .50;
  filter: brightness(.98);
  transition: opacity .18s ease, filter .18s ease;
}

.background-layer img.reaction-flash {
  opacity: .72;
  filter:
    brightness(1.08)
    saturate(1)
    contrast(1.02);
}

