/* Ezra ABC — kid side. Touch-first, full screen, big chunky candy buttons. */
/* Fredoka is self-hosted (SIL Open Font License) so the game works without Google Fonts. */
@font-face { font-family: 'Fredoka'; font-weight: 500; font-display: swap; src: url(../fonts/fredoka-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url(../fonts/fredoka-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url(../fonts/fredoka-latin-700-normal.woff2) format('woff2'); }
:root {
  --ink: #2b2160;
  --purple: #5b3df5;
  --purple-d: #3f25c9;
  --sky1: #6a4bff;
  --sky2: #29b6ff;
  --paper: #fffaf0;
  --sun: #ffd23f;
  --pink: #ff5ca8;
  --green: #35d07f;
  --orange: #ff8a3d;
  --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);
  --btn: clamp(56px, 7.4vmin, 84px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--purple);
  font-family: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif;
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
#app { position: fixed; inset: 0; }

.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- Shared buttons ---------- */
.round-btn, .pill-btn, .tool-btn, .arrow-btn {
  height: var(--btn); min-width: var(--btn);
  border-radius: calc(var(--btn) / 2);
  background: #fff;
  font-size: calc(var(--btn) * .48);
  box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 10px 20px rgba(0,0,0,.12);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s ease, box-shadow .12s ease;
}
.round-btn:active, .pill-btn:active, .tool-btn:active, .arrow-btn:active, .word-card:active {
  transform: translateY(4px) scale(.96);
  box-shadow: 0 2px 0 rgba(0,0,0,.18), 0 4px 10px rgba(0,0,0,.12);
}
.pill-btn { padding: 0 .7em; font-weight: 700; font-size: calc(var(--btn) * .4); color: var(--purple); letter-spacing: .02em; }
.bar-buttons { display: flex; gap: clamp(8px, 1.4vmin, 16px); align-items: center; }
.hidden { display: none !important; }

/* ---------- Splash ---------- */
#splash {
  background: linear-gradient(170deg, var(--sky1) 0%, #8a5cff 45%, var(--sky2) 100%);
  text-align: center; color: #fff;
}
#splash.active { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4vmin; }
.sky .cloud { position: absolute; background: rgba(255,255,255,.85); border-radius: 999px; filter: blur(.3px); animation: drift 26s linear infinite; }
.sky .cloud::before, .sky .cloud::after { content: ''; position: absolute; background: inherit; border-radius: 50%; }
.sky .cloud::before { width: 55%; height: 160%; left: 12%; top: -70%; }
.sky .cloud::after  { width: 40%; height: 130%; right: 14%; top: -50%; }
.c1 { width: 22vmin; height: 7vmin; top: 12%; left: -25%; }
.c2 { width: 16vmin; height: 5vmin; top: 70%; left: -25%; animation-delay: -9s !important; animation-duration: 32s !important; }
.c3 { width: 28vmin; height: 8vmin; top: 36%; left: -25%; animation-delay: -18s !important; animation-duration: 40s !important; }
@keyframes drift { to { transform: translateX(160vw); } }

.bubble-title { margin: 0; font-weight: 700; font-size: clamp(44px, 11vmin, 120px); line-height: 1; letter-spacing: .02em; position: relative; z-index: 1; }
.bubble-title span {
  display: inline-block; color: #fff;
  -webkit-text-stroke: .06em var(--ink); paint-order: stroke fill;
  text-shadow: 0 .07em 0 var(--ink);
  animation: bob 2.4s ease-in-out infinite;
}
.bubble-title.small { font-size: clamp(30px, 6vmin, 56px); }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-.12em) rotate(3deg); } }

.splash-logo { width: clamp(110px, 24vmin, 230px); height: auto; z-index: 1; filter: drop-shadow(0 1.4vmin 2.4vmin rgba(30,10,90,.35)); animation: bob 3s ease-in-out infinite; }
.home-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.home-logo { width: clamp(48px, 8vmin, 76px); height: auto; filter: drop-shadow(0 4px 6px rgba(30,10,90,.3)); flex: none; }
.blocks { display: flex; gap: 2.4vmin; z-index: 1; }
.blocks span {
  width: 12vmin; height: 12vmin; border-radius: 2.4vmin;
  display: grid; place-items: center; font-weight: 700; font-size: 8.4vmin; color: #fff;
  box-shadow: inset 0 -1.4vmin 0 rgba(0,0,0,.18), 0 1.6vmin 2.4vmin rgba(0,0,0,.2);
  animation: hop 1.6s ease-in-out infinite;
}
.blocks span:nth-child(1) { background: var(--pink); }
.blocks span:nth-child(2) { background: var(--sun); color: var(--ink); animation-delay: .2s; }
.blocks span:nth-child(3) { background: var(--green); animation-delay: .4s; }
@keyframes hop { 0%,100% { transform: translateY(0) rotate(-4deg); } 40% { transform: translateY(-3.5vmin) rotate(5deg); } }

.play-btn {
  z-index: 1; width: 22vmin; height: 22vmin; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff36b, var(--sun) 55%, #f5a400);
  box-shadow: 0 1.6vmin 0 #c97f00, 0 3vmin 5vmin rgba(0,0,0,.25);
  font-size: 10vmin; color: var(--purple-d); padding-left: 1.6vmin;
  animation: pulse 1.4s ease-in-out infinite;
}
.play-btn:active { transform: translateY(1vmin) scale(.95); box-shadow: 0 .6vmin 0 #c97f00; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.hint { margin: 0; font-size: clamp(20px, 3.4vmin, 34px); font-weight: 600; opacity: .9; z-index: 1; }

/* ---------- Home ---------- */
#home {
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,255,.18) 0 8%, transparent 8.2%),
    radial-gradient(circle at 90% 30%, rgba(255,255,255,.12) 0 6%, transparent 6.2%),
    linear-gradient(170deg, var(--sky1), var(--sky2));
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
}
.home-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + var(--safe-t)) calc(18px + var(--safe-r)) 14px calc(18px + var(--safe-l));
  background: linear-gradient(rgba(106,75,255,.95), rgba(106,75,255,.0));
}
.grid {
  display: grid; gap: clamp(12px, 2.2vmin, 24px);
  grid-template-columns: repeat(auto-fill, minmax(clamp(104px, 15vmin, 170px), 1fr));
  padding: 8px calc(20px + var(--safe-r)) calc(30px + var(--safe-b)) calc(20px + var(--safe-l));
}
.tile {
  position: relative; aspect-ratio: 1; border-radius: 22%;
  background: var(--c, var(--pink));
  box-shadow: inset 0 -10px 0 rgba(0,0,0,.16), 0 10px 18px rgba(30,10,90,.25);
  display: grid; place-items: center;
  animation: tileIn .45s cubic-bezier(.2,1.6,.4,1) both;
  animation-delay: calc(var(--i) * 22ms);
}
.tile:active { transform: scale(.92) rotate(-3deg); }
.tile svg { position: absolute; left: 13%; top: 13%; width: 74%; height: 74%; overflow: visible; }
.tile .t-emoji { position: absolute; right: 6%; bottom: 5%; font-size: clamp(22px, 3.6vmin, 38px); filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.tile .t-star { position: absolute; left: 5%; top: 4%; font-size: clamp(20px, 3.2vmin, 34px); animation: twinkle 1.8s ease-in-out infinite; }
@keyframes tileIn { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }
@keyframes twinkle { 50% { transform: scale(1.25) rotate(15deg); } }

/* ---------- Board ---------- */
#board {
  background:
    radial-gradient(circle, rgba(91,61,245,.10) 1.5px, transparent 1.6px) 0 0 / 28px 28px,
    var(--paper);
  touch-action: none;
}
#board canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#fx { pointer-events: none; }
.board-bar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) 0 calc(14px + var(--safe-l));
  pointer-events: none;
}
.board-bar > * { pointer-events: auto; }
.word-card {
  display: inline-flex; align-items: center; gap: .45em;
  height: var(--btn); padding: 0 .9em 0 .35em; border-radius: calc(var(--btn) / 2);
  background: #fff; font-weight: 600; font-size: clamp(20px, 3.6vmin, 36px);
  box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 10px 20px rgba(0,0,0,.12);
  max-width: 46vw; white-space: nowrap; overflow: hidden;
  transition: transform .12s;
}
.word-card.bounce { animation: wiggle .7s ease; }
@keyframes wiggle { 20% { transform: rotate(-6deg) scale(1.08); } 45% { transform: rotate(5deg) scale(1.1); } 70% { transform: rotate(-3deg); } }
.wc-pic { width: calc(var(--btn) - 12px); height: calc(var(--btn) - 12px); display: grid; place-items: center; font-size: calc(var(--btn) * .6); flex: none; }
.wc-pic img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.wc-text { overflow: hidden; text-overflow: ellipsis; }
.wc-text b { color: var(--purple); font-size: 1.2em; }
.wc-speaker { font-size: .8em; opacity: .75; }

.mode-switch { display: inline-flex; background: #fff; border-radius: calc(var(--btn) / 2); padding: 5px; gap: 4px; box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 10px 20px rgba(0,0,0,.12); }
.mode-btn { width: calc(var(--btn) - 10px); height: calc(var(--btn) - 10px); border-radius: 50%; background: transparent; font-size: calc(var(--btn) * .46); opacity: .45; transition: all .2s; }
.mode-btn.on { background: var(--sun); opacity: 1; transform: scale(1.05); }

.arrow-btn {
  position: absolute; top: 50%; z-index: 3; margin-top: calc(var(--btn) * -.5);
  color: #fff; background: var(--purple); font-size: calc(var(--btn) * .42);
  box-shadow: 0 6px 0 var(--purple-d), 0 10px 20px rgba(0,0,0,.18);
}
.arrow-btn.prev { left: calc(12px + var(--safe-l)); padding-right: 4px; }
.arrow-btn.next { right: calc(12px + var(--safe-r)); padding-left: 4px; }
.arrow-btn.glow { background: var(--green); box-shadow: 0 6px 0 #1f9c5a, 0 0 0 0 rgba(53,208,127,.7); animation: glow 1.1s ease-in-out infinite; }
@keyframes glow { 0% { box-shadow: 0 6px 0 #1f9c5a, 0 0 0 0 rgba(53,208,127,.7); transform: scale(1); } 60% { box-shadow: 0 6px 0 #1f9c5a, 0 0 0 26px rgba(53,208,127,0); transform: scale(1.14); } 100% { transform: scale(1); } }

.palette {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; align-items: flex-end; justify-content: center; gap: clamp(12px, 3vmin, 40px);
  padding: 0 calc(14px + var(--safe-r)) calc(14px + var(--safe-b)) calc(14px + var(--safe-l));
  pointer-events: none;
}
.palette > * { pointer-events: auto; }
.swatches {
  display: flex; gap: clamp(6px, 1.2vmin, 14px); align-items: flex-end;
  background: #fff; padding: 10px 14px 12px; border-radius: 28px;
  box-shadow: 0 6px 0 rgba(0,0,0,.14), 0 10px 20px rgba(0,0,0,.1);
  overflow-x: auto; max-width: 100%;
}
.swatch {
  flex: none; width: clamp(40px, 6.2vmin, 66px); height: clamp(52px, 8vmin, 84px);
  border-radius: 40% 40% 14px 14px / 50% 50% 14px 14px; position: relative;
  background: var(--c); box-shadow: inset -6px -6px 0 rgba(0,0,0,.15), inset 6px 6px 0 rgba(255,255,255,.25);
  transition: transform .18s cubic-bezier(.2,1.6,.4,1);
}
.swatch::after { content: ''; position: absolute; left: 22%; right: 22%; bottom: -6px; height: 10px; border-radius: 0 0 8px 8px; background: inherit; filter: brightness(.8); }
.swatch.on { transform: translateY(-14px) scale(1.12); }
.swatch.rainbow { background: conic-gradient(#ff4d4d, #ffb03b, #ffe23b, #3ddc84, #36a8ff, #8a5cff, #ff4dc4, #ff4d4d); }
.swatch.glitter { background: radial-gradient(circle at 30% 30%, #fff 0 8%, transparent 9%), radial-gradient(circle at 70% 60%, #fff 0 6%, transparent 7%), radial-gradient(circle at 40% 75%, #fff 0 5%, transparent 6%), linear-gradient(135deg, #ffd23f, #ff5ca8 50%, #8a5cff); }
.tools { display: flex; gap: clamp(8px, 1.6vmin, 18px); }
.tool-btn.save { background: #fff; box-shadow: 0 6px 0 #e0a800, 0 0 0 5px var(--sun) inset, 0 10px 20px rgba(0,0,0,.12); }
.tool-btn.saved { animation: wiggle .7s ease; }

/* Flying thumbnail when a drawing goes on the fridge */
.flyer { position: fixed; z-index: 50; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.3); border: 6px solid #fff; transition: all .9s cubic-bezier(.5,-0.3,.6,1); pointer-events: none; }

/* ---------- Fridge ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: none; background: rgba(30,15,90,.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.overlay.active { display: block; }
.fridge-door {
  position: absolute; inset: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(90deg, #eef4fb, #ffffff 40%, #e6eef8);
  border-radius: 34px; box-shadow: inset -14px 0 0 #d6e2f0, 0 20px 50px rgba(0,0,0,.35);
  padding: 20px 26px; overflow-y: auto; touch-action: pan-y;
  animation: doorIn .45s cubic-bezier(.2,1.4,.4,1);
}
@keyframes doorIn { from { transform: perspective(1200px) rotateY(-40deg) scale(.8); opacity: 0; } }
.fridge-door h2 { margin: 6px 0 18px; font-size: clamp(28px, 5vmin, 48px); }
.close-btn { position: absolute; top: 16px; right: 26px; }
.fridge-grid { display: grid; gap: 26px; grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 22vmin, 240px), 1fr)); padding: 10px 6px 30px; }
.fridge-grid figure { margin: 0; background: #fff; padding: 10px 10px 6px; border-radius: 6px; box-shadow: 0 8px 16px rgba(0,0,0,.18); position: relative; transform: rotate(var(--r, 0deg)); }
.fridge-grid figure:active { transform: scale(.95) rotate(var(--r)); }
.fridge-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; border-radius: 3px; background: #fffaf0; }
.fridge-grid figcaption { text-align: center; font-weight: 700; font-size: 22px; color: var(--purple); }
.fridge-grid figure::before { content: ''; position: absolute; top: -12px; left: 50%; width: 30px; height: 30px; margin-left: -15px; border-radius: 50%; background: var(--m, var(--pink)); box-shadow: inset -4px -4px 0 rgba(0,0,0,.2), 0 4px 6px rgba(0,0,0,.25); z-index: 1; }
.fridge-empty { font-size: 26px; text-align: center; opacity: .7; margin-top: 10vh; }
.fridge-zoom { position: absolute; inset: 0; display: none; place-items: center; background: rgba(0,0,0,.6); z-index: 2; }
.fridge-zoom.active { display: grid; }
.fridge-zoom img { max-width: 92vw; max-height: 88vh; border: 12px solid #fff; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: zoomIn .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes zoomIn { from { transform: scale(.3) rotate(-10deg); } }

/* ---------- Celebration ---------- */
.party { position: absolute; inset: 0; z-index: 15; display: none; place-items: center; pointer-events: none; }
.party.active { display: grid; pointer-events: auto; }
.party-card {
  background: #fff; border-radius: 40px; padding: 3vmin 6vmin 2.4vmin; text-align: center;
  box-shadow: 0 1.6vmin 0 rgba(0,0,0,.12), 0 3vmin 8vmin rgba(40,10,120,.35);
  animation: pop .6s cubic-bezier(.2,1.8,.4,1) both;
}
@keyframes pop { from { transform: scale(0) rotate(-25deg); } }
.party-pic { font-size: 22vmin; line-height: 1.1; animation: dance 1s ease-in-out infinite; }
.party-pic img { width: 30vmin; height: 30vmin; object-fit: cover; border-radius: 50%; border: 1.2vmin solid var(--sun); }
@keyframes dance { 0%,100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.1); } }
.party-text { font-size: clamp(30px, 6.4vmin, 64px); font-weight: 700; color: var(--purple); }
.party-stars { font-size: clamp(30px, 6vmin, 60px); letter-spacing: .2em; }
.party-stars { animation: twinkle 1s ease-in-out infinite; }

