body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    background-color: transparent;
    padding: 0;
    max-width: 600px;
    width: 100%;
    box-sizing: border-box;
}

header h1 {
    color: #1c1c1c;
    margin-bottom: 20px;
    font-size: 2.2em;
    text-align: center;
}

main {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 30px;
    margin-bottom: 20px;
}

.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 30px;
    margin-bottom: 20px;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #1c1c1c;
    text-align: center;
}

.results-container {
    min-height: 80px;
    margin-bottom: 30px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #fcfcfc;
    text-align: center; /* 내부 요소들을 중앙 정렬하기 위해 */
}

/* 번호 추천 결과 공들 */
.results-balls-display {
    display: flex; /* 가로 정렬 */
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px; /* 공들 사이 간격 */
    margin-bottom: 15px; /* 결과 텍스트와의 간격 */
}

.ball {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: scale(0.5);
    animation: fade-in-scale 0.4s forwards;
    box-sizing: border-box;
}

/* 번호별 색상 */
.ball.color-yellow { background-color: #ffc107; }
.ball.color-blue { background-color: #2196f3; }
.ball.color-red { background-color: #f44336; }
.ball.color-gray { background-color: #607d8b; }
.ball.color-green { background-color: #4caf50; }
.ball.bonus {
    border: 3px solid #ff9800; /* 보너스 번호 강조 테두리 */
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.8);
}

.ball.matched {
    border: 3px solid #00C853; /* 일치하는 번호는 녹색 테두리로 강조 */
    box-shadow: 0 0 15px rgba(0, 200, 83, 0.8);
}

.plus-sign {
    font-size: 2em;
    color: #888;
    margin: 0 5px;
    animation: fade-in-scale 0.4s forwards;
}


@keyframes fade-in-scale {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.simulation-controls {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    align-items: center;
}
.draw-controls {
    display: flex; /* 번호 추천 버튼과 입력 필드 정렬 */
    gap: 10px;
    width: 100%;
    justify-content: center;
    align-items: center;
}
.draw-controls span {
    font-size: 1.1em;
    font-weight: bold;
    color: #555;
    white-space: nowrap; /* 텍스트 줄바꿈 방지 */
}


#simulation-count, #draw-count {
    width: 120px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
    text-align: center;
    box-sizing: border-box;
}
#draw-count {
    width: 60px; /* '세트' 텍스트를 고려하여 너비 조정 */
}


button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    width: 100%;
}

.simulation-controls button {
    width: auto;
}
.draw-controls button {
    width: auto;
}

button:hover:not(:disabled) {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

#simulate-button { background-color: #2196f3; }
#simulate-button:hover:not(:disabled) { background-color: #1e88e5; }
#check-all-button {
    margin-top: 10px;
    background-color: #ff9800;
}
#check-all-button:hover:not(:disabled) { background-color: #f57c00; }


/* 시뮬레이션 결과 표시 영역 */
#simulation-results-display {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}
.simulation-result-title {
    color: #1c1c1c;
    font-size: 1.3em;
    margin-bottom: 15px;
    text-align: center;
}
#top-6-numbers {
    /* 기존 results-container의 flex 속성을 이리로 옮김 */
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 50px; /* 공들이 들어갈 최소 높이 */
    align-items: center;

    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #fcfcfc;
}
#recommended-combinations {
    margin-top: 20px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #fcfcfc;
}
#recommended-combinations h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #555;
    font-size: 1em;
    text-align: center;
}
.recommended-combination-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
}
.recommended-combination-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.recommended-combination-row .ball {
    width: 35px;
    height: 35px;
    font-size: 1.1em;
    animation: none;
    opacity: 1;
    transform: scale(1);
    box-shadow: none;
}


/* 당첨 번호 설정 섹션 */
#winning-number-form .form-group {
    margin-bottom: 15px;
    text-align: left;
}
#winning-number-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
#winning-number-form input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}
#winning-number-inputs {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6개 메인 번호 */
    gap: 10px;
}
.winning-lotto-number { text-align: center; }

/* 당첨 번호 설정 - 보너스 번호 입력 필드 스타일 */
input.winning-lotto-number.bonus {
    border: 2px solid #ff9800; /* 보너스 번호는 주황색 테두리로 강조 */
    background-color: #fffaf0;
}

#check-results-container {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    background-color: #f7f7f7;
    text-align: center;
    line-height: 1.6;
    min-height: 50px;
}
.loading-message, .error-message {
    font-style: italic;
    color: #666;
}
.error-message {
    color: #d32f2f;
}
.draw-result-summary {
    margin-top: 15px;
    font-size: 1.2em;
    font-weight: bold;
    color: #1c1c1c;
}
.draw-result-summary .rank {
    color: #ff9800;
}


/* 기록 섹션 */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
#clear-history-button {
    background-color: #f44336;
    width: auto;
    font-size: 0.9em;
    padding: 8px 12px;
}
#clear-history-button:hover:not(:disabled) { background-color: #d32f2f; }

#recent-results-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

#recent-results-list li {
    background-color: #fefefe;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
#recent-results-list li:last-child { margin-bottom: 0; }

.history-item-header {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #333;
}
.history-item-header .rank {
    color: #ff9800;
    background-color: #fff3e0;
    padding: 2px 6px;
    border-radius: 4px;
}
.history-item-body {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}
.history-item-body .ball {
    width: 35px;
    height: 35px;
    font-size: 1.1em;
    animation: none;
    opacity: 1;
    transform: scale(1);
    box-shadow: none;
}
.history-label {
    font-size: 0.9em;
    color: #666;
    margin: 0 5px;
}
.match-details {
    font-size: 0.9em;
    color: #555;
    margin-left: 5px;
}


/* 시뮬레이션 요약 표시 */
.simulation-summary-body.full {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); /* 유연한 그리드 */
    gap: 8px 12px; /* 세로, 가로 간격 */
    margin-top: 10px;
    font-size: 0.9em;
    text-align: left;
}
.simulation-summary-body .summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 5px;
    background-color: #f0f0f0;
    border-radius: 4px;
}
.simulation-summary-body .summary-num {
    font-weight: bold;
    color: #1c1c1c;
}
.simulation-summary-body .summary-freq {
    color: #4CAF50;
    font-weight: bold;
}

.stats-container {
    background-color: #e8f5e9; /* Light green background */
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.stats-container p {
    margin: 5px 0;
    font-size: 1em;
    color: #388e3c; /* Darker green text */
}
.stats-container strong {
    color: #1b5e20; /* Even darker green */
}


/* 미디어 쿼리 */
@media (max-width: 600px) {
    body { padding: 10px; }
    .card, main { padding: 20px; }
    header h1 { font-size: 1.8em; }
    #winning-number-inputs { grid-template-columns: repeat(3, 1fr); } /* 폼 입력 필드 */
    .simulation-controls {
        flex-direction: column;
    }
    #simulation-count {
        width: 100%;
    }
    .simulation-controls button {
        width: 100%;
    }
    .simulation-summary-body.full {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 5px;
    }
    .draw-controls {
        flex-direction: column;
    }
    #draw-count {
        width: 100%;
    }
    .draw-controls button {
        width: 100%;
    }
}