* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #dff8e6, #f4ffd9);
  color: #183527;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  width: 100%;
  position: relative;
}

.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  padding: 32px 20px;
  text-align: center;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.welcome-content {
  width: 100%;
  max-width: 620px;
  margin-bottom: 44px;
  padding: 0 8px;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(2.2rem, 9vw, 4.1rem);
  line-height: 1.05;
}

h2 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 8vw, 3rem);
}

p {
  margin: 0;
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  line-height: 1.5;
}

.subtitle {
  margin-bottom: 32px;
  opacity: 0.8;
}

.advance-btn {
  position: relative;
  min-width: 150px;
  max-width: calc(100vw - 48px);
  border: none;
  border-radius: 999px;
  padding: 16px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  background: #21a366;
  box-shadow: 0 10px 24px rgba(33, 163, 102, 0.35);
  cursor: pointer;
  transition:
    left 0.35s ease,
    top 0.35s ease,
    transform 0.2s ease,
    background 0.2s ease;
  touch-action: manipulation;
  z-index: 10;
  white-space: nowrap;
}

.advance-btn:active {
  transform: scale(0.96);
}

.advance-btn.is-moving {
  animation: wiggle 0.35s ease;
}

.advance-btn.is-changing-text {
  animation: button-pop 0.25s ease, wiggle 0.35s ease;
}

@keyframes button-pop {
  0% {
    scale: 0.95;
  }

  60% {
    scale: 1.06;
  }

  100% {
    scale: 1;
  }
}

@keyframes wiggle {
  0% {
    rotate: 0deg;
  }

  25% {
    rotate: -5deg;
  }

  50% {
    rotate: 5deg;
  }

  75% {
    rotate: -3deg;
  }

  100% {
    rotate: 0deg;
  }
}

.cards-container {
  width: 100%;
  max-width: 420px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.gift-card {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 190px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  perspective: 1000px;
  touch-action: manipulation;
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  transform-style: preserve-3d;
  transition: transform 0.7s ease;
}

.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  backface-visibility: hidden;
  overflow: hidden;
}

.card-back {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 35%),
    linear-gradient(145deg, #58d68d, #21a366);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 30px rgba(24, 83, 55, 0.25);
  border: 3px solid rgba(255, 255, 255, 0.7);
}

.card-back span {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #21a366;
  font-size: 2.2rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front {
  transform: rotateY(180deg);
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid rgba(33, 163, 102, 0.35);
  box-shadow: 0 14px 30px rgba(24, 83, 55, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
}

.card-front img {
  width: min(78%, 170px);
  height: auto;
  max-height: 120px;
  object-fit: contain;
}

.card-front strong {
  color: #14532d;
  font-size: 1.25rem;
}

.gift-card:active .card-inner {
  transform: scale(0.97);
}

.gift-card.is-fading {
  opacity: 0;
  transform: scale(0.85);
}

.gift-card.is-selected {
  position: relative;
  z-index: 5;
  animation: selected-card-grow 0.75s ease forwards;
}

.gift-card.is-selected .card-back {
  box-shadow: 0 24px 60px rgba(24, 83, 55, 0.35);
}

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

.gift-card.is-revealed {
  cursor: default;
}

@keyframes selected-card-grow {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.15) rotate(-2deg);
  }

  100% {
    transform: scale(2.5) rotate(0deg);
    opacity: 0;
  }
}

.riddle-card {
  width: min(100%, 520px);
  border-radius: 32px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 24px 70px rgba(24, 83, 55, 0.22);
  border: 3px solid rgba(255, 255, 255, 0.8);
  animation: riddle-appear 0.45s ease both;
}

.riddle-card-top {
  padding: 18px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 35%),
    linear-gradient(145deg, #58d68d, #21a366);
  color: white;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.riddle-content {
  padding: 28px 22px 30px;
}

.riddle-text {
  margin: 24px auto 28px;
  max-width: 430px;
  font-size: clamp(1.1rem, 4.5vw, 1.35rem);
  line-height: 1.65;
}

.answer-label {
  display: block;
  margin-bottom: 12px;
  font-weight: 800;
  font-size: 1.05rem;
}

.answer-row {
  width: 100%;
  display: flex;
  gap: 10px;
}

.answer-input {
  min-width: 0;
  flex: 1;
  border: 2px solid rgba(33, 163, 102, 0.25);
  border-radius: 999px;
  padding: 14px 16px;
  color: #183527;
  background: white;
  outline: none;
}

.answer-input:focus {
  border-color: #21a366;
  box-shadow: 0 0 0 4px rgba(33, 163, 102, 0.12);
}

.answer-input:disabled {
  opacity: 0.75;
}

.small-btn {
  border: none;
  border-radius: 999px;
  padding: 14px 18px;
  font-weight: 800;
  color: white;
  background: #21a366;
  box-shadow: 0 10px 22px rgba(33, 163, 102, 0.25);
  cursor: pointer;
  touch-action: manipulation;
}

.small-btn:active {
  transform: scale(0.96);
}

.small-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.riddle-result {
  min-height: 28px;
  margin-top: 18px;
  font-weight: 800;
  font-size: 1rem;
}

.riddle-result.success {
  color: #15803d;
}

.riddle-result.error {
  color: #b45309;
}

.confetti-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  top: -24px;
  border-radius: 3px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) translateX(0) rotate(0deg);
    opacity: 1;
  }

  50% {
    transform: translateY(50vh) translateX(36px) rotate(240deg);
    opacity: 1;
  }

  100% {
    transform: translateY(110vh) translateX(-36px) rotate(720deg);
    opacity: 0;
  }
}

@keyframes riddle-appear {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 600px) {
  .cards-container {
    grid-template-columns: repeat(3, 1fr);
    max-width: 760px;
  }

  .gift-card {
    max-height: none;
  }

  .card-front img {
    max-height: 180px;
  }
}

@media (max-width: 420px) {
  .answer-row {
    flex-direction: column;
  }

  .small-btn {
    width: 100%;
  }

  @keyframes selected-card-grow {
    0% {
      transform: scale(1);
    }

    45% {
      transform: scale(1.12) rotate(-2deg);
    }

    100% {
      transform: scale(2) rotate(0deg);
      opacity: 0;
    }
  }
}

.hand-card {
  width: min(100%, 560px);
}

.hand-intro {
  max-width: 430px;
  margin: 0 auto 20px;
  font-size: clamp(1rem, 4vw, 1.2rem);
}

.hand-image-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 22px;
  padding: 14px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 2px rgba(33, 163, 102, 0.12);
}

.hand-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
}

.finger-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.finger-grid label {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
}

.finger-grid label span {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  background: #21a366;
  box-shadow: 0 8px 18px rgba(33, 163, 102, 0.24);
}

.finger-input {
  width: 100%;
  min-width: 0;
  border: 2px solid rgba(33, 163, 102, 0.25);
  border-radius: 999px;
  padding: 13px 16px;
  color: #183527;
  background: white;
  outline: none;
}

.finger-input:focus {
  border-color: #21a366;
  box-shadow: 0 0 0 4px rgba(33, 163, 102, 0.12);
}

.finger-input.is-correct {
  border-color: #22c55e;
  background: #ecfdf5;
}

.finger-input.is-wrong {
  border-color: #f97316;
  background: #fff7ed;
}

.finger-input:disabled {
  opacity: 0.75;
}

.hand-check-btn {
  width: 100%;
  margin-top: 16px;
}

@media (min-width: 520px) {
  .finger-grid {
    grid-template-columns: 1fr 1fr;
  }

  .finger-grid label:last-child {
    grid-column: 1 / -1;
  }
}

.puzzle-card {
  width: min(100%, 560px);
}

.puzzle-grid {
  width: min(100%, 390px);
  aspect-ratio: 1 / 1;
  margin: 22px auto 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 24px;
  background: rgba(20, 83, 45, 0.18);
  box-shadow:
    0 18px 45px rgba(24, 83, 55, 0.2),
    inset 0 0 0 2px rgba(255, 255, 255, 0.7);
  touch-action: none;
}

.puzzle-piece {
  position: relative;
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.35);
  cursor: grab;
  box-shadow: 0 5px 12px rgba(24, 83, 55, 0.18);
  touch-action: none;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.puzzle-piece img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

.puzzle-piece.is-empty {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.42),
      rgba(255, 255, 255, 0.42) 8px,
      rgba(33, 163, 102, 0.12) 8px,
      rgba(33, 163, 102, 0.12) 16px
    );
  box-shadow: inset 0 0 0 2px rgba(33, 163, 102, 0.18);
}

.puzzle-piece.is-empty img {
  opacity: 0;
}

.puzzle-piece.is-dragging {
  opacity: 0.35;
  box-shadow: inset 0 0 0 2px rgba(33, 163, 102, 0.18);
  cursor: grabbing;
}

.puzzle-floating-piece {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(24, 83, 55, 0.38);
  transform: translate(-50%, -50%) scale(1.05);
}

.puzzle-floating-piece img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.puzzle-piece.just-swapped {
  animation: puzzle-swap-pop 0.24s ease;
}

.puzzle-piece:disabled {
  cursor: default;
}

.puzzle-help {
  max-width: 360px;
  margin: 0 auto;
  font-size: 0.95rem;
  opacity: 0.75;
}

@keyframes puzzle-swap-pop {
  0% {
    transform: scale(0.94);
  }

  60% {
    transform: scale(1.06);
  }

  100% {
    transform: scale(1);
  }
}

@media (max-width: 420px) {
  .puzzle-grid {
    width: min(100%, 330px);
    border-radius: 20px;
  }

  .puzzle-piece {
    border-radius: 10px;
  }

  .puzzle-floating-piece {
    border-radius: 10px;
  }
}
.closing-screen {
  padding: 32px 22px;
}

.closing-card {
  width: min(100%, 620px);
  padding: 42px 26px;
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.78);
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 24px 70px rgba(24, 83, 55, 0.22);
  animation: closing-appear 0.7s ease both;
}

.closing-text {
  max-width: 520px;
  margin: 0 auto;
  font-size: clamp(1.45rem, 6vw, 2.4rem);
  line-height: 1.35;
  font-weight: 800;
  color: #14532d;
}

@keyframes closing-appear {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}