/* ===========================================
   おべんとうやさん - デザイン改善版
   =========================================== */
/* 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(180deg, #FFECB3 0%, #FFE082 50%, #FFD54F 100%);
}

.home-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    border: 3px solid #FF8A65;
}

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

/* ステップ画面 */
.step-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: fadeIn 0.4s ease-out;
}

.step-screen.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-header {
    text-align: center;
    margin-bottom: 25px;
}

.step-header.small {
    margin-bottom: 15px;
}

.step-header.small h3 {
    font-size: 1rem;
    color: #5D4037;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 20px;
}

.step-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.step-header h2 {
    font-size: 1.3rem;
    color: #5D4037;
}

/* ========== Step 1: 弁当箱選択 ========== */
.box-options {
    display: flex;
    gap: 15px;
}

.box-option {
    background: white;
    border: 4px solid #FFCC80;
    border-radius: 20px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.box-option:active {
    transform: scale(0.95);
    border-color: #FF7043;
    background: #FFF3E0;
}

.box-preview-wrap {
    width: 80px;
    height: 65px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.box-preview {
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.box-preview.square {
    width: 70px;
    height: 50px;
    background: linear-gradient(180deg, #D32F2F 0%, #B71C1C 100%);
    border-radius: 8px;
}

.box-preview.round {
    width: 60px;
    height: 60px;
    background: linear-gradient(180deg, #D32F2F 0%, #B71C1C 100%);
    border-radius: 50%;
}

.box-preview.bear {
    width: 60px;
    height: 55px;
    background: linear-gradient(180deg, #FFCC80 0%, #FFB74D 100%);
    border-radius: 50% 50% 40% 40%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    position: relative;
}

.box-preview.bear::before,
.box-preview.bear::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: linear-gradient(180deg, #FFCC80 0%, #FFB74D 100%);
    border-radius: 50%;
    top: -8px;
}

.box-preview.bear::before {
    left: 5px;
}

.box-preview.bear::after {
    right: 5px;
}

.option-label {
    font-size: 0.9rem;
    font-weight: bold;
    color: #5D4037;
}

/* ========== Step 2: ごはん選択 ========== */
.bento-preview-container {
    margin-bottom: 30px;
}

.bento-preview {
    width: 180px;
    height: 120px;
    background: linear-gradient(180deg, #D32F2F 0%, #B71C1C 100%);
    border-radius: 15px;
    box-shadow: 0 8px 0 #7f0000, 0 15px 30px rgba(0, 0, 0, 0.2);
}

.rice-options {
    display: flex;
    gap: 15px;
}

.rice-option {
    background: white;
    border: 4px solid #FFCC80;
    border-radius: 20px;
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.rice-option:active {
    transform: scale(0.95);
    border-color: #4CAF50;
}

.rice-preview {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

/* ========== Step 3: おかず配置 ========== */
#step-okazu {
    padding-top: 60px;
    justify-content: flex-start;
    height: 100%; /* Ensure it takes full height */
    overflow: hidden;
}

.bento-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.bento-box {
    width: 320px;
    height: 320px;
    max-width: 90vw;
    max-height: 90vw; /* Responsive square */
    background: linear-gradient(145deg, #D32F2F 0%, #B71C1C 100%);
    border-radius: 15px;
    padding: 12px;
    box-shadow: 0 8px 0 #7f0000, 0 15px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    /* Maintain aspect ratio if needed, but flex center handles it */
}

.bento-box.round {
    border-radius: 50%;
}

.bento-box.bear {
    border-radius: 50% 50% 45% 45%;
    background: linear-gradient(145deg, #FFCC80 0%, #FFB74D 100%);
    box-shadow: 0 8px 0 #E65100, 0 15px 30px rgba(0, 0, 0, 0.3);
}

.bento-box.bear::before,
.bento-box.bear::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #FFCC80 0%, #FFB74D 100%);
    border-radius: 50%;
    top: -15px;
}

.bento-box.bear::before {
    left: 25px;
}

.bento-box.bear::after {
    right: 25px;
}

/* パズルモードの仕切り */
#bento-canvas {
    width: 100%;
    height: 100%;
    background: #FFFDE7; /* Default white rice */
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 4px; /* Reduced gap */
    padding: 8px;
}

#bento-canvas.rice-white { background: #FFFDE7; }
#bento-canvas.rice-sekihan { background: #F8BBD0; }
#bento-canvas.rice-wakame { background: #E0F2F1; }
#bento-canvas.rice-soboro { background: linear-gradient(45deg, #FFECB3 25%, #8D6E63 25%, #8D6E63 50%, #FFECB3 50%, #FFECB3 75%, #8D6E63 75%, #8D6E63 100%); background-size: 20px 20px; }

.bento-slot {
    background: rgba(0, 0, 0, 0.05);
    border: 2px dashed #BDBDBD;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.bento-slot.matched {
    background: transparent; /* Show rice underneath */
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent spill */
}

/* Hide hint when matched */
.bento-slot.matched .slot-hint {
    display: none;
}

.slot-hint {
    font-size: 2.2rem;
    opacity: 0.2;
    filter: grayscale(1);
}

.slot-item {
    font-size: 3rem;
    animation: slotPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slotPop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* 配置されたおかず */
.placed-okazu {
    position: absolute;
    font-size: 2.2rem;
    cursor: grab;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.3));
    transition: transform 0.1s;
    z-index: 10;
}

.placed-okazu.dragging {
    transform: scale(1.3);
    z-index: 100;
    cursor: grabbing;
}

/* おかずセクション */
.okazu-section {
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 12px 15px;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* Prevent crushing */
    z-index: 200;
}

.okazu-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #5D4037;
    margin-bottom: 8px;
    text-align: center;
}

.okazu-tray {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    justify-content: center;
    flex-wrap: wrap;
    padding-bottom: 5px;
}

.okazu-item {
    width: 65px;
    height: 75px;
    background: linear-gradient(180deg, #FFF8E1 0%, #FFECB3 100%);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: grab;
    transition: transform 0.1s;
    flex-shrink: 0;
    border: 3px solid #FFE082;
}

.okazu-item:active {
    transform: scale(0.95);
}

.okazu-icon {
    font-size: 2rem;
}

.okazu-name {
    font-size: 0.55rem;
    color: #5D4037;
    margin-top: 3px;
    font-weight: bold;
}

.finish-button {
    width: calc(100% - 30px);
    margin: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #8D6E63 0%, #6D4C41 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 #4E342E;
    cursor: pointer;
    font-family: inherit;
}

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

.btn-icon {
    font-size: 1.4rem;
}

/* ========== Step 4: 完成 ========== */
.complete-scene {
    text-align: center;
    padding: 20px;
}

.clear-banner {
    width: 180px;
    margin-bottom: 10px;
}

.complete-scene h2 {
    font-size: 1.6rem;
    color: #5D4037;
    margin-bottom: 20px;
}

.finished-bento-container {
    position: relative;
    width: 200px;
    height: 140px;
    margin: 0 auto 30px;
    z-index: 10;
}

.finished-bento {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #D32F2F 0%, #B71C1C 100%);
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.bento-lid {
    position: absolute;
    top: -10px;
    left: -5px;
    right: -5px;
    height: 50%;
    background: linear-gradient(180deg, #EF5350 0%, #D32F2F 100%);
    border-radius: 15px 15px 8px 8px;
    z-index: 10;
    animation: lidClose 0.8s ease-out forwards;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

@keyframes lidClose {
    0% {
        top: -80px;
        opacity: 0;
    }

    60% {
        top: 5px;
    }

    100% {
        top: -10px;
        opacity: 1;
    }
}

.furoshiki-wrap {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    animation: furiPop 0.5s 0.8s ease-out forwards;
    opacity: 0;
}

@keyframes furiPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.furoshiki {
    font-size: 4rem;
}

.praise-text {
    font-size: 1.2rem;
    color: #5D4037;
    margin-bottom: 25px;
    position: relative;
    z-index: 100;
}

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

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

/* ドラッグプロキシ */
.drag-proxy {
    position: fixed;
    font-size: 3rem;
    pointer-events: none;
    z-index: 9999;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
}

/* Ensure Make New button is clickable and visible */
#new-btn {
    position: relative;
    z-index: 100 !important;
}