body {
  background-attachment: fixed;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("assets/decor-hearts.png");
  background-size: 240px;
  opacity: 0.08;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 0;
}

body.quiz-locked #game,
body.quiz-locked footer,
body.quiz-locked #barny-float {
  display: none;
}

body.game-locked #game,
body.game-locked footer {
  display: none;
}

body.barny-dismissed #barny-float {
  display: none;
}

.section,
.card,
.footer-note,
#barny-float {
  position: relative;
  z-index: 1;
}

.hero {
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -30% -40% auto -40%;
  height: 70%;
  background: radial-gradient(60% 60% at 60% 40%, rgba(238, 142, 150, 0.3), transparent 70%);
  pointer-events: none;
}

.hero-card {
  display: grid;
  gap: var(--space-5);
}

.hero-decor {
  position: absolute;
  width: 120px;
  opacity: 0.18;
  filter: blur(0.2px);
}

.hero-decor.hearts {
  right: -10px;
  top: 20px;
  width: 140px;
}

.hero-decor.balloon {
  left: -20px;
  bottom: 30px;
  width: 120px;
}

.hero-decor.ring {
  right: 10px;
  bottom: -10px;
  width: 80px;
}

.love-counter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.counter-pill {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
  border: 1px solid rgba(224, 109, 119, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.counter-pill strong {
  display: block;
  font-size: 22px;
  font-family: var(--font-display);
}

.carousel {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 78%;
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-2);
}

.carousel::-webkit-scrollbar {
  height: 6px;
}

.carousel::-webkit-scrollbar-thumb {
  background: rgba(224, 109, 119, 0.4);
  border-radius: 999px;
}

.carousel-card {
  scroll-snap-align: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  background: #fff;
  border: 1px solid rgba(224, 109, 119, 0.18);
  display: flex;
  flex-direction: column;
}

.carousel-card img {
  height: 260px;
  width: 100%;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.9);
}

.carousel-card .caption {
  padding: var(--space-3);
  font-size: 13px;
  color: #6a3b45;
}

.quiz {
  display: grid;
  gap: var(--space-4);
}

.quiz-image {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  height: 260px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz-image img {
  height: 100%;
  width: 100%;
  object-fit: contain;
}

.quiz-options {
  display: grid;
  gap: var(--space-3);
}

.option-btn {
  background: #fff;
  border: 1px solid rgba(224, 109, 119, 0.3);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s var(--ease-bounce), border-color 0.15s;
}

.option-btn:hover {
  transform: translateY(-1px);
}

.option-btn.correct {
  border-color: #3d9f72;
  background: rgba(61, 159, 114, 0.12);
}

.option-btn.wrong {
  border-color: #d05b62;
  background: rgba(208, 91, 98, 0.12);
}

.quiz-message {
  min-height: 22px;
  color: #9f3f3c;
  font-weight: 600;
}

body.quiz-complete .quiz-message {
  display: none;
}

.quiz-title {
  text-align: center;
}

.quiz-progress {
  display: flex;
  gap: 8px;
  margin-bottom: var(--space-3);
}

.quiz-progress span {
  flex: 1;
  height: 6px;
  background: rgba(224, 109, 119, 0.2);
  border-radius: 999px;
}

.quiz-progress span.active {
  background: rgba(224, 109, 119, 0.7);
}

.promo {
  display: none;
  margin-top: var(--space-4);
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  border: 1px dashed rgba(224, 109, 119, 0.6);
  min-height: 220px;
  flex-direction: column;
  justify-content: center;
}

.promo-title {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 var(--space-2);
}

.promo .lead {
  margin: 0 0 var(--space-2);
}

.promo strong {
  font-family: var(--font-display);
  font-size: 20px;
  display: block;
  margin-top: var(--space-2);
}

#barny-float {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.4s var(--ease-slow), transform 0.4s var(--ease-slow);
  z-index: 5;
}

body.quiz-complete #barny-float {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.barny-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(224, 109, 119, 0.4);
  box-shadow: var(--shadow-soft);
  object-fit: cover;
}

.speech-bubble {
  max-width: 200px;
  background: #fff;
  border-radius: 16px 16px 16px 6px;
  padding: 10px 12px;
  font-size: 13px;
  color: #6a3b45;
  box-shadow: var(--shadow-soft);
  position: relative;
}

.promo strong {
  display: block;
  max-width: 100%;
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: -0.2px;
  font-family: var(--font-body);
  white-space: nowrap;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 10px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 3px;
}

.game-card {
  position: relative;
  display: grid;
  gap: var(--space-3);
  justify-items: center;
  text-align: center;
}

.game-wrapper {
  display: grid;
  gap: var(--space-3);
  justify-items: center;
  width: 100%;
}

.game-canvas {
  position: relative;
  display: block;
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
}

#flappy-canvas {
  display: block;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 250, 251, 0.6);
  border-radius: var(--radius-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-slow);
}

.game-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#flappy-canvas {
  background: #f8dfe1;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(224, 109, 119, 0.2);
}

.game-hud {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: #7c3a3a;
  justify-content: center;
}

.game-finish {
  position: absolute;
  inset: 16px;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(224, 109, 119, 0.45);
  background: rgba(255, 255, 255, 0.88);
  display: none;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-soft);
  z-index: 4;
  backdrop-filter: blur(4px);
}

body.game-complete .game-finish {
  display: flex;
}

.finish-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
}

.finish-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 66px;
}

.finish-bone {
  width: 66px;
  margin: 0;
  opacity: 0.8;
}

.finish-barny {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(224, 109, 119, 0.4);
  box-shadow: var(--shadow-soft);
  object-fit: cover;
}

.finish-bubble {
  max-width: 240px;
  font-size: 13px;
}

.finish-letter {
  margin-top: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.finish-letter .envelope {
  width: min(100%, 320px);
  height: 360px;
}

.letter {
  display: flex;
  justify-content: center;
  width: 100%;
}

.envelope {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: pointer;
  perspective: 1000px;
}

.envelope-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, #fff5f7, #ffdce5);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(224, 109, 119, 0.22);
  z-index: 1;
}

.envelope-paper {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 10%;
  bottom: 10%;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 14px 28px -20px rgba(81, 36, 45, 0.45);
  transform: translateY(0);
  transition: transform 0.8s var(--ease-slow), box-shadow 0.8s var(--ease-slow);
  z-index: 2;
  overflow: hidden;
}

.envelope-front {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(160deg, #f7b7be, #e06d77);
}

.envelope-front::before,
.envelope-front::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 50%;
  height: 60%;
  background: linear-gradient(145deg, #f8c2c8, #de6a74);
}

.envelope-front::before {
  left: 0;
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
}

.envelope-front::after {
  right: 0;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.envelope-flap {
  position: absolute;
  background: linear-gradient(160deg, #f6aeb7, #e06d77);
  transition: transform 0.8s var(--ease-slow);
  z-index: 6;
  opacity: 1;
}

.envelope-flap-top {
  left: 0;
  right: 0;
  top: 0;
  height: 52%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transform: rotateX(0deg);
}

.envelope-flap-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 52%;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  transform-origin: bottom;
  transform: rotateX(0deg);
}

.envelope-flap-left {
  left: 0;
  top: 0;
  bottom: 0;
  width: 52%;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transform-origin: left;
  transform: rotateY(0deg);
}

.envelope-flap-right {
  right: 0;
  top: 0;
  bottom: 0;
  width: 52%;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
  transform-origin: right;
  transform: rotateY(0deg);
}

.envelope .letter-content {
  width: 100%;
  height: 100%;
  padding: var(--space-4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: #4f2f35;
  text-align: left;
}

.envelope.open .envelope-flap-top {
  transform: rotateX(-160deg);
}

.envelope.open .envelope-flap-bottom {
  transform: rotateX(160deg);
}

.envelope.open .envelope-flap-left {
  transform: rotateY(160deg);
}

.envelope.open .envelope-flap-right {
  transform: rotateY(-160deg);
}

.envelope.open .envelope-paper {
  transform: translateY(0);
  box-shadow: 0 20px 36px -18px rgba(81, 36, 45, 0.5);
  z-index: 5;
}

.envelope.open .envelope-front {
  opacity: 0.2;
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: rgba(43, 28, 31, 0.5);
}

@media (min-width: 768px) {
  .love-counter {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .carousel {
    grid-auto-columns: 45%;
  }

  .quiz-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 440px) and (min-height: 900px) {
  .section {
    padding: 36px 18px;
  }

  .card {
    padding: 18px;
  }

  .promo {
    padding: 16px;
  }

  .title {
    font-size: clamp(26px, 7vw, 36px);
  }

  .subtitle {
    font-size: clamp(18px, 4.8vw, 26px);
  }

  .lead {
    font-size: 15px;
  }

  .hero-decor.hearts {
    width: 110px;
  }

  .hero-decor.balloon {
    width: 100px;
  }

  .hero-decor.ring {
    width: 70px;
  }

  .love-counter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .counter-pill strong {
    font-size: 18px;
  }

  .carousel {
    grid-auto-columns: 86%;
  }

  .carousel-card img {
    height: 220px;
  }

  .quiz-image img {
    height: 100%;
  }

  .quiz-image {
    height: 240px;
  }

  .quiz-options {
    gap: 10px;
  }

  .option-btn {
    padding: 12px 14px;
    font-size: 14px;
  }

  #flappy-canvas {
    border-radius: 18px;
  }
}
