/* Critter Studio — game styles. GameKit tokens load first. */

:root {
    --cs-wall-a: #FFF3E0;
    --cs-wall-b: #FFE7CC;
    --cs-floor:  #E7B98C;
    --cs-floor-d:#D19A67;
    --cs-panel:  #FFFDF8;
    --cs-ink:    #43304F;
}

html, body { overflow: hidden; }
body { background: var(--cs-wall-a); }

.screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

/* ═══════════ Backdrop — art-studio wall + splats + floor ═══════════ */
#backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bk-wall {
    position: absolute; inset: 0;
    background:
        radial-gradient(circle at 18% 20%, rgba(255,255,255,.55), transparent 40%),
        linear-gradient(160deg, var(--cs-wall-a) 0%, var(--cs-wall-b) 100%);
}
.bk-floor {
    position: absolute; left: 0; right: 0; bottom: 0; height: 16%;
    background: linear-gradient(to bottom, var(--cs-floor) 0%, var(--cs-floor-d) 100%);
    box-shadow: inset 0 6px 12px rgba(120,80,40,.18);
}
.bk-splat { position: absolute; border-radius: 46% 54% 60% 40% / 55% 45% 55% 45%; opacity: .5; filter: blur(.5px); }
.bk-splat.s1 { top: 12%; left: 8%;  width: 120px; height: 110px; background: #FFB3CE; animation: cs-float 13s ease-in-out infinite; }
.bk-splat.s2 { top: 22%; right: 9%; width: 150px; height: 140px; background: #A7E9F6; animation: cs-float 16s ease-in-out infinite reverse; }
.bk-splat.s3 { bottom: 24%; left: 12%; width: 96px; height: 90px; background: #C7E88C; animation: cs-float 18s ease-in-out infinite; }
.bk-splat.s4 { bottom: 30%; right: 14%; width: 108px; height: 100px; background: #FFE7A6; animation: cs-float 15s ease-in-out infinite reverse; }
@keyframes cs-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-16px) rotate(8deg); } }

/* ═══════════ Title screen ═══════════ */
.title-inner {
    flex: 1;
    display: grid;
    grid-template-areas: "top hero" "controls hero";
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    align-items: center;
    justify-items: center;
    padding: clamp(10px, 4vh, 40px) 4vw;
    row-gap: 8px;
}
.t-top { grid-area: top; text-align: center; align-self: end; }
.t-hero { grid-area: hero; align-self: center; justify-self: center; }
.t-controls { grid-area: controls; align-self: start; display: flex; flex-direction: column; align-items: center; gap: 16px; }

.game-title {
    font-size: clamp(2.6rem, 7.4vw, 4.8rem);
    line-height: 1.0;
    background: linear-gradient(100deg, #E63946 5%, #F77F00 26%, #FCBF49 44%, #7CB518 62%, #00B4D8 80%, #B565D8 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 3px 0 rgba(255,255,255,.9)) drop-shadow(0 6px 14px rgba(90,60,130,.28));
}
.tagline {
    margin-top: 12px;
    font-size: clamp(.95rem, 2.4vw, 1.3rem);
    font-weight: bold; color: var(--gk-text);
    background: rgba(255,255,255,.78);
    border-radius: 30px; padding: 6px 18px; display: inline-block;
    box-shadow: 0 3px 10px rgba(90,60,130,.12);
}
#hero-critter { width: clamp(190px, 27vw, 330px); }
#hero-critter .hero-svg { width: 100%; }

.start-btn {
    min-height: 88px; padding: 18px 64px;
    font-size: clamp(1.7rem, 4.6vw, 2.4rem); font-weight: bold; color: #fff;
    border: none; cursor: pointer; border-radius: 60px;
    background: linear-gradient(135deg, #FF7BAC 0%, #B565D8 100%);
    box-shadow: 0 10px 26px rgba(181,101,216,.5), inset 0 -5px 0 rgba(0,0,0,.12);
    transition: transform .15s;
}
.start-btn .btn-pulse { display: inline-block; animation: cs-pulse 1.6s ease-in-out infinite; }
.start-btn:active { transform: scale(.94); }
@keyframes cs-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.055); } }

.title-row { display: flex; gap: 14px; align-items: center; }
.star-pill {
    min-height: 52px; display: flex; align-items: center; padding: 6px 20px;
    font-size: 1.25rem; font-weight: bold;
    background: rgba(255,255,255,.9); border-radius: 30px;
    box-shadow: 0 4px 12px rgba(90,60,130,.16);
}
.parade-btn {
    min-height: 52px; padding: 6px 20px;
    font-size: 1.15rem; font-weight: bold; color: var(--gk-text);
    background: linear-gradient(135deg, #FFE3F1, #FFC9E4);
    border: 3px solid #EA5892; border-radius: 30px; cursor: pointer;
    box-shadow: 0 4px 12px rgba(234,88,146,.3); transition: transform .15s;
}
.parade-btn:active { transform: scale(.93); }

#level-row { display: flex; gap: 16px; }
.lvl-btn {
    position: relative; width: 92px; height: 98px; border: none; cursor: pointer;
    border-radius: 22px; background: linear-gradient(160deg, #FFFFFF, #F3EAFB);
    box-shadow: 0 6px 16px rgba(90,60,130,.2), inset 0 -4px 0 rgba(90,60,130,.08);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    transition: transform .15s;
}
.lvl-btn:active { transform: scale(.93); }
.lvl-num { font-size: 1.25rem; font-weight: bold; color: var(--gk-purple); line-height: 1; }
.lvl-ic { font-size: 2rem; line-height: 1; }
.lvl-stars { font-size: .78rem; letter-spacing: 1px; }
.lvl-stars .dim { filter: grayscale(1) opacity(.4); }
.lvl-btn.locked { filter: grayscale(.85); opacity: .78; }
.lvl-btn .lvl-lock { display: none; }
.lvl-btn.locked .lvl-lock {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 2rem; background: rgba(255,255,255,.45); border-radius: 22px;
}
.lvl-btn.just-unlocked { animation: cs-unlock 1s ease-in-out 3; }
@keyframes cs-unlock {
    0%, 100% { box-shadow: 0 6px 16px rgba(90,60,130,.2); transform: scale(1); }
    50% { box-shadow: 0 0 30px 8px rgba(252,191,73,.8); transform: scale(1.12); }
}
.lvl-btn.shake { animation: cs-shake .5s ease-in-out; }
@keyframes cs-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-7px) rotate(-3deg); } 75% { transform: translateX(7px) rotate(3deg); }
}

.info-btn {
    position: fixed; left: 14px; bottom: 14px; z-index: 30;
    width: 56px; height: 56px; border: none; border-radius: 50%;
    background: rgba(255,255,255,.92); box-shadow: 0 4px 12px rgba(90,60,130,.25);
    font-size: 1.5rem; cursor: pointer; transition: transform .15s;
}
.info-btn:active { transform: scale(.9); }

/* ═══════════ Play / Studio ═══════════ */
#quest-banner {
    flex: none; display: flex; align-items: center; gap: 12px;
    min-height: 60px; padding: 8px 210px 8px 20px;
}
#quest-text {
    font-size: clamp(1rem, 2.6vw, 1.35rem); font-weight: bold; color: var(--gk-text);
    background: rgba(255,255,255,.9); border-radius: 30px; padding: 8px 20px;
    box-shadow: 0 4px 12px rgba(90,60,130,.15);
    animation: cs-banner-in .5s cubic-bezier(.2,1.4,.4,1);
}
#quest-text b { color: var(--gk-purple); }
@keyframes cs-banner-in { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.mood-chip {
    display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 20px;
    transition: transform .2s, background .2s;
}
.mood-chip.matched { background: #FCEBA0; transform: scale(1.25); box-shadow: 0 0 14px 4px rgba(252,191,73,.6); }
#quest-pib { width: 66px; height: 74px; flex: none; }
#quest-pib .pib-critter { width: 100%; height: 100%; }

#studio {
    flex: 1 1 auto; min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
    gap: clamp(8px, 2vw, 22px);
    padding: 0 clamp(10px, 2.5vw, 26px) clamp(10px, 2vh, 20px);
}

#stage-wrap {
    min-width: 0; min-height: 0;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    background: rgba(255,255,255,.55);
    border-radius: 30px; padding: 12px;
    box-shadow: inset 0 2px 14px rgba(120,80,40,.08);
}
/* Showcase = the frame around the critter. Plain while building; snaps into a
   polaroid the moment it comes to life (the exact thing a grown-up screenshots). */
#showcase {
    position: relative;
    flex: 1 1 auto; min-width: 0; min-height: 0; width: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 4px; border-radius: 24px;
    transition: background .4s ease, box-shadow .4s ease, padding .4s ease, transform .4s ease;
}
#critter-stage {
    flex: 1 1 auto; min-height: 0; width: 100%;
    display: flex; align-items: center; justify-content: center;
}
.stage-critter { width: 100%; height: 100%; }

#showcase-caption {
    flex: none; width: 100%;
    display: flex; flex-direction: column; align-items: center; gap: 0;
    padding: 6px 4px 2px;
    animation: cs-pop-in .4s cubic-bezier(.2,1.5,.4,1);
}
#critter-name {
    font-size: clamp(1.2rem, 3vw, 1.7rem); font-weight: bold; color: var(--gk-purple);
    line-height: 1.1;
}
.showcase-tag { font-size: clamp(.72rem, 1.8vw, .95rem); font-weight: bold; color: var(--gk-orange); }

#stage-wrap.showcase #showcase {
    background: #fff;
    padding: 10px 12px 4px;
    box-shadow: 0 14px 32px rgba(90,60,130,.3), inset 0 0 0 1px rgba(0,0,0,.04);
    transform: rotate(-1.5deg);
}
#stage-wrap.showcase.snap #showcase { animation: cs-snap .55s ease; }
@keyframes cs-snap {
    0% { transform: rotate(-1.5deg) scale(1); }
    35% { transform: rotate(1.3deg) scale(1.035); }
    100% { transform: rotate(-1.5deg) scale(1); }
}

.showcase-spark { position: absolute; font-size: 1.7rem; opacity: 0; pointer-events: none; }
.showcase-spark.sp-a { top: 5%; left: 4%; }
.showcase-spark.sp-b { top: 9%; right: 6%; }
.showcase-spark.sp-c { bottom: 22%; right: 9%; }
#stage-wrap.showcase .showcase-spark { animation: cs-spark 1.9s ease-in-out infinite; }
#stage-wrap.showcase .showcase-spark.sp-b { animation-delay: .5s; }
#stage-wrap.showcase .showcase-spark.sp-c { animation-delay: 1s; }
@keyframes cs-spark {
    0%, 100% { opacity: 0; transform: scale(.5) rotate(-15deg); }
    50% { opacity: 1; transform: scale(1.15) rotate(20deg); }
}

#camera-flash {
    position: absolute; inset: 0; background: #fff; opacity: 0;
    pointer-events: none; border-radius: 24px;
}
#camera-flash.go { animation: cs-flash .5s ease-out; }
@keyframes cs-flash { 0% { opacity: 0; } 12% { opacity: .9; } 100% { opacity: 0; } }

.alive-btn {
    flex: none; min-height: 68px; padding: 14px 34px;
    font-size: clamp(1.2rem, 3.2vw, 1.6rem); font-weight: bold; color: #fff;
    border: none; border-radius: 50px; cursor: pointer;
    background: linear-gradient(135deg, #FCC947 0%, #F77F00 100%);
    box-shadow: 0 8px 22px rgba(247,127,0,.45), inset 0 -4px 0 rgba(0,0,0,.12);
    transition: transform .15s, opacity .2s;
}
.alive-btn .btn-pulse { display: inline-block; animation: cs-pulse 1.5s ease-in-out infinite; }
.alive-btn:active:not(:disabled) { transform: scale(.95); }
.alive-btn:disabled { opacity: .5; cursor: default; }
/* clean polaroid: drop the (now-disabled) button once the critter is alive */
#stage-wrap.showcase .alive-btn { display: none; }

#workbench { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#build-panel, #name-panel {
    flex: 1 1 auto; min-height: 0;
    background: var(--cs-panel); border-radius: 26px; padding: 14px;
    box-shadow: 0 8px 24px rgba(90,60,130,.16);
    display: flex; flex-direction: column; gap: 12px;
}
#build-panel.locked { pointer-events: none; opacity: .6; }

#cat-tabs { flex: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cat-tab {
    min-width: 62px; min-height: 58px; padding: 6px 8px;
    border: 3px solid transparent; border-radius: 18px; cursor: pointer;
    background: #F3ECFB; color: var(--gk-text);
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    transition: transform .12s, border-color .15s, background .15s;
}
.cat-tab:active { transform: scale(.92); }
.cat-tab.active { border-color: var(--gk-purple); background: #fff; box-shadow: 0 4px 12px rgba(181,101,216,.28); }
.cat-emoji { font-size: 1.5rem; line-height: 1; }
.cat-label { font-size: .72rem; font-weight: bold; }

#options {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    display: flex; flex-wrap: wrap; gap: 12px; align-content: flex-start; justify-content: center;
    padding: 4px;
}
.opt-chip {
    position: relative;
    width: clamp(74px, 12vw, 94px); height: clamp(74px, 12vw, 94px);
    border: 4px solid transparent; border-radius: 20px; cursor: pointer;
    background: #F7F1FC; padding: 4px;
    transition: transform .12s, border-color .15s, box-shadow .15s;
}
.opt-chip:active { transform: scale(.9); }
.opt-chip.selected {
    border-color: var(--gk-green);
    box-shadow: 0 0 0 3px rgba(124,181,24,.25), 0 6px 14px rgba(124,181,24,.3);
    background: #F2FBE4;
}
.opt-chip .chip-critter { width: 100%; height: 100%; }

/* Rare parts — a little sparkle, and a lock until they're earned */
.opt-chip.rare { background: linear-gradient(135deg, #FFF3D6, #FBE6FF); }
.opt-chip.rare:not(.locked) { box-shadow: 0 0 0 2px rgba(252,191,73,.6), 0 5px 14px rgba(181,101,216,.28); }
.rare-gem { position: absolute; top: 1px; right: 2px; font-size: .82rem; filter: drop-shadow(0 1px 1px rgba(0,0,0,.2)); }
.opt-chip.locked { filter: grayscale(.55); cursor: pointer; }
.opt-chip.locked .chip-critter { opacity: .45; }
.chip-lock {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 1.7rem; border-radius: 16px; background: rgba(255,255,255,.35);
}

.surprise-btn {
    flex: none; min-height: 56px; padding: 10px 20px;
    font-size: 1.15rem; font-weight: bold; color: #fff;
    border: none; border-radius: 40px; cursor: pointer;
    background: linear-gradient(135deg, #00B4D8, #B565D8);
    box-shadow: 0 6px 16px rgba(0,180,216,.35); transition: transform .15s;
}
.surprise-btn:active { transform: scale(.94); }

/* Name panel */
#name-panel { align-items: center; justify-content: center; text-align: center; gap: 16px; }
.name-title { font-size: clamp(1.1rem, 3vw, 1.5rem); color: var(--gk-purple); }
#name-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.name-chip {
    min-height: 52px; min-width: 84px; padding: 8px 16px;
    font-size: 1.1rem; font-weight: bold; color: var(--gk-text);
    border: 3px solid #E0D2F0; border-radius: 30px; cursor: pointer; background: #fff;
    transition: transform .12s, border-color .15s, background .15s;
}
.name-chip:active { transform: scale(.93); }
.name-chip.selected { border-color: var(--gk-pink); background: #FFE9F2; color: var(--gk-purple); }
.save-btn { min-height: 68px; }

/* ═══════════ Overlays ═══════════ */
.overlay {
    position: fixed; inset: 0; z-index: 800;
    display: flex; align-items: center; justify-content: center;
    background: rgba(74,59,92,.45); animation: gk-fade-in .3s ease-out;
    padding: 16px;
}
.overlay-card {
    position: relative; max-width: min(94vw, 640px); max-height: 88vh; overflow-y: auto;
    animation: cs-pop-in .4s cubic-bezier(.2,1.4,.4,1);
}
.overlay-card h3 { color: var(--gk-purple); font-size: clamp(1.3rem, 4vw, 1.7rem); margin-bottom: 12px; text-align: center; }
.overlay-card p { font-size: clamp(.95rem, 2.6vw, 1.1rem); line-height: 1.5; margin-bottom: 10px; }
.close-btn {
    position: absolute; top: 10px; right: 10px; width: 50px; height: 50px;
    border: none; border-radius: 50%; background: #F3ECFB; color: var(--gk-text);
    font-size: 1.3rem; cursor: pointer; box-shadow: 0 3px 8px rgba(90,60,130,.2);
}
.close-btn:active { transform: scale(.9); }

.parade-tally { text-align: center; font-size: clamp(.9rem, 2.4vw, 1.05rem); color: var(--gk-text); margin-bottom: 8px; }
.parade-tally b { color: var(--gk-purple); }

/* Marching band lane */
.parade-lane {
    position: relative; overflow: hidden; width: 100%; height: 96px; margin-bottom: 10px;
    border-radius: 18px;
    background: linear-gradient(180deg, #FFF3D6 0%, #FFE0B8 100%);
    box-shadow: inset 0 2px 10px rgba(120,80,40,.14), inset 0 -8px 10px rgba(120,80,40,.08);
}
.parade-track {
    display: flex; gap: 16px; width: max-content; height: 100%;
    align-items: flex-end; padding: 6px 14px;
    animation: cs-march 22s linear infinite;
}
@keyframes cs-march { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.parade-walker { flex: none; width: 66px; height: 82px; animation: cs-walk .9s ease-in-out infinite; }
.parade-walker .mini-critter { width: 100%; height: 100%; }
@keyframes cs-walk {
    0%, 100% { transform: translateY(0) rotate(-2.5deg); }
    50% { transform: translateY(-6px) rotate(2.5deg); }
}
.parade-hint { text-align: center; font-size: clamp(.85rem, 2.2vw, 1rem); color: var(--gk-text); opacity: .82; margin-bottom: 8px; }

#parade-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px;
}
.parade-cell {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: #FFF8EC; border: none; border-radius: 18px; padding: 8px; width: 100%;
    font-family: inherit; cursor: pointer;
    box-shadow: inset 0 2px 8px rgba(120,80,40,.08);
    transition: transform .12s, box-shadow .15s;
}
.parade-cell:active { transform: scale(.94); }
.parade-cell:hover { box-shadow: 0 4px 14px rgba(181,101,216,.28); }
.parade-art { width: 100%; aspect-ratio: 1 / 1; }
.mini-critter { width: 100%; height: 100%; }
.parade-name { font-weight: bold; color: var(--gk-purple); font-size: 1rem; }
.parade-empty { text-align: center; color: var(--gk-text); grid-column: 1 / -1; }

/* Rename a parade critter */
.rename-row { margin-top: 14px; padding-top: 12px; border-top: 2px dashed #E0D2F0; text-align: center; }
.rename-prompt { font-size: 1.05rem; color: var(--gk-purple); margin-bottom: 10px; }
.rename-prompt b { color: var(--gk-pink); }
.rename-options { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* Rare-unlock toast */
.cs-toast {
    position: fixed; left: 50%; top: 74px; transform: translateX(-50%);
    z-index: 920; max-width: 92vw; text-align: center;
    background: linear-gradient(135deg, #FFF3D6, #FBE6FF);
    color: var(--gk-text); font-weight: bold; font-size: clamp(.95rem, 2.6vw, 1.15rem);
    padding: 12px 22px; border-radius: 30px; border: 3px solid #FCC947;
    box-shadow: 0 8px 24px rgba(90,60,130,.28);
    animation: cs-toast-in .4s cubic-bezier(.2,1.5,.4,1);
}
.cs-toast.out { opacity: 0; transition: opacity .4s ease; }
@keyframes cs-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(.8); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.grownups-hero { width: 120px; height: 130px; margin: 0 auto 10px; }
.tip-row { display: flex; gap: 12px; align-items: flex-start; background: #FFF3D6; border-radius: 18px; padding: 12px 14px; margin-top: 8px; }
.tip-icons { font-size: 1.8rem; flex: none; }

/* ═══════════ Ghost hand ═══════════ */
#ghost-hand {
    position: fixed; z-index: 880; font-size: 2.6rem; pointer-events: none;
    filter: drop-shadow(0 3px 4px rgba(0,0,0,.25));
    animation: cs-hand 1.1s ease-in-out infinite;
}
@keyframes cs-hand { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }

/* ═══════════ Critter rig animations ═══════════ */
.critter-svg { display: block; overflow: visible; animation: cs-bob 3.2s ease-in-out infinite; }
@keyframes cs-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.crt-eyes { transform-box: fill-box; transform-origin: center; animation: cs-blink 4.6s infinite; }
@keyframes cs-blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.12); } }

.crt-ears { transform-box: fill-box; transform-origin: 50% 92%; animation: cs-earwiggle 3s ease-in-out infinite; }
@keyframes cs-earwiggle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.crt-antenna { transform-box: fill-box; transform-origin: 50% 100%; animation: cs-antwiggle 1.9s ease-in-out infinite; }
@keyframes cs-antwiggle { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
.crt-googly { transform-box: fill-box; transform-origin: center; animation: cs-jiggle 2.2s ease-in-out infinite; }
@keyframes cs-jiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

.crt-spiral-eye { transform-box: fill-box; transform-origin: center; animation: cs-spin 3.4s linear infinite; }
@keyframes cs-spin { to { transform: rotate(360deg); } }

.crt-wings { transform-box: fill-box; }
.crt-wing-l { transform-origin: 100% 40%; animation: cs-flap 1.4s ease-in-out infinite; }
.crt-wing-r { transform-origin: 0% 40%; animation: cs-flap 1.4s ease-in-out infinite; }
@keyframes cs-flap { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-15deg); } }

/* one-shot "personality" reactions when you pick a part */
.crt-mouth, .crt-acc { transform-box: fill-box; transform-origin: center; }
@keyframes cs-earpop { 0%, 100% { transform: rotate(-3deg); } 25% { transform: rotate(-13deg); } 75% { transform: rotate(13deg); } }
@keyframes cs-mouthpop { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }
@keyframes cs-accpop { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.22) rotate(-6deg); } }

.crt-figure { transform-box: fill-box; transform-origin: 50% 100%; }
.stage-critter.pop .crt-figure { animation: cs-poppy .35s ease-out; }
@keyframes cs-poppy { 0% { transform: scale(1); } 40% { transform: scale(1.09) translateY(-4px); } 100% { transform: scale(1); } }

/* Signature "bring to life" moment: blink, inflate, bounce */
.stage-critter.alive .crt-figure { animation: cs-boing .82s ease-in-out 2; }
@keyframes cs-boing {
    0% { transform: scale(1,1) translateY(0); }
    16% { transform: scale(1.16,.86) translateY(0); }
    38% { transform: scale(.9,1.14) translateY(-22px); }
    58% { transform: scale(1.06,.96) translateY(0); }
    78% { transform: scale(.98,1.02) translateY(-6px); }
    100% { transform: scale(1,1) translateY(0); }
}
.stage-critter.alive .crt-eyes { animation: cs-bigblink .82s ease-in-out 2; }
@keyframes cs-bigblink { 0%, 100% { transform: scaleY(1); } 30% { transform: scaleY(.1); } 60% { transform: scaleY(1.15); } }

@keyframes cs-pop-in { from { opacity: 0; transform: scale(.7) translateY(16px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.chip-critter { animation: none; }

/* ═══════════ Portrait layout ═══════════ */
@media (max-aspect-ratio: 1 / 1) {
    .title-inner {
        grid-template-areas: "top" "hero" "controls";
        grid-template-columns: 1fr; grid-template-rows: auto auto auto;
        row-gap: 6px;
    }
    #hero-critter { width: clamp(150px, 34vw, 240px); }
    #studio { grid-template-columns: 1fr; grid-template-rows: minmax(0, 0.9fr) minmax(0, 1.1fr); }
    #stage-wrap { padding: 8px; }
    #quest-banner { padding: 8px 188px 8px 18px; }
}

/* Very short landscape: shrink hero so controls fit */
@media (max-height: 560px) and (min-aspect-ratio: 1 / 1) {
    #hero-critter { width: clamp(150px, 20vw, 220px); }
    .lvl-btn { width: 82px; height: 88px; }
}

@media (prefers-reduced-motion: reduce) {
    .critter-svg, .crt-eyes, .crt-ears, .crt-antenna, .crt-googly,
    .crt-spiral-eye, .crt-wings, .crt-wing-l, .crt-wing-r,
    .bk-splat, .start-btn .btn-pulse, .alive-btn .btn-pulse, #ghost-hand,
    .stage-critter.pop .crt-figure, .stage-critter.alive .crt-figure, .stage-critter.alive .crt-eyes,
    #stage-wrap.showcase .showcase-spark, #stage-wrap.showcase.snap #showcase, #camera-flash.go,
    .parade-track, .parade-walker, .cs-toast {
        animation: none !important;
    }
    /* keep the polaroid readable without the tilt */
    #stage-wrap.showcase #showcase { transform: none; }
    .showcase-spark { opacity: .9 !important; }
}
