.cozy-page {
    --cream: #fff8ed;
    --ink: #49372f;
    --pink: #f786a8;
    --peach: #ffb57d;
    --mint: #78cdb1;
    --lavender: #a78bdb;
}

.cozy-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--pink) 24%, transparent);
    background:
        radial-gradient(circle at 12% 18%, rgba(255,255,255,.9) 0 5%, transparent 5.5%),
        radial-gradient(circle at 88% 24%, rgba(255,255,255,.75) 0 7%, transparent 7.5%),
        linear-gradient(135deg, #fff8ee, #ffe9ef 54%, #f2edff);
}

.cozy-hero::after {
    content: "";
    position: absolute;
    width: 150px;
    height: 150px;
    right: -55px;
    bottom: -85px;
    border: 22px solid rgba(255,255,255,.52);
    border-radius: 50%;
}

.cozy-stage {
    width: min(100%, 520px);
    min-height: 430px;
    margin-inline: auto;
    border: 1px solid rgba(124, 92, 74, .12);
    border-radius: 28px;
    background:
        linear-gradient(rgba(255,255,255,.78), rgba(255,255,255,.86)),
        repeating-linear-gradient(0deg, transparent 0 23px, rgba(247,134,168,.08) 24px);
    box-shadow: inset 0 1px 0 #fff, 0 18px 45px rgba(110, 74, 66, .12);
    color: var(--ink);
    touch-action: manipulation;
    overflow: hidden;
}

.cozy-status {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, 520px);
    gap: 8px;
    margin-inline: auto;
}

.cozy-stat {
    padding: 10px 8px;
    border-radius: 16px;
    background: rgba(255,255,255,.76);
    border: 1px solid rgba(124, 92, 74, .1);
    text-align: center;
}

.cozy-stat b { display:block; font-size:1.05rem; color:var(--ink); }
.cozy-stat span { font-size:.7rem; opacity:.58; font-weight:700; }

.daily-play-chip {
    width:max-content;
    max-width:100%;
    margin:-2px auto 12px;
    padding:6px 12px;
    border-radius:999px;
    background:rgba(255,255,255,.64);
    border:1px solid rgba(94,67,57,.08);
    color:rgba(73,55,47,.62);
    font-size:.68rem;
    font-weight:850;
    text-align:center;
}

.game-message {
    min-height: 24px;
    font-size: .85rem;
    font-weight: 750;
    color: color-mix(in srgb, var(--ink) 76%, var(--pink));
    text-align: center;
}

.stage-kicker {
    display:flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    width:max-content;
    margin:14px auto 0;
    padding:6px 11px;
    border-radius:999px;
    background:rgba(255,255,255,.72);
    border:1px solid rgba(91,65,55,.1);
    font-size:.66rem;
    font-weight:900;
    color:rgba(73,55,47,.65);
}

.stage-kicker i {
    display:block;
    width:6px;
    height:6px;
    border-radius:50%;
    background:var(--pink);
    box-shadow:10px 0 var(--peach),20px 0 var(--mint);
    margin-right:20px;
}

.game-pop { animation: game-pop .28s cubic-bezier(.2,.9,.3,1.35); }
@keyframes game-pop { 0% { transform:scale(.82); } 100% { transform:scale(1); } }
.message-pop { animation:message-pop .24s ease-out; }
@keyframes message-pop {
    0% { opacity:.45; transform:translateY(4px); }
    100% { opacity:1; transform:none; }
}

.game-shake { animation: game-shake .28s ease; }
@keyframes game-shake {
    25% { transform:translateX(-5px); }
    50% { transform:translateX(5px); }
    75% { transform:translateX(-3px); }
}

.sort-board {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
    gap: 18px 12px;
    padding: 26px 14px;
}

.dessert-cup {
    width: 64px;
    min-height: 178px;
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-start;
    align-items: center;
    gap: 5px;
    padding: 12px 7px 9px;
    border: 3px solid rgba(108, 73, 65, .23);
    border-top-color: rgba(108, 73, 65, .1);
    border-radius: 6px 6px 24px 24px;
    background: rgba(255,255,255,.48);
    transition: .18s ease;
}

.dessert-cup.selected {
    transform: translateY(-9px);
    border-color: var(--pink);
    box-shadow: 0 10px 22px rgba(247,134,168,.22);
}

.dessert-piece {
    --dessert-color: #ef839d;
    position: relative;
    width: 46px;
    height: 31px;
    border: 0;
    border-radius: 45% 45% 42% 42%;
    background:
        linear-gradient(90deg,rgba(255,255,255,.25),transparent 24% 76%,rgba(92,48,51,.08)),
        linear-gradient(180deg,#fff8f0 0 34%,#f7c6ca 35% 65%,#fff8f0 66%);
    box-shadow:
        0 3px 5px rgba(83,53,47,.18),
        inset 0 0 0 1px rgba(91,52,49,.09);
}

.dessert-piece::before,
.dessert-piece::after {
    content:"";
    position:absolute;
    left:1px;
    width:44px;
    height:12px;
    background:
        radial-gradient(ellipse at 4px 100%,rgba(102,55,59,.13) 0 1.5px,transparent 2px) 0 0/8px 5px repeat-x,
        linear-gradient(180deg,rgba(255,255,255,.42),transparent 52%),
        var(--dessert-color);
    border:1px solid rgba(83,53,47,.12);
    box-shadow:inset 0 -2px rgba(90,45,53,.09);
}

.dessert-piece::before {
    top:1px;
    border-radius:52% 52% 32% 32% / 70% 70% 28% 28%;
}

.dessert-piece::after {
    bottom:1px;
    border-radius:32% 32% 52% 52% / 28% 28% 70% 70%;
    transform:scaleY(-1);
}

.ribbon-mini-bow {
    position:relative;
    width:150px;
    height:88px;
    margin-inline:auto;
}
.ribbon-mini-bow::before,
.ribbon-mini-bow::after {
    content:"";
    position:absolute;
    top:10px;
    width:82px;
    height:58px;
    border:14px solid #ef88a8;
    border-radius:70% 45% 62% 46%;
}
.ribbon-mini-bow::before { left:0; transform:rotate(15deg); }
.ribbon-mini-bow::after { right:0; transform:scaleX(-1) rotate(15deg); }
.ribbon-scene {
    --ribbon-color:#ef7fa3;
    position:relative;
    width:min(100%,460px);
    height:310px;
    margin:12px auto 0;
    overflow:hidden;
    border-radius:32px;
    background:
        radial-gradient(circle at 50% 48%,rgba(255,255,255,.95),rgba(255,245,240,.78) 38%,transparent 39%),
        linear-gradient(145deg,#fff8f4,#f4ece7);
    isolation:isolate;
}
.ribbon-shadow-stack i {
    position:absolute;
    left:50%;
    top:50%;
    width:190px;
    height:84px;
    border:15px solid var(--stack-color);
    border-radius:50%;
    opacity:calc(.2 - var(--stack-index) * .04);
    transform:translate(-50%,-50%) rotate(calc((var(--stack-index) + 1) * 13deg));
}
.ribbon-loop {
    position:absolute;
    top:76px;
    width:142px;
    height:102px;
    border:22px solid var(--ribbon-color);
    border-radius:70% 44% 64% 45%;
    background:rgba(255,255,255,.38);
    box-shadow:inset 0 6px rgba(255,255,255,.22),0 10px 20px rgba(96,60,65,.12);
}
.ribbon-loop-left { left:44px; transform:rotate(17deg); }
.ribbon-loop-right { right:44px; transform:scaleX(-1) rotate(17deg); }
.ribbon-knot {
    position:absolute;
    z-index:3;
    left:50%;
    top:118px;
    width:76px;
    height:66px;
    border-radius:42% 56% 45% 55%;
    background:linear-gradient(145deg,color-mix(in srgb,var(--ribbon-color),white 18%),var(--ribbon-color));
    box-shadow:inset 8px 7px rgba(255,255,255,.2),0 8px 16px rgba(95,54,66,.18);
    transform:translateX(-50%) rotate(-4deg);
}
.ribbon-tail {
    position:absolute;
    z-index:2;
    top:168px;
    width:122px;
    height:104px;
    border:0;
    background:linear-gradient(100deg,var(--ribbon-color),color-mix(in srgb,var(--ribbon-color),white 15%));
    color:#fff;
    font-size:.7rem;
    font-weight:900;
    text-shadow:0 1px 2px rgba(0,0,0,.2);
    box-shadow:0 8px 16px rgba(97,58,69,.12);
    transition:transform .22s ease,filter .22s ease;
}
.ribbon-tail::after {
    content:"";
    position:absolute;
    bottom:-1px;
    width:30px;
    height:30px;
    background:#f7efea;
    transform:rotate(45deg);
}
.ribbon-tail-left { left:94px; clip-path:polygon(0 0,100% 10%,82% 100%,50% 82%,18% 100%); transform:rotate(9deg); }
.ribbon-tail-right { right:94px; clip-path:polygon(0 10%,100% 0,82% 100%,50% 82%,18% 100%); transform:rotate(-9deg); }
.ribbon-tail.is-loose { filter:brightness(1.12) drop-shadow(0 0 10px color-mix(in srgb,var(--ribbon-color),white 30%)); animation:ribbon-glint 1.1s ease-in-out infinite; }
@keyframes ribbon-glint { 50% { filter:brightness(1.28) drop-shadow(0 0 16px rgba(255,255,255,.9)); } }
.ribbon-scene.is-pulling-left .ribbon-tail-left { transform:translate(-170px,55px) rotate(25deg); opacity:0; }
.ribbon-scene.is-pulling-right .ribbon-tail-right { transform:translate(170px,55px) rotate(-25deg); opacity:0; }
.ribbon-hint,.sticker-hint { padding:0 16px 18px;text-align:center;font-size:.75rem;font-weight:800;opacity:.62; }

.sticker-scene {
    position:relative;
    width:min(88vw,390px);
    aspect-ratio:1;
    margin:18px auto 10px;
    display:grid;
    place-items:center;
    overflow:hidden;
    border-radius:34px;
    background:
        linear-gradient(45deg,rgba(120,85,75,.055) 25%,transparent 25% 75%,rgba(120,85,75,.055) 75%),
        var(--sticker-paper);
    background-size:28px 28px;
    box-shadow:inset 0 0 0 2px rgba(106,75,66,.08);
    touch-action:none;
}
.sticker-reveal {
    display:grid;
    place-items:center;
    gap:8px;
    color:#6f5148;
}
.sticker-reveal span { font-size:5.2rem; filter:saturate(.85); }
.sticker-reveal b { font-size:.92rem; }
.sticker-card {
    position:absolute;
    width:72%;
    aspect-ratio:1;
    display:grid;
    place-items:center;
    align-content:center;
    gap:6px;
    border:8px solid #fff;
    border-radius:46% 54% 48% 52%;
    background:linear-gradient(145deg,color-mix(in srgb,var(--sticker-color),white 22%),var(--sticker-color));
    box-shadow:0 15px 30px rgba(93,58,64,.2),inset 0 5px rgba(255,255,255,.22);
    color:#fff;
    touch-action:none;
    transition:transform .3s ease,opacity .3s ease;
}
.sticker-face { font-size:5.8rem; line-height:1; }
.sticker-name { font-size:.78rem;font-weight:950;text-shadow:0 1px 2px rgba(0,0,0,.16); }
.peel-corner {
    position:absolute;
    width:54px;
    height:54px;
    border-radius:8px 0 0;
    background:linear-gradient(135deg,#fff 0 48%,#ddd 49% 51%,transparent 52%);
    filter:drop-shadow(0 0 8px rgba(255,255,255,.9));
    animation:peel-glow 1s ease-in-out infinite;
}
.corner-top-left .peel-corner { left:-5px;top:-5px;transform:rotate(0); }
.corner-top-right .peel-corner { right:-5px;top:-5px;transform:rotate(90deg); }
.corner-bottom-right .peel-corner { right:-5px;bottom:-5px;transform:rotate(180deg); }
.corner-bottom-left .peel-corner { left:-5px;bottom:-5px;transform:rotate(270deg); }
@keyframes peel-glow { 50% { filter:drop-shadow(0 0 15px rgba(255,255,255,1)); } }
.sticker-card.is-peeled { transform:translate(130%,110%) rotate(24deg)!important;opacity:0!important; }
.sticker-meter { width:min(72%,300px);height:10px;margin:0 auto 12px;overflow:hidden;border-radius:999px;background:#e8ddd7; }
.sticker-meter span { display:block;width:0;height:100%;border-radius:inherit;background:linear-gradient(90deg,#f29bb4,#8c7bd7);transition:width .12s ease; }

.pouch-shell {
    position: relative;
    width: min(100%, 430px);
    margin: 30px auto 18px;
    padding: 34px 22px 22px;
    border-radius: 42px 42px 28px 28px;
    background: linear-gradient(145deg, #ffd9e2, #f7a9be);
    border: 3px solid #e888a5;
    box-shadow: inset 0 6px rgba(255,255,255,.35), 0 16px 30px rgba(202,105,136,.18);
}

.pouch-shell::before {
    content:"";
    position:absolute;
    top:14px;
    left:28px;
    right:28px;
    height:8px;
    border-radius:8px;
    background:repeating-linear-gradient(90deg,#885f69 0 7px,#f9c8d4 7px 11px);
    box-shadow:0 2px rgba(255,255,255,.55);
}

.pouch-shell::after {
    content:"";
    position:absolute;
    top:-18px;
    left:50%;
    width:118px;
    height:34px;
    transform:translateX(-50%);
    border:7px solid #df8aa2;
    border-bottom:0;
    border-radius:38px 38px 0 0;
    z-index:-1;
}

.pouch-label {
    margin-bottom:12px;
    text-align:center;
    color:#9b5269;
    font-size:.68rem;
    font-weight:950;
    letter-spacing:.18em;
}

.pouch-outside {
    margin:16px auto 0;
    width:min(100%,440px);
    padding:12px;
    border:2px dashed rgba(100,75,65,.16);
    border-radius:22px;
    background:rgba(255,255,255,.48);
}

.pouch-outside-title {
    text-align:center;
    font-size:.68rem;
    font-weight:900;
    opacity:.5;
}

.pouch-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.pouch-slot {
    min-height: 92px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:5px;
    border: 2px dashed rgba(96,55,68,.25);
    border-radius:18px;
    background:rgba(255,255,255,.4);
    color:rgba(117,72,85,.3);
    font-weight:800;
}

.pouch-slot .item-art { opacity:.25; filter:grayscale(1); transform:scale(.84); }
.pouch-slot.filled { border-style:solid; background:rgba(255,255,255,.76); }
.pouch-slot.filled .item-art { opacity:1; filter:none; transform:none; }

.pouch-items {
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    gap:10px;
    padding:14px;
}

.pouch-item {
    width:70px;
    height:70px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:18px;
    background:#fff;
    border:1px solid rgba(90,58,49,.12);
    box-shadow:0 7px 14px rgba(90,58,49,.1);
    cursor:grab;
}

.pouch-item.selected { outline:3px solid var(--pink); transform:translateY(-4px); }
.pouch-item.locked { opacity:.35; pointer-events:none; }
.item-art { width:42px; height:48px; position:relative; }
.art-lip { width:20px; height:45px; margin:auto; border-radius:8px; background:linear-gradient(#ff7f9e 0 30%,#f3c2cf 31% 100%); }
.art-comb { width:38px; height:40px; border:7px solid #b18add; border-left:0; border-radius:0 16px 16px 0; }
.art-comb::after { content:""; position:absolute; left:2px; top:8px; width:30px; height:3px; background:#b18add; box-shadow:0 7px #b18add,0 14px #b18add,0 21px #b18add; }
.art-note { width:38px; height:45px; border-radius:4px; background:repeating-linear-gradient(#fff5a9 0 8px,#edcf62 9px); transform:rotate(-5deg); }
.art-pen { width:11px; height:48px; margin:auto; border-radius:8px; background:linear-gradient(90deg,#54b9c6 0 55%,#bcecf0 56%); transform:rotate(12deg); }
.art-clip { width:26px; height:42px; margin:auto; border:5px solid #ff9f68; border-radius:13px; }
.art-cream { width:32px; height:44px; margin:auto; border-radius:8px 8px 12px 12px; background:linear-gradient(#8ad4bd 0 22%,#f2fff9 23%); }

.emoji-target { font-size:3.2rem; line-height:1; filter:drop-shadow(0 5px 8px rgba(91,63,53,.14)); }
.emoji-grid {
    display:grid;
    gap:clamp(3px,1vw,7px);
    padding:10px;
    width:100%;
    max-width:440px;
    margin:auto;
    box-sizing:border-box;
}
.emoji-cell {
    min-width:0;
    aspect-ratio:1;
    display:grid;
    place-items:center;
    border-radius:14px;
    background:rgba(255,255,255,.78);
    border:1px solid rgba(100,70,60,.09);
    font-size:clamp(1.1rem,5.4vw,2.15rem);
    transition:.14s ease;
}
.emoji-cell:active { transform:scale(.9); }

.cat-board {
    display:grid;
    grid-template-columns:repeat(5,1fr);
    width:calc(100% - 24px);
    max-width:390px;
    margin:20px auto;
    border:3px solid #71594f;
    border-radius:16px;
    overflow:hidden;
    background:#fff;
}
.cat-cell {
    aspect-ratio:1;
    display:grid;
    place-items:center;
    border:1px solid rgba(90,64,54,.17);
    font-size:clamp(1.35rem,7vw,2.2rem);
    position:relative;
}
.cat-cell::after { content:attr(data-region); position:absolute; right:4px; bottom:2px; font-size:.55rem; opacity:.35; font-weight:900; }
.cat-cell.cat { background:rgba(255,255,255,.78); }
.cat-cell.conflict { box-shadow:inset 0 0 0 3px #ef6b73; }
.cat-board.is-complete { animation:cat-complete .55s cubic-bezier(.2,.9,.25,1.2); }
@keyframes cat-complete {
    45% { transform:scale(1.035) rotate(-1deg); box-shadow:0 16px 32px rgba(104,75,62,.18); }
    100% { transform:none; }
}

.gem-palette { display:flex; justify-content:center; gap:9px; flex-wrap:wrap; padding:12px; }
.gem-goal {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:16px 18px 4px;
    font-size:.8rem;
    font-weight:900;
}
.gem-progress-track {
    flex:1;
    max-width:160px;
    height:9px;
    overflow:hidden;
    border-radius:999px;
    background:#e8ded6;
}
.gem-progress-fill {
    width:0;
    height:100%;
    border-radius:inherit;
    background:linear-gradient(90deg,#f081a3,#9a79d7);
    transition:width .15s ease;
}
.gem-swatch {
    width:52px; height:52px; border-radius:16px 16px 22px 22px;
    border:3px solid rgba(255,255,255,.8);
    box-shadow:0 5px 12px rgba(75,53,48,.14);
    color:#fff; font-weight:900; text-shadow:0 1px 3px rgba(0,0,0,.35);
}
.gem-swatch.selected { outline:3px solid #5c473f; transform:translateY(-4px); }
.gem-board {
    display:grid;
    grid-template-columns:repeat(9,1fr);
    width:calc(100% - 16px);
    max-width:420px;
    margin:8px auto 20px;
    border:4px solid #745d55;
    background:#fff;
    border-radius:18px;
    overflow:hidden;
    touch-action:none;
    user-select:none;
}
.gem-cell {
    aspect-ratio:1;
    display:grid;
    place-items:center;
    border:1px solid rgba(80,60,50,.08);
    background:#f5efe9;
    font-size:.5rem;
    font-weight:900;
    color:rgba(72,53,48,.42);
}
.gem-cell.done { color:transparent; box-shadow:inset 0 0 8px rgba(255,255,255,.48); }
.gem-cell.done::after {
    content:"";
    width:42%;
    height:42%;
    border-radius:50% 50% 45% 45%;
    background:rgba(255,255,255,.35);
    transform:rotate(35deg);
}

#cake-canvas {
    display:block;
    width:min(100%,420px);
    height:auto;
    margin:auto;
    border-radius:24px;
    touch-action:none;
}

.cozy-leaderboard-card {
    overflow:hidden;
    border:1px solid color-mix(in oklab, var(--color-secondary) 14%, transparent);
}
.cozy-leaderboard-card::before {
    content:"";
    display:block;
    height:4px;
    background:linear-gradient(90deg,#f19ab2,#f3c86a,#83cfb4,#a995df);
}
.cozy-leaderboard-head {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
}
.cozy-leaderboard-kicker {
    margin-bottom:4px;
    color:var(--color-secondary);
    font-size:.65rem;
    font-weight:950;
    letter-spacing:.16em;
}

@media (max-width: 480px) {
    #theme-select { width:54px; max-width:54px; padding-left:6px; padding-right:4px; }
    .cozy-stage { min-height:390px; border-radius:22px; }
    .dessert-cup { width:56px; min-height:154px; }
    .dessert-piece { width:40px; height:23px; }
    .dessert-piece::before,
    .dessert-piece::after { width:38px; height:10px; }
    .pouch-shell { padding:14px; }
    .pouch-shell { padding-top:34px; }
    .pouch-slot { min-height:78px; }
    .cozy-leaderboard-head { align-items:stretch; flex-direction:column; }
    .cozy-leaderboard-head .btn { width:100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; }
}
