/* ===========================================
   ハンバーガーやさん - Hamburger Shop
   =========================================== */
/* Mobile Responsive Fixes */
@media (max-width: 480px) {
    .game-header {
        padding: 60px 10px 10px;
    }
    .level-badge {
        font-size: 0.9rem;
        padding: 5px 10px;
    }
    .home-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: 10px;
        left: 10px;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Zen Maru Gothic', sans-serif;
    touch-action: none;
    user-select: none;
}

body {
    background: linear-gradient(135deg, #FFCCBC 0%, #FFAB91 100%);
}

.home-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 9999;
}

#game-container {
    max-width: 500px;
    height: 100%;
    margin: 0 auto;
    position: relative;
}

/* ========== Mode Selection ========== */
.mode-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.mode-screen.hidden,
.game-screen.hidden {
    display: none;
}

.mode-screen h2 {
    font-size: 1.4rem;
    color: #5D4037;
    margin-bottom: 30px;
}

.mode-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 300px;
}

.mode-btn {
    background: white;
    border: 3px solid #ddd;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.mode-btn:active {
    transform: scale(0.97);
    border-color: #FF5722;
    background: #FFF3E0;
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.mode-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.mode-desc {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}

/* ========== Game Screen ========== */
.game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-header {
    padding: 60px 20px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
}

.level-badge {
    background: #FF5722;
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
}

.stats-box {
    display: flex;
    gap: 10px;
}

.stat-item {
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 5px;
}

#layer-count, #goal-count {
    color: #FF5722;
    font-size: 1.2rem;
}

.instruction-text {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 30px;
    font-weight: bold;
    color: #5D4037;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 90; /* Lower z-index than burger */
    font-size: 0.9rem;
}

/* Build Area */
.build-area {
    flex: 1; /* Take all available space */
    min-height: 0; /* Crucial for flex */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 20px; /* Reduced padding */
    position: relative;
    overflow: visible; /* Allow burger to exceed if needed, or adjust scaling */
}

/* Add responsive scaling for short screens */
@media (max-height: 700px) {
    .burger-stack {
        transform: scale(0.75) !important; /* Force scale down */
        transform-origin: bottom center;
        bottom: 25px;
    }
    .plate {
        transform: scale(0.75);
    }
}

@media (max-height: 550px) {
    .burger-stack {
        transform: scale(0.6) !important;
        bottom: 15px;
    }
    .plate {
        transform: scale(0.6);
        margin-bottom: 10px;
    }
}

.plate-container {
    perspective: 1000px;
}

.plate {
    width: 220px;
    height: 30px;
    background: linear-gradient(180deg, #BDBDBD 0%, #9E9E9E 100%);
    border-radius: 50%;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.burger-stack {
    position: absolute;
    bottom: 55px; /* Plate top */
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    transform-origin: bottom center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

.burger-stack.fell-off {
    transform: translateY(300px) rotate(90deg);
    opacity: 0;
    transition: all 0.6s ease-in;
}

.burger-stack.wobble {
    animation: wobble 0.4s ease-in-out;
}

@keyframes wobble {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(3deg);
    }

    75% {
        transform: rotate(-3deg);
    }
}

.burger-layer {
    margin-bottom: -6px;
    animation: dropIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes dropIn {
    0% {
        transform: translateY(-80px) scale(0.5);
        opacity: 0;
    }

    60% {
        transform: translateY(10px) scale(1.1);
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Burger Layers - Emoji Display */
.layer-bun-bottom,
.layer-meat,
.layer-cheese,
.layer-lettuce,
.layer-tomato,
.layer-bun-top {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    margin-bottom: -15px;
}

.layer-bun-bottom {
    width: 140px;
    height: 40px;
    /* 少し低く */
    background: linear-gradient(135deg, #D2691E 0%, #A0522D 100%);
    border-radius: 10px 10px 30px 30px;
    /* 下を丸く */
    margin-bottom: -10px;
    font-size: 40px;
    /* アイコンサイズ調整 */
}

.layer-bun-bottom::before {
    content: '🥯';
}

.layer-bun-top {
    width: 140px;
    height: 40px;
    background: linear-gradient(135deg, #D2691E 0%, #A0522D 100%);
    border-radius: 30px 30px 10px 10px;
    /* 下のパンの反転 */
    margin-bottom: 0;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-bun-top::before {
    content: '🥯';
}

.layer-meat {
    width: 135px;
    height: 40px;
    background: linear-gradient(135deg, #8B4513 0%, #654321 100%);
    border-radius: 8px;
}

.layer-meat::before {
    content: '🥩';
}

.layer-cheese {
    width: 140px;
    height: 35px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    margin-bottom: -18px;
    border-radius: 8px;
}

.layer-cheese::before {
    content: '🧀';
}

.layer-lettuce {
    width: 145px;
    height: 35px;
    background: linear-gradient(135deg, #90EE90 0%, #228B22 100%);
    margin-bottom: -18px;
    border-radius: 8px;
}

.layer-lettuce::before {
    content: '🥬';
}

.layer-tomato {
    width: 130px;
    height: 30px;
    background: linear-gradient(135deg, #FF6347 0%, #DC143C 100%);
    margin-bottom: -18px;
    border-radius: 50%;
}

.layer-tomato::before {
    content: '🍅';
}

/* Flag - positioned relative to burger-stack */
.flag {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    z-index: 100;
    margin-bottom: 5px;
}

.flag.show {
    animation: flagPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.flag.hidden {
    display: none;
}

@keyframes flagPop {
    0% {
        transform: translateX(-50%) scale(0) translateY(30px);
        opacity: 0;
    }

    100% {
        transform: translateX(-50%) scale(1) translateY(0);
        opacity: 1;
    }
}

/* Ingredients Area */
.ingredients-area {
    background: white;
    padding: 15px;
    border-radius: 25px 25px 0 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    z-index: 200;
}

.ingredients-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0 10px;
    margin-bottom: 10px;
}

.ingredient-btn {
    flex-shrink: 0;
    width: 70px;
    height: 80px;
    background: #FFF8E1;
    border: 2px solid #FFE0B2;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.1s;
}

.ingredient-btn:active {
    transform: scale(0.95);
    background: #FFE0B2;
}

.ing-preview {
    width: 50px;
    height: 18px;
    border-radius: 5px;
    margin-bottom: 5px;
}

.ing-name {
    font-size: 0.65rem;
    color: #5D4037;
    font-weight: bold;
}

.complete-button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #FF5722 0%, #E64A19 100%);
    border: none;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 5px 0 #BF360C;
    cursor: pointer;
    font-family: inherit;
}

.complete-button:active {
    transform: translateY(5px);
    box-shadow: none;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.result-modal {
    background: white;
    border-radius: 30px;
    padding: 30px;
    text-align: center;
    animation: modalPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    min-width: 280px;
}

@keyframes modalPop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 10px;
}

.result-modal h2 {
    font-size: 1.4rem;
    color: #333;
    margin-bottom: 15px;
}

.result-stats {
    background: #FFF8E1;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #FF5722 0%, #E64A19 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
}

.btn-secondary {
    background: #EEEEEE;
    color: #333;
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
}