/* =========================================
   1. 기본 설정 및 변수 (두 번째 CSS 기준)
   ========================================= */
:root {
    --bg-color: #f2f4f7;
    --primary-blue: #5d87ff;
    --tag-pink: #ffdbe6; --tag-pink-text: #d6336c;
    --tag-blue: #dbeeff; --tag-blue-text: #228be6;
    --tag-red: #ffc9c9; --tag-red-text: #fa5252;
    --tag-green: #d3f9d8; --tag-green-text: #37b24d;
    --tag-yellow: #fff3bf; --tag-yellow-text: #f59f00;
    --tag-purple: #e5dbff; --tag-purple-text: #7950f2;
    --tag-orange: #ffe8cc; --tag-orange-text: #fd7e14;
    --tag-gray: #e9ecef; --tag-gray-text: #495057;
    --tag-teal: #c3fae8; --tag-teal-text: #12b886;
    --text-dark: #333;
    --text-gray: #868e96;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans KR', sans-serif;
}

body {
    background-color: #e9ecef;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* 모바일 컨테이너 스타일 */
.mobile-container {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-color);
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    overflow-y: auto;
    padding-bottom: 20px;
    position: relative;
}

/* 1. 상단 검색바 영역 */
.header-search {
    background: white;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.search-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.logo{
    width: 26px;
    height: 26px;
    display: block;
}

.search-box span {
    color: var(--text-dark);
    font-weight: 500;
    width: 300px;
}

.search-box i {
    color: var(--text-gray);
}

/* 공통 카드 스타일 */
.card {
    background: white;
    margin: 15px;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

/* 2. 업로드 섹션 스타일 */
/* ★ 중요: 높이 통일을 위해 height를 고정하고 스크롤을 숨깁니다 */
.upload-section {
    height: 500px !important; 
    min-height: 500px !important;
    gap: 15px;
    
    /* 내부 정렬 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    
    /* 박스 설정 */
    box-sizing: border-box;
    overflow: hidden; /* 내용 넘침 방지 */
}

/* 스크롤바 숨김 (깔끔하게) */
.upload-section::-webkit-scrollbar {
    display: none;
}

.upload-header {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.earth{
    width: 42px;
    height: 42px;
}
.avatar-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.text-group h3 {
    font-size: 14px; /* 두 번째 CSS 기준 */
    margin-bottom: 4px;
    color: var(--text-dark);
}

.text-group p {
    font-size: 13px;
    color: var(--text-gray);
}

.illustration-area {
    background-color: #f8f9fa; /* 선택사항: 삭제 가능 */
    border-radius: 10px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

/* 이미지 스타일 */
.illustration-items {
    font-size: 40px;
    display: flex;
    gap: 15px;
}

.illustration-items img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

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

.btn {
    flex: 1;
    padding: 12px;
    border-radius: 25px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
}

.btn-outline {
    background: white;
    border: 1px solid #dee2e6;
    color: var(--text-dark);
}

.btn-primary {
    background: var(--primary-blue);
    color: white;
    box-shadow: 0 4px 6px rgba(93, 135, 255, 0.2);
}

.white-btn {
    background-color: white;
    color: #000000;
    border: 1px solid #000000;
    padding: 12px 0;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    box-sizing: border-box;
    margin-bottom: 8px;
}

.white-btn:hover {
    background-color: #6485EE;
    border: 1px solid #ffffff;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(77, 171, 247, 0.3);
}
.game-over-modal{
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 20;
    border-radius: 16px;
}
.evolution-bar {
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    background: #fff; 
    padding: 10px 8px;
    border-radius: 12px;
    margin-bottom: 15px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    overflow: hidden; 
    white-space: nowrap;
}

/* 3. 지도 섹션 스타일 */
.map-section h3 {
    font-size: 15px;
    color: var(--text-gray);
    margin-bottom: 15px;
}

.map-placeholder {
    width: 100%;
    height: 180px;
    background-color: #e9ecef;
    border-radius: 10px;
    margin-bottom: 15px;
    position: relative;
    background-size: cover;
    background-position: center;
}

/* 지도 위 핀 아이콘 */
.map-pin {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary-blue);
    font-size: 30px;
}

.location-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}

.pin-icon {
    color: var(--primary-blue);
    font-size: 20px;
    margin-top: 2px; /* 두 번째 CSS 기준 미세 조정 */
}

.addr-text h4 {
    font-size: 14px;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.addr-text p {
    font-size: 13px;
    color: var(--text-gray);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.info-item h5 {
    display: flex;       
    align-items: center; 
    gap: 5px;           
    color: var(--text-dark);
    margin-bottom: 8px;
}

.tag {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 5px;
    margin-bottom: 5px;
}

.tag-pink { background: var(--tag-pink); color: var(--tag-pink-text); }
.tag-blue { background: var(--tag-blue); color: var(--tag-blue-text); }
.tag-red { background: var(--tag-red); color: var(--tag-red-text); }
.tag-green { background: var(--tag-green); color: var(--tag-green-text); }
.tag-yellow { background: var(--tag-yellow); color: var(--tag-yellow-text); }
.tag-purple { background: var(--tag-purple); color: var(--tag-purple-text); }
.tag-orange { background: var(--tag-orange); color: var(--tag-orange-text); }
.tag-gray { background: var(--tag-gray); color: var(--tag-gray-text); }
.tag-teal { background: var(--tag-teal); color: var(--tag-teal-text); }

/* --- [필수 추가] 로딩 애니메이션 및 결과 화면 (두 번째 CSS에 없던 부분 복구) --- */
.loading-container {
    text-align: center;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.earth-spinner {
    font-size: 60px;
    animation: bounce 2s infinite ease-in-out;
    margin-bottom: 20px;
    display: inline-block;
}

.progress-bar {
    width: 80%;
    height: 8px;
    background-color: #eee;
    border-radius: 4px;
    margin-top: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-blue);
    width: 0%;
    transition: width 0.1s linear;
}

.result-container {
    text-align: center;
    width: 100%;
}

.result-title {
    font-size: 20px;
    color: var(--primary-blue);
    margin-bottom: 10px;
    font-weight: 700;
}

.result-desc {
    font-size: 13px;
    color: var(--text-dark);
    background: #f1f3f5;
    padding: 12px;
    border-radius: 10px;
    display: inline-block;
    width: 100%;
    text-align: left;
}

.btn-full {
    width: 100%;
}

/* --- [필수 추가] 재활용품 안내 모달 (게임/결과 화면용) --- */
.modal {
    display: none;
    position: absolute;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    animation: fadeIn 0.3s ease;
    border-radius: 7px;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 10px;
}

.modal-content {
    background-color: white;
    border-radius: 7px;
    overflow: hidden; /*자식 요소가 부모의 둥근 모서리를 벗어나지 못하게 잘라냄?*/
    width: calc(100% - 30px);
    max-width: 370px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 8px 12px;
    position: relative;
}

.modal-header h3 {
    font-size: 10px;
    color: var(--text-dark);
    line-height: 1.3;
    margin: 0;
    padding-right: 25px;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    color: #aaa;
    cursor: pointer;
    padding: 0;
    width: 25px;
    height: 25px;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.recycling-card {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 8px 6px;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.recycling-card.available {
    border-color: #37b24d;
    background-color: #d3f9d8;
    box-shadow: 0 4px 12px rgba(55, 178, 77, 0.2);
}

.card-icon {
    margin-bottom: 4px;
}

.card-icon img {
    width: 35px;
    height: 35px;
    object-fit: contain;
}

.card-icons-multiple {
    display: flex;
    gap: 3px;
    justify-content: center;
    margin-bottom: 4px;
}

.card-icons-multiple img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.recycling-card h4 {
    font-size: 10px;
    color: var(--text-dark);
    margin-bottom: 3px;
    font-weight: 700;
    line-height: 1.2;
}

.card-divider {
    width: 100%;
    height: 1px;
    background-color: #dee2e6;
    margin: 3px 0;
}

.recycling-card.available .card-divider {
    background-color: #51cf66;
}

.recycling-card p {
    font-size: 9px;
    color: var(--text-gray);
    line-height: 1.2;
    margin-top: 1px;
}

.recycling-card.available p {
    color: #2b8a3e;
    font-weight: 600;
}

/* --- [필수 추가] 애니메이션 (Keyframes) --- */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 신기록 달성 깜빡임 애니메이션 */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

body {
    background-color: white;
    color: black;
}

@media (prefers-color-scheme: dark) {
    .search-box{
        background-color: #2C2E33;
        border: 1px solid #333333;
    }
    .mobile-container {
        background-color: #000000;
    }
    .header-search {
        background-color: #000000; 
        border-bottom: 1px solid #333333;
    }
    .illustration-area{
        background-color: #4E4E4E;
    }
    .container, .wrap, .main-content {
        background-color: #1C1E21;
        border-bottom: 1px solid #C8C9CA;
        color: #ffffff;      
        box-shadow: none;    
    }
    .text-group h3, .text-group p {
        color: #ffffff;
    }
    .loadingtext {
        color: #ffffff;
    }
    .white-btn{
        background-color: #1C1E21; /* 흰색 버튼 대신 어두운 회색 */
        color: #ffffff;
        border: 1px solid #C8C9CA;
    }
    /* 3. 상단 검색창/헤더 영역 */
    .header, input[type="text"] {
        background-color: #333333; /* 입력창은 배경보다 조금 더 밝게 */
        color: #ffffff;
        border: 1px solid #555555;
    }
    .search-box span {
        color: white;
    }
    button.outline, .btn-secondary {
        background-color: transparent;
        border: 1px solid #666;
        color: #ffffff;
    }

    button.primary, .btn-primary {
        background-color: #5c9aff; 
        border: 1px, solid #ffffff;
        color: white;
    }
    .speech-bubble {
        background-color: #3F4144;
        color: #ffffff;
        border: 1px solid #555555;
    }

    /* 5. 하단 정보 박스 (지도 아래 설명 부분) */
    .info-section, .card {
        background-color: #212121;
        color: #eeeeee;
    }
    .result_text{
        color: #ffffff !important;
    }
    .result_data{
        color: #C8C9CA !important;
    }
    p, span {
        color: #cccccc; /* 너무 쨍한 흰색보다 살짝 회색이 눈이 편함 */
    }
    .modal-header, .modal-body, .score-box, .next-box, .evolution-bar {
        background-color: #37383A;
    }
    .map-section h3, .modal-header h3, .location-info h4, p, .info-item h5{
        color: #ffffff;
    }
    .recycling-card {
        background-color: #37383A;
        border: 1px solid #C8C9CA;
    }
    .score, .game-score , .final-score{
        color: #ffffff !important;
    }
    .canvas, .game-over-modal, .game-over-page, .game-over-modal{
        background-color: #37383A !important;
    }
    #game-wrapper {
        background-color: #37383A !important;
    }
}