/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    min-height: 100vh;
    color: #fff;
    padding: 20px;
}

.container {
    max-width: 680px;
    margin: 0 auto;
}

/* ===== Header ===== */
header {
    text-align: center;
    padding: 40px 0 20px;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, #f7971e, #ffd200);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.subtitle {
    color: #aaa;
    font-size: 1.1rem;
}

/* ===== Cards ===== */
.options-card {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 28px;
    margin: 24px 0;
    border: 1px solid rgba(255,255,255,0.1);
}

.option-group {
    margin-bottom: 24px;
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #ddd;
}

/* ===== Counter ===== */
.counter {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.counter-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.counter-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: #ffd200;
    color: #ffd200;
}

#setCount {
    width: 60px;
    text-align: center;
    background: transparent;
    border: none;
    color: #ffd200;
    font-size: 1.8rem;
    font-weight: 700;
    -moz-appearance: textfield;
}

#setCount::-webkit-outer-spin-button,
#setCount::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

/* ===== Number Grid (제외/포함) ===== */
.exclude-grid, .include-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.num-toggle {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: #ccc;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-toggle:hover {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.12);
}

.num-toggle.excluded {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
    transform: scale(1.05);
}

.num-toggle.included {
    background: #2ecc71;
    border-color: #2ecc71;
    color: #fff;
    transform: scale(1.05);
}

.clear-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: #aaa;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

/* ===== Generate Button ===== */
.generate-btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #1a1a2e;
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 8px 30px rgba(255, 210, 0, 0.3);
    margin-bottom: 30px;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(255, 210, 0, 0.4);
}

.generate-btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.6rem;
}

.generate-btn.spinning .btn-icon {
    animation: spin 0.5s ease-in-out;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Results ===== */
.result-set {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    animation: slideUp 0.5s ease-out;
    animation-fill-mode: both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-label {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 12px;
    font-weight: 600;
}

.balls-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.ball {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    box-shadow: 
        inset 0 -4px 8px rgba(0,0,0,0.2),
        inset 0 4px 8px rgba(255,255,255,0.2),
        0 4px 15px rgba(0,0,0,0.2);
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation-fill-mode: both;
    position: relative;
}

.ball::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 12px;
    width: 12px;
    height: 8px;
    background: rgba(255,255,255,0.35);
    border-radius: 50%;
    transform: rotate(-30deg);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Ball Colors by Range */
.ball-1-10 { background: linear-gradient(145deg, #ffc107, #e6a800); }
.ball-11-20 { background: linear-gradient(145deg, #42a5f5, #1e88e5); }
.ball-21-30 { background: linear-gradient(145deg, #ef5350, #d32f2f); }
.ball-31-40 { background: linear-gradient(145deg, #78909c, #546e7a); }
.ball-41-45 { background: linear-gradient(145deg, #66bb6a, #43a047); }

/* ===== History ===== */
.history-section {
    margin-top: 40px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-header h2 {
    font-size: 1.2rem;
    color: #ddd;
}

.history-item {
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}

.history-time {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 8px;
}

.history-balls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.history-ball {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}

/* ===== Stats ===== */
.stats-section {
    margin-top: 40px;
}

.stats-section h2 {
    font-size: 1.2rem;
    color: #ddd;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
}

.stat-item {
    text-align: center;
    padding: 8px 4px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
}

.stat-num {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-count {
    font-size: 0.7rem;
    color: #888;
}

.stat-bar {
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #ffd200, #f7971e);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 40px 0 20px;
    color: #555;
    font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }

    .exclude-grid, .include-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    .ball {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .balls-container {
        gap: 8px;
    }

    .options-card {
        padding: 20px;
    }
}

/* ===== Confetti Canvas ===== */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}