/* CodeCubs — bright, rounded, big-touch design for ages 4–10 */
:root {
  --sky: #3EC1F3; --sun: #FFC93C; --leaf: #5BD16E; --coral: #FF6B6B; --lav: #8E7CFF;
  --navy: #24305E; --cream: #FFF8E7; --card: #FFFFFF; --muted: #6B7395; --line: #E9E1CC;
  --r: 22px; --shadow: 0 6px 0 rgba(36, 48, 94, .12), 0 10px 24px rgba(36, 48, 94, .08);
  --font: 'Fredoka', 'Nunito', 'Quicksand', ui-rounded, 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); color: var(--navy); background: var(--cream);
  background-image: radial-gradient(circle at 10% 10%, #FFF1C9 0 120px, transparent 121px), radial-gradient(circle at 92% 30%, #DFF5FF 0 160px, transparent 161px), radial-gradient(circle at 30% 95%, #E5F9DF 0 140px, transparent 141px);
  background-attachment: fixed; font-size: 18px; line-height: 1.35; overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 4px solid var(--sun); outline-offset: 2px; }
h1, h2 { margin: .2em 0; line-height: 1.15; }
h1 { font-size: clamp(26px, 4.5vw, 40px); }
svg { display: block; }
#app { max-width: 1280px; margin: 0 auto; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }

/* ---------- Buttons ---------- */
.btn { border-radius: 999px; padding: 12px 22px; font-size: 20px; font-weight: 700; min-height: 56px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: var(--shadow); transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(36, 48, 94, .15); }
.btn-go { background: var(--leaf); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.btn-go.go { background: var(--coral); min-width: 120px; font-size: 22px; }
.btn-go:disabled { opacity: .6; }
.btn-go.big { font-size: 24px; padding: 14px 32px; }
.btn-go.huge { font-size: 30px; padding: 16px 44px; min-height: 72px; background: var(--coral); }
.btn-soft { background: #fff; border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn-soft.on { background: #FFF3C4; border-color: var(--sun); }
.btn-danger { background: var(--coral); color: #fff; }
.btn.sm { min-height: 40px; padding: 6px 14px; font-size: 16px; }
.icon-btn { width: 52px; height: 52px; border-radius: 16px; background: #fff; font-size: 26px; box-shadow: var(--shadow); display: grid; place-items: center; flex: none; }
.icon-btn.pulse { animation: pulse 1s infinite; background: #FFF3C4; }
.link-btn { font-size: 17px; font-weight: 600; color: var(--muted); text-decoration: underline; padding: 10px; }
.chip { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 16px; }

/* ---------- Logo ---------- */
.logo-full { display: flex; align-items: center; gap: 12px; }
.logo-full .logo-mark { width: 84px; height: 84px; }
.wordmark { font-size: 48px; font-weight: 700; letter-spacing: -.5px; }
.w-code { color: var(--navy); } .w-cubs { color: var(--coral); }
.brand-sm .logo-mark { width: 42px; height: 42px; } .brand-sm .wordmark { font-size: 26px; }

/* ---------- Welcome & wizard ---------- */
.welcome, .wizard { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 28px 16px; text-align: center; }
.welcome-logo { margin-top: 3vh; animation: bob 3s ease-in-out infinite; }
.tagline { font-size: 22px; color: var(--muted); margin: 4px 0 20px; font-weight: 600; }
.who { font-size: 28px; }
.players { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin: 12px 0 28px; max-width: 900px; }
.player { width: 150px; padding: 14px 10px; background: #fff; border-radius: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .15s; }
.player:hover { transform: translateY(-4px) rotate(-1deg); }
.player-face { width: 100px; height: 100px; display: grid; place-items: center; }
.player-face svg { width: 100%; height: 100%; }
.player-face.plus { font-size: 64px; color: var(--sky); background: #EAF8FF; border-radius: 50%; width: 92px; height: 92px; }
.player b { font-size: 21px; } .player small { color: var(--muted); font-size: 14px; }
.welcome-foot { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; }
.wiz-cubby { width: 150px; animation: bob 2.5s ease-in-out infinite; }
.wiz-face { width: 130px; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; max-width: 620px; width: 100%; margin: 16px 0; }
.avatar { background: #fff; border-radius: 24px; padding: 10px; box-shadow: var(--shadow); aspect-ratio: 1; transition: transform .12s; }
.avatar:hover, .avatar:focus-visible { transform: scale(1.06); }
.avatar svg { width: 100%; height: 100%; }
.sub { color: var(--muted); margin: 0 0 12px; }
.name-input { font-family: inherit; font-size: 28px; padding: 14px 20px; border-radius: 20px; border: 4px solid var(--line); text-align: center; width: min(360px, 90vw); color: var(--navy); background: #fff; }
.wiz-btns { display: flex; gap: 14px; margin-top: 22px; }
.age-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 760px; width: 100%; margin-top: 16px; }
.age { background: #fff; border-radius: 28px; padding: 22px 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 6px; border: 5px solid transparent; transition: transform .12s; }
.age:hover { transform: translateY(-4px); }
.age-1 { border-color: var(--leaf); } .age-2 { border-color: var(--sky); } .age-3 { border-color: var(--lav); }
.age-emoji { font-size: 58px; } .age b { font-size: 24px; } .age small { color: var(--muted); font-size: 15px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: rgba(255, 248, 231, .92); backdrop-filter: blur(8px); }
.me { display: flex; align-items: center; gap: 8px; background: #fff; padding: 4px 14px 4px 4px; border-radius: 999px; box-shadow: var(--shadow); font-size: 18px; }
.me-face { width: 44px; height: 44px; } .me-face svg { width: 100%; height: 100%; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pill { background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 700; box-shadow: var(--shadow); font-size: 18px; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; }

/* ---------- Map ---------- */
.map, .world, .album, .shop, .parent { padding: 8px 16px 40px; }
.hero { display: flex; align-items: center; gap: 18px; background: linear-gradient(135deg, #DFF5FF, #FFF3C4); border-radius: 32px; padding: 18px 24px; box-shadow: var(--shadow); margin: 8px 0 18px; }
.hero-cubby { width: 140px; flex: none; animation: bob 2.8s ease-in-out infinite; }
.hero-text p { margin: 4px 0 14px; color: var(--muted); font-weight: 600; }
.sec { font-size: 24px; margin: 22px 4px 10px; }
.islands { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.island-card { position: relative; background: #fff; border-radius: 28px; padding: 12px 16px 16px; box-shadow: var(--shadow); text-align: left; display: flex; flex-direction: column; gap: 4px; border-bottom: 8px solid var(--wc); transition: transform .15s; }
.island-card:hover { transform: translateY(-4px); }
.island-card b { font-size: 22px; } .island-card small { color: var(--muted); font-size: 15px; }
.island-art { height: 110px; } .island-art svg { width: 100%; height: 100%; }
.island-prog { font-weight: 700; margin-top: 4px; }
.island-card.locked { filter: grayscale(.85); opacity: .75; }
.island-card .lock { position: absolute; top: 12px; right: 14px; font-size: 32px; }
.chest { display: flex; align-items: center; gap: 12px; margin: 0 auto; background: var(--sun); border-radius: 24px; padding: 10px 26px; box-shadow: var(--shadow); font-size: 22px; animation: wiggle 2.2s ease-in-out infinite; }
.chest-ico { font-size: 44px; }
.map-foot { display: flex; gap: 16px; margin-top: 22px; flex-wrap: wrap; }
.tile-btn { flex: 1; min-width: 150px; background: #fff; border-radius: 24px; padding: 16px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 22px; }
.tile-btn span { font-size: 40px; }

/* ---------- World path ---------- */
.world-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 16px; }
.world-head p { margin: 0; color: var(--muted); }
.world-art { width: 120px; flex: none; }
.path { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.node { position: relative; background: #fff; border-radius: 26px; padding: 12px 8px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 2px; border: 4px solid transparent; animation: pop .35s backwards; animation-delay: calc(var(--i) * 40ms); }
.node.current { border-color: var(--coral); animation: pop .35s backwards, glow 1.6s 0.5s infinite; }
.node.done { border-color: var(--leaf); }
.node.locked { opacity: .55; }
.node-face { width: 78px; height: 78px; display: grid; place-items: center; font-size: 34px; }
.node-face svg { width: 100%; height: 100%; }
.node-n { position: absolute; top: 8px; left: 10px; background: var(--wc, var(--sky)); color: #fff; border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; font-size: 17px; }
.node-title { font-weight: 600; font-size: 16px; text-align: center; }
.stars b { color: #DDD5C2; font-size: 22px; } .stars b.on { color: var(--sun); text-shadow: 0 2px 0 #E8A400; }

/* ---------- Play layout ---------- */
.play { min-height: 100vh; display: flex; flex-direction: column; }
.play-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.play-title { flex: 1; display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.play-title small { color: var(--muted); font-weight: 600; font-size: 14px; }
.play-title b { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-main { flex: 1; display: grid; grid-template-columns: 1fr; gap: 14px; padding: 0 14px 18px; }
@media (min-width: 900px), (orientation: landscape) and (min-width: 700px) {
  .play-main { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
}
.board-wrap { display: flex; flex-direction: column; gap: 12px; }
.board { background: #fff; border-radius: 30px; padding: 10px; box-shadow: var(--shadow); display: flex; justify-content: center; }
.board-svg { width: 100%; max-height: 52vh; }
@media (min-width: 900px) { .board-svg { max-height: 70vh; } }
.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mission { background: #fff; border-radius: 20px; padding: 14px 18px; font-size: 19px; font-weight: 600; box-shadow: var(--shadow); border-left: 8px solid var(--sky); }
.mission.oops { border-left-color: var(--coral); background: #FFF0F0; }
.mission.good { border-left-color: var(--leaf); background: #F0FFF2; }
.mission.hint { border-left-color: var(--sun); background: #FFF8DD; }
.needs { margin-top: 8px; font-size: 15px; color: var(--muted); }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.controls .go { margin-left: auto; }
.count { color: var(--muted); font-weight: 600; font-size: 15px; }

/* Board animation */
.bot-pos { transition: transform .38s cubic-bezier(.35, 1.4, .6, 1); }
.bot-body { transform-box: fill-box; transform-origin: 50% 80%; }
.bot-body.hop { animation: hop .42s ease-out; }
.bot-body.bump { animation: bump .6s ease; }
.bot-body.dance { animation: dance .5s ease-in-out 4; }
.goal-friend.cheer { animation: cheer .45s ease-in-out 4; transform-box: fill-box; transform-origin: 50% 100%; }
.gem-wrap { transition: transform .3s, opacity .3s; transform-box: fill-box; transform-origin: center; }
.gem-wrap.taken { transform: scale(1.8) translateY(-20px); opacity: 0; }
.gem { animation: twinkle 2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.ghost-step { animation: fadein .3s backwards; }
.antenna { animation: blink 2s infinite; }

/* ---------- Block editor ---------- */
.editor { display: flex; flex-direction: column; gap: 12px; }
.program { min-height: 96px; background: #fff; border-radius: 22px; padding: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; box-shadow: inset 0 0 0 4px var(--line); }
.program.target { box-shadow: inset 0 0 0 4px var(--sky); }
.prog-hint { color: var(--muted); font-weight: 600; align-self: center; padding: 8px; }
.palette { display: flex; flex-wrap: wrap; gap: 10px; }
.pal { min-width: 70px; min-height: 70px; border-radius: 20px; background: var(--sky); color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; box-shadow: 0 6px 0 #1E8DBA; transition: transform .08s; }
.pal:active { transform: translateY(4px); box-shadow: 0 2px 0 #1E8DBA; }
.pal-ico { font-size: 34px; line-height: 1; }
.pal-repeat { background: var(--lav); box-shadow: 0 6px 0 #6352D6; }
.pal-jump { background: var(--sun); color: var(--navy); box-shadow: 0 6px 0 #D9A200; }
.pal-ifrock { background: var(--leaf); box-shadow: 0 6px 0 #34A14B; }
.editor-sprout .pal { min-width: 86px; min-height: 86px; }
.editor-sprout .pal-ico { font-size: 46px; }
.blk { position: relative; min-width: 58px; min-height: 58px; border-radius: 16px; background: #E6F7FF; border: 3px solid var(--sky); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 12px; font-weight: 700; }
.blk.new { animation: pop .25s; }
.blk-ico { font-size: 30px; }
.editor-sprout .blk { min-width: 66px; min-height: 66px; } .editor-sprout .blk-ico { font-size: 38px; }
.blk.running { background: #FFF3C4; border-color: var(--sun); transform: scale(1.12); box-shadow: 0 0 0 5px rgba(255, 201, 60, .45); z-index: 2; }
.blk-x { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%; background: var(--coral); color: #fff; font-size: 14px; display: grid; place-items: center; box-shadow: 0 2px 0 #C94848; }
.blk-dir { font-size: 26px; background: #fff; border-radius: 12px; padding: 2px 6px; border: 2px dashed currentColor; }
.blk-jump { background: #FFF6D6; border-color: var(--sun); }
.blk-if { background: #E9FBEA; border-color: var(--leaf); flex-wrap: wrap; max-width: 260px; }
.blk-txt { font-size: 18px; } .blk-txt.small { font-size: 13px; color: var(--muted); width: 100%; text-align: center; }
.blk-rep { flex-direction: column; align-items: stretch; background: #F1EEFF; border-color: var(--lav); padding: 8px; flex-basis: 100%; }
.rep-head { display: flex; align-items: center; gap: 10px; font-size: 19px; }
.rep-n { background: var(--lav); color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 18px; min-height: 40px; }
.rep-n.big { font-size: 20px; padding: 10px 18px; }
.rep-body { margin-top: 8px; min-height: 70px; border: 3px dashed #C5BCFF; border-radius: 14px; padding: 10px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: #fff; }
.rep-body.target { border-color: var(--lav); background: #FBFAFF; box-shadow: 0 0 0 4px rgba(142, 124, 255, .25); }
.rep-hint { color: var(--muted); font-size: 15px; }
.editor.locked .palette { opacity: .5; pointer-events: none; }
.twin-wrap { background: #1E2547; color: #fff; border-radius: 18px; padding: 10px 14px; }
.twin-wrap summary { font-weight: 700; cursor: pointer; }
.twin { margin: 8px 0 0; font-size: 16px; color: #C9F7D0; white-space: pre-wrap; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }

/* ---------- Python ---------- */
.code-wrap { display: flex; background: #1E2547; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); min-height: 220px; }
.gutter { padding: 14px 6px; text-align: right; color: #7C86B8; font: 17px/1.5 ui-monospace, Menlo, Consolas, monospace; user-select: none; overflow: hidden; min-width: 38px; }
.gutter span { display: block; padding: 0 6px; border-radius: 6px; }
.gutter .cur { background: var(--sun); color: var(--navy); }
.gutter .err { background: var(--coral); color: #fff; }
.code { flex: 1; resize: vertical; border: 0; background: transparent; color: #F5F7FF; font: 17px/1.5 ui-monospace, Menlo, Consolas, monospace; padding: 14px 12px; min-height: 220px; outline: none; tab-size: 4; white-space: pre; }
.snips { display: flex; flex-wrap: wrap; gap: 8px; }
.snip { background: #F1EEFF; border: 2px solid var(--lav); border-radius: 12px; padding: 8px 12px; font: 600 15px ui-monospace, Menlo, Consolas, monospace; color: #4B3BB5; min-height: 44px; }
.console { background: #fff; border-radius: 16px; padding: 12px 14px; min-height: 60px; margin: 0; white-space: pre-wrap; font: 16px/1.45 ui-monospace, Menlo, Consolas, monospace; box-shadow: var(--shadow); max-height: 200px; overflow: auto; }
.console:empty::before { content: 'Messages from your program appear here.'; color: var(--muted); font-family: var(--font); }
.console .err { color: #C0392B; font-family: var(--font); font-weight: 600; }
.console .warn { color: #B26B00; font-family: var(--font); font-weight: 600; }
.console .hint { color: #4B3BB5; }
.py-status { color: var(--lav); font-weight: 600; }

/* ---------- Science ---------- */
.sci-body { padding: 0 14px 30px; display: flex; flex-direction: column; gap: 14px; max-width: 1000px; margin: 0 auto; width: 100%; }
.sci-dots { display: flex; gap: 8px; justify-content: center; }
.sci-dots i { width: 16px; height: 16px; border-radius: 50%; background: #E3DCC8; } .sci-dots i.on { background: var(--leaf); }
.sci-stage { display: flex; flex-direction: column; gap: 16px; }
.space { background: linear-gradient(#1B2150, #2D2A6E); border-radius: 30px; padding: 16px; box-shadow: var(--shadow); }
.space-lane { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding: 8px 4px; }
.sun-wrap { width: 90px; flex: none; }
.slot { flex: none; width: 82px; min-height: 100px; border-radius: 18px; border: 3px dashed rgba(255, 255, 255, .45); color: rgba(255, 255, 255, .7); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; }
.slot.filled { border-style: solid; border-color: var(--sun); color: #fff; font-size: 13px; animation: pop .3s; }
.slot svg { width: 70px; height: 70px; }
.tray { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; padding: 14px 4px 4px; }
.planet-btn, .pic-btn { width: 110px; padding: 6px; border-radius: 20px; background: rgba(255, 255, 255, .12); color: #fff; display: flex; flex-direction: column; align-items: center; font-weight: 600; font-size: 15px; }
.planet-btn svg { width: 90px; height: 90px; }
.pic-btn { background: #fff; color: var(--navy); box-shadow: var(--shadow); width: 130px; }
.pic-btn svg { width: 100px; height: 100px; }
.plant-line { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; background: #E9FBEA; border-radius: 26px; padding: 14px; }
.plant-slot { width: 110px; min-height: 130px; border-color: #9ED9A6; color: #6BB777; background: #fff; }
.plant-slot.filled { color: var(--navy); border-color: var(--leaf); }
.plant-slot svg { width: 90px; height: 90px; }
.needs-grid, .lab-grid, .shop-grid, .sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.need-btn { background: #fff; border-radius: 22px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 18px; border: 4px solid transparent; }
.need-btn.ok { border-color: var(--leaf); background: #F0FFF2; } .need-btn.no { border-color: var(--coral); opacity: .55; }
.big-emoji { font-size: 50px; line-height: 1; } .huge-emoji { font-size: 96px; line-height: 1; }
.circuit-wrap { background: #fff; border-radius: 30px; padding: 16px; box-shadow: var(--shadow); }
.circuit { width: 100%; max-height: 56vh; }
.circuit .sw:hover rect { fill: #FFF8DD; }
.count-game { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.plate { background: #fff; border-radius: 50%; width: min(320px, 80vw); aspect-ratio: 1; box-shadow: var(--shadow), inset 0 0 0 14px #F4EEDD; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; align-content: center; gap: 4px; padding: 40px; }
.cookie-pic { width: 70px; height: 70px; } .cookie-pic svg { width: 100%; height: 100%; }
.num-row { display: flex; gap: 16px; }
.num-btn { width: 96px; height: 96px; border-radius: 26px; background: var(--sky); color: #fff; font-size: 48px; font-weight: 700; box-shadow: 0 6px 0 #1E8DBA; }
.binary { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.bin-target { font-size: 28px; font-weight: 700; } .bin-target b { color: var(--coral); font-size: 40px; }
.bin-cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.bin-card { width: 132px; min-height: 190px; border-radius: 22px; background: #2B2F55; color: #fff; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow); transition: transform .2s, background .2s; }
.bin-card.on { background: #FFF3C4; color: var(--navy); transform: translateY(-6px); }
.bin-card:not(.on) .bin-cookies { opacity: .15; }
.bin-cookies { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; min-height: 92px; align-content: center; }
.mini-cookie { width: 26px; height: 26px; } .mini-cookie svg { width: 100%; height: 100%; }
.bin-num { font-size: 30px; } .bin-bit { font: 700 26px ui-monospace, Menlo, monospace; background: rgba(0, 0, 0, .12); border-radius: 10px; padding: 0 12px; }
.bin-sum { font-size: 20px; font-weight: 600; } .bin-sum code { font-size: 26px; background: #1E2547; color: var(--sun); padding: 2px 10px; border-radius: 10px; }
.sort-current { background: #fff; border-radius: 30px; padding: 18px; display: flex; flex-direction: column; align-items: center; box-shadow: var(--shadow); font-size: 26px; animation: pop .3s; }
.sort-bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.sort-bin { border-radius: 26px; padding: 16px 10px; min-height: 160px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 20px; box-shadow: var(--shadow); }
.bin-pile { font-size: 30px; display: flex; flex-wrap: wrap; justify-content: center; }
.lab-card { background: #fff; border-radius: 26px; padding: 16px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; transition: transform .15s; }
.lab-card:hover { transform: translateY(-4px); }
.lab-emoji { font-size: 56px; } .lab-card b { font-size: 20px; } .lab-card small { color: var(--muted); font-size: 14px; }

/* ---------- Art ---------- */
.art-wrap { background: #fff; border-radius: 30px; padding: 10px; box-shadow: var(--shadow); }
.art-canvas { width: 100%; border-radius: 22px; aspect-ratio: 1; touch-action: none; }
.art-prog .blk { cursor: pointer; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: flex; background: #fff; border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.seg-b { border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 16px; }
.seg-b.on { background: var(--lav); color: #fff; }

/* ---------- Album / shop ---------- */
.sticker { background: #fff; border-radius: 24px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; animation: pop .3s; }
.sticker svg { width: 90px; height: 90px; }
.sticker.missing { filter: grayscale(1) brightness(1.4); opacity: .45; }
.sticker.emoji span { font-size: 64px; line-height: 90px; }
.shop-preview { width: 180px; margin: 0 auto; animation: bob 2.8s ease-in-out infinite; }
.shop-item { background: #fff; border-radius: 24px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; border: 4px solid transparent; }
.shop-item.on { border-color: var(--leaf); }
.shop-ico { width: 90px; } .swatch { width: 70px; height: 70px; border-radius: 50%; border: 4px solid var(--navy); margin: 10px; }
.shop-item small { color: var(--muted); }

/* ---------- Parent ---------- */
.parent { max-width: 860px; margin: 0 auto; }
.card { background: #fff; border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); margin: 14px 0; }
.card h2 { font-size: 22px; }
.muted, .muted-card p { color: var(--muted); }
.kid { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 2px solid #F3EEE0; flex-wrap: wrap; }
.kid-face { width: 60px; flex: none; }
.kid-info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 220px; }
.kid-info small { color: var(--muted); font-size: 15px; }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0; font-size: 17px; }
.check input { width: 22px; height: 22px; }
select, .auth input { font-family: inherit; font-size: 18px; padding: 10px 12px; border-radius: 14px; border: 3px solid var(--line); background: #fff; color: var(--navy); }
.auth { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.err { color: #C0392B; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #fff; border-radius: 20px; padding: 16px; box-shadow: var(--shadow); text-align: center; }
.stat b { font-size: 34px; display: block; color: var(--sky); } .stat small { color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: 16px; }
.tbl th, .tbl td { text-align: left; padding: 8px; border-bottom: 2px solid #F3EEE0; }
.gate { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }

/* ---------- Modal, toast, confetti ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(36, 48, 94, .45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fadein .2s; }
.modal-back.out { animation: fadeout .25s forwards; }
.modal { position: relative; background: #fff; border-radius: 32px; padding: 26px 22px; max-width: 520px; width: 100%; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: popin .35s cubic-bezier(.3, 1.5, .5, 1); }
.modal-x { position: absolute; top: 10px; right: 12px; font-size: 22px; width: 44px; height: 44px; border-radius: 50%; }
.win, .learn { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.win-art { display: flex; gap: 10px; align-items: flex-end; justify-content: center; }
.win-art > div { width: 130px; }
.win-art > div:last-child svg { animation: cheer .45s ease-in-out 5; }
.win-stars .stars b { font-size: 54px; }
.win-coins { font-size: 26px; font-weight: 700; margin: 0; }
.win-sticker { background: #FFF3C4; border-radius: 999px; padding: 6px 16px; font-weight: 700; }
.win-tip { color: var(--muted); font-weight: 600; }
.win-btns { display: flex; gap: 12px; margin-top: 10px; }
.win-btns .btn { white-space: nowrap; }
.learn-badge { background: var(--sun); border-radius: 999px; padding: 6px 16px; font-weight: 700; }
.learn-art { width: 120px; }
.chest-big { font-size: 90px; animation: wiggle .6s 3; } .treasure { font-size: 80px; animation: popin .5s; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 999px; font-weight: 600; z-index: 200; transition: transform .3s; max-width: 92vw; text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
.rest { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 20px; background: linear-gradient(#2D2A6E, #1B2150); color: #fff; }
.rest p { font-size: 22px; max-width: 480px; } .rest-cubby { width: 200px; animation: bob 4s ease-in-out infinite; } .rest .link-btn { color: #C9C1FF; }

/* ---------- Animations ---------- */
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes popin { from { transform: scale(.7); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.12); } }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgba(255, 107, 107, .25), var(--shadow); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes hop { 40% { transform: translateY(-60px) scale(1.05); } }
@keyframes bump { 25% { transform: translate(var(--bx), var(--by)); } 50% { transform: translate(calc(var(--bx) * -.4), calc(var(--by) * -.4)) rotate(-6deg); } 75% { transform: rotate(5deg); } }
@keyframes dance { 25% { transform: translateY(-14px) rotate(-8deg); } 75% { transform: translateY(-14px) rotate(8deg); } }
@keyframes cheer { 50% { transform: translateY(-16px); } }
@keyframes twinkle { 50% { transform: scale(1.08); } }
@keyframes blink { 50% { fill: #FFF3C4; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.shake { animation: wiggle .25s 2; }
.reduce-motion *, .reduce-motion *::before { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .05s !important; }
@media (prefers-reduced-motion: reduce) { * { animation-iteration-count: 1 !important; } }

/* ---------- Small phones ---------- */
@media (max-width: 560px) {
  body { font-size: 17px; }
  .wordmark { font-size: 38px; } .logo-full .logo-mark { width: 66px; height: 66px; }
  .avatar-grid { grid-template-columns: repeat(3, 1fr); }
  .age-grid { grid-template-columns: 1fr; }
  .age { flex-direction: row; justify-content: flex-start; gap: 14px; padding: 14px 18px; text-align: left; }
  .age-emoji { font-size: 44px; }
  .hero { flex-direction: column; text-align: center; padding: 16px; }
  .hero-cubby { width: 110px; }
  .me b { display: none; } .me { padding: 4px; }
  .pill { padding: 5px 10px; font-size: 16px; }
  .path { grid-template-columns: repeat(2, 1fr); }
  .pal { min-width: 62px; min-height: 62px; } .pal-ico { font-size: 30px; }
  .editor-sprout .pal { min-width: 74px; min-height: 74px; flex: 1; }
  .play-title b { font-size: 19px; }
  .btn-go.go { min-width: 100px; }
  .player { width: 130px; } .player-face { width: 84px; height: 84px; }
}

/* ---------- Drag and drop (fingers or mouse; tapping still works) ---------- */
.pal, .blk, .planet-btn, .pic-btn, .sort-current { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.blk, .sort-current { cursor: grab; }
.drag-ghost { position: fixed !important; left: 0; top: 0; margin: 0; z-index: 300; pointer-events: none; opacity: .95; box-shadow: 0 16px 34px rgba(36, 48, 94, .3); transition: none !important; animation: none !important; }
.dragging { opacity: .35; }
.program.drop-over, .rep-body.drop-over { box-shadow: inset 0 0 0 5px var(--sun) !important; background: #FFFBEA; }
.space-lane.drop-over, .plant-line.drop-over { box-shadow: 0 0 0 5px var(--sun); }
.sort-bin.drop-over { transform: scale(1.06); box-shadow: 0 0 0 5px var(--sun), var(--shadow); }
.editor.drag-out .program { box-shadow: inset 0 0 0 4px var(--coral); }
.drop-caret { width: 6px; height: 56px; border-radius: 3px; background: var(--coral); align-self: center; animation: pulse .8s infinite; }
