:root {
    /* 기본값: 다크 모드 */
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --toggle-btn-bg: rgba(30, 41, 59, 0.7);
    --toggle-btn-border: rgba(255, 255, 255, 0.08);
    --toggle-btn-shadow: rgba(0, 0, 0, 0.4);
    --toggle-btn-text: #f8fafc;
}

[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --toggle-btn-bg: rgba(255, 255, 255, 0.85);
    --toggle-btn-border: rgba(15, 23, 42, 0.08);
    --toggle-btn-shadow: rgba(15, 23, 42, 0.15);
    --toggle-btn-text: #0f172a;
}

body {
    margin: 0;
    font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: background 0.3s ease;
}
.container {
    width: 100%;
    max-width: 500px;
    /* 고정된 프리미엄 딥블루 그라데이션 */
    background: linear-gradient(135deg, #1e295d 0%, #0f173a 100%);
    border: 1px solid rgba(58, 97, 255, 0.25);
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
    padding: 30px;
    backdrop-filter: blur(12px);
    /* 내부 텍스트는 언제나 밝은 색으로 고정 */
    color: #edf2ff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
h1 {
    margin: 0 0 10px;
    font-size: 2rem;
    text-align: center;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
p {
    margin: 0 0 24px;
    text-align: center;
    color: #93c5fd;
}
#numberContainer {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}
.lotto-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(58, 97, 255, 0.08);
    border: 1px solid rgba(58, 97, 255, 0.15);
    border-radius: 16px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
.ball {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 800;
    font-size: 1.05rem;
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3), inset -3px -3px 6px rgba(0, 0, 0, 0.45), inset 3px 3px 6px rgba(255, 255, 255, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
    position: relative;
}
/* 3D 광택 효과 */
.ball::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 6px;
    width: 12px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    transform: rotate(-15deg);
}
/* 추첨 롤링 중 (임팩트 있는 떨림 애니메이션) */
.ball.ball-spinning {
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #e5e7eb 70%, #9ca3af 100%);
    color: #374151;
    opacity: 1;
    transform: scale(1);
    animation: jitter 0.12s infinite alternate;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25), inset -2px -2px 5px rgba(0, 0, 0, 0.3), inset 2px 2px 5px rgba(255, 255, 255, 0.5);
}
/* 최종 번호 확정 시 (통통 튀는 애니메이션) */
.ball.ball-revealed {
    animation: revealPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
/* 로또 번호 대역별 한국 공식 색상 */
.ball.color-yellow {
    background: radial-gradient(circle at 35% 35%, #ffe993 0%, #ffbe00 80%, #d89000 100%);
    color: #2b1f00;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.4);
}
.ball.color-blue {
    background: radial-gradient(circle at 35% 35%, #8ae2ff 0%, #007cff 80%, #0056b3 100%);
    color: #ffffff;
}
.ball.color-red {
    background: radial-gradient(circle at 35% 35%, #ff9797 0%, #e62222 80%, #b30c0c 100%);
    color: #ffffff;
}
.ball.color-gray {
    background: radial-gradient(circle at 35% 35%, #f7fafc 0%, #718096 80%, #4a5568 100%);
    color: #ffffff;
}
.ball.color-green {
    background: radial-gradient(circle at 35% 35%, #aef3ae 0%, #2db42d 80%, #1c7c1c 100%);
    color: #ffffff;
}
.bonus-section {
    display: flex;
    align-items: center;
    gap: 10px;
}
.plus-sign {
    color: #60a5fa;
    font-weight: bold;
    margin: 0 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.plus-sign.visible {
    opacity: 1;
}
button {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 14px rgba(29, 78, 216, 0.3);
}
button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(29, 78, 216, 0.45);
}
.theme-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--toggle-btn-border);
    background: var(--toggle-btn-bg);
    color: var(--toggle-btn-text);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--toggle-btn-shadow);
    backdrop-filter: blur(8px);
    transition: transform 0.2s ease, background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
    z-index: 1000;
}
.theme-toggle-btn:hover {
    transform: scale(1.1);
}
.theme-toggle-btn:active {
    transform: scale(0.95);
}
.footer {
    margin-top: 20px;
    text-align: center;
    color: #93c5fd;
    font-size: 0.88rem;
}
.winning-section {
    margin-top: 10px;
    margin-bottom: 20px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(218, 165, 32, 0.05) 100%);
    border: 1px dashed rgba(255, 215, 0, 0.3);
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.15);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.5s ease forwards;
}
.winning-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    margin: 0;
    text-align: center;
}
.simulate-btn {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
    margin-top: 12px;
    display: none;
}
.simulate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(217, 119, 6, 0.5);
}
.row-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    animation: fadeIn 0.4s ease forwards;
}
.badge-container {
    width: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}
.result-badge {
    font-size: 0.8rem;
    font-weight: 800;
    padding: 5px 8px;
    border-radius: 8px;
    text-align: center;
    width: 100%;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    animation: revealPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.result-badge.rank-1 { background: #ffd700; color: #1e295d; }
.result-badge.rank-2 { background: #e2e8f0; color: #1e295d; }
.result-badge.rank-3 { background: #f59e0b; color: #ffffff; }
.result-badge.rank-4 { background: #3b82f6; color: #ffffff; }
.result-badge.rank-5 { background: #10b981; color: #ffffff; }
.result-badge.rank-none { background: rgba(255, 255, 255, 0.12); color: #93c5fd; border: 1px solid rgba(255, 255, 255, 0.05); }

.ball.match-highlight::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid #ffd700;
    box-shadow: 0 0 12px #ffd700;
    animation: pulseGlow 0.8s infinite alternate;
    z-index: 1;
}
@keyframes jitter {
    0% { transform: translate(-1px, -1px) scale(0.97); }
    100% { transform: translate(1px, 1px) scale(1.03); }
}
@keyframes revealPop {
    0% {
        transform: scale(0.6);
        opacity: 0;
    }
    70% {
        transform: scale(1.25);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.08); opacity: 1; }
}
