@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700;9..144,800&family=Nunito:wght@400;600;700;800&display=swap');

:root {
    --wall: #f3ead8;
    --wall-shadow: #e4d5bb;
    --tile: #fff8ee;
    --grout: #d4c4b0;
    --wood-1: #c4a06a;
    --wood-2: #a67c4e;
    --wood-3: #d4b483;
    --wood-dark: #7a5430;
    --floor-a: #c4785a;
    --floor-b: #a85f44;
    --jam: #c1121f;
    --jam-deep: #8b0d18;
    --jam-light: #e63946;
    --cream: #fff6e9;
    --ink: #3d2914;
    --ink-soft: #6b4a2e;
    --copper: #b87333;
    --sky-1: #8ec5e8;
    --sky-2: #fbe2b4;
    --shadow: 0 12px 30px rgba(61, 41, 20, 0.18);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background:
        radial-gradient(1200px 500px at 80% -10%, rgba(251, 226, 180, 0.55), transparent 60%),
        linear-gradient(180deg, #f7edd8 0%, var(--cream) 40%, #ead9c0 100%);
    color: var(--ink);
    line-height: 1.5;
}

.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem 0.75rem;
    flex-wrap: wrap;
}

.brand {
    text-align: center;
    flex: 1;
}

.logo {
    font-family: 'Fraunces', serif;
    font-weight: 800;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    letter-spacing: -0.03em;
    color: var(--jam);
    text-shadow: 0 2px 0 #fff3e0;
}

.tagline {
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.95rem;
}

.scoreboard {
    display: flex;
    gap: 0.6rem;
}

.score-chip {
    background: #fffaf1;
    border: 2px solid #ead7b8;
    border-radius: 14px;
    padding: 0.35rem 0.85rem;
    min-width: 4.5rem;
    text-align: center;
    box-shadow: 0 4px 0 #e2ccaa;
}

.score-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    font-weight: 800;
}

.score-value {
    font-family: 'Fraunces', serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem 1rem 1.25rem;
}

.stage-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage {
    position: relative;
    width: min(1100px, 100%, calc((100dvh - 240px) * 1.6));
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: 18px;
    box-shadow: var(--shadow), 0 0 0 3px #ead7b8;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.wall {
    position: absolute;
    inset: 0 0 15% 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 40%),
        linear-gradient(90deg, var(--wall-shadow), var(--wall) 18%, var(--wall) 82%, #e8d7bc);
}

.window {
    position: absolute;
    top: 8%;
    right: 10%;
    width: 18%;
    height: 32%;
    background: linear-gradient(180deg, var(--sky-1), var(--sky-2));
    border: 7px solid #f7f1e6;
    box-shadow:
        0 0 0 5px #c4a06a,
        0 10px 24px rgba(61, 41, 20, 0.12),
        inset 0 0 30px rgba(255, 255, 255, 0.25);
    z-index: 2;
}

.window-sash {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(#f7f1e6, #f7f1e6) center / 6px 100% no-repeat,
        linear-gradient(#f7f1e6, #f7f1e6) center / 100% 6px no-repeat;
}

.curtain {
    position: absolute;
    top: -6%;
    width: 28%;
    height: 108%;
    background: repeating-linear-gradient(
        90deg,
        #e45a4f 0 6px,
        #ef7a6c 6px 12px
    );
    box-shadow: 2px 4px 8px rgba(61, 41, 20, 0.15);
}

.curtain-left {
    left: -8%;
    border-radius: 0 0 40% 40%;
    transform: rotate(-4deg);
}

.curtain-right {
    right: -8%;
    border-radius: 0 0 40% 40%;
    transform: rotate(4deg);
}

.shelf {
    position: absolute;
    top: 14%;
    left: 8%;
    width: 22%;
    height: 14%;
    z-index: 2;
}

.shelf-board {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18%;
    height: 14%;
    background: linear-gradient(180deg, var(--wood-3), var(--wood-2));
    border-radius: 2px;
    box-shadow: 0 6px 0 var(--wood-dark);
}

.spice {
    position: absolute;
    bottom: 32%;
    width: 16%;
    height: 48%;
    border-radius: 3px 3px 2px 2px;
}

.spice-1 {
    left: 12%;
    background: linear-gradient(180deg, #d9a441, #b07a22);
}

.spice-2 {
    left: 34%;
    background: linear-gradient(180deg, #7aa35a, #4f7a38);
}

.mug {
    position: absolute;
    right: 12%;
    bottom: 32%;
    width: 22%;
    height: 46%;
    background: #f2f2f0;
    border-radius: 4px 4px 8px 8px;
    box-shadow: inset 0 8px 0 #e8e4dc;
}

.mug::after {
    content: '';
    position: absolute;
    right: -28%;
    top: 28%;
    width: 34%;
    height: 38%;
    border: 4px solid #e8e4dc;
    border-left: none;
    border-radius: 0 50% 50% 0;
}

.backsplash {
    position: absolute;
    left: 0;
    right: 0;
    top: 42%;
    height: 20%;
    background-color: var(--tile);
    background-image:
        linear-gradient(to right, var(--grout) 2px, transparent 2px),
        linear-gradient(to bottom, var(--grout) 2px, transparent 2px);
    background-size: 52px 34px;
    box-shadow: inset 0 8px 16px rgba(61, 41, 20, 0.06);
    z-index: 1;
}

.cabinets {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 9%;
    background:
        linear-gradient(180deg, #b88955, #a07242);
    box-shadow: 0 8px 0 #8a5a32;
    z-index: 3;
}

.utensils {
    position: absolute;
    top: 8%;
    left: 36%;
    width: 16%;
    height: 18%;
    z-index: 3;
}

.pan,
.ladle {
    position: absolute;
    top: 0;
    width: 8px;
    background: var(--copper);
    border-radius: 0 0 8px 8px;
}

.pan {
    left: 24%;
    height: 78%;
}

.pan::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -10px;
    width: 34px;
    height: 22px;
    border: 5px solid var(--copper);
    border-radius: 50%;
    transform: translateX(-50%);
}

.ladle {
    left: 68%;
    height: 70%;
    width: 6px;
}

.ladle::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -8px;
    width: 16px;
    height: 16px;
    background: var(--copper);
    border-radius: 50%;
    transform: translateX(-50%);
}

.floor {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 15%;
    background-color: var(--floor-a);
    background-image:
        linear-gradient(45deg, var(--floor-b) 25%, transparent 25%),
        linear-gradient(-45deg, var(--floor-b) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--floor-b) 75%),
        linear-gradient(-45deg, transparent 75%, var(--floor-b) 75%);
    background-size: 44px 44px;
    background-position: 0 0, 0 22px, 22px -22px, -22px 0;
}

.baseboard {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 14.2%;
    height: 2%;
    background: #8d6240;
    z-index: 4;
}

.table {
    position: absolute;
    left: 0;
    top: 54%;
    width: 40%;
    height: 46%;
    z-index: 5;
}

.table-top {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 11%;
    background: repeating-linear-gradient(
        90deg,
        var(--wood-1) 0 10px,
        var(--wood-3) 10px 18px,
        var(--wood-2) 18px 28px
    );
    box-shadow: 0 6px 0 var(--wood-dark);
    z-index: 2;
}

.table-edge {
    position: absolute;
    right: 0;
    top: 0;
    width: 10px;
    height: 11%;
    background: var(--wood-dark);
    z-index: 3;
}

.table-leg {
    position: absolute;
    top: 10%;
    width: 7%;
    height: 78%;
    background: linear-gradient(90deg, var(--wood-dark), var(--wood-2) 40%, var(--wood-dark));
}

.table-leg-back {
    right: 8%;
    opacity: 0.7;
}

.table-leg-front {
    right: 2%;
}

.tea-towel {
    position: absolute;
    right: 18%;
    top: 10%;
    width: 16%;
    height: 28%;
    background:
        repeating-linear-gradient(
            90deg,
            #f4f0e6 0 8px,
            #d94a4a 8px 12px,
            #f4f0e6 12px 20px,
            #3a6ea5 20px 24px
        );
    border-radius: 0 0 6px 6px;
    transform: rotate(6deg);
    z-index: 1;
}

.hand {
    position: absolute;
    left: 28%;
    top: 42%;
    width: 9%;
    height: 16%;
    z-index: 8;
    transform-origin: 20% 80%;
    transform: rotate(-28deg);
    pointer-events: none;
    opacity: 0.92;
}

.hand.charging {
    transform: rotate(-48deg) translate(-8%, 6%);
}

.hand.slapping {
    animation: slap 160ms ease-out;
}

.hand-palm {
    width: 72%;
    height: 70%;
    background: #f0c7a0;
    border-radius: 40% 50% 45% 40%;
    box-shadow: 3px 4px 0 #d9a980;
    position: relative;
}

.hand-palm::before {
    content: '';
    position: absolute;
    right: -18%;
    top: 18%;
    width: 28%;
    height: 55%;
    background: #f0c7a0;
    border-radius: 40%;
    transform: rotate(18deg);
}

@keyframes slap {
    0% { transform: rotate(-48deg) translate(-8%, 6%); }
    60% { transform: rotate(12deg) translate(18%, 8%); }
    100% { transform: rotate(-28deg); }
}

.bread {
    position: absolute;
    width: 11.5%;
    z-index: 9;
    transform: translate(-50%, -50%);
    filter: drop-shadow(4px 6px 4px rgba(61, 41, 20, 0.28));
    will-change: left, top, transform;
}

.bread svg {
    display: block;
    width: 100%;
    height: auto;
}

.splat {
    position: absolute;
    width: 9%;
    height: 4.5%;
    background: radial-gradient(circle at 40% 40%, var(--jam-light), var(--jam) 55%, var(--jam-deep));
    border-radius: 60% 40% 55% 45%;
    z-index: 6;
    transform: translate(-50%, -30%);
    filter: drop-shadow(0 2px 0 var(--jam-deep));
}

.splat::before,
.splat::after {
    content: '';
    position: absolute;
    background: var(--jam);
    border-radius: 50%;
}

.splat::before {
    width: 32%;
    height: 55%;
    left: -18%;
    top: 20%;
}

.splat::after {
    width: 24%;
    height: 40%;
    right: -10%;
    bottom: 10%;
}

.fx-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.whap {
    position: absolute;
    left: 34%;
    top: 38%;
    font-family: 'Fraunces', serif;
    font-weight: 800;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: var(--jam);
    text-shadow: 2px 2px 0 #fff6e9;
    opacity: 0;
    transform: rotate(-12deg) scale(0.6);
    pointer-events: none;
    z-index: 12;
}

.whap.show {
    animation: whapPop 420ms ease-out;
}

@keyframes whapPop {
    0% { opacity: 0; transform: rotate(-12deg) scale(0.6); }
    30% { opacity: 1; transform: rotate(-8deg) scale(1.15); }
    100% { opacity: 0; transform: rotate(-4deg) translateY(-18px) scale(1); }
}

.result-sign {
    position: absolute;
    left: 58%;
    top: 12%;
    transform: translateX(-50%);
    min-width: 32%;
    background: #f7efe0;
    border: 4px solid var(--wood-2);
    border-radius: 8px;
    padding: 0.7rem 1rem 0.85rem;
    text-align: center;
    box-shadow: 0 8px 0 var(--wood-dark);
    z-index: 13;
}

.result-sign.hidden {
    display: none;
}

.result-sign::before {
    content: '';
    position: absolute;
    top: -18px;
    left: 18%;
    right: 18%;
    height: 18px;
    background:
        linear-gradient(#c4a06a, #c4a06a) left / 4px 100% no-repeat,
        linear-gradient(#c4a06a, #c4a06a) right / 4px 100% no-repeat;
}

.result-title {
    font-family: 'Fraunces', serif;
    font-size: clamp(1.1rem, 2.4vw, 1.7rem);
    font-weight: 800;
    color: var(--ink);
}

.result-sign.is-win .result-title {
    color: #2f7d32;
}

.result-sign.is-miss .result-title {
    color: var(--jam);
}

.result-sub {
    font-size: 0.85rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    width: min(1100px, 100%);
    margin: 0 auto;
}

.jam-meter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.jar {
    width: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.jar-lid {
    width: 42px;
    height: 10px;
    background: linear-gradient(180deg, #d9b36a, #b8893e);
    border-radius: 3px 3px 2px 2px;
    z-index: 1;
}

.jar-body {
    width: 40px;
    height: 64px;
    margin-top: -2px;
    border: 3px solid rgba(255, 255, 255, 0.55);
    border-radius: 6px 6px 10px 10px;
    background: rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 0 0 2px rgba(180, 70, 70, 0.18), 0 4px 0 #e2ccaa;
    overflow: hidden;
    position: relative;
}

.jar-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 0%;
    overflow: hidden;
    background: linear-gradient(180deg, var(--jam-light), var(--jam-deep));
    transition: height 50ms linear;
}

.jar-fill::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 10px;
    background: radial-gradient(circle at 30% 50%, #ff8a8a, var(--jam-light) 55%, transparent);
    opacity: 0.9;
}

.jar-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.slap-wrap {
    text-align: center;
}

.slap-btn {
    appearance: none;
    border: none;
    cursor: pointer;
    min-width: min(280px, 78vw);
    min-height: 72px;
    padding: 0.9rem 1.6rem;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, #ef5b4a, var(--jam) 46%, var(--jam-deep));
    color: #fff8f2;
    font-family: 'Fraunces', serif;
    font-size: 1.35rem;
    font-weight: 800;
    box-shadow:
        0 6px 0 var(--jam-deep),
        0 12px 20px rgba(193, 18, 31, 0.28);
    transition: transform 80ms ease, box-shadow 80ms ease, filter 80ms ease;
    touch-action: none;
    user-select: none;
}

.slap-btn:hover {
    filter: brightness(1.05);
}

.slap-btn:active,
.slap-btn.is-charging {
    transform: translateY(4px);
    box-shadow:
        0 2px 0 var(--jam-deep),
        0 6px 12px rgba(193, 18, 31, 0.25);
}

.slap-btn:disabled {
    cursor: default;
    filter: saturate(0.7);
}

.slap-btn:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
}

.slap-hint {
    margin-top: 0.45rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
    font-weight: 600;
    max-width: 22rem;
    margin-left: auto;
    margin-right: auto;
}

#footer {
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    color: var(--ink-soft);
    font-size: 0.88rem;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: var(--ink-soft);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--jam);
    text-decoration: underline;
}

.footer-separator {
    opacity: 0.5;
}

.footer-copyright {
    font-size: 0.8rem;
    opacity: 0.85;
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 0.75rem 1rem 0.4rem;
        gap: 0.55rem;
    }

    .logo {
        font-size: 1.7rem;
    }

    .tagline {
        font-size: 0.85rem;
    }

    .score-chip {
        padding: 0.25rem 0.7rem;
    }

    .score-value {
        font-size: 1.15rem;
    }

    .scoreboard {
        justify-content: center;
    }

    .main {
        padding: 0.25rem 0.75rem 1rem;
        gap: 0.7rem;
    }

    .stage {
        width: 100%;
        max-height: none;
        aspect-ratio: 16 / 11;
    }

    .controls {
        gap: 0.8rem;
    }

    .slap-btn {
        min-height: 64px;
        font-size: 1.15rem;
        min-width: min(240px, 70vw);
    }

    .space-hint {
        display: none;
    }

    .result-sign {
        top: 8%;
        min-width: 46%;
    }

    .footer-links {
        flex-direction: column;
        gap: 0.4rem;
    }

    .footer-separator {
        display: none;
    }

    #footer {
        padding: 1rem 1rem 1.4rem;
    }
}
