/* The only stylesheet. The canvas draws the kitchen; every readable thing on screen is
   DOM, so it stays crisp, selectable by the accessibility tree and free of hit-test maths. */

:root {
    --top: calc(env(safe-area-inset-top) + 52px);
    --bottom: calc(env(safe-area-inset-bottom) + 12px);
    --cream: #FFF6E2;
    --ink: #3A2216;
    --mute-ink: #7A4B60;
    --pink: #C2456A;
    --pink-hi: #FF5C86;
    --green: #59C63F;
    --green-lo: #2C6B26;
    --blue: #3AA0C6;
    --blue-lo: #1C566F;
    --gold: #FFD24A;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: #1a1024;
    color: var(--cream);
    font-family: var(--font);
    /* half of stopping mobile scroll; the document-wide preventDefault in input.js is
       the other half, and either alone does nothing */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* #game, never a bare `canvas`: menu.js paints the how-to icons and the menu-collection
   tiles into their own small canvases, and a bare rule pinned every one of them to the
   viewport origin behind the card. */
#game {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: block;
}

.howto-icon,
.menu-cell canvas {
    display: block;
}

/* Measured by layout(), never seen. */
.probe {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    pointer-events: none;
    opacity: 0;
}

#probe-top {
    height: var(--top);
}

#probe-bottom {
    height: var(--bottom);
}

.home-link {
    position: fixed;
    z-index: 40;
    top: calc(env(safe-area-inset-top) + 10px);
    left: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(30, 14, 32, .55);
    color: rgba(255, 244, 224, .85);
    font: 700 12px/1 var(--font);
    letter-spacing: .04em;
    text-decoration: none;
}

.home-link:hover {
    background: rgba(30, 14, 32, .8);
    color: var(--gold);
}

/* ---------- HUD ---------- */

#hud {
    position: fixed;
    inset: 0;
    z-index: 20;
    /* nothing in here is clickable — see the note in index.html */
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s ease;
}

#hud.playing {
    opacity: 1;
}

.hud-top {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 44px);
    left: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#coins {
    font: 800 26px/1 var(--font);
    color: var(--gold);
    text-shadow: 0 2px 0 rgba(30, 14, 32, .9), 0 0 6px rgba(30, 14, 32, .9);
}

.hearts {
    display: flex;
    gap: 2px;
}

.heart {
    width: 20px;
    height: 20px;
    fill: rgba(255, 255, 255, .16);
    stroke: rgba(30, 14, 32, .7);
    stroke-width: 1.6;
}

.heart.on {
    fill: var(--pink-hi);
}

.hud-bottom {
    position: absolute;
    left: 14px;
    bottom: calc(var(--bottom) + 46px);
    width: min(60vw, 260px);
}

.hud-bottom p {
    margin: 0;
    font: 800 13px/1.5 var(--font);
    color: rgba(255, 244, 224, .9);
}

#next-line {
    font: 700 12px/1.6 var(--font);
    color: rgba(255, 244, 224, .72);
}

.hud-bottom .bar {
    width: 116px;
    height: 8px;
    margin: 4px 0 2px;
    border-radius: 4px;
    background: rgba(30, 14, 32, .5);
    overflow: hidden;
}

.hud-bottom .bar i {
    display: block;
    height: 100%;
    min-width: 7px;
    width: 0;
    border-radius: 4px;
    background: #8CF06A;
    transition: width .18s ease;
}

.boosts {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px !important;
}

.boosts .chip {
    padding: 2px 7px;
    border-radius: 8px;
    background: rgba(30, 14, 32, .55);
    font: 800 10px/1.4 var(--font);
}

.combo {
    position: absolute;
    right: 14px;
    bottom: calc(var(--bottom) + 64px);
    margin: 0;
    font: 800 20px/1 var(--font);
    color: #7BE0FF;
    text-shadow: 0 2px 0 rgba(30, 14, 32, .9);
    opacity: 0;
    transform: scale(.7);
    transition: opacity .12s ease, transform .12s ease;
}

.combo.on {
    opacity: 1;
    transform: scale(1);
}

.combo.hot {
    color: #FF9BE0;
}

/* ---------- mute ---------- */

.mute {
    position: fixed;
    z-index: 40;
    top: calc(env(safe-area-inset-top) + 8px);
    right: 12px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--gold);
    border-radius: 50%;
    background: rgba(30, 14, 32, .55);
    color: var(--gold);
    cursor: pointer;
}

.mute svg {
    width: 22px;
    height: 22px;
    display: block;
    margin: auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.mute .note-head {
    fill: currentColor;
    stroke: none;
}

.mute .slash {
    opacity: 0;
    stroke: #FF6B6B;
    stroke-width: 2.6;
}

.mute.off {
    border-color: rgba(255, 244, 224, .55);
    color: rgba(255, 244, 224, .55);
}

.mute.off .slash {
    opacity: 1;
}

/* ---------- screens ---------- */

.screen {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(var(--top) + 8px) 16px calc(var(--bottom) + 8px);
    background: rgba(23, 12, 28, .66);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.screen.on {
    display: flex;
    animation: fade .22s ease both;
}

@keyframes fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.card {
    width: min(344px, 100%);
    margin: auto;
    padding: 34px 20px 22px;
    border: 4px solid var(--ink);
    border-radius: 22px;
    background: var(--cream);
    color: var(--mute-ink);
    text-align: center;
    animation: pop .22s cubic-bezier(.2, 1.4, .4, 1) both;
}

@keyframes pop {
    from {
        transform: scale(.9);
    }

    to {
        transform: scale(1);
    }
}

.card-head {
    position: relative;
    margin: -50px -6px 16px;
    padding: 12px 10px;
    border: 3.4px solid var(--ink);
    border-radius: 16px;
    color: var(--cream);
    font: 800 22px/1.2 var(--font);
    letter-spacing: .02em;
}

#screen-title .card-head {
    font-size: 30px;
}

.card-head.pink {
    background: var(--pink-hi);
}

.card-head.green {
    background: var(--green);
}

.card-head.blue {
    background: var(--blue);
}

.card-head.tilt-l {
    transform: rotate(-2deg);
}

.card-head.tilt-r {
    transform: rotate(2deg);
}

#over-best {
    display: none;
}

#over-best.on {
    display: block;
}

.label {
    margin: 14px 0 2px;
    font: 800 12px/1.4 var(--font);
    letter-spacing: .08em;
    color: var(--mute-ink);
}

.money {
    margin: 0;
    font: 800 46px/1.1 var(--font);
    color: var(--ink);
}

.money.sm {
    font-size: 24px;
    color: #B0662A;
}

.note {
    margin: 6px 0 0;
    font: 700 14px/1.5 var(--font);
    color: var(--mute-ink);
}

.note.small {
    font-size: 12px;
    color: #8A6072;
}

.note.blue {
    color: #2C7F9E;
    font-weight: 800;
}

.note.pink {
    color: var(--pink);
    font-weight: 800;
}

.note:empty {
    display: none;
}

/* ---------- how-to ---------- */

.howto {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: left;
}

.howto li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 3px 0;
    font: 700 15px/1.3 var(--font);
    color: #5B3A4C;
}

.howto-icon {
    flex: 0 0 auto;
}

/* ---------- buttons ---------- */

.btn {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 14px 12px;
    border: 3.4px solid var(--ink);
    border-radius: 16px;
    color: var(--cream);
    font: 800 20px/1.1 var(--font);
    cursor: pointer;
    transition: transform .08s ease, filter .12s ease;
}

.btn small {
    display: block;
    margin-top: 3px;
    font: 700 11px/1 var(--font);
    opacity: .85;
}

.btn.big {
    font-size: 24px;
    padding: 16px 12px;
}

.btn.green {
    background: var(--green);
    box-shadow: 0 5px 0 var(--green-lo);
}

.btn.blue {
    background: var(--blue);
    box-shadow: 0 5px 0 var(--blue-lo);
}

.btn.pink {
    background: var(--pink);
    box-shadow: 0 5px 0 #7A2E56;
    font-size: 16px;
}

.btn:active {
    transform: translateY(3px);
    filter: brightness(1.05);
}

.btn:disabled {
    cursor: default;
    filter: grayscale(.5) brightness(.9);
}

.row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.row .btn {
    width: auto;
    flex: 0 0 38%;
}

.row .btn.grow {
    flex: 1 1 auto;
}

/* ---------- rewards ---------- */

.rewards {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.reward {
    padding: 6px 10px;
    border: 2.4px solid var(--ink);
    border-radius: 10px;
    background: #FFE9C4;
    font: 800 14px/1.3 var(--font);
    animation: reward .24s ease both;
    animation-delay: calc(var(--i) * .16s + .35s);
}

@keyframes reward {
    from {
        opacity: 0;
        transform: scale(.7);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ---------- shop ---------- */

.shop-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.shop-top .note {
    margin: 0;
}

.tabs {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.tab {
    flex: 1 1 0;
    padding: 7px 0 6px;
    border: 2.4px solid var(--ink);
    border-radius: 10px;
    background: #EFE2E6;
    color: #A9909B;
    font: 800 13px/1.1 var(--font);
    letter-spacing: .04em;
    cursor: pointer;
}

.tab small {
    display: block;
    font: 700 9px/1.4 var(--font);
    letter-spacing: .12em;
    opacity: .8;
}

.tab.on {
    background: var(--pink-hi);
    color: var(--cream);
}

/* Both lists stay in the DOM; only the selected one is displayed. */
.shop-rows {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: none;
    gap: 6px;
}

.shop-rows.on {
    display: grid;
}

.shop-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border: 2.4px solid var(--ink);
    border-radius: 10px;
    background: #EFE2E6;
    text-align: left;
}

.shop-row.afford {
    background: #FFE9C4;
}

.shop-row.owned {
    background: #DDF2CE;
}

.shop-info {
    flex: 1 1 auto;
    min-width: 0;
}

.shop-name {
    margin: 0;
    font: 800 13px/1.3 var(--font);
    color: #A9909B;
}

.shop-desc {
    margin: 0;
    font: 700 10px/1.4 var(--font);
    color: #B7A2AC;
}

.shop-row.afford .shop-desc,
.shop-row.owned .shop-desc {
    color: #8A6072;
}

.shop-row .buy {
    flex: 0 0 66px;
    padding: 6px 0;
    border: 0;
    border-radius: 8px;
    background: #CDBBC2;
    color: var(--cream);
    font: 800 12px/1.2 var(--font);
    cursor: pointer;
}

.shop-row.afford .buy {
    background: var(--pink-hi);
}

.shop-row.owned .buy {
    background: var(--green);
    cursor: default;
}

/* ---------- menu collection ---------- */

.menu-grid {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.menu-cell {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 2px;
    border: 2.5px solid var(--ink);
    border-radius: 8px;
    background: #EADCE0;
}

.menu-cell.got {
    background: #FFE9C4;
}

.menu-cell canvas {
    display: block;
    max-width: 100%;
}

/* ---------- input-mode copy ---------- */

body.touch .only-mouse,
body.mouse .only-touch {
    display: none;
}

@media (prefers-reduced-motion: reduce) {

    .screen.on,
    .card,
    .reward {
        animation: none;
    }
}
