/* Expiry Date — Chef Ron's Pantry Quest
   8-bit platformer styling */

:root {
    --bg: #1a2a3f;
    --sky: #5cb9f0;
    --ground: #3a5a2a;
    --ink: #1d2433;
    --hud: #f2d24a;
    --safe: #46c97a;
    --warn: #f2942e;
    --danger: #e35050;
    --frame-bg: #181e3e;
    --frame-border: #2eb37f;
}

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

html, body {
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    font-family: ui-monospace, "Menlo", "Courier New", Courier, monospace;
    letter-spacing: 0.04em;
    overflow: hidden;
    -webkit-font-smoothing: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background:
        radial-gradient(ellipse at top, #2a3a5a, #0a0f1f),
        linear-gradient(180deg, #0a0f1f 0%, #1a2a3f 100%);
    overflow: hidden;
}

#game {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    background: #5cb9f0;
    border: 4px solid #000;
    box-shadow:
        0 0 0 4px #2eb37f,
        0 12px 0 0 #000,
        0 0 40px rgba(46, 179, 122, 0.4);
    max-width: min(100vw - 32px, (100vh - 32px) * 1.6);
    max-height: min(100vh - 32px, (100vw - 32px) / 1.6);
    width: auto;
    height: auto;
    display: block;
}

/* Overlays */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.screen.active { display: flex; }
.screen .title-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% 20%, rgba(92, 185, 240, 0.35), transparent 55%),
        linear-gradient(180deg, #1a3050 0%, #0a1220 100%);
    background-size: cover;
    background-position: center;
    image-rendering: pixelated;
}
.screen .title-fg {
    position: relative;
    text-align: center;
    background: rgba(10, 16, 32, 0.78);
    padding: 24px 28px;
    border: 4px solid #000;
    box-shadow: 0 0 0 4px var(--frame-border), 0 8px 0 0 #000;
    max-width: min(440px, 90vw);
}

.frame {
    background: var(--frame-bg);
    border: 4px solid #000;
    box-shadow: 0 0 0 4px var(--frame-border), 0 8px 0 0 #000;
    padding: 28px 32px 24px;
    text-align: center;
    max-width: min(420px, 92vw);
}

.frame h2 {
    font-size: 16px;
    color: var(--hud);
    margin-bottom: 14px;
    letter-spacing: 1px;
    text-shadow: 3px 3px 0 #000;
    line-height: 1.4;
}
.frame h2.win { color: var(--safe); }
.frame h3 {
    font-size: 9px;
    color: var(--frame-border);
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.level-frame .recipe-block {
    background: rgba(0,0,0,0.3);
    border: 2px solid #000;
    padding: 14px 12px;
    margin: 16px 0 18px;
}
.recipe-label { font-size: 8px; color: #c8d0e2; letter-spacing: 2px; margin-bottom: 6px; }
.recipe-name { font-size: 14px; color: var(--hud); letter-spacing: 1px; margin-bottom: 12px; }
.recipe-ingredients {
    display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
    font-size: 8px; color: #fff;
}
.recipe-ingredients .ing {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(46,179,122,0.18); padding: 6px 8px;
    border: 2px solid var(--frame-border);
}
.recipe-ingredients .swatch {
    width: 12px; height: 12px; image-rendering: pixelated;
    display: inline-block;
}
.boss-hint {
    font-size: 8px;
    line-height: 1.65;
    color: #e8ecf5;
    text-align: center;
    margin: 0 auto;
    max-width: 52ch;
}
.boss-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    border: 2px solid #000;
    background: #f2d24a;
    color: #1a1208;
    font-size: 7px;
    font-family: inherit;
}

.recipe-result {
    font-size: 14px;
    color: var(--hud);
    margin: 6px 0 18px;
    letter-spacing: 1px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    margin: 8px 0;
    padding: 6px 10px;
    background: rgba(0,0,0,0.3);
    border: 2px solid #000;
}
.result-row.best { background: rgba(46,179,122,0.18); border-color: var(--frame-border); }
.result-label { color: #c8d0e2; letter-spacing: 1px; }
.result-value { color: #fff; }

.win-sub {
    font-size: 8px;
    color: #c8d0e2;
    line-height: 1.7;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.pixel-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    color: #fff;
    background: #2a3a5a;
    border: 4px solid #000;
    padding: 12px 18px;
    margin: 14px 6px 0;
    cursor: pointer;
    box-shadow: 4px 4px 0 0 #000;
    text-decoration: none;
    display: inline-block;
    letter-spacing: 1px;
    transition: transform 0.06s, box-shadow 0.06s;
    text-transform: uppercase;
}
.pixel-btn:hover { background: #3c5483; }
.pixel-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 0 #000;
}
.pixel-btn.primary { background: var(--frame-border); color: #001a14; }
.pixel-btn.primary:hover { background: #3ed084; }
.pixel-btn.ghost { background: transparent; border-color: var(--frame-border); color: var(--frame-border); }

.controls {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 22px;
    font-size: 8px;
    color: #c8d0e2;
}
.controls .ctrl { display: inline-flex; align-items: center; gap: 4px; }
kbd {
    display: inline-block;
    padding: 4px 6px;
    background: #fff;
    color: #000;
    border: 2px solid #000;
    box-shadow: 2px 2px 0 0 #000;
    font-family: inherit;
    font-size: 8px;
    margin: 0 2px;
}

.byline {
    margin-top: 14px;
    font-size: 7px;
    color: var(--hud);
    letter-spacing: 1.5px;
    line-height: 1.7;
}

/* In-game pause / menu button (top-right of stage; opens pause overlay) */
#hud-pause-btn {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 14px);
    right: calc(env(safe-area-inset-right) + 14px);
    width: 46px;
    height: 46px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(20, 26, 50, 0.88);
    border: 4px solid #000;
    box-shadow: 3px 3px 0 0 #000;
    cursor: pointer;
    z-index: 6;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    padding: 0;
}
#hud-pause-btn .bar {
    display: block;
    width: 6px;
    height: 22px;
    background: var(--frame-border);
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.35);
}
#hud-pause-btn:active {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 0 #000;
    background: #2a3a5a;
}
body.playing #hud-pause-btn { display: inline-flex; }

/* Recipe toast */
#recipe-toast {
    position: absolute;
    top: 76px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #f2d24a;
    color: #1d2433;
    padding: 10px 16px;
    border: 4px solid #000;
    box-shadow: 4px 4px 0 0 #000;
    font-size: 10px;
    letter-spacing: 1px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 8;
    white-space: nowrap;
}
#recipe-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Boss victory — bless-logo.png animation + bless.m4a */
#bless-flash {
    position: absolute;
    left: 50%;
    top: 38%;
    width: min(88vw, 440px);
    transform: translate(-50%, -50%);
    z-index: 12;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}
#bless-flash.show {
    opacity: 1;
    visibility: visible;
}
.bless-flash-frame {
    border: 4px solid #000;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.75);
    background: #fff;
    padding: 6px;
    transform: scale(0) rotate(-14deg);
    opacity: 0;
}
#bless-flash.show .bless-flash-frame {
    animation:
        bless-logo-pop 0.5s cubic-bezier(0.34, 1.65, 0.64, 1) forwards,
        bless-logo-bounce 0.42s ease-in-out 0.5s 4,
        bless-logo-shine 0.35s ease-in-out 0.5s 4;
}
.bless-flash-img {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
@keyframes bless-logo-pop {
    0% {
        transform: scale(0) rotate(-14deg);
        opacity: 0;
    }
    55% {
        transform: scale(1.14) rotate(5deg);
        opacity: 1;
    }
    78% {
        transform: scale(0.94) rotate(-3deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}
@keyframes bless-logo-bounce {
    0%, 100% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.05) translateY(-12px);
    }
}
@keyframes bless-logo-shine {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

/* Mobile touch controls */
#touch-controls {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 16px;
    pointer-events: none;
    z-index: 5;
}
.touch-cluster { display: flex; gap: 8px; pointer-events: auto; }
.touch-btn {
    pointer-events: auto;
    width: 60px;
    height: 60px;
    background: rgba(46, 179, 122, 0.85);
    border: 4px solid #000;
    box-shadow: 4px 4px 0 0 #000;
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    color: #001a14;
    cursor: pointer;
    user-select: none;
}
.touch-btn.jump { font-size: 10px; width: 76px; background: var(--hud); }
.touch-btn.fire {
    font-size: 9px;
    width: 56px;
    background: rgba(242, 210, 74, 0.92);
    color: #1a1208;
}
.touch-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 0 #000;
    background: #3ed084;
}
.touch-btn.jump:active { background: #ffea75; }
.touch-btn.fire:active { background: #ffd54a; }

@media (hover: none) and (pointer: coarse) {
    #touch-controls { display: flex; }
    .controls { display: none; }
}

@media (max-width: 520px) {
    .frame { padding: 18px 18px 16px; }
    .frame h2 { font-size: 12px; }
    .pixel-btn { font-size: 9px; padding: 10px 14px; }
    .screen .title-fg { padding: 16px 16px; }
}

/* App Store / marketing capture (?shot=1…8) */
body.marketing-shot {
    overflow: hidden;
    background: #0a0f1f;
}
body.marketing-shot #stage {
    padding: 0;
    width: 100vw;
    height: 100vh;
    background: #0a0f1f;
}
body.marketing-shot #game {
    width: 640px;
    height: 400px;
    max-width: none;
    max-height: none;
    border: 4px solid #000;
    box-shadow: 0 0 0 4px #2eb37f;
}
body.marketing-shot #hud-pause-btn,
body.marketing-shot .screen {
    display: none !important;
}
body.marketing-shot #touch-controls {
    display: none !important;
}
body.marketing-shot.marketing-show-touch #touch-controls {
    display: flex !important;
}
