:root {
    --bg: #2b1d16;
    --paper: #fff8ec;
    --ink: #3a2a22;
    --muted: #8a6f5c;
    --accent: #f97316;
    --accent-dark: #c2410c;
    --good: #16a34a;
    --gold: #facc15;
    font-family: 'Fredoka', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

[hidden] { display: none !important; }

.screen {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    background:
        radial-gradient(circle at 20% 10%, rgba(249, 115, 22, .25), transparent 40%),
        radial-gradient(circle at 80% 90%, rgba(250, 204, 21, .18), transparent 45%),
        repeating-linear-gradient(45deg, #f3e6cf 0 18px, #ead9bb 18px 36px);
}

/* Centre when there's room, scroll from the top when there isn't. */
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }

.title-art { display: flex; gap: 6px; align-items: flex-end; height: 110px; }
.title-art img { width: 84px; height: 84px; animation: bob 1.4s ease-in-out infinite; }
.title-art img:nth-child(2) { width: 110px; height: 110px; animation-delay: .2s; }
.title-art img:nth-child(3) { animation-delay: .4s; }

@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }

h1 {
    margin: 0;
    font-size: clamp(44px, 12vw, 72px);
    font-weight: 700;
    color: var(--accent);
    text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
    letter-spacing: .5px;
}

h2 { margin: 0 0 6px; font-size: 26px; font-weight: 700; }

.tagline {
    max-width: 440px;
    margin: 0;
    text-align: center;
    font-size: 17px;
    line-height: 1.4;
    color: var(--ink);
    background: rgba(255, 248, 236, .85);
    padding: 10px 14px;
    border-radius: 14px;
}

.btn {
    font: inherit;
    font-size: 19px;
    font-weight: 600;
    min-width: 220px;
    padding: 12px 22px;
    border: 3px solid var(--ink);
    border-radius: 16px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 4px 0 var(--ink);
    cursor: pointer;
    transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; min-width: 0; }
.btn-ghost:active { transform: none; box-shadow: none; }

.howto {
    max-width: 460px;
    width: 100%;
    background: rgba(255, 248, 236, .92);
    border: 3px solid var(--ink);
    border-radius: 14px;
    padding: 8px 14px;
}
.howto summary { font-weight: 600; cursor: pointer; }
.howto ul { margin: 8px 0 4px; padding-left: 20px; line-height: 1.45; font-size: 15px; }

.level-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 640px;
}

.level-card {
    font: inherit;
    text-align: left;
    padding: 14px;
    border: 3px solid var(--ink);
    border-radius: 16px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 4px 0 var(--ink);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.level-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.level-card .num { font-size: 13px; color: var(--muted); font-weight: 600; }
.level-card .name { font-size: 21px; font-weight: 700; }
.level-card .blurb { font-size: 14px; color: var(--muted); }
.level-card .card-stars { font-size: 22px; letter-spacing: 2px; color: var(--gold); text-shadow: 0 1px 0 var(--ink); }
.level-card.locked { opacity: .55; cursor: not-allowed; }

.game {
    position: fixed;
    inset: 0;
    background: var(--bg);
    touch-action: none;
}

.world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.round-btn {
    position: absolute;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid var(--ink);
    background: var(--paper);
    color: var(--ink);
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 3px 0 var(--ink);
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 2;
}
.round-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.pause-btn { left: calc(10px + env(safe-area-inset-left)); bottom: calc(10px + env(safe-area-inset-bottom)); width: 42px; height: 42px; font-size: 18px; }
.switch-btn { right: calc(12px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); width: 64px; height: 64px; font-size: 30px; background: var(--accent); color: #fff; }

.countdown {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: clamp(56px, 16vw, 120px);
    font-weight: 700;
    color: #fff;
    text-shadow: 4px 4px 0 var(--ink);
    pointer-events: none;
    z-index: 3;
    animation: pop .5s ease-out;
}
@keyframes pop { from { transform: scale(1.6); opacity: 0; } }

.rotate-hint {
    display: none;
    position: absolute;
    left: 50%;
    top: calc(12px + env(safe-area-inset-top));
    transform: translateX(-50%);
    background: rgba(255, 248, 236, .9);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 14px;
    pointer-events: none;
    white-space: nowrap;
}
@media (orientation: portrait) { .rotate-hint { display: block; } }

.overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(20, 12, 8, .6);
    z-index: 4;
    padding: 16px;
}

.card {
    background: var(--paper);
    border: 4px solid var(--ink);
    border-radius: 22px;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 0 var(--ink);
    max-height: 100%;
    overflow: auto;
}

.stars { font-size: 52px; letter-spacing: 6px; line-height: 1; }
.stars span { color: #d6c8b4; text-shadow: 0 2px 0 var(--ink); display: inline-block; }
.stars span.on { color: var(--gold); animation: starIn .45s cubic-bezier(.3, 1.8, .5, 1) both; }
.stars span.on:nth-child(2) { animation-delay: .25s; }
.stars span.on:nth-child(3) { animation-delay: .5s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }

.big-score { margin: 0; font-size: 30px; font-weight: 700; }
.detail { margin: 0; color: var(--muted); text-align: center; }

@media (max-height: 420px) {
    .card { padding: 10px 16px; gap: 6px; }
    .stars { font-size: 36px; }
    .btn { padding: 8px 18px; font-size: 16px; }
}

/* ---- cook together ---- */

.field { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 320px; font-weight: 600; }
.field input, .code-row input {
    font: inherit;
    font-size: 19px;
    padding: 10px 14px;
    border: 3px solid var(--ink);
    border-radius: 14px;
    background: var(--paper);
    color: var(--ink);
    user-select: text;
    -webkit-user-select: text;
}
.code-row { display: flex; gap: 8px; width: 100%; max-width: 320px; }
.code-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 3px; text-align: center; }
.btn-small { min-width: 0; padding: 8px 14px; font-size: 17px; }
.btn:disabled { opacity: .6; }
.divider { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 320px; color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 2px; background: rgba(58, 42, 34, .25); }
.error { margin: 0; color: #b91c1c; font-weight: 600; text-align: center; background: rgba(255, 248, 236, .9); padding: 6px 10px; border-radius: 10px; }

.player-list {
    list-style: none;
    margin: 0;
    padding: 10px 14px;
    width: 100%;
    max-width: 420px;
    background: var(--paper);
    border: 3px solid var(--ink);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
}
.player-list li { display: flex; align-items: center; gap: 10px; }
.player-list li.offline { opacity: .45; }
.player-list .tag { margin-left: auto; font-size: 13px; color: var(--muted); }
.chef-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }

.level-card.selected { outline: 4px solid var(--accent); outline-offset: 2px; }
.level-card:disabled { cursor: default; }
.level-card:disabled:not(.selected) { opacity: .7; }

.banner {
    position: absolute;
    left: 50%;
    top: calc(12px + env(safe-area-inset-top));
    transform: translateX(-50%);
    background: rgba(255, 248, 236, .95);
    border: 2px solid var(--ink);
    padding: 6px 14px;
    border-radius: 12px;
    font-weight: 600;
    z-index: 3;
    pointer-events: none;
    white-space: nowrap;
}
.banner-warn { background: #fde68a; }
