:root {
  --bg: #fff1dc;
  --ink: #4a3018;
  --paper: #fffaf3;
  --coral: #ff6b57;
  --sun: #ffd166;
  --mint: #7bd389;
  --sky: #6ec6ff;
  --lilac: #c9a0ff;
  --peach: #ffb4a2;
  --rose: #ff8fab;
  --shadow: 0 10px 0 rgba(74, 48, 24, 0.18);
  --radius: 32px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei",
    ui-rounded, system-ui, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100dvh;
  min-height: 100svh;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: 100svh;
  padding: calc(12px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  gap: 12px;
  overflow: auto;
}

#screen-bubbles,
#screen-paint,
#screen-animals,
#screen-shapes,
#screen-coloring {
  overflow: hidden;
}

.screen.is-active {
  display: flex;
}.home-hero {
  position: relative;
  text-align: center;
  padding: 18px 12px 8px;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(36px, 10vw, 56px);
  letter-spacing: 0.04em;
}

.home-hero p {
  margin: 6px 0 0;
  font-size: clamp(18px, 4.6vw, 24px);
  opacity: 0.8;
}

.deco {
  position: absolute;
  pointer-events: none;
}

.deco.sun {
  top: 8px;
  right: 18px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 8px rgba(255, 209, 102, 0.35);
}

.deco.cloud {
  top: 28px;
  left: 12px;
  width: 72px;
  height: 36px;
  background: #fff;
  border-radius: 40px;
  opacity: 0.9;
}

.deco.cloud::before,
.deco.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.deco.cloud::before {
  width: 34px;
  height: 34px;
  top: -16px;
  left: 12px;
}

.deco.cloud::after {
  width: 26px;
  height: 26px;
  top: -10px;
  right: 10px;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 8px 4px 20px;
  flex: 1;
  align-content: start;
}

.game-card {
  min-height: clamp(132px, 22vh, 180px);
  border: 6px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  transition: transform 0.12s ease;
}

.game-card:active {
  transform: translateY(6px) scale(0.98);
  box-shadow: 0 4px 0 rgba(74, 48, 24, 0.18);
}

.card-paint {
  grid-column: 1 / -1;
}

.card-icon {
  width: 72px;
  height: 72px;
}

.card-icon svg {
  width: 100%;
  height: 100%;
}

.card-title {
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
}

.card-coloring {
  background: #ffe3d6;
}
.card-bubbles {
  background: #d7f3ff;
}
.card-animals {
  background: #d9f8df;
}
.card-shapes {
  background: #fff3c2;
}
.card-paint {
  background: #efe2ff;
}

.game-bar {
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  gap: 8px;
}

.game-bar h2 {
  margin: 0;
  text-align: center;
  font-size: clamp(28px, 7vw, 40px);
}

.round-btn {
  min-height: 56px;
  border: 5px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(74, 48, 24, 0.16);
}

.round-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(74, 48, 24, 0.16);
}

.back-btn {
  background: var(--peach);
}

.clear-btn {
  background: var(--sun);
}

.bar-spacer {
  display: block;
  min-height: 56px;
}

.hint,
.page-name,
.celebrate {
  text-align: center;
  font-size: clamp(18px, 4.5vw, 24px);
  margin: 0;
  font-weight: 700;
}

.celebrate {
  color: #c1121f;
  font-size: clamp(24px, 6vw, 32px);
}

.coloring-layout {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-height: 0;
}

.art-frame {
  background: var(--paper);
  border: 6px solid var(--ink);
  border-radius: 28px;
  box-shadow: var(--shadow);
  height: 100%;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  padding: 8px;
}

.coloring-art {
  flex: 1;
  min-height: 0;
}

.coloring-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

.coloring-art .fill-me {
  fill: #fffdf7;
  stroke: #3d2914;
  stroke-width: 7;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.coloring-art .ink {
  pointer-events: none;
  fill: #3d2914;
}

.page-btn {
  font-size: 42px;
  min-width: 56px;
  padding: 0;
  background: #fff3c2;
}

.crayon-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px 4px;
}

.crayon {
  width: 44px;
  height: 64px;
  border: 5px solid var(--ink);
  border-radius: 18px 18px 22px 22px;
  flex: 1;
  max-width: 64px;
  box-shadow: 0 5px 0 rgba(74, 48, 24, 0.16);
}

.crayon.is-selected {
  transform: translateY(-8px) scale(1.08);
  box-shadow: 0 10px 0 rgba(74, 48, 24, 0.16);
}

.screen-sky {
  background: linear-gradient(#9ee7ff 0%, #e8f9ff 55%, #fff1dc 100%);
}

.bubble-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  border-radius: 28px;
  border: 6px solid var(--ink);
  background: linear-gradient(#7ad7ff, #e7fbff);
  touch-action: none;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  border: 6px solid rgba(74, 48, 24, 0.35);
  box-shadow: inset -12px -16px 0 rgba(255, 255, 255, 0.45);
  animation: rise linear forwards;
  touch-action: none;
}

.bubble.is-popped {
  animation: pop 0.28s ease-out forwards;
}

@keyframes rise {
  from {
    transform: translateY(20px);
  }
  to {
    transform: translateY(-120vh);
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.45);
    opacity: 0;
  }
}

.screen-meadow {
  background: linear-gradient(#9ee7ff 0%, #c7f5c4 48%, #8ed18a 100%);
}

.animals-stage {
  flex: 1;
  min-height: 280px;
  border: 6px solid var(--ink);
  border-radius: 28px;
  overflow: hidden;
  background: #bfe9ff;
  box-shadow: var(--shadow);
}

.animals-stage svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hide-spot {
  cursor: pointer;
}

.critter {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  pointer-events: none;
}

.critter.is-found {
  opacity: 1;
  animation: critter-in 0.45s ease-out;
}

@keyframes critter-in {
  0% {
    transform: scale(0.2) translateY(24px);
  }
  70% {
    transform: scale(1.15) translateY(-8px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

.peek {
  opacity: 0.95;
}

.shape-stage {
  position: relative;
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
}

.shape-holes,
.shape-tray {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 12px;
}

.shape-holes {
  flex: 0 0 auto;
  padding: 8px 0 4px;
  min-height: 140px;
}

.shape-tray {
  flex: 1;
  min-height: 160px;
}

.hole,
.piece {
  width: clamp(96px, 28vw, 132px);
  height: clamp(96px, 28vw, 132px);
  min-width: 96px;
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  padding: 0;
}

.hole svg,
.piece svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.piece {
  position: absolute;
  touch-action: none;
  z-index: 2;
  filter: drop-shadow(0 8px 0 rgba(74, 48, 24, 0.16));
  -webkit-tap-highlight-color: transparent;
}

.piece.is-held {
  z-index: 5;
  filter: drop-shadow(0 14px 0 rgba(74, 48, 24, 0.2));
  transform: scale(1.08);
}

.piece.is-placed {
  pointer-events: none;
}

.shape-holes {
  min-height: clamp(120px, 32vw, 160px);
}

.shape-tray {
  min-height: clamp(140px, 36vw, 200px);
}

.paint-wrap {
  flex: 1;
  min-height: 240px;
  border: 6px solid var(--ink);
  border-radius: 28px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  touch-action: none;
}

#paint-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

@media (min-width: 600px) {
  .crayon {
    height: 72px;
  }

  .hole,
  .piece {
    width: 140px;
    height: 140px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .home-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .card-paint {
    grid-column: auto;
  }

  .game-card {
    min-height: 120px;
  }

  .card-title {
    font-size: 22px;
  }

  .coloring-layout,
  .animals-stage,
  .bubble-stage,
  .paint-wrap {
    min-height: 160px;
  }
}

.animals-stage {
  position: relative;
  aspect-ratio: 360 / 640;
  width: 100%;
  max-height: min(68vh, 640px);
  margin: 0 auto;
  background: #bfe9ff;
}

.animals-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.animal-spot {
  position: absolute;
  width: 28%;
  min-width: 88px;
  min-height: 88px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
  z-index: 2;
}

.animal-spot img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 4px 0 rgba(43, 27, 18, 0.12));
}

.animal-spot.is-found {
  z-index: 4;
  animation: critter-in 0.45s ease-out;
}

.animals-tools {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}

.animals-tools .round-btn {
  min-width: 120px;
  min-height: 72px;
  font-size: 1.15rem;
}

.color-link {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 6;
  min-width: 160px;
  min-height: 72px;
  border-radius: 999px;
  border: 5px solid var(--ink);
  background: var(--accent, #ffd23f);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}

.color-link.is-on {
  display: block;
}
