/* Popper Lab. A sky-blue room with soft bubbles in the background; white
   round buttons with purple pictures; big glossy tiles. Everything a finger
   can touch is at least 64 px. */

:root {
  --ink: #4A2F8A;
  --sky1: #CDEFFF;
  --sky2: #E9DDFF;
  --pink: #FF7EB6;
  --sun: #FFD23F;
  --mint: #4CD787;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.55) 0 38px, transparent 39px),
    radial-gradient(circle at 86% 12%, rgba(255,255,255,0.45) 0 24px, transparent 25px),
    radial-gradient(circle at 78% 84%, rgba(255,255,255,0.5) 0 46px, transparent 47px),
    radial-gradient(circle at 20% 88%, rgba(255,255,255,0.4) 0 20px, transparent 21px),
    radial-gradient(circle at 50% 55%, rgba(255,255,255,0.25) 0 70px, transparent 71px),
    linear-gradient(160deg, var(--sky1), var(--sky2));
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
}
section { position: fixed; inset: 0; }
section[hidden], [hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; padding: 0; background: none; cursor: pointer; }
canvas { display: block; }

/* ---------- round buttons ---------- */
.round {
  position: absolute; z-index: 50;
  width: 76px; height: 76px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #F3EEFF);
  box-shadow: 0 6px 0 #D5C8F2, 0 10px 18px rgba(74, 47, 138, 0.18);
  display: grid; place-items: center;
  transition: transform 0.12s;
}
.round svg { width: 64%; height: 64%; }
.round:active { transform: translateY(4px) scale(0.96); box-shadow: 0 2px 0 #D5C8F2, 0 4px 10px rgba(74, 47, 138, 0.18); }
.round.home { top: calc(16px + var(--safe-top)); left: calc(16px + var(--safe-left)); }
.round.right { top: calc(16px + var(--safe-top)); right: calc(16px + var(--safe-right)); }
.round.right2 { top: calc(16px + var(--safe-top)); right: calc(104px + var(--safe-right)); }

.play {
  width: 132px; height: 132px; border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #FFA6CC, var(--pink) 55%, #E85A98);
  box-shadow: 0 8px 0 #C9447F, 0 14px 26px rgba(201, 68, 127, 0.35);
  display: grid; place-items: center;
  transition: transform 0.12s;
}
.play svg { width: 62%; height: 62%; }
.play:active { transform: translateY(5px) scale(0.97); box-shadow: 0 3px 0 #C9447F, 0 6px 14px rgba(201, 68, 127, 0.35); }
.play.small { width: 96px; height: 96px; }
.play.mint { background: radial-gradient(circle at 35% 28%, #9DF0BE, var(--mint) 55%, #34B26C); box-shadow: 0 8px 0 #2E9A5E, 0 14px 26px rgba(46, 154, 94, 0.3); }

/* ---------- title ---------- */
#title { display: grid; place-items: center; grid-template-rows: 1fr auto auto; padding: 24px 24px calc(28px + var(--safe-bottom)); gap: 10px; }
#title .hero { align-self: end; perspective: 1200px; }
.wordmark { margin: 0; font-size: clamp(44px, 8vw, 84px); font-weight: 900; letter-spacing: 1px; line-height: 1; }
.wordmark span { display: inline-block; -webkit-text-stroke: 3px #fff; paint-order: stroke fill; text-shadow: 0 5px 0 rgba(74, 47, 138, 0.18); }
.wordmark.small { font-size: 40px; }

/* ---------- home ---------- */
#home { display: grid; place-items: center; }
.tiles { display: flex; gap: clamp(16px, 3vw, 40px); flex-wrap: wrap; justify-content: center; padding: 100px 24px 24px; }
.tile {
  width: clamp(200px, 26vw, 290px); aspect-ratio: 1; border-radius: 40px;
  background: radial-gradient(circle at 30% 20%, #FFD0E5, var(--pink) 70%);
  box-shadow: 0 10px 0 #C9447F, 0 18px 30px rgba(74, 47, 138, 0.2);
  display: grid; place-items: center; transition: transform 0.12s;
}
.tile.sun { background: radial-gradient(circle at 30% 20%, #FFF3B8, var(--sun) 70%); box-shadow: 0 10px 0 #D9A90F, 0 18px 30px rgba(74, 47, 138, 0.2); }
.tile.mint { background: radial-gradient(circle at 30% 20%, #C8F7DA, var(--mint) 70%); box-shadow: 0 10px 0 #2E9A5E, 0 18px 30px rgba(74, 47, 138, 0.2); }
.tile:active { transform: translateY(6px) scale(0.98); }
.tile canvas { width: 78%; height: 78%; }
.tile .pic { width: 70%; height: 70%; display: grid; place-items: center; }
.tile .pic svg { width: 100%; height: 100%; }

/* ---------- shelf and shape picker ---------- */
.scroll { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(104px + var(--safe-top)) 20px calc(30px + var(--safe-bottom)); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; max-width: 1100px; margin: 0 auto; }
.board-tile {
  position: relative; aspect-ratio: 1; border-radius: 28px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 0 rgba(213, 200, 242, 0.9), 0 10px 18px rgba(74, 47, 138, 0.12);
  display: grid; place-items: center; transition: transform 0.12s;
}
.board-tile:active { transform: translateY(4px) scale(0.97); }
.board-tile canvas { width: 86%; height: 86%; }
.board-tile.locked { background: rgba(255, 255, 255, 0.35); }
.board-tile .badge { position: absolute; right: 6px; bottom: 6px; width: 48px; height: 48px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(74, 47, 138, 0.2); }
.board-tile .badge svg { width: 78%; height: 78%; }
.board-tile.fresh { animation: wiggle 1.2s ease-in-out 3; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg) scale(1.04); } 75% { transform: rotate(4deg) scale(1.04); } }

/* ---------- boards ---------- */
.stage { position: absolute; inset: 0; display: grid; place-items: center; perspective: 1400px; }
.flipper { transform-style: preserve-3d; will-change: transform; }

/* ---------- puzzle ---------- */
#puzzle-stage { display: block; touch-action: none; }
#puzzle-stage canvas { position: absolute; }
#puzzle-stage .ghost { opacity: 0.22; filter: grayscale(1) brightness(0.6); }
#puzzle-stage .piece { filter: drop-shadow(0 8px 10px rgba(74, 47, 138, 0.25)); transition: transform 0.15s; }
#puzzle-stage .piece.lift { transform: scale(1.04); filter: drop-shadow(0 16px 18px rgba(74, 47, 138, 0.3)); }
#puzzle-stage .piece.home { transition: left 0.2s ease-out, top 0.2s ease-out; filter: none; }
#puzzle-stage .flipper { position: absolute; }

/* ---------- paint ---------- */
#paint .stage { right: 200px; }
#tray {
  position: absolute; top: 0; right: 0; bottom: 0; width: 200px;
  padding: calc(18px + var(--safe-top)) calc(16px + var(--safe-right)) calc(18px + var(--safe-bottom)) 16px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  background: rgba(255, 255, 255, 0.45); border-left: 3px solid rgba(255, 255, 255, 0.8);
}
#pots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; justify-items: center; }
.pot {
  width: 70px; height: 70px; border-radius: 50%;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,0.15), inset 0 6px 8px rgba(255,255,255,0.5), 0 4px 8px rgba(74, 47, 138, 0.2);
  border: 4px solid #fff; transition: transform 0.12s;
}
.pot.on { transform: scale(1.12); outline: 5px solid var(--ink); outline-offset: 2px; }
.pot.rainbow { background: conic-gradient(#FF4D5E, #FF8A3D, #FFD23F, #4CD787, #3CC8E0, #4F7DF3, #A665E8, #FF4D5E); }
.tray-buttons { display: flex; justify-content: space-around; align-items: center; }
#bucket { position: static; }

@media (orientation: portrait) {
  #paint .stage { right: 0; bottom: 230px; }
  #tray { top: auto; left: 0; width: auto; height: 230px; border-left: 0; border-top: 3px solid rgba(255,255,255,0.8); flex-direction: row; align-items: center; padding: 14px 16px calc(14px + var(--safe-bottom)); }
  #pots { grid-template-columns: repeat(7, 1fr); flex: 1; }
  .tray-buttons { flex-direction: column; gap: 14px; }
}

/* ---------- What's new ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(74, 47, 138, 0.35); }
.card { background: #fff; border-radius: 36px; padding: 26px; max-height: 90dvh; overflow: auto; text-align: center; box-shadow: 0 20px 50px rgba(74, 47, 138, 0.3); }
#news-items { display: flex; gap: 16px; justify-content: center; margin: 16px 0 22px; flex-wrap: wrap; }
#news-items button canvas { width: 150px; height: 150px; }

/* ---------- debug sheet ---------- */
#sheet { overflow: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, 260px); gap: 10px; align-content: start; }
#sheet figure { margin: 0; background: #fff8; border-radius: 12px; padding: 6px; text-align: center; font-size: 14px; }

/* the springy arrival of a screen's things */
.pop-in { animation: popIn 0.5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes popIn { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 30; }
