:root {
    /* Dark Mode Palette (Default) using OKLCH */
    --bg-main: oklch(0.12 0.02 240);
    --bg-card: oklch(0.18 0.03 240 / 0.8);
    --accent-primary: oklch(0.72 0.15 150);
    --accent-secondary: oklch(0.68 0.12 210);
    --text-main: oklch(0.95 0.01 240);
    --text-muted: oklch(0.75 0.01 240);
    --glass-border: oklch(1 0 0 / 0.15);
    
    /* Lotto Ball Colors */
    --ball-yellow: oklch(0.85 0.18 85);
    --ball-blue: oklch(0.75 0.15 220);
    --ball-red: oklch(0.7 0.22 25);
    --ball-gray: oklch(0.7 0.01 240);
    --ball-green: oklch(0.78 0.16 140);

    /* Spacing & Radii */
    --radius-lg: 24px;
    --radius-md: 12px;
    --spacing-lg: 2.5rem;
}

[data-theme="light"] {
    /* Light Mode Palette */
    --bg-main: oklch(0.96 0.01 240);
    --bg-card: oklch(1 0 0 / 0.7);
    --accent-primary: oklch(0.65 0.15 150);
    --accent-secondary: oklch(0.6 0.12 210);
    --text-main: oklch(0.2 0.02 240);
    --text-muted: oklch(0.4 0.02 240);
    --glass-border: oklch(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Background Effects */
.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    opacity: 0.04;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    transition: opacity 0.4s ease;
}

[data-theme="light"] .noise-overlay {
    opacity: 0.02;
}

.background-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    filter: blur(100px);
    opacity: 0.1;
    z-index: 0;
    pointer-events: none;
    top: -100px;
    right: -100px;
}

/* Layout */
.app-container {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 800px;
    padding: var(--spacing-lg);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.app-header {
    margin-bottom: var(--spacing-lg);
    position: relative;
}

.theme-btn {
    position: absolute;
    top: 0;
    right: 0;
}

/* Theme Icon Toggling */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }

.logo {
    font-family: 'Bungee', cursive;
    font-size: 3rem;
    letter-spacing: -2px;
    margin-bottom: 0.5rem;
}

.logo span {
    color: var(--accent-primary);
    text-shadow: 0 0 20px var(--accent-primary);
    transition: text-shadow 0.4s ease;
}

[data-theme="light"] .logo span {
    text-shadow: none;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Stage */
.drawing-stage {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.balls-display {
    min-height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.2);
    transition: background-color 0.4s ease;
}

[data-theme="light"] .balls-display {
    background: rgba(0, 0, 0, 0.05);
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.1rem;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.primary-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: var(--accent-primary);
    color: oklch(0.12 0.02 240);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 20px -5px var(--accent-primary);
}

[data-theme="light"] .primary-btn {
    color: white;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -10px var(--accent-primary);
}

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

.secondary-btn, .icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s, background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

.secondary-btn:hover, .icon-btn:hover {
    background: rgba(128, 128, 128, 0.2);
}

/* History Panel */
.history-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    background: var(--bg-card);
    backdrop-filter: blur(40px);
    border-left: 1px solid var(--glass-border);
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease, border-color 0.4s ease;
    display: flex;
    flex-direction: column;
}

.history-panel.active {
    transform: translateX(0);
}

.history-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    transition: border-color 0.4s ease;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background: rgba(128, 128, 128, 0.1);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.4s ease;
}

.empty-msg {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 2rem;
}

/* Responsive */
@media (max-width: 600px) {
    .logo { font-size: 2rem; }
    .app-container { width: 95%; padding: 1.5rem; }
    .history-panel { width: 100%; }
}

/* Shaking animation for drawing */
@keyframes shake {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-5px, 5px); }
    50% { transform: translate(5px, -5px); }
    75% { transform: translate(-5px, -5px); }
    100% { transform: translate(5px, 5px); }
}

.drawing .balls-display {
    animation: shake 0.1s infinite;
}