:root {
  --ink: #23314f; --navy: #1e3a6e; --sky1: #bfe6ff; --sky2: #fff4dc;
  --green: #2fbf71; --green-d: #1f8f53; --gold: #ffc93c; --pink: #ff7aa8;
  --card: #ffffff; --soft: #f3f7ff; --shadow: 0 8px 0 rgba(30, 58, 110, .18), 0 14px 30px rgba(30, 58, 110, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; font-family: Nunito, system-ui, sans-serif; color: var(--ink); background: linear-gradient(var(--sky1), var(--sky2)); overflow: hidden; }
button { font-family: inherit; cursor: pointer; border: 0; color: inherit; }
.screen { position: fixed; inset: 0; display: none; }
.screen.show { display: flex; flex-direction: column; }

/* ---------- home ---------- */
#home { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.cloud { position: absolute; width: 160px; height: 50px; background: #fff; border-radius: 50px; opacity: .85; animation: drift 60s linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 70px; height: 70px; left: 25px; top: -35px; }
.cloud::after { width: 55px; height: 55px; left: 80px; top: -22px; }
.c1 { top: 10%; left: -10%; } .c2 { top: 26%; left: 40%; animation-duration: 80s; transform: scale(.7); } .c3 { top: 6%; left: 70%; animation-duration: 70s; }
@keyframes drift { from { translate: -20vw 0; } to { translate: 120vw 0; } }
.home-wrap { position: relative; min-height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2vw; padding: 70px 3vw 24px; }
.hero { flex: 1 1 45%; display: flex; justify-content: center; align-items: flex-end; align-self: stretch; }
.bryce { max-height: min(78vh, 640px); max-width: 100%; object-fit: contain; filter: drop-shadow(0 12px 18px rgba(30, 58, 110, .25)); }
.side { flex: 0 1 430px; display: flex; flex-direction: column; gap: 10px; }
.title { margin: 0; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: clamp(34px, 5vw, 54px); line-height: .95; color: var(--navy); text-shadow: 0 3px 0 #fff; text-align: center; }
.title span { color: #ff8a3d; display: block; }
.panel { background: var(--card); border-radius: 26px; padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; border: 4px solid #e3ecff; }
.tag { margin: 0; text-align: center; font-weight: 800; }
.panel h2 { margin: 0; font-family: 'Baloo 2'; font-size: 22px; text-align: center; color: var(--navy); }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.level { background: var(--soft); border: 3px solid #d5e2ff; border-radius: 18px; padding: 10px; display: flex; flex-direction: column; font-size: 18px; }
.level small { font-size: 13px; opacity: .75; }
.level.sel { background: #fff6d6; border-color: var(--gold); box-shadow: 0 4px 0 #e5a900; }
.case-row { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; }
.pill { background: var(--soft); border: 3px solid #d5e2ff; border-radius: 999px; padding: 6px 16px; font-weight: 800; font-size: 17px; }
.pill.sel { background: var(--navy); color: #fff; border-color: var(--navy); }
.big-go { background: var(--green); color: #fff; font-family: 'Baloo 2'; font-weight: 800; font-size: 26px; border-radius: 20px; padding: 10px 18px; box-shadow: 0 6px 0 var(--green-d); }
.big-go:active, .zoo-go:active { translate: 0 4px; box-shadow: none; }
.zoo-go { background: var(--gold); font-family: 'Baloo 2'; font-weight: 800; font-size: 20px; border-radius: 18px; padding: 8px 16px; box-shadow: 0 5px 0 #d9a100; color: var(--navy); }
.toggles { display: flex; gap: 10px; justify-content: center; }
.tog { background: var(--soft); border: 3px solid #d5e2ff; border-radius: 14px; padding: 6px 14px; font-weight: 800; }
.tog.off { opacity: .45; text-decoration: line-through; }
.voice-pick { display: flex; gap: 8px; align-items: center; justify-content: center; font-weight: 800; }
.voice-pick[hidden] { display: none; }
.voice-pick select { font: inherit; padding: 4px 8px; border-radius: 10px; border: 2px solid #d5e2ff; }
.ver { margin: 0; text-align: center; font-size: 12px; opacity: .5; }
@media (max-width: 760px) and (orientation: portrait) {
  .home-wrap { flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 60px; }
  .hero { flex: 0 0 auto; align-self: center; } .bryce { max-height: 30vh; }
  .side { flex: 0 0 auto; width: 100%; max-width: 440px; }
}

/* ---------- game ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.menu-pill { background: var(--gold); color: var(--navy); font-weight: 800; font-size: 17px; border-radius: 999px; padding: 8px 16px; box-shadow: 0 4px 0 #d9a100; white-space: nowrap; }
.bar-r { display: flex; gap: 8px; }
.round-btn { width: 48px; height: 48px; border-radius: 50%; background: #fff; font-size: 22px; box-shadow: 0 4px 0 rgba(30, 58, 110, .2); }
.round-btn.off { opacity: .4; }
.stars { display: flex; gap: 6px; font-size: 26px; }
.stars span { filter: grayscale(1) opacity(.35); transition: .3s; }
.stars span.on { filter: none; animation: pop .5s; }
.stage { flex: 1; display: flex; gap: 18px; padding: 6px 18px 18px; min-height: 0; }
.pic-card { flex: 0 0 30%; position: relative; background: #fff; border-radius: 28px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; padding: 14px; }
.pic-card img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pic-card img.pop { animation: bounce .8s; }
.pic-card.sparkly { background: radial-gradient(#fff9d6, #fff); box-shadow: 0 0 0 6px var(--gold), var(--shadow); }
.sparkle-badge { position: absolute; top: 8px; right: 12px; font-size: 34px; animation: pop 1s infinite alternate; }
.trace-card { flex: 1; background: #fffdf6; border-radius: 28px; box-shadow: var(--shadow); position: relative; min-width: 0; }
#trace { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
@media (orientation: portrait) { .stage { flex-direction: column; } .pic-card { flex: 0 0 30%; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-24px) rotate(-4deg); } 60% { transform: translateY(0) rotate(3deg); } }

/* ---------- streak ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30, 58, 110, .45); display: flex; align-items: center; justify-content: center; z-index: 5; }
.overlay[hidden] { display: none; }
.streak-card { position: relative; background: #fff; border-radius: 30px; padding: 22px 26px; box-shadow: var(--shadow); text-align: center; width: min(92vw, 640px); overflow: hidden; }
.streak-card h2 { margin: 0 0 6px; font-family: 'Baloo 2'; font-size: 34px; color: var(--navy); }
.parade { height: 130px; position: relative; overflow: hidden; }
.parade img { position: absolute; bottom: 6px; height: 100px; animation: walk 3.2s ease-out forwards; }
@keyframes walk { from { left: -25%; } to { left: var(--to); } }
.parade img { animation-name: walk, hop; animation-duration: 3.2s, .45s; animation-iteration-count: 1, 7; animation-timing-function: ease-out, ease-in-out; }
@keyframes hop { 50% { transform: translateY(-12px); } }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

/* ---------- zoo ---------- */
#zoo { background: #8fd36b; }
.zoo-title { margin: 0; font-family: 'Baloo 2'; color: var(--navy); font-size: clamp(18px, 3vw, 28px); text-shadow: 0 2px 0 #fff; text-align: center; }
.zoo-scene { position: relative; margin: 0 auto; width: min(100vw, calc((100vh - 72px) * 1.765)); aspect-ratio: 1920 / 1088; background: url(../art/zoo.webp) center / cover; border-radius: 18px; overflow: hidden; }
.zoo-friend { position: absolute; height: 13%; translate: -50% -85%; transition: transform .2s; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .25)); background: none; padding: 0; }
.zoo-friend img { height: 100%; width: auto; display: block; }
.zoo-friend.sparkly { filter: drop-shadow(0 0 10px #ffd84a) drop-shadow(0 0 4px #fff); }
.zoo-friend.sparkly::after { content: '✨'; position: absolute; top: -10%; right: -10%; font-size: 1.6vw; }
.zoo-friend.hi { animation: bounce .8s; }
.zoo-friend.new { animation: pop .7s; }
.zoo-empty { position: absolute; left: 50%; top: 82%; translate: -50% 0; margin: 0; background: #fff; padding: 10px 18px; border-radius: 16px; font-weight: 800; box-shadow: var(--shadow); white-space: nowrap; }
body.calm *, body.calm *::before, body.calm *::after { animation: none !important; transition: none !important; }
.groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.group { position: relative; background: var(--soft); border: 3px solid #d5e2ff; border-radius: 16px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; font-weight: 800; font-size: 16px; }
.group .pics { display: flex; justify-content: center; height: 34px; }
.group .pics img { height: 34px; margin: 0 -5px; }
.group.sel { background: #fff6d6; border-color: var(--gold); box-shadow: 0 4px 0 #e5a900; }
.group.done::after { content: '✓'; position: absolute; top: -8px; right: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #fff; font-size: 15px; line-height: 24px; }
