
/* ===== GENERAL ===== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  background: white;
  color: #222;
  font-family: Arial, sans-serif;
  text-align: center;
}

.container {
  width: 100%;
  max-width: 650px;
  margin: 30px auto;
}

.page {
  width: 100%;
  padding: 20px 10px;
}

.hidden {
  display: none !important;
}

h1 {
  font-size: 28px;
  line-height: 1.3;
}

h2 {
  font-size: 22px;
}

p {
  line-height: 1.7;
}

/* ===== BUTTONS ===== */
button {
  padding: 12px 20px;
  margin: 8px 4px;
  background: white;
  color: #222;
  border: 1px solid #222;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #f2f2f2;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== WELCOME ===== */
.main-picture {
  display: block;
  width: 100%;
  max-width: 300px;
  max-height: 300px;
  object-fit: contain;
  margin: 15px auto;
}

/* ===== QUIZ ===== */
.answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 450px;
  margin: 20px auto;
}

.answers button {
  width: 100%;
  margin: 0;
}

.answers button.selected {
  background: #e8e8e8;
  border: 2px solid #222;
}

#feedback {
  min-height: 28px;
}

/* ===== GIFT SELECTION ===== */
.gift-container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 25px 0;
}

.gift-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 30%;
  max-width: 150px;
  min-width: 95px;
  padding: 8px;
}

.gift-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
}

.gift-button span {
  font-size: 14px;
}

#gift-reveal {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
}

#revealed-picture {
  display: block;
  width: 100%;
  max-width: 350px;
  max-height: 450px;
  object-fit: contain;
  margin: 15px auto;
}

#letter-section {
  margin: 30px 0;
  padding: 15px 5px;
}

#letter-section hr {
  border: 0;
  border-top: 1px dashed #aaa;
  margin-bottom: 25px;
}

.ending-message {
  margin-top: 35px;
  font-size: 14px;
}

/* ===== WRONG ANSWER SCREEN ===== */
.wrong-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: wrongShake 0.25s ease-in-out 2;
}

.wrong-content {
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.wrong-content h1 {
  color: red;
  font-size: clamp(32px, 9vw, 60px);
  font-weight: 900;
  text-shadow: 0 0 15px darkred;
}

.wrong-content p {
  font-size: clamp(18px, 5vw, 25px);
  font-weight: bold;
}

.wrong-face {
  font-size: clamp(80px, 25vw, 150px);
  margin: 20px 0;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ===== LETTER POPUP ===== */
.letter-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.85);
}

.letter-window {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px 18px;
  background: white;
  color: #222;
  border: 4px solid #222;
  box-shadow: 8px 8px 0 #555;
  animation: popupAppear 0.25s ease-out;
}

.close-letter {
  position: sticky;
  float: right;
  top: 0;
  margin: -18px -8px 0 0;
  padding: 6px 10px;
  background: white;
  border: 2px solid #222;
  font-weight: bold;
}

@keyframes popupAppear {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== PIXEL ENVELOPE ===== */
.pixel-envelope {
  position: relative;
  display: block;
  width: 144px;
  height: 100px;
  margin: 40px auto;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: #e8a6b5;
  box-shadow:
    0 -6px #222,
    0 6px #222,
    6px 0 #222,
    -6px 0 #222;
  image-rendering: pixelated;
}

.pixel-envelope:hover {
  background: #f0b9c5;
}

/* Paper inside the envelope */
.pixel-paper {
  position: absolute;
  top: 10px;
  left: 48px;
  width: 48px;
  height: 65px;
  background: #fffaf0;
  border: 3px solid #222;
  z-index: 1;
}

.pixel-heart {
  display: block;
  margin-top: 12px;
  color: #d84f73;
  font-size: 24px;
}

/* Envelope flap */
.pixel-flap {
  position: absolute;
  inset: 0;
  width: 0;
  height: 0;
  border-left: 72px solid transparent;
  border-right: 72px solid transparent;
  border-top: 48px solid #c97891;
  z-index: 3;
}

/* Envelope front folds */
.pixel-front {
  position: absolute;
  inset: 0;
  background: #e8a6b5;
  clip-path: polygon(
    0 45%,
    50% 85%,
    100% 45%,
    100% 100%,
    0 100%
  );
  z-index: 4;
}

.pixel-envelope:active {
  transform: translateY(3px);
}

/* ===== PERSONAL LETTER ===== */
.personal-letter {
  margin-top: 25px;
  padding: 18px;
  background: #fffaf0;
  border: 3px dashed #d49aaa;
  text-align: left;
  animation: letterAppear 0.4s ease;
}

.personal-letter h2 {
  text-align: center;
}

.personal-letter p {
  line-height: 1.8;
}

.signature {
  text-align: right;
  font-weight: bold;
}

@keyframes letterAppear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MOBILE ===== */
@media (max-width: 400px) {
  body {
    padding: 12px;
  }

  .container {
    margin-top: 10px;
  }

  h1 {
    font-size: 24px;
  }

  .page {
    padding: 15px 4px;
  }

  .gift-button {
    min-width: 85px;
  }

  .letter-window {
    padding: 25px 12px;
  }

  .personal-letter {
    padding: 12px;
  }
}


/* PIXEL-ART INTRO */
.intro-screen {
  font-family: "Courier New", monospace;
}

.pixel-label,
.pixel-footer {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: bold;
}

.pixel-frame {
  max-width: 420px;
  margin: 20px auto;
  padding: 8px;
  background: #222;
  box-shadow: 6px 6px 0 #aaa;
}

.pixel-sky {
  height: 220px;
  position: relative;
  overflow: hidden;
  background: #17172f;
  image-rendering: pixelated;
}

.pixel-moon {
  position: absolute;
  width: 45px;
  height: 45px;
  top: 25px;
  right: 50px;
  background: #fff2c7;
  box-shadow: 0 0 20px #fff2c755;
}

.pixel-star {
  position: absolute;
  color: white;
  animation: pixelTwinkle 1s steps(2, end) infinite;
}

.star-one { top: 25px; left: 45px; }
.star-two { top: 70px; left: 120px; }
.star-three { top: 45px; right: 130px; }

.pixel-cat {
  position: absolute;
  z-index: 2;
  bottom: 35px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 65px;
  image-rendering: pixelated;
  filter: grayscale(1);
}

.pixel-ground {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 35px;
  background: repeating-linear-gradient(
    90deg,
    #48506b 0px,
    #48506b 20px,
    #343a55 20px,
    #343a55 40px
  );
  border-top: 5px solid #69718a;
}

.pixel-title {
  font-family: "Courier New", monospace;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 #ccc;
}

.pixel-subtitle {
  font-size: 12px;
  letter-spacing: 1px;
}

.intro-description {
  margin-top: 25px;
}

.start-game {
  margin: 18px auto;
  padding: 14px 24px;
  border: 3px solid #222;
  border-radius: 0;
  font-family: "Courier New", monospace;
  font-weight: bold;
  animation: startBlink 1s steps(2, end) infinite;
}

.start-game:hover {
  background: #222;
  color: white;
}

@keyframes startBlink {
  50% { opacity: 0.45; }
}

@keyframes pixelTwinkle {
  50% { opacity: 0.2; }
}

#birthday-message {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 3px dashed #222;
  animation: introReveal 0.5s steps(5, end);
}

@keyframes introReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}


/* REUSABLE FADE-UP ANIMATION */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pixelPop {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  75% {
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Animate each new page */
.page:not(.hidden) {
  animation: fadeUp 0.5s ease-out both;
}

/* Birthday intro */
.intro-screen > * {
  animation: fadeUp 0.55s ease-out both;
}

.intro-screen > *:nth-child(1) { animation-delay: 0.05s; }
.intro-screen > *:nth-child(2) { animation-delay: 0.15s; }
.intro-screen > *:nth-child(3) { animation-delay: 0.25s; }
.intro-screen > *:nth-child(4) { animation-delay: 0.35s; }
.intro-screen > *:nth-child(5) { animation-delay: 0.45s; }

/* Question heading and answers */
#question-number,
#question,
#feedback {
  animation: fadeUp 0.4s ease-out both;
}

#answers button {
  animation: fadeUp 0.4s ease-out both;
}

#answers button:nth-child(1) { animation-delay: 0.05s; }
#answers button:nth-child(2) { animation-delay: 0.12s; }
#answers button:nth-child(3) { animation-delay: 0.19s; }
#answers button:nth-child(4) { animation-delay: 0.26s; }

/* Buttons pop slightly when clicked */
button:active:not(:disabled) {
  transform: scale(0.96);
}

/* Gift cards */
.gift-button {
  animation: pixelPop 0.45s ease-out both;
}

.gift-button:nth-child(2) { animation-delay: 0.1s; }
.gift-button:nth-child(3) { animation-delay: 0.2s; }

/* Gift reveal */
#gift-reveal:not(.hidden) {
  animation: fadeUp 0.55s ease-out both;
}

/* Letter popup and message */
.letter-window {
  animation: pixelPop 0.35s ease-out both;
}

.personal-letter:not(.hidden) {
  animation: fadeUp 0.5s ease-out both;
}

/* Keep animations comfortable for users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* ===== QUIZ QUESTION BACKGROUNDS ===== */
#quiz {
  min-height: 75vh;
  padding: 30px 20px;
  border-radius: 12px;

  background-color: #f5f5f5;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  transition: background-image 0.4s ease;
}

/* Keep quiz answers readable over the pictures */
#quiz h2,
#quiz p {
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.5);
}

#quiz .answers button {
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
}

#quiz .answers button:hover:not(:disabled) {
  background-color: white;
}

#quiz #next-button {
  background-color: white;
}