
@layer base, components, utilities;

@layer base {
    :root {
        --bg-color: oklch(0.97 0.01 240);
        --container-bg: rgba(255, 255, 255, 0.7);
        --primary-color: oklch(0.55 0.18 250);
        --secondary-color: oklch(0.65 0.15 200);
        --accent-color: oklch(0.7 0.2 30);
        --text-color: oklch(0.2 0.02 240);
        --border-color: rgba(255, 255, 255, 0.3);
        
        /* Ball colors using oklch */
        --ball-yellow: oklch(0.85 0.2 90);
        --ball-blue: oklch(0.7 0.15 240);
        --ball-red: oklch(0.65 0.2 30);
        --ball-gray: oklch(0.6 0.01 0);
        --ball-green: oklch(0.8 0.18 140);
    }

    body {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        background-color: var(--bg-color);
        color: var(--text-color);
        margin: 0;
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        overflow-x: hidden;
    }

    body::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><filter id="n" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.75" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23n)" opacity="0.05"/></svg>');
        pointer-events: none;
        z-index: -1;
    }
}

@layer components {
    .container {
        background: var(--container-bg);
        backdrop-filter: blur(12px) saturate(180%);
        -webkit-backdrop-filter: blur(12px) saturate(180%);
        border: 1px solid var(--border-color);
        border-radius: 24px;
        padding: 3rem;
        box-shadow: 
            0 10px 15px -3px rgba(0, 0, 0, 0.1),
            0 4px 6px -4px rgba(0, 0, 0, 0.1),
            inset 0 0 20px rgba(255, 255, 255, 0.5);
        max-width: 600px;
        width: 90%;
        text-align: center;
        transition: transform 0.3s ease;
    }

    h1 {
        font-size: 2.5rem;
        font-weight: 800;
        background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        margin-bottom: 2rem;
        letter-spacing: -0.02em;
    }

    .game-controls {
        display: flex;
        justify-content: center;
        gap: 1rem;
        margin-bottom: 2rem;
    }

    select {
        padding: 0.75rem 1.5rem;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        background: rgba(255, 255, 255, 0.5);
        backdrop-filter: blur(4px);
        font-size: 1rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    select:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px oklch(0.55 0.18 250 / 0.1);
    }

    #generate-btn {
        background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
        color: white;
        border: none;
        padding: 1rem 2.5rem;
        border-radius: 16px;
        font-size: 1.25rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 10px 20px -5px oklch(0.55 0.18 250 / 0.3);
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
    }

    #generate-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 15px 30px -10px oklch(0.55 0.18 250 / 0.4);
    }

    #generate-btn:active {
        transform: translateY(1px);
    }

    #generate-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }

    .results-area {
        margin: 2rem 0;
        min-height: 120px;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }

    .history-section {
        margin-top: 3rem;
        padding-top: 2rem;
        border-top: 1px solid var(--border-color);
        text-align: left;
    }

    .history-title {
        font-size: 1.1rem;
        font-weight: 700;
        margin-bottom: 1rem;
        color: var(--primary-color);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .history-list {
        max-height: 200px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding-right: 0.5rem;
    }

    .history-item {
        background: rgba(255, 255, 255, 0.3);
        padding: 0.75rem 1rem;
        border-radius: 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.9rem;
        animation: slideIn 0.3s ease-out;
    }

    .history-balls {
        display: flex;
        gap: 4px;
    }

    .mini-ball {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 0.7rem;
        font-weight: bold;
        color: white;
    }
}

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

@layer utilities {
    .glass {
        background: rgba(255, 255, 255, 0.4);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
}
