:root {
    --ink: #3a3222;
    --ink-soft: #7a6f58;
    --paper: #fffdf7;
    --a: #ff9a3c;
    --a-dark: #d9741a;
    --b: #8a5cd6;
    --b-dark: #6a3fb8;
    --grass: #7cc35a;
    --good: #2fbf71;
    --bad: #ff6b6b;
    --shadow: 0 6px 0 rgba(0, 0, 0, .07), 0 12px 26px rgba(110, 90, 50, .14);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
    color: var(--ink);
    background: linear-gradient(175deg, #fff3cf 0%, #fffaf0 45%, #eaf7dc 100%);
    min-height: 100vh;
    padding: 56px 14px 60px;
    font-size: 1.15rem;
    line-height: 1.45;
}

main { max-width: 680px; margin: 0 auto; display: grid; gap: 1.2rem; }

.topbar { position: fixed; top: 10px; left: 0; right: 0; z-index: 10; display: flex; gap: 8px; justify-content: center; }
.chip {
    font-family: inherit; border: 2px solid #fff; cursor: pointer; font-weight: 700; font-size: .95rem; color: var(--ink);
    text-decoration: none; background: rgba(255, 255, 255, .92); border-radius: 999px; padding: .3rem .9rem; box-shadow: 0 3px 10px rgba(110, 90, 50, .13);
}

.title { text-align: center; }
.title h1 { font: clamp(2.3rem, 8vw, 3.4rem)/1.05 'Fredoka One', sans-serif; color: var(--a-dark); }
.title h1 span { color: var(--b); }
.title p { color: var(--ink-soft); }

.card { background: var(--paper); border: 4px solid #fff; border-radius: 26px; box-shadow: var(--shadow); padding: 1.2rem 1.3rem 1.4rem; display: grid; gap: .7rem; }
h2 { font: 1.45rem 'Fredoka One', sans-serif; display: flex; align-items: center; gap: .5rem; }
.num { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--a); color: #fff; font-size: 1.1rem; box-shadow: 0 3px 0 var(--a-dark); }
.stars { margin-left: auto; color: #ffc93c; letter-spacing: 1px; font-size: 1.2rem; text-align: right; }
.story { font-size: 1.25rem; }
.note { color: var(--ink-soft); }

/* ---------- animals and legs ---------- */
.pen, .heads {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
    padding: .8rem; border-radius: 20px;
    background: linear-gradient(#e9f7dc, #d6efc0); border: 3px dashed #b9dd9c;
}
.ani {
    font: inherit; color: inherit; border: 3px solid #fff; cursor: pointer;
    display: grid; justify-items: center; gap: .15rem; padding: .4rem 0 .5rem;
    background: rgba(255, 255, 255, .75); border-radius: 18px; box-shadow: 0 3px 0 rgba(0, 0, 0, .06);
    transition: transform .15s, background .15s;
}
.ani .em { font-size: clamp(2rem, 9vw, 2.8rem); line-height: 1.1; }
.ani.chicken { background: #fff3e2; border-color: #ffd7ad; }
.ani.rabbit { background: #f2ebff; border-color: #d8c8f7; }
.ani.got { border-color: var(--b); animation: hop .5s ease; }
button.ani:active { transform: scale(.94); }
@media (hover: hover) { button.ani:hover { transform: translateY(-3px); } }
@keyframes hop { 40% { transform: translateY(-10px); } }
.heads .ani { cursor: default; }

.legs { display: flex; gap: 4px; height: 18px; align-items: flex-start; }
.leg { display: block; width: 5px; height: 18px; border-radius: 3px; background: #c98a2d; }
.ani.rabbit .leg, .ani.got .leg { background: #9a7ad8; }
.leg.glow { background: var(--b); box-shadow: 0 0 0 3px rgba(138, 92, 214, .25); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateY(-3px); } }

.meters { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.meter { font: 1.3rem 'Fredoka One', sans-serif; padding: .2rem 1rem; border-radius: 999px; background: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .06); }
.meter b { color: var(--a-dark); }
.meter small { color: var(--ink-soft); font-size: 1rem; }
.meter.pop { animation: pop .35s ease-out; }
@keyframes pop { 40% { transform: scale(1.12); } }

.hint { background: #fff6e2; border-radius: 14px; padding: .5rem .9rem; min-height: 2.6em; }
.hint.win { background: #e6f8ee; }
.watch { background: #f2ebff; border-left: 6px solid var(--b); border-radius: 12px; padding: .6rem .9rem; }

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0 4px; text-align: center; font-size: 1.2rem; }
.tbl th { font: 1rem 'Fredoka One', sans-serif; color: var(--ink-soft); padding: .2rem; }
.tbl td { background: #fff; padding: .25rem; }
.tbl td:first-child { border-radius: 12px 0 0 12px; color: var(--b-dark); font-weight: 800; }
.tbl td:last-child { border-radius: 0 12px 12px 0; font-weight: 800; }
.tbl td small { color: var(--good); font-size: .85rem; }
.tbl tr { animation: rowin .35s ease-out both; }
@keyframes rowin { from { opacity: 0; transform: translateY(-6px); } }
.tbl tr.hit td { background: #e6f8ee; outline: 3px solid var(--good); outline-offset: -3px; }
.count { margin-right: auto; align-self: center; font-size: 1.1rem; }

/* ---------- share out the legs ---------- */
.share { display: grid; gap: .6rem; }
.pile { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .5rem .9rem; border-radius: 16px; background: #fff6e2; min-height: 3.2rem; }
.pilelabel { font: 1.1rem 'Fredoka One', sans-serif; }
.pile .legs { flex-wrap: wrap; height: auto; }
.step { background: #fff6e2; border-radius: 18px; padding: .7rem 1rem; min-height: 5em; }
.step .big { display: block; font: 1.25rem 'Fredoka One', sans-serif; }
.step .dots { color: var(--ink-soft); font-size: .95rem; }

/* ---------- buttons and inputs ---------- */
.row { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.row.center { justify-content: center; }
.btn { font: 1.1rem 'Fredoka One', sans-serif; color: #fff; background: var(--good); border: none; border-radius: 999px; padding: .55rem 1.3rem; box-shadow: 0 4px 0 #23965a; cursor: pointer; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #23965a; }
.btn.soft { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #e2dccb; border: 2px solid #eee7d6; }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- practice ---------- */
.levels { display: flex; gap: .4rem; background: #f6efdd; padding: .3rem; border-radius: 999px; }
.lvl { flex: 1; font: 1.05rem 'Fredoka One', sans-serif; color: var(--ink-soft); background: none; border: none; border-radius: 999px; padding: .4rem .2rem; cursor: pointer; }
.lvl.on { background: #fff; color: var(--ink); box-shadow: 0 3px 0 rgba(0, 0, 0, .07); }
.lvlinfo { color: var(--ink-soft); font-size: 1rem; }
.lvlinfo b { color: #c99400; }
#pBody { display: grid; gap: .7rem; }
.pdots { display: flex; gap: 6px; justify-content: center; }
.pdots i { width: 14px; height: 14px; border-radius: 50%; background: #e8e1cf; }
.pdots i.now { background: var(--a); box-shadow: 0 0 0 4px #ffe2c2; }
.pdots i.ok { background: #ffc93c; }
.pdots i.done { background: var(--good); }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.answers label { display: grid; gap: .3rem; justify-items: center; text-align: center; padding: .6rem; border-radius: 16px; background: #fff; border: 2px solid #f1ead8; font-weight: 700; }
input {
    width: 3.2em; font: inherit; font-size: clamp(1.4rem, 6vw, 1.9rem); text-align: center; color: inherit; background: #fffdf7;
    border: 3px dashed var(--a); border-radius: 14px; padding: .05em 0;
}
input:focus { outline: none; border-style: solid; box-shadow: 0 0 0 4px rgba(255, 154, 60, .25); }
input.ok { border: 3px solid var(--good); background: #e6f8ee; }
input.no { border: 3px solid var(--bad); background: #ffecec; animation: shake .35s; }
@keyframes shake { 25% { translate: -5px; } 75% { translate: 5px; } }

.helper { display: grid; gap: .4rem; padding: .7rem; border-radius: 18px; background: #f3faea; border: 2px dashed #c6e3ab; }
.tokens { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; }
.tok { position: relative; font: inherit; width: 3rem; height: 3rem; border-radius: 14px; border: 2px solid #fff; background: #fff3e2; cursor: pointer; font-size: 1.6rem; line-height: 1; }
.tok.b { background: #f2ebff; }
.tok small { position: absolute; right: -4px; bottom: -6px; font: .75rem 'Fredoka One', sans-serif; background: var(--ink); color: #fff; border-radius: 999px; padding: 0 .35rem; }
.tally { text-align: center; font-size: 1.15rem; }
.tally b { font: 1.4rem 'Fredoka One', sans-serif; color: var(--a-dark); }
.tally.win b { color: var(--good); }
.hints { display: grid; gap: .35rem; padding-left: 1.6rem; }
.hints:empty { display: none; }
.hints li { background: #fff6e2; border-radius: 12px; padding: .35rem .7rem; animation: rowin .35s ease-out both; }
.result { text-align: center; display: grid; gap: .5rem; padding: .6rem 0; }
.bigstars { font: 3.4rem 'Fredoka One', sans-serif; color: #ffc93c; text-shadow: 0 4px 0 #e09b00; }

.grown ul { display: grid; gap: .5rem; padding-left: 1.2rem; }
.grown li { color: var(--ink); }

.confetti { position: fixed; top: -20px; width: 10px; height: 14px; border-radius: 3px; z-index: 50; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

@media (max-width: 480px) {
    .answers { grid-template-columns: 1fr; }
    .pen, .heads { gap: .35rem; padding: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
