/* 1. 기본 배경 및 레이아웃 설정 */
body {
    font-family: 'Malgun Gothic', sans-serif;
    background-color: #f0f2f5;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 10px;
    min-height: 100vh;
    margin: 0;
    box-sizing: border-box;
}

.wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    width: 100%;
    max-width: 790px;
}

/* 2. 번호 생성기 컨테이너 (왼쪽) */
.container {
    background-color: white;
    padding: 20px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    flex: 1; /* 남은 공간 모두 차지 */
    min-height: 282px;
    box-sizing: border-box;
}

h1 { color: #333; margin-bottom: 20px; line-height: 1.1; }
h1 .title-lotto { font-family: "Pretendard Variable", sans-serif; font-size: clamp(41px, 8vw, 56px); font-weight: 800; letter-spacing: -1px; display: block; }
h1 .lotto-normal-size { font-size: 1em; font-weight: inherit; }
h1 .lotto-small-size { font-size: 0.6em; font-weight: 650; }
h1 .title-round { display: block; margin-top: 12px; font-size: clamp(18px, 4vw, 24px); font-weight: bold; }
h1 .title-date { font-size: 14px; color: #888; font-weight: normal; display: block; margin-top: 3px; }

/* 3. 버튼 스타일 */
.button-group { display: flex; justify-content: center; gap: 10px; margin-bottom: 15px; margin-top: 25px; }
button { background-color: #4CAF50; color: white; padding: 12px 24px; border: none; border-radius: 5px; font-size: 18px; cursor: pointer; transition: all 0.3s; font-weight: bold; }
button:hover { background-color: #45a049; }
button:disabled { background-color: #ccc; cursor: not-allowed; }
#immediate-generate { background-color: #f44336; }
/* hover가 존재하는 모든 환경에서 즉시생성 버튼은 진해져라 : 모바일 오류 */
/* #immediate-generate:hover { background-color: #d32f2f; } */
.hidden { display: none; }

/* 카카오톡 공유 버튼 스타일 */
.share-section { margin-bottom: 30px; }
.kakao-btn { background-color: #FEE500; color: #000000; width: 100%; max-width: 260px; font-size: 16px; display: inline-block; }
.kakao-btn:hover { background-color: #E6CF00; }

/* 4. 결과 공(Ball) 스타일 (위치 변경됨) */
#result { margin-top: 10px; font-size: 24px; font-weight: bold; display: flex; justify-content: center; gap: 8px; min-height: 45px; flex-wrap: wrap; }
.ball { width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; color: white; font-size: 18px; flex-shrink: 0; }
.ball.placeholder { background-color: transparent; border: 2px solid #e0e0e0; color: transparent; }

/* 오른쪽 사이드바 (기록 + 지도) */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 300px;
    flex-shrink: 0;
}

/* 5. 번호 기록 섹션 */
#history-container { 
    background-color: white; 
    padding: 20px 20px; 
    border-radius: 10px; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); 
    width: 100%; 
    box-sizing: border-box; 
    display: flex;
    flex-direction: column;
    max-height: 355px;
    min-height: 355px; 
}

#history-container h2 { 
    text-align: center; 
    margin-top: 0; 
    margin-bottom: 0; 
    color: #333; 
    font-size: 20px; 
    flex-shrink: 0;
}

/* ★ 기록 헤더/전체삭제 버튼 */
.history-header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
}

.history-clear-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background-color: #e0e0e0;
    color: #333;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: bold;
}
.history-clear-btn:hover { background-color: #d5d5d5; }

.history-limit-info {
    margin: 0 0 10px 0;
    font-size: 11px;
    color: #888;
    text-align: left;
}

#history-list {
    overflow-y: auto; 
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding-right: 5px; 
}

/* 스크롤바 디자인 */
#history-list::-webkit-scrollbar { width: 4px; }
#history-list::-webkit-scrollbar-thumb { background-color: #ddd; border-radius: 10px; }

.history-item { 
    display: flex; 
    justify-content: flex-start; 
    align-items: center; 
    padding: 8px 0; 
    border-bottom: 1px solid #eee; 
    font-size: 14px; 
    flex-shrink: 0; 
    height: 45px; 
    box-sizing: border-box;
    gap: 8px;

    /* ★ 웹: 액션 버튼(📋❌) 공간 확보해서 가로 스크롤 방지 */
    position: relative;
    padding-right: 70px;
}

.history-number-prefix { font-weight: bold; margin-right: 0px; color: #555; flex-shrink: 0; width: 16px; }
.history-numbers { 
    display: flex; 
    gap: 4px; 

    /* ★ 웹: flex 넘침으로 생기는 스크롤 방지 */
    min-width: 0;
    overflow: hidden;
}
.history-ball { width: 28px; height: 28px; border-radius: 50%; display: flex; justify-content: center; align-items: center; color: white; font-size: 12px; font-weight: bold; }

/* ★ 기록 액션 버튼 */
.history-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;

    /* ★ 웹: 버튼을 오른쪽에 고정 */
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
}

.history-action-btn {
    background: #f3f3f3;
    border: 1px solid #e5e5e5;
    color: #333;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    padding: 0;
}
.history-action-btn:hover { background: #e9e9e9; }

.copy-toast {
    font-size: 11px;
    color: #2e7d32;
    font-weight: bold;
    margin-left: 4px;
    white-space: nowrap;
}

/* 5-1. 지도 컨테이너 스타일 */
#map-container-box {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    text-align: center;

    /* ★ 추가: 배너를 지도 위에 겹쳐 띄우기 위한 기준 */
    position: relative;
}

/* ★ 추가: 위치 권한 영구 차단 안내 배너(지도 위, 최상단) */
.map-permission-banner {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 10;

    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);

    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    line-height: 1.35;
    color: #333;
}

#map-container-box h2 { font-size: 18px; margin-top: 0; margin-bottom: 10px; color: #333; }

/* ★ 수정: 배너와 지도의 겹침이 자연스럽게 보이도록 overflow 처리 */
#map { width: 100%; height: 250px; border-radius: 8px; background-color: #eee; overflow: hidden; }

.map-info { font-size: 12px; color: #888; margin-top: 8px; margin-bottom: 0; text-align: left; }

/* 5-2. 필터 스타일 */
.filter-wrapper { margin-top: 20px; border-top: 1px solid #eee; padding-top: 20px; text-align: left; }
.filter-wrapper h3 { text-align: center; margin-bottom: 20px; color: #333; font-size: 18px; }

.filter-section { margin-bottom: 25px; }
.filter-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 14px; font-weight: bold; color: #555; }
.count-badge { background: #eee; padding: 2px 8px; border-radius: 10px; font-size: 12px; color: #333; }

.number-grid { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 5px; 
}

/* 숫자 버튼 (필터용) */
.filter-btn { 
    width: 39px; 
    height: 39px; 
    border: 1px solid #ddd; 
    background-color: white; 
    color: #333; 
    border-radius: 5px; 
    font-size: 15px; 
    padding: 0; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    cursor: pointer;
    font-weight: normal; /* 상단 생성 버튼과 구분 */
}
.filter-btn:hover { background-color: #f9f9f9; }

/* 포함(초록) 활성화 상태 */
.filter-btn.included { background-color: #4CAF50 !important; color: white; border-color: #4CAF50; font-weight: bold; }
/* 제외(빨강) 활성화 상태 */
.filter-btn.excluded { background-color: #f44336 !important; color: white; border-color: #f44336; font-weight: bold; }

/* 1~9, 10~18... 줄바꿈을 위한 보조 클래스 (JS에서 처리하거나 flex-wrap으로 자동 처리) */
/* 790px 너비 기준에서는 flex-wrap으로 자연스럽게 떨어지게 함 */


/* 6. 설명 컨테이너 */
#explanation-container { 
    background-color: white; 
    padding: 30px 20px; 
    border-radius: 10px; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); 
    width: 100%;
    max-width: 790px; 
    box-sizing: border-box; 
    margin-top: 40px; 
    color: #555; 
    margin-bottom: 50px;
}

.guide-title { text-align: center; margin-bottom: 20px; color: #333; font-size: 22px; }
.guide-list { 
    text-align: left; 
    list-style-type: disc; 
    padding-left: 20px; 
    margin-bottom: 30px; 
    line-height: 1.6;
}
.guide-list li { margin-bottom: 8px; }

.prize-title { text-align: center; margin-top: 30px; margin-bottom: 20px; color: #333; font-size: 22px; }

/* 표 가로스크롤 방지 및 비율 최적화 */
.table-responsive { width: 100%; overflow-x: hidden; }
.prize-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 14px; 
    table-layout: fixed; 
}
.prize-table th { background-color: #e94e6b; color: white; padding: 10px 5px; border: 1px solid #ddd; }
.prize-table td { padding: 10px 5px; border: 1px solid #ddd; text-align: center; color: #333; word-break: keep-all; }

/* ★ 웹(기본) 당첨확률(4번째 칸) 오른쪽 정렬 */
.prize-table td:nth-child(4) { 
    text-align: right; 
    padding-right: 10px; /* 오른쪽 벽에서 10px 띄움 */
}

/* 표 열 너비 고정 */
.prize-table th:nth-child(1), .prize-table td:nth-child(1) { width: 12%; }
.prize-table th:nth-child(2), .prize-table td:nth-child(2) { width: 33%; }
.prize-table th:nth-child(3), .prize-table td:nth-child(3) { width: 35%; }
.prize-table th:nth-child(4), .prize-table td:nth-child(4) { width: 20%; }

.match-dots { display: flex; gap: 2px; margin-top: 5px; justify-content: center; } 
.dot { width: 8px; height: 8px; border-radius: 50%; background-color: transparent; border: 1px solid #ddd; }
.dot.active, .dot.bonus { background-color: #FB8EA1; border: 1px solid #FB8EA1; }
.dot.bonus-plus { border: none; color: #666; font-size: 10px; width: auto; line-height: 8px; }

/* 7. 모바일 반응형 설정 */
/* 앱 사용자를 위한 레이아웃: 생성기 -> 기록 -> 지도 순으로 배치 */
@media (max-width: 768px) {
    .wrapper {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    .container {
        width: 100%;
        min-height: auto;
    }
    .sidebar {
        width: 100%;
        /* 모바일에서는 사이드바가 컨테이너 아래로 떨어지므로 자연스럽게 '기록 -> 지도' 순서가 됨 */
    }
    #history-container {
        width: 100%;
        margin-top: 0;
        max-height: 340px; 
        min-height: 340px;
    }
    .prize-table {
        font-size: 10px;
    }
    .prize-table td {
        padding: 8px 2px;
    }
    /* ★ 모바일 당첨확률(4번째 칸) 오른쪽 정렬 미세 조정 */
    .prize-table td:nth-child(4) {
        text-align: right;
        padding-right: 2px; /* 모바일은 화면이 좁으니 여백을 5px로 줄임 */
    }
    /* 필터 버튼 모바일 최적화 */
    .filter-btn {
        width: 11%; /* 한 줄에 9개 정도 들어가도록 */
        height: 36px;
    }

    /* ★ 추가: 모바일에서 배너 여백/폰트 살짝 축소 */
    .map-permission-banner {
        top: 8px;
        left: 8px;
        right: 8px;
        padding: 9px 10px;
        font-size: 11px;
    }
}

/* (추가) 번호 필터 설정 위 안내 문구 */
.filter-note{
  margin: 0 0 0;
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
  color: #666;
}

/* 모바일에서 너무 크거나 답답해 보이면 살짝 조절 */
@media (max-width: 480px){
  .filter-note{
    font-size: 14px;
    margin: 0 0 0;
  }
}

/* PC에서만 즉시생성 hover 효과 */
@media (hover: hover) and (pointer: fine) {
  #immediate-generate:hover {
    background-color: #d32f2f;
  }
}
