/* Princess Luna's Elsa Game — kit assets, iPad-first */

:root {
  --ice: #6ec4f0;
  --ice-deep: #3a8fc4;
  --lavender: #c4a8e8;
  --lavender-deep: #8b6bc4;
  --gold: #ffe27a;
  --snow: #fffaf5;
  --ink: #2a3a6a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

button,
input {
  font-family: inherit;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Nunito", "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
  background: #5bb8e8;
  touch-action: manipulation;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

/* ---- Backgrounds ---- */

.sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
}

.bg-forest {
  display: none;
}

.ground-glow {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.45));
}

.snow {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -40px;
  width: 22px;
  height: 22px;
  background: url("../assets/ui/snowflake.svg") center / contain no-repeat;
  opacity: 0.85;
  animation: fall linear infinite;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.8));
}

.snowflake.party {
  width: 32px;
  height: 32px;
  animation-duration: 2.2s !important;
}

.snowflake.heart {
  background: none;
  display: grid;
  place-items: center;
}

.snowflake.heart::after {
  content: "💕";
  font-size: 0.9em;
  line-height: 1;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(180deg) translateX(24px);
    opacity: 0.2;
  }
}

/* ---- Parent voice (long-press, hidden from little fingers) ---- */

.parent-zone {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 60;
  width: 72px;
  height: 72px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: default;
}

.parent-toast {
  position: absolute;
  top: max(16px, var(--safe-top));
  right: max(16px, var(--safe-right));
  z-index: 61;
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(40, 60, 100, 0.25);
}

.parent-toast[hidden] {
  display: none;
}

.said {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---- Family love strip (always visible) ---- */

.love-strip {
  position: absolute;
  top: max(14px, calc(var(--safe-top) + 8px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(80, 50, 120, 0.28);
  max-width: min(calc(100vw - 28px), 420px);
  box-sizing: border-box;
}

.love-frame {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--lavender-deep);
  font-weight: 800;
  flex-shrink: 0;
}

.love-frame:active {
  transform: scale(0.96);
}

.love-frame img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  object-position: center 28%;
  border-radius: 50%;
  border: 3px solid #f5a0c8;
  box-shadow: 0 2px 8px rgba(180, 60, 120, 0.3);
  display: block;
}

.love-frame span {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--lavender-deep);
  line-height: 1;
}

.love-msg {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: clamp(0.8rem, 2.4vw, 1rem);
  font-weight: 800;
  color: #c45080;
  text-align: center;
  line-height: 1.1;
}

.love-msg span {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.screen[hidden] {
  display: none !important;
}

/* ---- Start — Luna is the hero ---- */

.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* flex-start (not center): tall cards no longer clip the hero photo above the viewport */
  justify-content: flex-start;
  padding: 20px;
  padding-top: max(132px, calc(var(--safe-top) + 118px));
  padding-bottom: max(28px, calc(var(--safe-bottom) + 16px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.start-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 32px;
  padding: 20px 24px 28px;
  box-shadow: 0 16px 48px rgba(50, 70, 140, 0.35);
  max-width: 440px;
  width: 100%;
  text-align: center;
  margin-top: 4px;
  margin-bottom: 12px;
}

.start-hero {
  position: relative;
  width: min(42vw, 200px);
  margin-top: 16px;
  margin-bottom: 4px;
  overflow: visible;
  flex-shrink: 0;
  /* room for floaty bounce so the face never leaves the card */
  padding-top: 10px;
}

.start-luna {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: center 22%;
  border-radius: 50%;
  border: 5px solid #fff;
  box-shadow:
    0 0 0 4px #f5a0c8,
    0 12px 28px rgba(80, 60, 140, 0.4);
  animation: floaty 3s ease-in-out infinite;
  display: block;
}

.start-crown {
  position: absolute;
  top: -4px;
  right: 8%;
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  animation: twinkle 1.6s ease-in-out infinite;
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.start-title {
  margin: 4px 0 0;
  font-size: clamp(1.35rem, 4.2vw, 1.9rem);
  font-weight: 800;
  color: var(--lavender-deep);
  line-height: 1.15;
  text-shadow: 0 1px 0 #fff;
}

.start-sub {
  margin: 0;
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  font-weight: 700;
  color: var(--ice-deep);
}

.start-love {
  margin: 2px 0 0;
  font-size: clamp(0.95rem, 2.8vw, 1.1rem);
  font-weight: 700;
  color: #c45080;
}

.start-hint {
  margin: 4px 0 0;
  font-size: 1.1rem;
  color: #5a6a9a;
}

.play-btn {
  margin-top: 10px;
  min-width: 220px;
  min-height: 96px;
  padding: 16px 44px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #d4b8f8 0%, #8b6bc4 55%, #6a4aa8 100%);
  color: #fff;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow:
    0 8px 0 #4a3080,
    0 14px 28px rgba(80, 50, 140, 0.4);
  cursor: pointer;
}

.play-btn:active {
  transform: translateY(5px);
  box-shadow:
    0 3px 0 #4a3080,
    0 6px 12px rgba(80, 50, 140, 0.35);
}

.start-family {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 6px;
}

.family-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: transparent;
  color: #c45080;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.family-btn img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  object-position: center 18%;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow:
    0 0 0 3px #f5a0c8,
    0 6px 14px rgba(160, 50, 100, 0.3);
}

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

.start-photos {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.luna-pick {
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: 18px;
  border: 3px solid #fff;
  overflow: hidden;
  background: #ffe8f4;
  box-shadow: 0 4px 12px rgba(80, 40, 100, 0.25);
  cursor: pointer;
}

.luna-pick img,
.love-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.luna-pick:active,
.love-mini:active {
  transform: scale(0.96);
}

.parent-hint {
  margin: 8px 0 0;
  max-width: 28rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #7d8aaf;
}

/* ---- Game layout (portrait) ---- */

.game-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px;
  padding-top: max(86px, calc(var(--safe-top) + 74px));
  padding-bottom: max(10px, var(--safe-bottom));
}

.guide {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 110px;
}

.luna-btn {
  position: relative;
  flex-shrink: 0;
  width: 108px;
  height: 128px;
  padding: 4px;
  border: 3px solid #fff;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffe8f4, #f5a0c8);
  box-shadow: 0 4px 16px rgba(180, 60, 120, 0.35);
  cursor: pointer;
  overflow: hidden;
  animation: guidePulse 2s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.luna-img {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: cover;
  object-position: center 12%;
  border-radius: 16px;
  display: block;
}

.luna-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(120, 40, 80, 0.5);
  line-height: 1.4;
}

.luna-sparkle {
  position: absolute;
  inset: 0;
  background: url("../assets/ui/star-burst.svg") 88% 8% / 26px no-repeat;
  opacity: 0.85;
  pointer-events: none;
  animation: twinkle 1.4s ease-in-out infinite;
}

@keyframes guidePulse {
  0%,
  100% {
    box-shadow: 0 4px 16px rgba(80, 60, 140, 0.35);
  }
  50% {
    box-shadow:
      0 0 0 6px rgba(255, 226, 122, 0.45),
      0 6px 20px rgba(80, 60, 140, 0.4);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

.bubble {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 100px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 24px;
  border: 2px solid rgba(200, 180, 255, 0.6);
  box-shadow: 0 6px 20px rgba(50, 70, 140, 0.25);
  position: relative;
}

.bubble::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 36px;
  border: 10px solid transparent;
  border-right-color: rgba(255, 255, 255, 0.94);
}

.bubble-pic {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #e8f6ff, #d8e8ff);
  border-radius: 18px;
  border: 2px solid #9cc4e8;
  overflow: hidden;
}

.bubble-pic img {
  max-width: 68px;
  max-height: 68px;
  object-fit: contain;
}

.bubble-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble-text {
  margin: 0;
  font-size: clamp(1.05rem, 3.4vw, 1.4rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.bubble-face {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.love-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.love-row[hidden] {
  display: none !important;
}

.love-mini {
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 16px;
  border: 3px solid #fff;
  overflow: hidden;
  background: #ffe8f4;
  box-shadow: 0 4px 10px rgba(80, 40, 100, 0.25);
  cursor: pointer;
}

/* ---- Stage / snowman ---- */

.stage {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
  padding-bottom: 4px;
}

.reindeer-btn {
  position: absolute;
  left: max(4%, 8px);
  bottom: 4%;
  width: min(28vw, 170px);
  padding: 0;
  border: none;
  background: transparent;
  z-index: 3;
  cursor: pointer;
  animation: hopIn 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.reindeer-btn[hidden] {
  display: none !important;
}

.reindeer {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 6px 10px rgba(40, 40, 60, 0.35));
  pointer-events: none;
}

@keyframes hopIn {
  from {
    opacity: 0;
    transform: translateX(-40px) scale(0.6);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.snowman-btn {
  position: relative;
  width: min(70vw, 320px);
  height: min(52vh, 400px);
  max-height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

.snowman-btn[hidden] {
  display: none !important;
}

.snowman-stack {
  position: relative;
  width: 100%;
  height: 100%;
}

.snowman-final {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 10px 16px rgba(40, 60, 100, 0.35));
}

.snowman-final[hidden] {
  display: none;
}

.part {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(40, 50, 80, 0.25));
}

.part[hidden] {
  display: none;
}

.part.placing {
  animation: popIn 0.45s cubic-bezier(0.34, 1.45, 0.64, 1) both;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.55);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Piece layout — assemble classic snowman */
.part-big {
  left: 12%;
  bottom: 0;
  width: 76%;
  z-index: 1;
}

.part-middle {
  left: 20%;
  bottom: 28%;
  width: 60%;
  z-index: 3;
}

.part-head {
  left: 28%;
  bottom: 48%;
  width: 44%;
  z-index: 5;
}

.part-arms {
  left: -2%;
  bottom: 36%;
  width: 32%;
  z-index: 2;
  transform-origin: 90% 50%;
}

.part-arms-r {
  right: -2%;
  left: auto;
  bottom: 36%;
  width: 32%;
  z-index: 2;
  transform-origin: 10% 50%;
}

.part-buttons {
  left: 42%;
  bottom: 18%;
  width: 16%;
  z-index: 4;
}

.part-scarf {
  left: 24%;
  bottom: 32%;
  width: 50%;
  z-index: 6;
}

.part-eyes {
  left: 36%;
  bottom: 62%;
  width: 12%;
  z-index: 7;
}

.part-eyes-2 {
  left: 52%;
  bottom: 62%;
  width: 12%;
  z-index: 7;
}

.part-nose {
  left: 44%;
  bottom: 56%;
  width: 28%;
  z-index: 8;
}

.part-hat {
  left: 30%;
  bottom: 68%;
  width: 40%;
  z-index: 9;
}

.part-bow {
  left: 28%;
  bottom: 64%;
  width: 44%;
  z-index: 9;
}

.part.look-purple {
  filter: hue-rotate(285deg) saturate(1.7)
    drop-shadow(0 4px 6px rgba(40, 50, 80, 0.25));
}

.part.look-pink,
img.look-pink {
  filter: hue-rotate(300deg) saturate(1.45)
    drop-shadow(0 4px 6px rgba(40, 50, 80, 0.25));
}

.part.look-ice,
img.look-ice {
  filter: hue-rotate(175deg) saturate(1.35)
    drop-shadow(0 4px 6px rgba(40, 50, 80, 0.25));
}

img.look-purple {
  filter: hue-rotate(285deg) saturate(1.7);
}

.snowman-btn.has-eyes .part-eyes,
.snowman-btn.has-eyes .part-eyes-2 {
  animation: blink 3.4s ease-in-out infinite;
  transform-origin: center;
}

@keyframes blink {
  0%,
  46%,
  54%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.08);
  }
}

.part-nose.boop {
  animation: boop 0.45s ease;
}

@keyframes boop {
  40% {
    transform: translateX(8px) scale(1.18);
  }
  100% {
    transform: translateX(0) scale(1);
  }
}

.snowman-btn.waving .part-arms-r {
  animation: waveR 0.45s ease-in-out 3;
}

.snowman-btn.waving .part-arms {
  animation: waveL 0.45s ease-in-out 3;
}

.snowman-btn.giggle .snowman-stack,
.snowman-btn.giggle .snowman-final {
  animation: giggle 0.35s ease-in-out 2;
}

@keyframes waveR {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-18deg);
  }
}

@keyframes waveL {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(16deg);
  }
}

@keyframes giggle {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-3deg);
  }
  75% {
    transform: rotate(3deg);
  }
}

/* ---- Piece bar ---- */

.piece-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  padding-bottom: max(8px, var(--safe-bottom));
}

.piece-btn {
  position: relative;
  width: min(94vw, 500px);
  min-height: 120px;
  padding: 14px;
  border: 4px solid #fff;
  border-radius: 30px;
  background: linear-gradient(180deg, #fff8e0 0%, #ffe27a 55%, #f0c84a 100%);
  box-shadow:
    0 0 0 5px rgba(255, 200, 80, 0.4),
    0 10px 28px rgba(140, 100, 30, 0.35);
  cursor: pointer;
  animation: glowPulse 1.3s ease-in-out infinite;
  display: grid;
  place-items: center;
}

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

.piece-btn:active {
  transform: scale(0.97);
}

.piece-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 82px;
}

.piece-preview img {
  max-height: 78px;
  max-width: 140px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(60, 40, 20, 0.25));
}

@keyframes glowPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 5px rgba(255, 200, 80, 0.35),
      0 10px 28px rgba(140, 100, 30, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 12px rgba(255, 226, 122, 0.55),
      0 12px 32px rgba(140, 100, 30, 0.4);
  }
}

.choice-row {
  display: flex;
  gap: 12px;
  width: min(96vw, 680px);
}

.choice-row[hidden] {
  display: none !important;
}

.choice-row .piece-btn {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 120px;
}

.choice-row .piece-btn img {
  max-height: 88px;
  max-width: 100%;
  object-fit: contain;
}

.piece-btn.needs-help,
.choice-row.needs-help .piece-btn,
.snow-btn.needs-help {
  animation: helpGrow 0.7s ease-in-out infinite;
}

@keyframes helpGrow {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
}

.party-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(96vw, 720px);
}

.party-bar:has(.tickle-btn:not([hidden])) {
  grid-template-columns: 1fr 1fr;
}

.party-bar:not(:has(.tickle-btn:not([hidden]))) {
  grid-template-columns: 1fr 1fr 1fr;
}

.party-bar[hidden] {
  display: none !important;
}

.party-btn,
.party-bar .again-btn,
.snow-more {
  width: auto;
  min-height: 112px;
  border: none;
  border-radius: 26px;
  color: #fff;
  font-size: clamp(1.35rem, 3.4vw, 1.9rem);
  font-weight: 800;
  cursor: pointer;
}

.hug-btn {
  background: linear-gradient(180deg, #ffc2dc 0%, #f06aa4 55%, #d94888 100%);
  box-shadow:
    0 8px 0 #b03070,
    0 12px 20px rgba(180, 40, 100, 0.3);
}

.more-btn {
  background: linear-gradient(180deg, #b7e4ff 0%, #5eb6e8 55%, #3a92c8 100%);
  box-shadow:
    0 8px 0 #2a74a4,
    0 12px 20px rgba(40, 100, 160, 0.3);
}

.party-btn:active,
.snow-more:active {
  transform: translateY(5px);
}

.snow-more {
  width: min(94vw, 420px);
}

.snow-more[hidden] {
  display: none !important;
}

.again-btn {
  width: min(94vw, 500px);
  min-height: 112px;
  border: none;
  border-radius: 30px;
  background: linear-gradient(180deg, #b8f090 0%, #5cc84a 55%, #3aa832 100%);
  color: #fff;
  font-size: 2.3rem;
  font-weight: 800;
  box-shadow:
    0 8px 0 #2a8820,
    0 14px 28px rgba(40, 120, 40, 0.35);
  cursor: pointer;
  animation: glowPulse 1.3s ease-in-out infinite;
}

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

.again-btn:active {
  transform: translateY(5px);
  box-shadow:
    0 3px 0 #2a8820,
    0 6px 12px rgba(40, 120, 40, 0.3);
}

/* Tap burst */
.burst {
  position: fixed;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  background: url("../assets/ui/star-burst.svg") center / contain no-repeat;
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}

.burst.show {
  animation: burstOut 0.55s ease-out forwards;
}

@keyframes burstOut {
  0% {
    opacity: 1;
    transform: scale(0.3) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.6) rotate(40deg);
  }
}

body.celebrating .ground-glow {
  background: linear-gradient(transparent, rgba(255, 240, 180, 0.35));
}

body.celebrating .snowman-btn,
body.celebrating .reindeer-btn,
body.celebrating .feed-deer-btn {
  animation: dance 0.7s ease-in-out infinite;
}

@keyframes dance {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-12px) rotate(2deg);
  }
}

/* ---- Picture home, feed, and snow ---- */

.home-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  padding-top: max(96px, calc(var(--safe-top) + 84px));
  padding-bottom: max(16px, var(--safe-bottom));
}

.home-love {
  margin: 0;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  font-size: clamp(1.2rem, 3.4vw, 1.6rem);
  font-weight: 800;
  color: #c45080;
  text-align: center;
}

.home-sub {
  margin: 0 0 8px;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  font-size: clamp(1rem, 2.8vw, 1.15rem);
  font-weight: 700;
  color: var(--ice-deep);
  text-align: center;
}

.home-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(92vw, 560px);
}

.home-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 140px;
  padding: 10px 18px;
  border: 4px solid #fff;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 24px rgba(40, 70, 120, 0.28);
  cursor: pointer;
  color: var(--lavender-deep);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
}

.home-card img {
  width: 132px;
  height: 120px;
  object-fit: contain;
  flex-shrink: 0;
  transform: scale(1.55);
}

.home-card.card-snow img {
  width: 108px;
  height: 108px;
  transform: none;
}

.home-card:active {
  transform: scale(0.98);
}

.home-card.card-feed {
  background: linear-gradient(180deg, #fff, #e7f8e4);
}

.home-card.card-snow {
  background: linear-gradient(180deg, #dff4ff, #8ecff5);
  color: #1d4f86;
}

.play-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2;
}

.play-layer[hidden] {
  display: none !important;
}

.feed-deer-btn {
  width: min(48vw, 250px);
  margin-bottom: 6px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}

.feed-deer-btn img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 12px rgba(40, 40, 60, 0.35));
}

.feed-deer-btn.hop,
.reindeer-btn.hop {
  animation: hopDeer 0.4s ease;
}

@keyframes hopDeer {
  50% {
    transform: translateY(-18px) scale(1.04);
  }
}

.carrot-field {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.carrot {
  position: absolute;
  top: -20%;
  width: min(112px, 24vw);
  height: min(112px, 24vw);
  padding: 10px;
  border: 4px solid #fff;
  border-radius: 28px;
  background: radial-gradient(circle at 40% 30%, #fff, #ffe0b0);
  box-shadow:
    0 8px 0 #e0a050,
    0 12px 18px rgba(80, 40, 20, 0.25);
  animation-name: carrotFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  cursor: pointer;
}

.carrot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.carrot.eaten {
  animation: nom 0.35s ease forwards;
  pointer-events: none;
}

@keyframes carrotFall {
  to {
    top: calc(100% - 128px);
  }
}

@keyframes nom {
  to {
    transform: scale(0.15);
    opacity: 0;
  }
}

.snow-layer {
  align-items: center;
}

.snow-btn {
  width: min(62vw, 280px);
  height: min(62vw, 280px);
  border-radius: 50%;
  border: 8px solid #fff;
  background: radial-gradient(circle at 40% 35%, #fff, #c5ecff 55%, #6ec4f0);
  box-shadow:
    0 12px 0 #3a8fc4,
    0 18px 28px rgba(40, 90, 140, 0.35);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.snow-btn img {
  width: 58%;
  height: 58%;
  pointer-events: none;
}

.snow-btn:active,
.snow-btn.pressed {
  transform: translateY(8px);
  box-shadow:
    0 4px 0 #3a8fc4,
    0 8px 14px rgba(40, 90, 140, 0.3);
}

.float-heart {
  position: fixed;
  z-index: 80;
  font-size: 2rem;
  pointer-events: none;
  animation: heartUp 0.9s ease-out forwards;
}

@keyframes heartUp {
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.4);
  }
}

.finger-spark {
  position: fixed;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.45),
    0 0 16px #fff;
  pointer-events: none;
  z-index: 70;
  animation: sparkOut 0.7s ease-out forwards;
}

@keyframes sparkOut {
  to {
    opacity: 0;
    transform: scale(0.3);
  }
}

/* ---- Landscape ---- */

@media (orientation: landscape) and (min-width: 700px) {
  .bg-palace {
    display: none;
  }

  .bg-forest {
    display: block;
  }

  .love-strip {
    left: max(12px, var(--safe-left));
    right: auto;
    transform: none;
    max-width: min(42vw, 320px);
  }

  .love-msg {
    max-width: 7em;
  }

  .home-grid {
    flex-direction: row;
    flex-wrap: wrap;
    width: min(94vw, 920px);
  }

  .home-card {
    flex: 1 1 180px;
    flex-direction: column;
    justify-content: center;
    min-height: 200px;
    text-align: center;
  }

  .start-hero {
    width: min(28vh, 170px);
    margin-top: 8px;
  }

  .family-btn img {
    width: 76px;
    height: 76px;
  }

  .start-card {
    padding: 12px 16px 14px;
    gap: 4px;
  }

  .game-screen {
    grid-template-columns: minmax(240px, 34%) 1fr;
    grid-template-rows: 1fr auto;
    padding-top: max(12px, var(--safe-top));
  }

  .start-screen {
    padding-top: max(28px, calc(var(--safe-top) + 20px));
    padding-left: max(28px, calc(var(--safe-left) + min(42vw, 320px) + 20px));
  }

  .guide {
    grid-row: 1;
    grid-column: 1;
    flex-direction: column;
    align-items: stretch;
    height: 100%;
  }

  .luna-btn {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1.15;
    max-height: 200px;
  }

  .bubble {
    flex-direction: column;
    text-align: center;
  }

  .bubble::before {
    left: 50%;
    top: -16px;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-bottom-color: rgba(255, 255, 255, 0.94);
  }

  .stage {
    grid-row: 1;
    grid-column: 2;
  }

  .piece-bar {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .snowman-btn {
    width: min(42vw, 340px);
    height: min(70vh, 440px);
  }

  .reindeer-btn {
    width: min(18vw, 140px);
  }
}

/* ---- Rich interactions: stars, magic, crystals, treats ---- */

.star-hud {
  position: absolute;
  top: max(12px, calc(var(--safe-top) + 4px));
  left: max(12px, var(--safe-left));
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid #fff;
  box-shadow: 0 6px 16px rgba(80, 50, 120, 0.25);
  color: #b07020;
  font-weight: 800;
  font-size: 1.15rem;
}

.star-hud[hidden] {
  display: none !important;
}

.star-hud img {
  width: 28px;
  height: 28px;
}

.star-hud.star-pop {
  animation: starPop 0.45s ease;
}

@keyframes starPop {
  40% {
    transform: scale(1.18);
  }
}

.star-field {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
}

.float-star {
  position: absolute;
  width: min(72px, 16vw);
  height: min(72px, 16vw);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  animation: floaty 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(255, 200, 80, 0.55));
}

.float-star img {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.float-star:active {
  transform: scale(0.9);
}

.float-star.caught {
  animation: nom 0.35s ease forwards;
  pointer-events: none;
}

.world-tap {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.magic-btn {
  position: absolute;
  top: 8%;
  right: 4%;
  z-index: 8;
  width: min(72px, 16vw);
  height: min(72px, 16vw);
  border-radius: 50%;
  border: 4px solid #fff;
  background: radial-gradient(circle at 35% 30%, #fff8d0, #ffe27a 45%, #c4a8e8);
  box-shadow:
    0 6px 0 #8b6bc4,
    0 10px 18px rgba(80, 40, 120, 0.3);
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  cursor: pointer;
  animation: floaty 2.8s ease-in-out infinite;
}

.magic-btn[hidden] {
  display: none !important;
}

.magic-btn:active {
  transform: translateY(4px) scale(0.96);
  box-shadow:
    0 2px 0 #8b6bc4,
    0 4px 10px rgba(80, 40, 120, 0.28);
}

.luna-btn.luna-bounce {
  animation: hopDeer 0.4s ease;
}

.home-card-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}

.home-card-copy small {
  font-size: 0.55em;
  font-weight: 700;
  opacity: 0.75;
  color: var(--ice-deep);
}

.home-card.card-snow .home-card-copy small {
  color: #1d4f86;
}

.party-bar .tickle-btn {
  background: linear-gradient(180deg, #fff, #ffe0f0);
  color: #c45080;
}

.treat-field,
.crystal-field {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.treat-berry,
.ice-crystal {
  position: absolute;
  width: min(78px, 18vw);
  height: min(78px, 18vw);
  padding: 0;
  border: 4px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e8d0ff);
  box-shadow: 0 8px 16px rgba(60, 40, 90, 0.28);
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  cursor: pointer;
  pointer-events: auto;
  animation: floaty 2.2s ease-in-out infinite;
}

.treat-berry:active,
.ice-crystal:active {
  transform: scale(0.92);
}

.treat-berry.eaten,
.ice-crystal.caught {
  animation: nom 0.35s ease forwards;
  pointer-events: none;
}

.carrot.carrot-late {
  background: radial-gradient(circle at 40% 30%, #fff, #ffd4a8);
}

.snow-hint {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ice-deep);
  font-weight: 800;
  font-size: clamp(0.85rem, 2.4vw, 1rem);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(40, 70, 120, 0.2);
}

.snowman-btn .part {
  pointer-events: auto;
  cursor: pointer;
}

body[data-mode="feed"] .bg-palace {
  filter: saturate(1.08) hue-rotate(-8deg);
}

body[data-mode="snow"] .bg-palace,
body[data-mode="snow"] .bg-forest {
  filter: brightness(1.06) saturate(1.1);
}

body[data-mode="learn"] .bg-palace,
body[data-mode="learn"] .bg-forest {
  filter: saturate(1.12) brightness(1.04);
}

.home-card.card-learn {
  background: linear-gradient(180deg, #fff8e8, #ffe27a 70%, #f5d060);
  color: #8a5a10;
}

.home-card.card-learn img {
  width: 96px;
  height: 96px;
  transform: none;
}

.learn-layer {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  padding-bottom: 24px;
}

.learn-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  width: min(94vw, 560px);
  z-index: 2;
}

.learn-pick {
  flex: 1 1 140px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: 4px solid #fff;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 22px rgba(40, 70, 120, 0.28);
  color: var(--lavender-deep);
  font-size: clamp(1.25rem, 3.5vw, 1.7rem);
  font-weight: 800;
  cursor: pointer;
}

.learn-pick:active {
  transform: scale(0.97);
}

.learn-pick-emoji {
  font-size: clamp(2.2rem, 8vw, 3rem);
  line-height: 1;
  width: 1.2em;
  height: 1.2em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #e8f4ff);
  border: 3px solid #fff;
}

.learn-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(96vw, 640px);
  z-index: 2;
}

.learn-play[hidden],
.learn-picker[hidden] {
  display: none !important;
}

.learn-stage {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 140px;
  width: 100%;
  padding: 16px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  border: 4px solid #fff;
  box-shadow: 0 10px 24px rgba(40, 70, 120, 0.22);
}

.learn-token {
  width: min(92px, 20vw);
  height: min(92px, 20vw);
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: radial-gradient(circle at 40% 30%, #fff, #ffe8c8);
  border: 3px solid #fff;
  box-shadow: 0 6px 0 rgba(180, 120, 60, 0.35);
  font-size: clamp(2rem, 7vw, 2.8rem);
  animation: popIn 0.45s ease;
}

.learn-token img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  pointer-events: none;
}

.learn-token.scarf-swatch {
  border-radius: 50%;
  box-shadow: 0 6px 0 rgba(80, 50, 120, 0.25);
}

.learn-token.letter-big {
  font-size: clamp(3rem, 12vw, 4.5rem);
  font-weight: 800;
  color: var(--lavender-deep);
  background: radial-gradient(circle at 40% 30%, #fff, #efe4ff);
}

.learn-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.learn-choice {
  min-width: min(100px, 28vw);
  min-height: 88px;
  padding: 12px 16px;
  border: 4px solid #fff;
  border-radius: 24px;
  background: linear-gradient(180deg, #fff, #e8f6ff);
  box-shadow:
    0 8px 0 #3a8fc4,
    0 12px 18px rgba(40, 90, 140, 0.28);
  color: var(--ink);
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 800;
  cursor: pointer;
}

.learn-choice.color-choice {
  min-width: min(88px, 22vw);
  min-height: min(88px, 22vw);
  border-radius: 50%;
  font-size: 0;
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.18),
    0 12px 18px rgba(40, 70, 120, 0.25);
}

.learn-choice:active {
  transform: translateY(4px);
}

.learn-choice.wrong-shake {
  animation: learnShake 0.45s ease;
}

.learn-choice.correct-pop {
  animation: starPop 0.45s ease;
}

@keyframes learnShake {
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(6px);
  }
}

.learn-more[hidden] {
  display: none !important;
}

.learn-more {
  width: min(94vw, 420px);
}

@media (orientation: landscape) and (min-width: 700px) {
  .home-card-copy {
    align-items: center;
    text-align: center;
  }

  .magic-btn {
    top: 6%;
    right: 3%;
  }

  .star-hud {
    top: max(88px, calc(var(--safe-top) + 76px));
  }

  .learn-layer {
    padding-top: 8px;
  }

  .learn-pick {
    min-height: 120px;
  }
}
