:root, [data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --bg-glow: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.05) 50%, rgba(15, 23, 42, 0) 70%);
    --toast-bg: #1e293b;
    --toast-text: #f8fafc;
    --toast-border: rgba(255, 255, 255, 0.2);
    --card-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    
    /* Lotto Ball Gradients */
    --ball-yellow: radial-gradient(circle at 35% 35%, #fde047, #ca8a04);
    --ball-blue: radial-gradient(circle at 35% 35%, #38bdf8, #0284c7);
    --ball-red: radial-gradient(circle at 35% 35%, #f87171, #dc2626);
    --ball-gray: radial-gradient(circle at 35% 35%, #94a3b8, #475569);
    --ball-green: radial-gradient(circle at 35% 35%, #4ade80, #16a34a);
    
    --primary-btn: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --primary-btn-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --shadow-glow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
    --font-main: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --set-label-bg: rgba(99, 102, 241, 0.12);
    --set-label-color: #818cf8;
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(203, 213, 225, 0.7);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --bg-glow: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(168, 85, 247, 0.06) 50%, rgba(248, 250, 252, 0) 70%);
    --toast-bg: #0f172a;
    --toast-text: #ffffff;
    --toast-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 10px 25px rgba(148, 163, 184, 0.2);
    
    --set-label-bg: rgba(99, 102, 241, 0.1);
    --set-label-color: #4f46e5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: 20px 16px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Dynamic Glow */
.background-glow {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: var(--bg-glow);
    z-index: -1;
    pointer-events: none;
    transition: background 0.3s ease;
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 620px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* Header */
.app-header {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    color: var(--set-label-color);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
}

.theme-toggle-btn:hover {
    transform: translateY(-50%) scale(1.08);
    border-color: rgba(99, 102, 241, 0.5);
    color: #6366f1;
}

.app-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Action Section */
.action-section {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: 14px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.25s ease;
    user-select: none;
}

.btn-primary {
    background: var(--primary-btn);
    color: #ffffff;
    box-shadow: var(--shadow-glow);
    flex: 1;
    max-width: 320px;
}

.btn-primary:hover {
    background: var(--primary-btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 14px 30px -5px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Results Section */
.results-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Placeholder Card */
.placeholder-card {
    background: var(--card-bg);
    border: 1px dashed var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 48px 20px;
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.placeholder-icon {
    font-size: 2.5rem;
    color: #6366f1;
    opacity: 0.7;
}

/* Lotto Set Card */
.lotto-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.3s ease;
}

.lotto-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.4);
}

.set-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--set-label-color);
    background: var(--set-label-bg);
    padding: 6px 12px;
    border-radius: 10px;
    min-width: 70px;
    text-align: center;
}

/* Balls Container */
.balls-container {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

/* Individual Lotto Ball */
.lotto-ball {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    box-shadow: inset -2px -2px 6px rgba(0, 0, 0, 0.4),
                inset 2px 2px 6px rgba(255, 255, 255, 0.4),
                0 4px 10px rgba(0, 0, 0, 0.3);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    animation-delay: var(--delay, 0s);
}

.ball-yellow { background: var(--ball-yellow); color: #422006; text-shadow: 0 1px 1px rgba(255,255,255,0.4); }
.ball-blue   { background: var(--ball-blue); }
.ball-red    { background: var(--ball-red); }
.ball-gray   { background: var(--ball-gray); }
.ball-green  { background: var(--ball-green); }

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-30deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Footer */
.app-footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
    opacity: 0.8;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 12px 24px;
    border-radius: 30px;
    border: 1px solid var(--toast-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive Media Queries */
@media (max-width: 520px) {
    .app-header h1 {
        font-size: 1.8rem;
    }
    
    .action-section {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        max-width: none;
    }

    .lotto-card {
        flex-direction: column;
        gap: 12px;
        padding: 16px 12px;
    }

    .set-label {
        width: 100%;
    }

    .balls-container {
        gap: 6px;
    }

    .lotto-ball {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }
}

@media (max-width: 360px) {
    .lotto-ball {
        width: 33px;
        height: 33px;
        font-size: 0.85rem;
    }
    .balls-container {
        gap: 4px;
    }
}
