@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css");
@import url("https://fonts.googleapis.com/css2?family=Gaegu:wght@700&display=swap");

@font-face {
    font-family: "BMJUA";
    src: url("assets/font/BMJUA_otf.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --olive-900: #243104;
    --olive-700: #50680a;
    --olive-500: #7ba314;
    --olive-300: #cde47a;
    --cream: #fff6d7;
    --cream-deep: #f3df98;
    --brown: #4d2b12;
    --yellow: #ffd94e;
    --yellow-shadow: #b97709;
    --green: #7fd44c;
    --green-shadow: #2f6e11;
    --line: rgba(54, 32, 10, 0.86);
    --panel-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --arcade-purple: #a05bd8;
    --arcade-purple-deep: #7e35b7;
    --arcade-yellow: #ffd400;
    --arcade-orange: #ff7b00;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(163, 204, 43, 0.28), transparent 38%),
        linear-gradient(180deg, #4d650f 0%, #1a2304 100%);
    color: #1c1408;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.05) 0,
            rgba(255, 255, 255, 0.05) 2px,
            transparent 2px,
            transparent 14px
        );
    opacity: 0.25;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(6px, 1vw, 12px);
}

#game-container {
    position: relative;
    width: min(1500px, calc((100vh - 16px) * 1024 / 639), calc(100vw - 12px));
    aspect-ratio: 1024 / 639;
    overflow: hidden;
    border: 6px solid rgba(255, 244, 191, 0.8);
    border-radius: 26px;
    background: #85ab11;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

.screen,
.modal {
    position: absolute;
    inset: 0;
}

.screen {
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

.full-screen-image,
.intro-video,
.scene-rice-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 0;
}

.screen-gradient {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(13, 13, 5, 0.3) 0%, rgba(13, 13, 5, 0.55) 100%),
        radial-gradient(circle at center, transparent 20%, rgba(0, 0, 0, 0.35) 100%);
    pointer-events: none;
    z-index: 1;
}

.kicker,
.panel-kicker {
    font-size: clamp(10px, 1vw, 12px);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(62, 42, 9, 0.75);
}

.ui-button {
    border: 4px solid var(--line);
    border-radius: 16px;
    padding: 12px 20px;
    font-size: clamp(14px, 1.55vw, 22px);
    font-weight: 800;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
    color: var(--brown);
}

.ui-button:hover {
    filter: brightness(1.04);
}

.ui-button:active {
    transform: translateY(3px);
}

.ui-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.yellow-button {
    background: linear-gradient(180deg, #ffe78e 0%, var(--yellow) 100%);
    box-shadow: inset 0 -4px 0 rgba(164, 110, 0, 0.28), 0 8px 0 var(--yellow-shadow);
}

.green-button {
    background: linear-gradient(180deg, #b6f58e 0%, var(--green) 100%);
    box-shadow: inset 0 -4px 0 rgba(28, 93, 10, 0.28), 0 8px 0 var(--green-shadow);
}

.ghost-button {
    background: rgba(255, 250, 229, 0.92);
    box-shadow: inset 0 -4px 0 rgba(111, 96, 64, 0.24), 0 8px 0 rgba(54, 42, 14, 0.88);
}

#screen-intro {
    background: #000;
}

.intro-copy {
    position: absolute;
    left: clamp(24px, 3.5vw, 42px);
    bottom: clamp(24px, 3.5vw, 42px);
    max-width: min(460px, 48%);
    padding: clamp(18px, 2vw, 28px);
    border: 4px solid rgba(255, 244, 191, 0.78);
    border-radius: 22px;
    background: rgba(19, 24, 6, 0.72);
    color: #fff5d8;
    box-shadow: var(--panel-shadow);
    z-index: 2;
}

.intro-copy h1,
.title-card h1 {
    margin: 10px 0 14px;
    font-size: clamp(28px, 4vw, 54px);
    line-height: 1.05;
}

.intro-copy p {
    font-size: clamp(13px, 1.4vw, 18px);
    line-height: 1.5;
}

.intro-skip {
    position: absolute;
    right: clamp(24px, 3.5vw, 42px);
    bottom: clamp(24px, 3.5vw, 42px);
    z-index: 2;
}

#screen-intro .screen-gradient,
#screen-title .screen-gradient {
    display: none;
}

.title-card {
    position: absolute;
    bottom: clamp(20px, 3vw, 34px);
    right: clamp(28px, 4.4vw, 54px);
    width: min(600px, 58%);
    padding: clamp(18px, 2vw, 24px);
    border: 5px solid rgba(255, 239, 181, 0.92);
    border-radius: 26px;
    background: rgba(255, 248, 223, 0.82);
    box-shadow: var(--panel-shadow);
    z-index: 2;
}

.title-copy {
    font-size: clamp(14px, 1.45vw, 20px);
    line-height: 1.55;
    color: rgba(58, 41, 15, 0.92);
}

.title-card h1 {
    font-size: clamp(26px, 3vw, 44px);
    white-space: nowrap;
}

.title-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 24px;
}

.game-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
}

.hud {
    position: absolute;
    top: clamp(16px, 2vw, 20px);
    left: clamp(18px, 2vw, 22px);
    right: clamp(18px, 2vw, 22px);
    display: flex;
    justify-content: flex-end;
    z-index: 4;
}

.panel-helper,
.modal-copy,
.result-text,
.result-summary {
    font-size: clamp(13px, 1.25vw, 18px);
    line-height: 1.45;
}

.selection-summary {
    padding: 12px 16px;
    border-radius: 18px;
    background: rgba(41, 32, 12, 0.85);
    color: #fff2cf;
    font-size: clamp(12px, 1.2vw, 16px);
    line-height: 1.4;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
    justify-self: end;
}

.scene-board {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.result-scene {
    overflow: hidden;
    pointer-events: none;
}

.scene-rice-layer {
    z-index: 1;
}

.scene-items,
.scene-sauce {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.scene-item {
    position: absolute;
    width: clamp(145px, 18vw, 240px);
    aspect-ratio: 1 / 1;
    object-fit: contain;
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.18));
    transform:
        translate(-50%, -50%)
        rotate(var(--rotation, 0deg))
        scale(var(--scale, 1));
}

.scene-sauce img {
    position: absolute;
    left: var(--left, 56%);
    top: var(--top, 42%);
    width: clamp(142px, 17vw, 228px);
    aspect-ratio: 1 / 1;
    object-fit: contain;
    opacity: 0.88;
    mix-blend-mode: multiply;
    filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.18));
    transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)) scale(var(--scale, 1));
}

.mix-flash {
    position: absolute;
    inset: 0;
    opacity: 0;
    background:
        radial-gradient(circle at 56% 40%, rgba(255, 247, 202, 0.95) 0%, rgba(255, 218, 99, 0.55) 12%, rgba(255, 255, 255, 0) 30%);
    z-index: 5;
    transition: opacity 180ms ease;
    pointer-events: none;
}

#scene-board.is-mixing .mix-flash {
    opacity: 1;
}

#scene-board.is-mixing {
    animation: bowl-shake 680ms ease;
}

.control-panel {
    position: absolute;
    left: clamp(18px, 2vw, 22px);
    right: clamp(18px, 2vw, 22px);
    bottom: clamp(14px, 1.8vw, 18px);
    height: clamp(172px, 31%, 208px);
    padding: clamp(12px, 1.4vw, 16px);
    display: grid;
    grid-template-columns: minmax(160px, 22%) 1fr auto;
    gap: clamp(14px, 1.8vw, 18px);
    align-items: center;
    border: 5px solid rgba(74, 50, 15, 0.86);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 247, 213, 0.94) 0%, rgba(241, 220, 151, 0.91) 100%);
    backdrop-filter: blur(6px);
    box-shadow: var(--panel-shadow);
    z-index: 4;
}

.panel-heading {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-self: stretch;
    gap: 10px;
    padding-top: 10px;
}

.panel-heading h2 {
    font-size: clamp(20px, 1.95vw, 28px);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(10px, 1.25vw, 14px);
    align-content: center;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.option-grid[data-step="rice"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(14px, 1.6vw, 18px);
}

.option-grid.mix-grid {
    grid-template-columns: minmax(0, 1fr);
    align-content: stretch;
}

.option-card,
.summary-card {
    border: 4px solid rgba(255, 248, 230, 0.96);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffe45a 0%, var(--arcade-yellow) 100%);
    box-shadow:
        inset 0 -4px 0 rgba(201, 126, 0, 0.3),
        0 8px 0 rgba(100, 32, 127, 0.42);
}

.option-card {
    display: grid;
    grid-template-columns: clamp(48px, 5vw, 62px) 1fr;
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding: 8px 10px;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.option-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2);
}

.option-card[data-step="rice"] {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(72px, 8vw, 92px);
    padding: 10px 16px;
    text-align: center;
}

.rice-only-label {
    display: inline-block;
    font-size: clamp(22px, 2vw, 29px);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    word-break: keep-all;
    letter-spacing: -0.04em;
    color: var(--arcade-orange);
    font-family: "Gaegu", "Pretendard", sans-serif;
    text-shadow: 1px 1px 0 rgba(255, 247, 210, 0.92);
}

.option-card[data-step="sides"] {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(64px, 7vw, 82px);
    padding: 10px 12px;
    text-align: center;
}

.sides-only-label {
    display: inline-block;
    font-size: clamp(17px, 1.35vw, 22px);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    word-break: keep-all;
    letter-spacing: -0.04em;
    color: var(--arcade-orange);
    font-family: "Gaegu", "Pretendard", sans-serif;
    text-shadow: 1px 1px 0 rgba(255, 247, 210, 0.92);
}

.option-card[data-step="sauce"] {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(64px, 7vw, 82px);
    padding: 10px 12px;
    text-align: center;
}

.sauce-only-label {
    display: inline-block;
    font-size: clamp(17px, 1.35vw, 22px);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    word-break: keep-all;
    letter-spacing: -0.04em;
    color: var(--arcade-orange);
    font-family: "Gaegu", "Pretendard", sans-serif;
    text-shadow: 1px 1px 0 rgba(255, 247, 210, 0.92);
}

.option-card.selected {
    border-color: #fffef8;
    box-shadow:
        0 0 0 4px rgba(255, 255, 255, 0.38),
        inset 0 -4px 0 rgba(201, 126, 0, 0.3),
        0 8px 0 rgba(100, 32, 127, 0.42);
}

.option-thumb {
    position: relative;
    display: grid;
    place-items: center;
    width: clamp(48px, 5vw, 62px);
    min-height: clamp(48px, 5vw, 62px);
    border-radius: 12px;
    background:
        radial-gradient(circle at center, rgba(165, 215, 83, 0.46) 0%, rgba(165, 215, 83, 0.12) 65%, rgba(165, 215, 83, 0) 100%),
        linear-gradient(180deg, rgba(255, 254, 247, 0.95) 0%, rgba(244, 237, 206, 0.95) 100%);
}

.option-thumb img {
    max-width: 84%;
    max-height: 84%;
    object-fit: contain;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.14));
}

.option-card[data-option-id="butter"] .option-thumb img,
.option-card[data-option-id="soy-sauce"] .option-thumb img {
    max-width: 96%;
    max-height: 96%;
}

.option-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    align-items: flex-start;
}

.option-copy strong {
    font-size: clamp(13px, 1.15vw, 17px);
    line-height: 1.1;
    white-space: nowrap;
    word-break: keep-all;
    color: var(--arcade-orange);
    font-family: "Gaegu", "Pretendard", sans-serif;
    text-shadow: 1px 1px 0 rgba(255, 247, 210, 0.92);
}

.option-copy span,
.option-tag,
.summary-card li {
    font-size: clamp(10px, 0.9vw, 12px);
    line-height: 1.35;
    word-break: keep-all;
}

.option-tag {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(91, 136, 10, 0.12);
    color: rgba(52, 78, 7, 0.9);
    white-space: nowrap;
}

.option-card[data-tone="danger"] .option-tag {
    background: rgba(195, 61, 40, 0.12);
    color: rgba(126, 29, 18, 0.94);
}

.option-card[data-tone="odd"] .option-tag {
    background: rgba(142, 93, 11, 0.12);
    color: rgba(109, 69, 5, 0.94);
}

.panel-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: center;
    gap: 12px;
    min-width: clamp(140px, 16vw, 182px);
    padding: 0;
}

.panel-actions .ui-button {
    width: 100%;
    min-height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(18px, 1.45vw, 24px);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.summary-card {
    height: 100%;
    padding: 16px 18px;
}

.summary-card h3 {
    font-size: clamp(18px, 1.8vw, 24px);
    margin-bottom: 10px;
}

.summary-card ul {
    list-style: none;
    display: grid;
    gap: 6px;
}

#screen-result .screen-gradient {
    background:
        linear-gradient(90deg, rgba(18, 21, 8, 0.4) 0%, rgba(18, 21, 8, 0.72) 100%),
        linear-gradient(180deg, rgba(18, 21, 8, 0.2) 0%, rgba(18, 21, 8, 0.64) 100%);
}

.result-layout {
    position: absolute;
    inset: clamp(28px, 3vw, 34px);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: clamp(18px, 2vw, 24px);
    align-items: center;
    z-index: 2;
}

.fail-ending-layout {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: #000;
}

.fail-ending-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fail-ending-actions {
    position: absolute;
    right: clamp(20px, 2.2vw, 30px);
    bottom: clamp(18px, 2.2vw, 28px);
    display: flex;
    gap: 12px;
    z-index: 4;
}

.result-scene {
    position: relative;
    aspect-ratio: 1024 / 639;
    border: 5px solid rgba(255, 239, 181, 0.82);
    border-radius: 26px;
    background:
        linear-gradient(180deg, rgba(24, 30, 8, 0.12) 0%, rgba(24, 30, 8, 0.34) 100%),
        url("assets/background/게임 배경.png") center / cover no-repeat;
    box-shadow: var(--panel-shadow);
}

.result-card {
    padding: clamp(24px, 3vw, 30px);
    border: 5px solid rgba(255, 239, 181, 0.92);
    border-radius: 26px;
    background: rgba(255, 248, 223, 0.92);
    box-shadow: var(--panel-shadow);
}

.result-grade {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(78, 114, 12, 0.14);
    color: rgba(52, 78, 7, 0.92);
    font-size: clamp(13px, 1.2vw, 16px);
    font-weight: 800;
}

.result-title {
    margin: 12px 0 14px;
    font-size: clamp(24px, 2.6vw, 34px);
    line-height: 1.15;
}

.result-text,
.result-summary {
    color: rgba(61, 44, 16, 0.92);
}

.result-summary {
    margin-top: 12px;
}

.modal {
    display: grid;
    place-items: center;
    background: rgba(7, 8, 3, 0.66);
    z-index: 10;
}

.modal-card {
    width: min(480px, calc(100% - 40px));
    padding: 24px;
    border: 5px solid rgba(255, 239, 181, 0.96);
    border-radius: 24px;
    background: rgba(255, 248, 223, 0.98);
    box-shadow: var(--panel-shadow);
}

.modal-card h2 {
    margin: 10px 0 14px;
    font-size: clamp(24px, 2.2vw, 30px);
}

.instruction-list {
    margin-left: 18px;
    display: grid;
    gap: 8px;
    font-size: clamp(13px, 1.2vw, 18px);
    line-height: 1.45;
}

.modal-copy {
    margin: 16px 0 20px;
}

@keyframes bowl-shake {
    0% { transform: translate(0, 0) rotate(0deg); }
    15% { transform: translate(-5px, 4px) rotate(-2deg); }
    30% { transform: translate(7px, -3px) rotate(2deg); }
    45% { transform: translate(-6px, 2px) rotate(-1deg); }
    60% { transform: translate(6px, -4px) rotate(1deg); }
    75% { transform: translate(-3px, 2px) rotate(-1deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

@media (max-width: 860px) {
    .title-card {
        width: min(480px, calc(100% - 36px));
        right: 18px;
        left: 18px;
        bottom: 18px;
    }

    .title-card h1 {
        white-space: normal;
    }

    .control-panel {
        grid-template-columns: 1fr;
        height: auto;
    }

    .panel-actions {
        flex-direction: row;
        min-width: 0;
    }

    .result-layout {
        grid-template-columns: 1fr;
        align-content: start;
    }
}

@media (max-width: 620px) {
    #game-container {
        width: min(calc((100vh - 10px) * 1024 / 639), calc(100vw - 8px));
        border-width: 4px;
        border-radius: 18px;
    }

    .option-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        height: auto;
    }

    .panel-actions {
        flex-wrap: wrap;
    }

    .ui-button {
        border-width: 3px;
        border-radius: 12px;
        box-shadow: none;
    }
}

@media (max-width: 700px) and (orientation: portrait) {
    .ui-button {
        padding: 8px 10px;
        font-size: clamp(12px, 3.9vw, 16px);
        border-width: 3px;
        border-radius: 12px;
    }

    #screen-intro,
    #screen-title,
    .fail-ending-layout {
        background: #1b2206;
    }

    #screen-intro .intro-video,
    #screen-title .intro-video {
        object-fit: contain;
        object-position: center center;
        background: #1b2206;
    }

    .fail-ending-video {
        object-fit: contain;
        object-position: center center;
        background: #1b2206;
    }

    .app-shell {
        padding: 4px;
    }

    #game-container {
        width: calc(100vw - 8px);
        height: calc(100dvh - 8px);
        aspect-ratio: auto;
        border-width: 4px;
        border-radius: 18px;
    }

    .intro-skip {
        right: 12px;
        bottom: 12px;
    }

    .title-card {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        padding: 14px;
        border-width: 4px;
        border-radius: 18px;
    }

    .title-card h1 {
        font-size: clamp(24px, 7vw, 34px);
        white-space: normal;
    }

    .title-copy {
        font-size: 14px;
        line-height: 1.45;
    }

    .title-actions {
        gap: 10px;
        margin-top: 16px;
    }

    .title-actions .ui-button {
        flex: 1 1 calc(50% - 10px);
        min-height: 52px;
        font-size: 16px;
        padding: 10px 12px;
    }

    .hud {
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .selection-summary {
        max-width: 100%;
        width: auto;
        padding: 10px 12px;
        font-size: 12px;
        line-height: 1.35;
    }

    #screen-game .full-screen-image {
        inset: auto;
        top: 0;
        left: 50%;
        width: 132%;
        height: auto;
        transform: translateX(-50%);
        object-fit: contain;
        object-position: center top;
        background: #85ab11;
    }

    #screen-result .full-screen-image {
        object-fit: contain;
        object-position: center top;
        background: #85ab11;
    }

    #screen-game .scene-board {
        inset: auto;
        top: 0;
        left: 50%;
        width: 132%;
        height: auto;
        aspect-ratio: 1024 / 639;
        transform: translateX(-50%);
    }

    #screen-game .scene-rice-layer,
    #screen-result .scene-rice-layer {
        object-fit: contain;
        object-position: center top;
    }

    #screen-game .scene-rice-layer {
        inset: auto;
        left: 50%;
        top: 62%;
        width: 30%;
        height: auto;
        transform: translate(-50%, -50%);
    }

    .scene-item {
        width: clamp(90px, 22vw, 132px);
    }

    .scene-sauce img {
        width: clamp(82px, 21vw, 128px);
    }

    .control-panel {
        left: 10px;
        right: 10px;
        bottom: 10px;
        height: 38%;
        min-height: 0;
        padding: 10px;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr) auto;
        gap: 10px;
        align-items: stretch;
        border-width: 4px;
        border-radius: 18px;
        overflow: hidden;
    }

    .panel-heading {
        gap: 6px;
        padding-top: 0;
    }

    .panel-kicker {
        font-size: 10px;
    }

    .panel-heading h2 {
        font-size: 18px;
    }

    .panel-helper {
        font-size: 12px;
        line-height: 1.35;
    }

    .option-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        min-height: 0;
        height: 100%;
        align-content: start;
        overflow-y: auto;
        padding-right: 4px;
    }

    .option-grid[data-step="rice"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .option-card[data-step="rice"],
    .option-card[data-step="sides"],
    .option-card[data-step="sauce"] {
        min-height: 50px;
        padding: 7px 8px;
        border-width: 3px;
        border-radius: 14px;
    }

    .rice-only-label,
    .sides-only-label,
    .sauce-only-label {
        font-size: 14px;
        line-height: 1;
    }

    .panel-actions {
        flex-direction: row;
        align-self: stretch;
        min-width: 0;
        gap: 8px;
    }

    .panel-actions .ui-button {
        min-height: 44px;
        font-size: 14px;
        padding: 8px 6px;
    }

    .result-layout {
        inset: 10px;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        gap: 10px;
    }

    .result-card {
        padding: 16px;
        border-width: 4px;
        border-radius: 18px;
    }

    .result-title {
        font-size: 22px;
    }

    .fail-ending-actions {
        left: 10px;
        right: 10px;
        bottom: 10px;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .fail-ending-actions .ui-button {
        min-height: 48px;
        padding: 8px 6px;
        font-size: 14px;
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    .app-shell {
        padding: 4px;
    }

    #game-container {
        width: calc(100vw - 8px);
        height: calc(100dvh - 8px);
        aspect-ratio: auto;
        border-width: 4px;
        border-radius: 18px;
    }

    .title-card {
        width: min(320px, 34%);
        left: auto;
        right: 12px;
        bottom: 12px;
        padding: 10px;
        border-width: 4px;
        border-radius: 18px;
    }

    .title-card h1 {
        font-size: clamp(18px, 2vw, 24px);
    }

    .title-copy {
        font-size: 11px;
        line-height: 1.3;
    }

    .title-actions {
        gap: 5px;
        margin-top: 8px;
    }

    .title-actions .ui-button {
        min-height: 34px;
        font-size: 11px;
        padding: 5px 8px;
        border-width: 3px;
        border-radius: 12px;
    }

    .hud {
        top: 8px;
        left: 8px;
        right: 8px;
    }

    .selection-summary {
        padding: 8px 10px;
        font-size: 11px;
        line-height: 1.25;
    }

    #screen-game .scene-board {
        inset: 0 0 34% 0;
    }

    #screen-game .scene-rice-layer,
    #screen-result .scene-rice-layer {
        object-fit: contain;
        object-position: center top;
    }

    .scene-item {
        width: clamp(88px, 12vw, 128px);
    }

    .scene-sauce img {
        width: clamp(80px, 11vw, 120px);
    }

    .control-panel {
        left: 8px;
        right: 8px;
        bottom: 8px;
        height: 31%;
        min-height: 140px;
        padding: 10px;
        grid-template-columns: minmax(150px, 24%) 1fr 150px;
        gap: 10px;
        border-width: 4px;
        border-radius: 18px;
    }

    .panel-heading {
        gap: 6px;
        padding-top: 0;
    }

    .panel-kicker {
        font-size: 10px;
    }

    .panel-heading h2 {
        font-size: 17px;
    }

    .panel-helper {
        font-size: 12px;
        line-height: 1.3;
    }

    .option-grid {
        gap: 8px;
    }

    .option-grid[data-step="rice"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .option-card[data-step="rice"],
    .option-card[data-step="sides"],
    .option-card[data-step="sauce"] {
        min-height: 48px;
        padding: 8px 10px;
        border-width: 3px;
        border-radius: 14px;
    }

    .rice-only-label,
    .sides-only-label,
    .sauce-only-label {
        font-size: 15px;
        line-height: 1;
    }

    .panel-actions {
        min-width: 150px;
        gap: 8px;
    }

    .panel-actions .ui-button {
        min-height: 46px;
        font-size: 15px;
        padding: 8px 10px;
    }

    .result-layout {
        inset: 10px;
        grid-template-columns: 1.1fr 0.9fr;
        gap: 10px;
    }

    .result-card {
        padding: 14px;
        border-width: 4px;
        border-radius: 18px;
    }

    .result-title {
        font-size: 20px;
    }

    .fail-ending-actions {
        right: 10px;
        left: auto;
        bottom: 10px;
        gap: 8px;
    }

    .fail-ending-actions .ui-button {
        min-height: 42px;
        font-size: 13px;
        padding: 8px 10px;
    }
}

@media (max-width: 900px) {
    #game-container {
        width: min(calc((100dvh - 8px) * 1024 / 639), calc(100vw - 8px));
        height: auto;
        aspect-ratio: 1024 / 639;
        border-width: 4px;
        border-radius: 18px;
    }

    .ui-button {
        padding: 12px 20px;
        font-size: clamp(14px, 1.55vw, 22px);
        border-width: 4px;
        border-radius: 16px;
    }

    #screen-intro,
    #screen-title,
    .fail-ending-layout {
        background: #000;
    }

    #screen-intro .intro-video,
    #screen-title .intro-video,
    .fail-ending-video {
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        object-position: center center;
        transform: none;
        background: #000;
    }

    .intro-skip {
        right: clamp(24px, 3.5vw, 42px);
        bottom: clamp(24px, 3.5vw, 42px);
    }

    .title-card {
        left: auto;
        right: clamp(28px, 4.4vw, 54px);
        bottom: clamp(20px, 3vw, 34px);
        width: min(600px, 58%);
        padding: clamp(18px, 2vw, 24px);
        border-width: 5px;
        border-radius: 26px;
    }

    .title-card h1 {
        font-size: clamp(26px, 3vw, 44px);
        white-space: nowrap;
    }

    .title-copy {
        font-size: clamp(14px, 1.45vw, 20px);
        line-height: 1.55;
    }

    .title-actions {
        gap: 14px;
        margin-top: 24px;
    }

    .title-actions .ui-button {
        flex: 0 1 auto;
        min-height: 0;
        font-size: clamp(14px, 1.55vw, 22px);
        padding: 12px 20px;
        border-width: 4px;
        border-radius: 16px;
    }

    .hud {
        top: clamp(16px, 2vw, 20px);
        left: clamp(18px, 2vw, 22px);
        right: clamp(18px, 2vw, 22px);
    }

    .selection-summary {
        width: auto;
        max-width: none;
        padding: 12px 16px;
        font-size: clamp(12px, 1.2vw, 16px);
        line-height: 1.4;
    }

    #screen-game .full-screen-image,
    #screen-result .full-screen-image {
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center center;
        transform: none;
        background: transparent;
    }

    #screen-game .scene-board {
        inset: 0;
        width: auto;
        height: auto;
        aspect-ratio: auto;
        transform: none;
    }

    #screen-game .scene-rice-layer,
    #screen-result .scene-rice-layer {
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center center;
        transform: none;
    }

    .scene-item {
        width: clamp(145px, 18vw, 240px);
    }

    .scene-sauce img {
        width: clamp(142px, 17vw, 228px);
    }

    .control-panel {
        left: clamp(18px, 2vw, 22px);
        right: clamp(18px, 2vw, 22px);
        bottom: clamp(14px, 1.8vw, 18px);
        height: clamp(172px, 31%, 208px);
        min-height: 0;
        padding: clamp(12px, 1.4vw, 16px);
        grid-template-columns: minmax(160px, 22%) 1fr auto;
        grid-template-rows: none;
        gap: clamp(14px, 1.8vw, 18px);
        align-items: center;
        border-width: 5px;
        border-radius: 22px;
        overflow: visible;
    }

    .panel-heading {
        gap: 10px;
        padding-top: 10px;
    }

    .panel-kicker {
        font-size: clamp(10px, 1vw, 12px);
    }

    .panel-heading h2 {
        font-size: clamp(20px, 1.95vw, 28px);
    }

    .panel-helper {
        font-size: clamp(13px, 1.25vw, 18px);
        line-height: 1.45;
    }

    .option-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: clamp(10px, 1.25vw, 14px);
        height: 100%;
        min-height: 0;
        align-content: center;
        overflow: visible;
        padding-right: 0;
    }

    .option-grid[data-step="rice"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: clamp(14px, 1.6vw, 18px);
    }

    .option-card[data-step="rice"],
    .option-card[data-step="sides"],
    .option-card[data-step="sauce"] {
        min-height: clamp(64px, 7vw, 82px);
        padding: 10px 12px;
        border-width: 4px;
        border-radius: 18px;
    }

    .option-card[data-step="rice"] {
        min-height: clamp(72px, 8vw, 92px);
        padding: 10px 16px;
    }

    .rice-only-label,
    .sides-only-label,
    .sauce-only-label {
        font-size: clamp(20px, 2vw, 32px);
        line-height: 1;
    }

    .panel-actions {
        flex-direction: column;
        align-self: center;
        min-width: clamp(140px, 16vw, 182px);
        gap: 12px;
    }

    .panel-actions .ui-button {
        min-height: 64px;
        font-size: clamp(18px, 1.45vw, 24px);
        padding: 12px 20px;
    }

    .result-layout {
        inset: clamp(28px, 3vw, 34px);
        grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
        grid-template-rows: none;
        gap: clamp(18px, 2vw, 24px);
    }

    .result-card {
        padding: clamp(24px, 3vw, 30px);
        border-width: 5px;
        border-radius: 26px;
    }

    .result-title {
        font-size: clamp(24px, 2.6vw, 34px);
    }

    .fail-ending-actions {
        left: auto;
        right: clamp(20px, 2.2vw, 30px);
        bottom: clamp(18px, 2.2vw, 28px);
        display: flex;
        gap: 12px;
    }

    .fail-ending-actions .ui-button {
        min-height: 0;
        padding: 12px 20px;
        font-size: clamp(14px, 1.55vw, 22px);
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    .control-panel {
        height: clamp(124px, 23%, 152px);
        padding: 10px 12px;
        grid-template-columns: minmax(132px, 17%) 1fr minmax(116px, 12%);
        gap: 12px;
    }

    .panel-heading {
        gap: 6px;
        padding-top: 0;
    }

    .panel-kicker {
        font-size: 10px;
    }

    .panel-heading h2 {
        font-size: 16px;
    }

    .panel-helper {
        font-size: 11px;
        line-height: 1.25;
    }

    .option-grid {
        gap: 10px;
    }

    .option-grid[data-step="rice"] {
        gap: 10px;
    }

    .option-card[data-step="rice"],
    .option-card[data-step="sides"],
    .option-card[data-step="sauce"] {
        min-height: 48px;
        padding: 7px 8px;
        border-width: 3px;
        border-radius: 14px;
    }

    .option-card[data-step="rice"] {
        min-height: 60px;
        padding: 8px 12px;
    }

    .rice-only-label,
    .sides-only-label,
    .sauce-only-label {
        font-size: 12px;
        letter-spacing: -0.05em;
    }

    .rice-only-label {
        font-size: 16px;
    }

    .sides-only-label,
    .sauce-only-label {
        font-size: 11px;
    }

    .panel-actions {
        min-width: 116px;
        gap: 8px;
    }

    .panel-actions .ui-button {
        min-height: 42px;
        font-size: 14px;
        padding: 8px 9px;
    }
}

#game-container {
    width: calc(1024px * var(--stage-scale, 1));
    height: calc(639px * var(--stage-scale, 1));
    aspect-ratio: auto;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

#game-stage {
    position: relative;
    width: 1024px;
    height: 639px;
    --gameplay-safe-inset: 94px;
    overflow: hidden;
    transform: scale(var(--stage-scale, 1));
    transform-origin: top left;
    border: 6px solid rgba(255, 244, 191, 0.8);
    border-radius: 26px;
    background: #85ab11;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

#game-stage .screen,
#game-stage .modal {
    position: absolute;
    inset: 0;
}

#game-stage .full-screen-image,
#game-stage .scene-rice-layer {
    object-fit: cover;
    object-position: center center;
}

#game-stage .intro-video {
    object-fit: contain;
    object-position: center center;
    background: #000;
}

#game-stage .fail-ending-video {
    object-fit: cover;
    object-position: center center;
    background: #000;
}

#game-stage #screen-intro .intro-video {
    object-fit: cover;
    object-position: center center;
}

#game-stage #screen-title .intro-video {
    object-fit: cover;
    object-position: center center;
}

#game-stage #screen-game::before,
#game-stage #screen-game::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 78px;
    background: #000;
    z-index: 3;
    pointer-events: none;
}

#game-stage #screen-game::before {
    left: 0;
}

#game-stage #screen-game::after {
    right: 0;
}

#game-stage #screen-game .full-screen-image,
#game-stage #screen-game .game-layer {
    left: 0;
    right: 0;
}

#game-stage .panel-kicker,
#game-stage .kicker {
    font-size: 12px;
}

#game-stage .ui-button {
    padding: 12px 20px;
    font-size: 22px;
    border-width: 4px;
    border-radius: 16px;
}

#game-stage .intro-skip {
    right: 42px;
    bottom: 42px;
}

#game-stage .intro-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    min-width: 84px;
    min-height: 84px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    line-height: 1;
    z-index: 3;
}

#game-stage .title-card {
    left: auto;
    right: 150px;
    bottom: 34px;
    width: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

#game-stage #screen-title .title-actions {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 14px;
    margin-top: 0;
    justify-content: flex-start;
}

#game-stage #screen-title .title-actions .ui-button {
    width: auto;
    min-height: 48px;
    font-size: 22px;
    padding: 6px 12px;
}

#game-stage .hud {
    top: 20px;
    left: var(--gameplay-safe-inset);
    right: var(--gameplay-safe-inset);
}

#game-stage .selection-summary {
    max-width: none;
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.4;
}

#game-stage .scene-item {
    width: 210px;
}

#game-stage .scene-sauce img {
    width: 200px;
}

#game-stage .control-panel {
    left: var(--gameplay-safe-inset);
    right: var(--gameplay-safe-inset);
    bottom: 12px;
    height: 160px;
    padding: 11px;
    grid-template-columns: 186px 1fr 154px;
    grid-template-rows: none;
    gap: 12px;
    align-items: center;
    overflow: visible;
    border-width: 4px;
    border-radius: 18px;
}

#game-stage .panel-heading {
    gap: 6px;
    padding-top: 2px;
}

#game-stage .panel-heading h2 {
    font-size: 22px;
}

#game-stage .panel-helper,
#game-stage .modal-copy,
#game-stage .result-text,
#game-stage .result-summary {
    font-size: 14px;
    line-height: 1.28;
}

#game-stage .panel-helper {
    font-family: "BMJUA", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    white-space: pre-line;
}

#game-stage .option-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    height: 100%;
    min-height: 0;
    align-content: center;
    overflow: visible;
    padding-right: 0;
}

#game-stage .option-grid[data-step="rice"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

#game-stage .option-grid[data-step="sides"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#game-stage .option-grid.mix-grid {
    grid-template-columns: minmax(0, 1fr);
    align-content: stretch;
}

#game-stage .option-card[data-step="rice"] {
    min-height: 64px;
    padding: 7px 10px;
    border-width: 4px;
    border-radius: 14px;
}

#game-stage .option-card[data-step="sides"],
#game-stage .option-card[data-step="sauce"] {
    min-height: 54px;
    padding: 6px 8px;
    border-width: 4px;
    border-radius: 14px;
}

#game-stage .rice-only-label {
    font-size: 21px;
}

#game-stage .sides-only-label,
#game-stage .sauce-only-label {
    font-size: 15px;
    letter-spacing: -0.04em;
}

#game-stage .panel-actions {
    flex-direction: column;
    min-width: 154px;
    gap: 8px;
}

#game-stage .panel-actions .ui-button {
    min-height: 46px;
    font-size: 19px;
    padding: 8px 12px;
}

#game-stage .summary-card {
    width: 100%;
    height: 100%;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-family: "BMJUA", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    overflow: hidden;
}

#game-stage .summary-card * {
    font-family: "BMJUA", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

#game-stage .summary-card h3 {
    font-size: 20px;
    line-height: 1.05;
    margin-bottom: 8px;
}

#game-stage .summary-card ul {
    gap: 5px;
}

#game-stage .summary-card li {
    font-size: 14px;
    line-height: 1.2;
}

#game-stage .result-layout {
    inset: 34px;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    grid-template-rows: none;
    gap: 24px;
}

#game-stage .result-card {
    padding: 30px;
    border-width: 5px;
    border-radius: 26px;
}

#game-stage .result-grade {
    font-size: 16px;
}

#game-stage .result-title {
    font-size: 34px;
}

#game-stage .fail-ending-actions {
    left: auto;
    right: 30px;
    bottom: 28px;
    display: flex;
    gap: 12px;
}

#game-stage .fail-ending-actions .ui-button {
    min-height: 0;
    font-size: 22px;
}

#game-stage .modal-card {
    width: 480px;
    padding: 24px;
}

#game-stage .modal-card h2 {
    font-size: 30px;
}

#game-stage .instruction-list {
    font-size: 18px;
}
