:root {
    /* Color System */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    
    /* Light Theme */
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: rgba(226, 232, 240, 0.8);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --glass-border: rgba(255, 255, 255, 0.4);
    
    /* Ball Colors */
    --ball-1: #facc15; /* Yellow */
    --ball-11: #3b82f6; /* Blue */
    --ball-21: #ef4444; /* Red */
    --ball-31: #64748b; /* Grey */
    --ball-41: #22c55e; /* Green */
    
    /* Layout */
    --container-max: 1200px;
    --header-height: 70px;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.8);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(51, 65, 85, 0.8);
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    --glass-border: rgba(255, 255, 255, 0.05);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.nav-container {
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--border);
}

.sun-icon { display: block; width: 20px; height: 20px; }
.moon-icon { display: none; width: 20px; height: 20px; }

[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

/* Sections */
main { margin-top: var(--header-height); }
section { padding: 5rem 0; }

/* Hero Section */
.hero-section {
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent),
                radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent);
    text-align: center;
    padding-bottom: 8rem;
}

.hero-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    line-height: 1.1;
    font-weight: 900;
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2.5rem;
}

.stat-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.main-card {
    max-width: 700px;
    margin: -5rem auto 0;
    padding: 3.5rem 2rem;
    position: relative;
    z-index: 10;
}

/* Generator */
.lucky-message {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 2.5rem;
    color: var(--primary);
    height: 1.5rem;
}

.lotto-display {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 3rem;
    min-height: 80px;
}

.placeholder-area { display: flex; gap: 1rem; opacity: 0.2; }
.empty-ball {
    width: 60px;
    height: 60px;
    border: 2px dashed var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.lotto-ball {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    box-shadow: inset -4px -4px 8px rgba(0,0,0,0.2), 0 4px 10px rgba(0,0,0,0.15);
    animation: ballPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.ball-1 { background: radial-gradient(circle at 30% 30%, #fde047, #ca8a04); }
.ball-11 { background: radial-gradient(circle at 30% 30%, #60a5fa, #1d4ed8); }
.ball-21 { background: radial-gradient(circle at 30% 30%, #f87171, #b91c1c); }
.ball-31 { background: radial-gradient(circle at 30% 30%, #94a3b8, #334155); }
.ball-41 { background: radial-gradient(circle at 30% 30%, #4ade80, #15803d); }

.ball-bonus {
    border: 3px solid var(--accent);
    position: relative;
}

.ball-bonus::after {
    content: '+';
    position: absolute;
    left: -20px;
    color: var(--text-muted);
    font-size: 2rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-large {
    padding: 1.25rem;
    font-size: 1.25rem;
}

.sub-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-secondary { background: var(--secondary); color: white; flex: 1; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text-main); flex: 1; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
    text-align: center;
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-dist {
    font-size: 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* History */
.history-card { padding: 2rem; }
.history-list { list-style: none; }
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.history-balls { display: flex; gap: 0.5rem; }
.h-ball {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
}

/* Animations */
@keyframes ballPop {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.fade-in { animation: fadeIn 0.8s ease-out both; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .lotto-ball { width: 45px; height: 45px; font-size: 1.125rem; }
    .empty-ball { width: 45px; height: 45px; }
    .main-card { padding: 2rem 1rem; }
    .ball-bonus::after { left: -10px; font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .sub-buttons { flex-direction: column; }
    .history-balls { gap: 0.25rem; }
    .h-ball { width: 24px; height: 24px; font-size: 0.625rem; }
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--text-main);
    color: var(--bg-main);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: toastUp 0.3s ease-out;
}

@keyframes toastUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
