body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #e0f2f7;
    margin: 0;
    padding: 10px; /* 전체 패딩 줄임 */
    display: flex;
    justify-content: center;
    align-items: center; /* 전체 콘텐츠 중앙 정렬 */
    min-height: 100vh; /* 뷰포트 높이 꽉 채우기 */
    box-sizing: border-box;
    overflow: hidden; /* 스크롤바 숨김 */
}

.container {
    background-color: #ffffff;
    padding: 20px; /* 패딩 줄임 */
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 700px; /* 최대 너비 조정 */
    height: calc(100vh - 20px); /* 뷰포트 높이에서 패딩 제외 */
    display: flex;
    flex-direction: column;
    gap: 15px; /* 간격 조정 */
    box-sizing: border-box;
}

h1 {
    text-align: center;
    color: #334e68;
    margin-bottom: 10px; /* 마진 조정 */
    font-size: 2em; /* 폰트 사이즈 조정 */
    font-weight: 700;
}

h2 {
    color: #557a95;
    font-size: 1.2em; /* 폰트 사이즈 조정 */
    margin-top: 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #e0f2f7; /* 보더 두께 줄임 */
    padding-bottom: 5px;
}

/* 냉장고 컨테이너 */
.fridge-container {
    display: flex;
    flex-direction: row; /* 이미지를 옆으로 배치 */
    align-items: flex-start; /* 상단 정렬 */
    gap: 10px; /* 간격 조정 */
    padding: 10px; /* 패딩 줄임 */
    border: 1px solid #cfd8dc;
    border-radius: 10px;
    background-color: #f5f8fa;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    flex-grow: 1; /* 남은 공간 차지 */
    overflow: hidden; /* 내부 스크롤 방지 */
}

.fridge-image {
    width: 100%; /* 이미지 크기 조정 */
    height: 100%; /* 높이 조정 */
    object-fit: contain; /* 원본 형태 유지 */
    cursor: pointer;
    transition: transform 0.3s ease-in-out;
    border: 2px solid #90a4ae;
    border-radius: 5px;
}

.fridge-image:hover {
    transform: scale(1.05);
}

/* 냉장고 내부 */
.fridge-interior {
    background-color: #e3f2fd;
    border: 2px solid #90a4ae;
    border-radius: 8px;
    width: calc(100% - 110px); /* 이미지 너비만큼 제외 */
    height: 100%; /* 부모 컨테이너 높이 꽉 채우기 */
    padding: 10px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    gap: 5px; /* 간격 조정 */
    position: relative;
    transition: all 0.5s ease-in-out;
    opacity: 0;
    transform: translateX(20px); /* 옆으로 이동하며 나타나도록 */
    box-sizing: border-box;
}

.fridge-interior.open {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

.fridge-interior h2 {
    margin-bottom: 5px; /* 내부 h2 마진 조정 */
    font-size: 1.1em;
    border-bottom: none;
}

/* 전체 삭제 버튼 */
.clear-all-btn {
    background-color: #f44336;
    color: white;
    padding: 5px 10px; /* 패딩 줄임 */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em; /* 폰트 사이즈 조정 */
    margin-top: 5px;
    align-self: flex-end;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.clear-all-btn:hover {
    background-color: #d32f2f;
}

.fridge-items {
    display: flex;
    flex-wrap: wrap;
    gap: 5px; /* 간격 조정 */
    min-height: 50px;
    border: 1px dashed #a7d9f7;
    padding: 5px;
    border-radius: 5px;
    align-content: flex-start;
    flex-grow: 1; /* 남은 공간 차지 */
    overflow-y: auto; /* 내용이 많아지면 스크롤 */
}

/* 냉장고 안의 음식 아이템 */
.fridge-item {
    background-color: #ffffff;
    border: 1px solid #b0bec5;
    border-radius: 5px;
    padding: 5px 8px; /* 패딩 줄임 */
    font-size: 0.8em; /* 폰트 사이즈 조정 */
    color: #455a64;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: all 0.3s ease;
    cursor: grab;
}

.fridge-item .expiry-info {
    font-size: 0.7em; /* 폰트 사이즈 조정 */
    color: #78909c;
    white-space: nowrap;
}

.fridge-item.expired {
    background-color: #ffebee; /* 옅은 붉은색 */
    border-color: #ef9a9a;
    animation: pulseRed 1.5s infinite alternate;
}

/* 0-1일 남음 (빨간색 경고) */
.fridge-item.expiring-soon-red {
    background-color: #ffebee; /* 만료와 유사한 붉은색 계열 */
    border-color: #ef9a9a;
    animation: pulseRed 1.5s infinite alternate; /* 강한 경고 */
}

/* 2-3일 남음 (노란색 경고) */
.fridge-item.expiring-soon-yellow {
    background-color: #fffde7; /* 옅은 노란색 */
    border-color: #ffcc80;
    animation: pulseYellow 1.5s infinite alternate; /* 중간 경고 */
}

/* 4-7일 남음 (기존 노란색 경고) */
.fridge-item.expiring-soon {
    background-color: #fff8e1; /* 더 옅은 노란색 */
    border-color: #ffe0b2;
}

/* 삭제 버튼 */
.fridge-item .delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #ef5350;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7em;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    visibility: hidden; /* 기본적으로 숨김 */
    opacity: 0;
}

.fridge-item:hover .delete-btn {
    visibility: visible;
    opacity: 1;
}

.fridge-item .delete-btn:hover {
    background-color: #d32f2f;
}

/* 음식 추가 선택 섹션 */
.food-selection {
    background-color: #f0f4f8;
    padding: 15px; /* 패딩 줄임 */
    border-radius: 10px;
    border: 1px solid #cfd8dc;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-shrink: 0; /* 줄어들지 않도록 */
    /* display: none; */ /* 초기에는 숨김 */
}

.food-selection h2 {
    margin-bottom: 10px;
    font-size: 1.2em;
}

.food-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* 간격 조정 */
    justify-content: center;
    padding-top: 5px;
    max-height: 150px; /* 최대 높이 설정 */
    overflow-y: auto; /* 스크롤바 추가 */
    border: 1px dashed #cfd8dc;
    border-radius: 5px;
    padding: 5px;
}

.food-item-select {
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 15px; /* 둥근 정도 조정 */
    padding: 6px 12px; /* 패딩 조정 */
    font-size: 0.9em;
    color: #1976d2;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px; /* Adjust as needed */
}

.food-item-select:hover {
    background-color: #bbdefb;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.food-item-select.selected-modal-item {
    background-color: #4CAF50; /* Green background for selected items */
    color: white;
    border-color: #4CAF50;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

/* Quantity control in modal */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quantity-btn {
    background-color: #64b5f6;
    color: white;
    border: none;
    border-radius: 5px;
    width: 30px;
    height: 30px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.quantity-btn:hover {
    background-color: #42a5f5;
}

.quantity-input {
    width: 40px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 5px 0;
    font-size: 0.9em;
    -moz-appearance: textfield; /* Firefox hide arrows */
}

/* Hide arrows for number input in Chrome, Safari, Edge, Opera */
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 애니메이션 키프레임 (기존 유지) */
@keyframes pulseRed {
    0% { background-color: #ffebee; }
    50% { background-color: #ef9a9a; }
    100% { background-color: #ffebee; }
}

@keyframes pulseYellow {
    0% { background-color: #fffde7; }
    50% { background-color: #ffeb3b; }
    100% { background-color: #fffde7; }
}

/* 아이템 제거 애니메이션 */
@keyframes fadeOutZoom {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.8); }
}

.fridge-item.removing {
    animation: fadeOutZoom 0.4s forwards;
}

/* 언어 선택 */
.language-selector {
    text-align: center;
    margin-bottom: 15px;
    font-size: 0.9em;
    display: none; /* 초기에는 숨김 */
}

.language-selector select {
    padding: 5px 8px;
    border-radius: 5px;
    border: 1px solid #cfd8dc;
    background-color: #f5f8fa;
    cursor: pointer;
}


.food-category-select {
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 15px;
    padding: 6px 12px;
    font-size: 0.9em;
    color: #1976d2;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    display: inline-block; /* Or use flexbox for parent */
    margin: 4px; /* Spacing between categories */
}

.food-category-select:hover {
    background-color: #bbdefb;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Style for selected category */
.food-category-select.selected {
    background-color: #2196f3;
    color: white;
    font-weight: bold;
    border-color: #1976d2;
}

.add-selected-foods-btn {
    background-color: #4CAF50; /* Green */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 10px;
    align-self: center; /* Center the button */
    transition: background-color 0.3s ease;
}

.add-selected-foods-btn:hover {
    background-color: #45a049;
}

/* Modal (popup) styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 10; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    backdrop-filter: blur(5px); /* Optional: blur background */
    -webkit-backdrop-filter: blur(5px); /* Safari support */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 10px;
    width: 90%; /* Could be more specific, e.g., 80% */
    max-width: 500px; /* Max width for larger screens */
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 80vh; /* Limit height for scrollable content */
    overflow-y: auto; /* Scroll content if it overflows */
}

/* Close button for modal */
.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#modalCategoryTitle {
    text-align: center;
    color: #334e68;
    margin-bottom: 5px;
    font-size: 1.5em;
    border-bottom: 1px solid #e0f2f7;
    padding-bottom: 5px;
}

#modalFoodItems {
    /* Inherits from .food-list for basic styling, but adjust if needed */
    flex-grow: 1; /* Allow to take available space */
    max-height: unset; /* Override fixed height from .food-list if necessary */
    overflow-y: auto; /* Ensure scroll for items within modal */
    border: none; /* Remove border from .food-list */
    padding-top: 0;
}
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    .container {
        padding: 15px;
        height: calc(100vh - 10px); /* 패딩 조정 */
        max-width: 95%;
    }
    .fridge-container {
        flex-direction: column; /* 세로로 쌓기 */
        align-items: center;
        flex-grow: unset; /* 모바일에서 고정 높이 */
        height: 40vh; /* 화면의 40% 차지 */
    }
    .fridge-image {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    .fridge-interior {
        width: 95%;
        height: auto; /* 내부 높이 자동 */
        min-height: 100px; /* 최소 높이 */
        transform: translateY(20px); /* 애니메이션 방향 변경 */
    }
    .fridge-interior.open {
        transform: translateY(0);
    }
    h1 {
        font-size: 1.8em;
        margin-bottom: 5px;
    }
    h2 {
        font-size: 1.3em;
        margin-bottom: 5px;
    }
    .food-selection {
        flex-grow: 1; /* 남은 공간 차지 */
        padding: 10px;
    }
    .food-list {
        max-height: 100%; /* 남은 공간을 채우도록 */
    }
    .fridge-item {
        font-size: 0.75em;
        padding: 4px 6px;
    }
    .food-item-select {
        font-size: 0.8em;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }
    h2 {
        font-size: 1.1em;
    }
    .fridge-image {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    .fridge-interior {
        min-height: 80px;
    }
    .food-item-select {
        font-size: 0.75em;
        padding: 4px 8px;
    }
    .clear-all-btn {
        font-size: 0.7em;
        padding: 4px 8px;
    }
}