:root {
    --cream: #FFF6E9;
    --cream-dark: #F6E6CF;
    --latte: #E9CBA7;
    --cookie: #EBAE62;
    --cookie-dark: #C98742;
    --chocolate: #5A3825;
    --espresso: #3B2418;
    --pink: #F5A3A3;
    --mint: #A8D8C2;
    --paper: #FFFDF7;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Fredoka", "Trebuchet MS", sans-serif;
    color: var(--chocolate);
    background-color: var(--cream);
    background-image:
        radial-gradient(circle at 20px 20px, rgba(90, 56, 37, 0.10) 5px, transparent 6px),
        radial-gradient(circle at 70px 60px, rgba(235, 174, 98, 0.22) 7px, transparent 8px);
    background-size: 90px 90px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

.page {
    width: 100%;
    max-width: 460px;
    padding: 28px 18px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--paper);
    border: 3px solid var(--chocolate);
    border-radius: 999px;
    padding: 6px 16px 6px 10px;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 4px 0 var(--chocolate);
}

.brand svg {
    width: 26px;
    height: 26px;
}

h1 {
    font-size: 30px;
    margin: 22px 0 4px;
    color: var(--espresso);
    letter-spacing: 0.3px;
}

.subtitle {
    margin: 0 0 8px;
    font-size: 16px;
    opacity: 0.8;
}

/* ---------- the cookie ---------- */

.stage {
    position: relative;
    width: 100%;
    min-height: 300px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-top: 6px;
}

.cookie {
    position: relative;
    width: 250px;
    height: 170px;
}

.cookie svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.half {
    transition: transform 0.7s cubic-bezier(.3, 1.6, .5, 1);
}

.half-left,
.half-right {
    transform-origin: 125px 112px;
}

.peek {
    transition: opacity 0.2s ease;
}

.cookie.cracked .peek {
    opacity: 0;
}

.cookie.ready {
    cursor: pointer;
    animation: tap-me 1.6s ease-in-out infinite;
}

.cookie.ready:focus-visible {
    outline: 3px dashed var(--cookie-dark);
    outline-offset: 10px;
    border-radius: 20px;
}

@keyframes tap-me {
    0%, 70%, 100% { transform: scale(1) rotate(0deg); }
    78% { transform: scale(1.04) rotate(-3deg); }
    86% { transform: scale(1.04) rotate(3deg); }
    94% { transform: scale(1.02) rotate(0deg); }
}

.cookie.waiting {
    animation: wiggle 0.9s ease-in-out infinite;
}

.cookie.cracked .half-left {
    transform: translate(-46px, -6px) rotate(-16deg);
}

.cookie.cracked .half-right {
    transform: translate(46px, -6px) rotate(16deg);
}

.crumbs circle {
    opacity: 0;
}

.cookie.cracked .crumbs circle {
    animation: crumb 0.8s ease-out forwards;
}

.cookie.cracked .crumbs circle:nth-child(2) { animation-delay: 0.05s; }
.cookie.cracked .crumbs circle:nth-child(3) { animation-delay: 0.1s; }
.cookie.cracked .crumbs circle:nth-child(4) { animation-delay: 0.15s; }

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    25% { transform: rotate(-4deg) translateY(-4px); }
    75% { transform: rotate(4deg) translateY(-2px); }
}

@keyframes crumb {
    0% { opacity: 1; transform: translate(0, 0); }
    100% { opacity: 0; transform: translate(var(--dx), 40px); }
}

/* ---------- sleeping cookie (daily limit reached) ---------- */

.eye-closed,
.zzz {
    display: none;
}

.cookie.sleeping .eye {
    display: none;
}

.cookie.sleeping .eye-closed {
    display: inline;
}

.cookie.sleeping .zzz {
    display: inline;
}

.cookie.sleeping {
    animation: snooze 3s ease-in-out infinite;
}

.cookie.sleeping .zzz text {
    animation: float-z 2.4s ease-in-out infinite;
}

.cookie.sleeping .zzz text:nth-child(2) { animation-delay: 0.4s; }
.cookie.sleeping .zzz text:nth-child(3) { animation-delay: 0.8s; }

.page.sleeping .stage {
    flex-direction: column;
    align-items: center;
    min-height: 0;
}

.page.sleeping .slip {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    margin-top: -20px;
    background: #F6F0FA;
}

.page.sleeping .lucky {
    display: none;
}

@keyframes snooze {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(3px) scale(1.01, 0.99); }
}

@keyframes float-z {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-4px); }
}

/* ---------- the paper slip ---------- */

.slip {
    position: absolute;
    left: 50%;
    top: 112px;
    width: min(92%, 380px);
    transform: translateX(-50%) scaleY(0.05);
    transform-origin: 50% 0;
    opacity: 0;
    background: var(--paper);
    border: 3px solid var(--chocolate);
    border-radius: 6px;
    padding: 22px 26px 16px;
    box-shadow: 0 6px 0 var(--chocolate);
    transition: transform 0.6s cubic-bezier(.3, 1.4, .5, 1) 0.35s, opacity 0.25s ease 0.35s;
    z-index: 2;
}

.slip::before,
.slip::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    background: var(--pink);
    border: 3px solid var(--chocolate);
    border-radius: 50%;
}

.slip::before {
    left: -10px;
}

.slip::after {
    right: -10px;
}

.show-slip .slip {
    transform: translateX(-50%) scaleY(1);
    opacity: 1;
}

.fortune-text {
    font-family: "Mali", "Comic Sans MS", cursive;
    font-size: 21px;
    line-height: 1.25;
    margin: 0;
    color: var(--espresso);
    font-weight: 700;
}

.lucky {
    margin-top: 12px;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--cookie-dark);
    font-weight: 600;
    text-transform: uppercase;
}

.status {
    min-height: 24px;
    font-size: 16px;
    margin-top: 4px;
}

.dots span {
    animation: blink 1.2s infinite;
}

.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

/* ---------- buttons, cup, footer ---------- */

.btn {
    margin-top: 18px;
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    color: var(--espresso);
    background: var(--mint);
    border: 3px solid var(--chocolate);
    border-radius: 999px;
    padding: 10px 22px;
    box-shadow: 0 4px 0 var(--chocolate);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    opacity: 0;
    pointer-events: none;
}

.show-slip .btn {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.4s ease 1s, transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--chocolate);
}

.cup {
    width: 120px;
    margin-top: 26px;
}

.steam path {
    animation: steam 2.6s ease-in-out infinite;
}

.steam path:nth-child(2) { animation-delay: 0.6s; }
.steam path:nth-child(3) { animation-delay: 1.2s; }

@keyframes steam {
    0% { opacity: 0; transform: translateY(6px); }
    50% { opacity: 0.8; }
    100% { opacity: 0; transform: translateY(-10px); }
}

footer {
    font-size: 13px;
    padding: 0 16px 18px;
    text-align: center;
    color: rgba(90, 56, 37, 0.7);
}

footer a {
    color: var(--chocolate);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--cookie);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

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