@layer base, components, utilities;

@layer base {
    :root {
        --primary: #6366f1;
        --primary-hover: #4f46e5;
        --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        --card-bg: rgba(255, 255, 255, 0.85);
        --text: #1f2937;
        --text-light: #6b7280;
        --glass-bg: rgba(255, 255, 255, 0.5);
        --glass-border: rgba(255, 255, 255, 0.6);
        --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
        --ball-shadow: rgba(0, 0, 0, 0.15);
    }

    [data-theme="dark"] {
        --primary: #818cf8;
        --primary-hover: #a5b4fc;
        --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
        --card-bg: rgba(30, 41, 59, 0.85);
        --text: #f8fafc;
        --text-light: #94a3b8;
        --glass-bg: rgba(255, 255, 255, 0.08);
        --glass-border: rgba(255, 255, 255, 0.12);
        --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
        --ball-shadow: rgba(0, 0, 0, 0.3);
    }

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

    body {
        font-family: 'Poppins', sans-serif;
        background: var(--bg-gradient);
        background-attachment: fixed;
        color: var(--text);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        overflow-x: hidden;
        transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s ease;
        padding: 1rem;
    }

    /* Background decorative blobs */
    .background-blobs {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        overflow: hidden;
    }

    .blob {
        position: absolute;
        border-radius: 50%;
        filter: blur(80px);
        opacity: 0.35;
        animation: move 25s infinite alternate ease-in-out;
    }

    .blob-1 { width: 500px; height: 500px; background: #818cf8; top: -150px; left: -150px; }
    .blob-2 { width: 400px; height: 400px; background: #c084fc; bottom: -100px; right: -100px; animation-delay: -7s; }
    .blob-3 { width: 300px; height: 300px; background: #60a5fa; top: 30%; left: 70%; animation-delay: -15s; }

    @keyframes move {
        from { transform: translate(0, 0) scale(1) rotate(0deg); }
        to { transform: translate(100px, 150px) scale(1.2) rotate(45deg); }
    }

    header {
        text-align: center;
        margin-bottom: 2rem;
        z-index: 10;
        width: 100%;
        max-width: 650px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    h1 {
        font-size: clamp(1.8rem, 8vw, 3rem);
        font-weight: 800;
        letter-spacing: -1.5px;
        margin: 0;
        line-height: 1;
    }

    .highlight {
        background: linear-gradient(135deg, #6366f1, #a855f7);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    #theme-toggle {
        background: var(--glass-bg);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid var(--glass-border);
        width: 48px;
        height: 48px;
        border-radius: 14px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.3rem;
        margin-left: 1.2rem;
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        color: var(--text);
    }

    #theme-toggle:hover {
        transform: scale(1.1) rotate(10deg);
        background: var(--glass-border);
    }
}

@layer components {
    .lotto-card {
        background: var(--card-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid var(--glass-border);
        padding: clamp(1.2rem, 5vw, 2.5rem);
        border-radius: 32px;
        box-shadow: var(--shadow);
        width: 100%;
        max-width: 650px;
        transition: all 0.4s ease;
        z-index: 10;
    }

    #lotto-sets-container {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        margin-bottom: 2.5rem;
    }

    .lotto-row {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0.4rem;
        border-radius: 20px;
        transition: all 0.3s ease;
        animation: slideIn 0.6s cubic-bezier(0.23, 1, 0.32, 1) backwards;
    }

    @keyframes slideIn {
        from { opacity: 0; transform: translateX(-30px); }
        to { opacity: 1; transform: translateX(0); }
    }

    .game-label {
        font-weight: 700;
        color: var(--text-light);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 1.5px;
        min-width: 55px;
        flex-shrink: 0;
    }

    .lotto-numbers {
        display: flex;
        gap: clamp(0.3rem, 1.5vw, 0.6rem);
        flex: 1;
        justify-content: space-between;
        background: var(--glass-bg);
        padding: 0.5rem clamp(0.6rem, 2vw, 1.2rem);
        border-radius: 100px;
        border: 1px solid var(--glass-border);
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
        align-items: center;
    }

    .number {
        width: clamp(30px, 8.5vw, 40px);
        height: clamp(30px, 8.5vw, 40px);
        border-radius: 50%;
        display: grid;
        place-items: center;
        font-size: clamp(0.8rem, 3.5vw, 1.05rem);
        font-weight: 700;
        color: white;
        text-shadow: 0 1px 2px rgba(0,0,0,0.15);
        box-shadow: 0 4px 10px var(--ball-shadow);
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        position: relative;
        overflow: hidden;
        flex-shrink: 0;
    }

    .number::before {
        content: '';
        position: absolute;
        top: 15%;
        left: 15%;
        width: 30%;
        height: 30%;
        background: rgba(255, 255, 255, 0.4);
        border-radius: 50%;
        filter: blur(1px);
    }

    .number:hover {
        transform: scale(1.2) rotate(10deg);
        z-index: 5;
    }

    #generate-btn {
        background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
        color: white;
        border: none;
        padding: 1.2rem 2rem;
        font-size: 1.1rem;
        font-weight: 700;
        border-radius: 20px;
        cursor: pointer;
        width: 100%;
        position: relative;
        overflow: hidden;
        transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
        box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
        text-transform: uppercase;
        letter-spacing: 2px;
    }

    #generate-btn:hover {
        transform: translateY(-3px) scale(1.01);
        box-shadow: 0 20px 35px -5px rgba(99, 102, 241, 0.5);
    }

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

    .btn-shine {
        position: absolute;
        top: 0;
        left: -100%;
        width: 50%;
        height: 100%;
        background: linear-gradient(
            to right,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent
        );
        transform: skewX(-25deg);
        transition: 0.75s;
    }

    #generate-btn:hover .btn-shine {
        left: 150%;
    }
}

@media (max-width: 400px) {
    .game-label {
        min-width: 45px;
        font-size: 0.65rem;
    }
    
    .lotto-numbers {
        padding: 0.4rem 0.6rem;
    }
}
