@font-face {
  font-family: Fredoka;
  src: url("../fonts/fredoka-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Fredoka;
  src: url("../fonts/fredoka-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Fredoka;
  src: url("../fonts/fredoka-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --cream: #f4e8d0;
  --paper: #fff6ea;
  --ink: #2c2416;
  --ink-soft: #8a6d52;
  --strawberry: #e45b4a;
  --apricot: #f09a4a;
  --marmalade: #e8782e;
  --butter: #e8c03a;
  --mint: #4db87a;
  --sky: #4c8fe8;
  --grape: #8b6bc4;
  --dirt: #6b4a32;
  --grass: #7cb35a;
  --font: Fredoka, ui-rounded, "Trebuchet MS", sans-serif;
  --radius-toy: 28px;
  --radius-card: 18px;
  --stroke: 3px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 560px at 8% -8%, #f7d3b0 0%, transparent 52%),
    radial-gradient(720px 480px at 108% 12%, #f3c4b6 0%, transparent 48%),
    var(--cream);
}

button {
  font-family: inherit;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

svg {
  display: block;
}

#app {
  height: 100dvh;
  height: 100svh;
}

.fx-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 80;
}

/* ----- Home ----- */

.home {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  max-width: 920px;
  margin: 0 auto;
}

.home-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  min-height: 56px;
}

.mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: var(--stroke) solid var(--ink);
  object-fit: cover;
  flex: none;
  background: var(--paper);
}

.wordmark {
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--marmalade);
  margin: 0;
  flex: 1;
}

.home-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.star-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 12px 0 8px;
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
}

.star-chip svg {
  width: 22px;
  height: 22px;
}

.home-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(158px, auto);
  align-content: start;
  gap: 14px;
  padding-bottom: 8px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px 16px;
  min-height: 158px;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-toy);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  overflow: hidden;
  touch-action: manipulation;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}

.tile:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.tile .art {
  width: min(62%, 150px);
  height: auto;
  filter: drop-shadow(0 2px 0 rgb(44 36 22 / 0.12));
}

.tile .art svg {
  width: 100%;
  height: auto;
}

.tile span {
  font-size: clamp(18px, 4.6vw, 26px);
  letter-spacing: -0.02em;
  line-height: 1;
}

.tile-pop { background: #f7b4a8; }
.tile-match { background: #cbb6ee; }
.tile-catch { background: #9ec7f5; }
.tile-paint { background: #9ee0b6; }
.tile-shapes { background: #f6c48a; }
.tile-pick { background: #f3d76a; }
.tile-chomp { background: #ffe08a; }
.tile-space { background: #c5d0f5; }
.tile-snake { background: #b8e0c4; }
.tile-copy { background: #f3d4c4; }
.tile-flap { background: #9ec7f5; }
.tile-blocks { background: #f6c48a; }
.tile-hop { background: #9ee0b6; }
.tile-break { background: #cbb6ee; }
.tile-color { background: #f7d3b8; }
.tile-stories { background: #b9c8f2; }

.level-banner {
  text-align: center;
  animation: yay-in 0.32s cubic-bezier(0.2, 0.85, 0.2, 1);
}

.level-banner span {
  display: block;
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: -0.02em;
}

.level-banner b {
  display: block;
  font-size: clamp(84px, 26vw, 160px);
  line-height: 0.9;
  color: var(--marmalade);
  letter-spacing: -0.04em;
}

.parent-tip {
  flex: none;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.parent-tip p {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-soft);
  flex: 1;
}

.parent-tip b {
  color: var(--ink);
  font-weight: 700;
}

.parent-tip .got-it {
  flex: none;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--butter);
  box-shadow: 2px 2px 0 var(--ink);
}

.parent-tip .got-it:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ----- Shared chrome ----- */

.icon-btn {
  width: 56px;
  height: 56px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: var(--stroke) solid var(--ink);
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
  padding: 0;
  touch-action: manipulation;
}

.icon-btn svg {
  width: 26px;
  height: 26px;
}

.icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.game {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--game-tint, var(--cream));
}

.game-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l));
  min-height: calc(64px + var(--safe-t));
}

.game-bar h1 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: clamp(22px, 6vw, 36px);
  letter-spacing: -0.03em;
  line-height: 1;
}

.playfield {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.score {
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  min-width: 52px;
  justify-content: flex-end;
}

.score svg {
  width: 22px;
  height: 22px;
}

.level-chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 10px;
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.arcade-cv {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.chomp-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chomp-wrap .arcade-cv {
  flex: 1;
  min-height: 0;
}

.dpad {
  flex: none;
  display: grid;
  grid-template-columns: 88px 88px 88px;
  grid-template-rows: 72px 72px;
  gap: 6px;
  justify-content: center;
  padding: 10px 12px calc(14px + var(--safe-b));
  touch-action: manipulation;
}

.dpad-btn {
  position: relative;
  width: 88px;
  height: 72px;
  padding: 0;
  border: var(--stroke) solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.dpad-btn::before {
  content: "";
  position: absolute;
  inset: -10px;
}

.dpad-btn:active,
.dpad-btn.is-on {
  background: var(--butter);
}

.dpad-btn svg {
  width: 28px;
  height: 28px;
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }

.ready-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgb(255 246 234 / 0.78);
}

.ready-start {
  min-width: 200px;
  height: 88px;
  padding: 0 36px;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-toy);
  background: var(--butter);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 40px;
  letter-spacing: -0.03em;
}

.ready-start:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.ready-count {
  font-size: clamp(84px, 28vw, 160px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--marmalade);
  animation: yay-in 0.28s cubic-bezier(0.2, 0.85, 0.2, 1);
}

.copy-grid {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
  padding: 16px 16px calc(18px + var(--safe-b));
  max-width: 560px;
  margin: 0 auto;
}

.copy-tile {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 8%;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-toy);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  touch-action: manipulation;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, background 0.12s ease-out;
}

.copy-tile .copy-face {
  display: grid;
  place-items: center;
  height: 62%;
  width: auto;
}

.copy-tile svg {
  height: 100%;
  width: auto;
}

.copy-tile.is-on {
  transform: scale(1.06);
  box-shadow: 6px 6px 0 var(--ink);
}

.copy-tile[data-i="0"].is-on { background: #f7b4a8; }
.copy-tile[data-i="1"].is-on { background: #9ec7f5; }
.copy-tile[data-i="2"].is-on { background: #9ee0b6; }
.copy-tile[data-i="3"].is-on { background: #f3d76a; }

.copy-tile.is-wrong {
  background: #e45b4a;
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ----- Pop ----- */

.bubble {
  position: absolute;
  padding: 0;
  border: none;
  background: transparent;
  animation: rise linear forwards;
  touch-action: manipulation;
  z-index: 2;
}

.bubble-ball {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgb(255 255 255 / 0.5);
  box-shadow:
    inset -14px -18px 0 rgb(255 255 255 / 0.22),
    inset 10px 12px 0 rgb(255 255 255 / 0.18),
    0 6px 0 rgb(44 36 22 / 0.12);
}

.bubble.popping .bubble-ball {
  animation: pop 0.26s cubic-bezier(0.2, 0.85, 0.3, 1) forwards;
}

@keyframes rise {
  0% { transform: translate(0, 0); }
  40% { transform: translate(16px, -42dvh); }
  100% { transform: translate(-10px, calc(-110dvh - 40px)); }
}

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

/* ----- Match ----- */

.match-grid {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  padding: 16px 14px 24px;
  max-width: 560px;
  margin: 0 auto;
  align-content: center;
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  align-self: center;
  padding: 0;
  border: none;
  background: none;
  perspective: 800px;
  touch-action: manipulation;
  display: block;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card.is-flipped .card-inner,
.card.is-matched .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-card);
  border: var(--stroke) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.card-front {
  background:
    radial-gradient(circle at 30% 28%, rgb(255 255 255 / 0.38) 0 7px, transparent 8px),
    var(--strawberry);
}

.card-back {
  transform: rotateY(180deg);
  background: var(--paper);
  display: grid;
  place-items: center;
  padding: 8%;
}

.card-back svg {
  width: 78%;
  height: auto;
}

.card.is-matched .card-back {
  background: #fff3c4;
}

/* ----- Catch ----- */

.sky-field {
  background: linear-gradient(#8ec4f4 0%, #d7eefc 48%, #c8e89a 100%);
  touch-action: none;
}

.cloud {
  position: absolute;
  pointer-events: none;
  opacity: 0.92;
}

.cloud svg {
  width: 100%;
  height: auto;
}

.cloud.c1 {
  width: 108px;
  top: 10%;
  left: 6%;
}

.cloud.c2 {
  width: 136px;
  top: 20%;
  right: 4%;
}

.fall {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  border: none;
  background: none;
  z-index: 2;
  touch-action: manipulation;
}

.fall svg {
  width: 100%;
  height: 100%;
}

.basket {
  position: absolute;
  bottom: calc(18px + var(--safe-b));
  left: 50%;
  width: 128px;
  height: 70px;
  transform: translateX(-50%);
  background: #c56a38;
  border: var(--stroke) solid var(--ink);
  border-radius: 10px 10px 30px 30px;
  box-shadow: 3px 3px 0 var(--ink);
  z-index: 3;
  pointer-events: none;
}

.basket::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 10px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #e8a36a;
}

/* ----- Paint ----- */

.paint-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.paint-cv {
  display: block;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--paper);
  touch-action: none;
  cursor: crosshair;
}

.paint-dock {
  flex: none;
  padding: 8px calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l));
  background: rgb(244 232 208 / 0.94);
  border-top: var(--stroke) solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paint-colors {
  display: grid;
  grid-template-columns: repeat(4, 48px);
  gap: 8px;
  justify-content: center;
}

.paint-tools {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.swatch,
.tool {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: var(--stroke) solid var(--ink);
  padding: 0;
  box-shadow: 2px 2px 0 var(--ink);
  display: grid;
  place-items: center;
  background: var(--paper);
}

.swatch.is-on,
.tool.is-on {
  transform: scale(1.12);
  box-shadow: 3px 3px 0 var(--ink);
}

.tool {
  border-radius: 12px;
  width: 48px;
}

.tool svg {
  width: 24px;
  height: 24px;
}

.tool-new {
  background: var(--butter);
}

.color-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.color-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px 16px 4px;
}

.color-page {
  width: min(100%, 420px);
  height: 100%;
  max-height: 100%;
  overflow: visible;
  filter: drop-shadow(3px 4px 0 rgb(44 36 22 / 0.12));
}

.color-spot {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  touch-action: manipulation;
}

.color-spot.is-pop {
  animation: color-pop 0.28s cubic-bezier(0.2, 0.85, 0.25, 1);
}

@keyframes color-pop {
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ----- Shapes ----- */

.shapes-board {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 8px 16px calc(16px + var(--safe-b));
  gap: 16px;
}

.zones {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.zone {
  border: 3px dashed var(--ink);
  border-radius: 24px;
  background: rgb(255 246 234 / 0.45);
  display: grid;
  place-items: center;
  min-height: 0;
}

.zone svg {
  width: min(58%, 150px);
  height: auto;
  opacity: 0.55;
}

.zone.is-filled {
  background: rgb(255 246 234 / 0.92);
  border-style: solid;
}

.zone.is-filled svg {
  opacity: 1;
}

.tray {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  min-height: 96px;
  padding: 8px;
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: 24px;
  box-shadow: 3px 3px 0 var(--ink);
}

.shape-piece {
  width: 72px;
  height: 72px;
  padding: 0;
  border: none;
  background: none;
  touch-action: none;
  z-index: 4;
}

.shape-piece svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(2px 2px 0 var(--ink));
}

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

.shape-piece.is-dragging {
  z-index: 20;
  filter: drop-shadow(4px 6px 0 rgb(44 36 22 / 0.2));
}

/* ----- Pick ----- */

.garden {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  padding: 16px 18px calc(36px + var(--safe-b));
  align-content: end;
  background: linear-gradient(#f3d76a 0 34%, #8fbf62 34%);
}

.hole {
  aspect-ratio: 1;
  margin: auto;
  width: min(100%, 180px);
  background: var(--dirt);
  border: var(--stroke) solid var(--ink);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 10px 0 rgb(0 0 0 / 0.12);
}

.flower {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 72%;
  padding: 0;
  border: none;
  background: none;
  transform: translateX(-50%) scale(0);
  transform-origin: 50% 100%;
  transition: transform 0.28s cubic-bezier(0.2, 0.85, 0.25, 1);
  touch-action: manipulation;
}

.hole.is-up .flower {
  transform: translateX(-50%) scale(1);
}

.hole.is-picked .flower {
  transform: translateX(-50%) scale(1.18);
}

.flower svg {
  width: 100%;
  height: auto;
}

/* ----- Yay overlay ----- */

.yay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(255 246 234 / 0.72);
  z-index: 6;
  pointer-events: none;
}

.yay svg {
  width: min(46vw, 220px);
  height: auto;
  animation: yay-in 0.5s cubic-bezier(0.2, 0.85, 0.2, 1);
}

@keyframes yay-in {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media (min-width: 768px) {
  .home {
    padding-top: calc(20px + var(--safe-t));
  }

  .home-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-auto-rows: minmax(180px, 1fr);
    gap: 18px;
    overflow: visible;
  }

  .tile {
    min-height: 180px;
  }

  .tile span {
    font-size: 24px;
  }

  .icon-btn {
    width: 64px;
    height: 64px;
  }

  .paint-colors {
    grid-template-columns: repeat(8, 52px);
  }

  .swatch {
    width: 52px;
    height: 52px;
  }

  .tool {
    width: 56px;
    height: 52px;
  }

  .shape-piece {
    width: 96px;
    height: 96px;
  }

  .basket {
    width: 160px;
    height: 84px;
  }

  .dpad {
    grid-template-columns: 88px 88px 88px;
    grid-template-rows: 64px 64px;
  }

  .dpad-btn {
    width: 88px;
    height: 64px;
  }

  .match-grid {
    gap: 16px;
    padding: 16px 24px 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  .icon-btn,
  .card-inner,
  .flower,
  .yay svg,
  .bubble-ball {
    transition: none;
    animation: none;
  }

  .bubble {
    animation-duration: 14s;
  }
}
