:root {
            --card-width: 100px;
            --card-height: 115px;
            --card-gap: 20px;
            --theme-bg: linear-gradient(to bottom, #091321 0%, #152b47 50%, #193836 100%);
            --theme-color: #fff;
            --hud-bg: rgba(0, 0, 0, 0.4);
            --car-back-url: url('https://images.unsplash.com/photo-1494976388531-d1058494cdd8?ixlib=rb-4.0.3&auto=format&fit=crop&w=300&q=80');
        }

        /* --- RESPONSIVE BREAKPOINTS --- */
        @media (max-width: 900px) {
            :root {
                --card-width: 76px;
                --card-height: 88px;
                --card-gap: 10px;
            }
        }
        @media (max-width: 600px) {
            :root {
                --card-width: 52px;
                --card-height: 62px;
                --card-gap: 6px;
            }
        }
        @media (max-width: 380px) {
            :root {
                --card-width: 42px;
                --card-height: 50px;
                --card-gap: 4px;
            }
        }

        body {
            margin: 0;
            padding: 0;
            font-family: 'Rajdhani', sans-serif;
            background: var(--theme-bg);
            color: var(--theme-color);
            overflow-x: hidden;
            overflow-y: auto;
            user-select: none;
            transition: background 0.6s ease;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* The "Light Theme" triggered during drag */
        body.theme-light-dragging {
            --theme-bg: linear-gradient(to bottom, #74b9ff 0%, #81ecec 50%, #ffeaa7 100%);
            --hud-bg: rgba(255, 255, 255, 0.3);
            color: #2d3436;
        }

        #glitter-canvas {
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            pointer-events: none;
            z-index: 1;
        }

        /* --- HUD --- */
        .hud-bar {
            position: relative;
            z-index: 10;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 20px;
            background: var(--hud-bg);
            backdrop-filter: blur(10px);
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
            transition: background 0.6s ease;
            flex-wrap: wrap;
            gap: 6px;
        }

       .hud-left, .hud-right { flex: 1; display: flex; gap: 12px; flex-wrap: nowrap; align-items: center; }
        .hud-right { justify-content: flex-end; }
        .hud-center { flex: 2; text-align: center; min-width: 100px; }

        .game-title {
            font-family: 'Cinzel', serif;
            font-size: clamp(14px, 3vw, 28px);
            font-weight: 700;
            letter-spacing: 2px;
            text-shadow: 0 2px 10px rgba(255,255,255,0.3);
        }

        .hud-item { display: flex; flex-direction: column; align-items: center; }
        .hud-label { font-size: clamp(9px, 1.5vw, 14px); font-weight: 600; opacity: 0.8; letter-spacing: 1px; }
        .hud-value { font-size: clamp(14px, 2.5vw, 24px); font-weight: 700; }

        .hud-btn {
            background: rgba(255,255,255,0.1);
            border: 1px solid rgba(255,255,255,0.3);
            color: inherit;
            padding: clamp(5px, 1vw, 10px) clamp(8px, 1.5vw, 20px);
            font-family: 'Rajdhani', sans-serif;
            font-size: clamp(11px, 1.8vw, 16px);
            font-weight: 700;
            cursor: pointer;
            border-radius: 8px;
            transition: all 0.2s;
            white-space: nowrap;
        }
        .hud-btn:hover { background: rgba(255,255,255,0.25); transform: translateY(-2px); }

      @media (max-width: 600px) {
    .hud-bar { padding: 6px 10px; gap: 4px; }
    .hud-left, .hud-right { gap: 6px; flex-wrap: nowrap; }
    .hud-center { display: none; }
}

        /* --- GAME BOARD --- */
        #game-board {
            position: relative;
            z-index: 5;
            flex: 1;
            padding: clamp(10px, 3vw, 40px);
            display: flex;
            flex-direction: column;
            gap: clamp(10px, 2vw, 40px);
            max-width: 1200px;
            margin: 0 auto;
            width: 100%;
            box-sizing: border-box;
            padding-bottom: 60px;
        }

        .row { display: flex; justify-content: space-between; width: 100%; }
        
        .zone-group { display: flex; gap: var(--card-gap); }

        .card-slot {
            width: var(--card-width);
            height: var(--card-height);
            border: 2px dashed rgba(255,255,255,0.3);
            border-radius: 12px;
            position: relative;
        }

        .foundation-slot {
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: clamp(18px, 3.5vw, 40px);
            color: rgba(255,255,255,0.2);
        }

        /* --- CARDS --- */
        .card {
            position: absolute;
            width: var(--card-width);
            height: var(--card-height);
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
            cursor: grab;
            background-color: white;
            color: #2d3436;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            box-sizing: border-box;
            padding: 8px;
            font-family: Arial, sans-serif;
            font-weight: bold;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            touch-action: none;   /* prevent scroll hijack on mobile */
            -webkit-user-select: none;
            user-select: none;
        }

        /* Disable transition during drag for performance */
        .card.dragging {
            transition: none !important;
        }

        .card[data-color="red"] { color: #d63031; }
        
        .card.face-down {
            background-image: var(--car-back-url);
            background-size: cover;
            background-position: center;
            border: 3px solid #f1f2f6;
        }

        .card.face-down .card-content { display: none; }
        
        .card-content {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            height: 100%;
            pointer-events: none;
        }

        .card-top { text-align: left; font-size: clamp(9px, 1.8vw, 20px); line-height: 1; }
        .card-center { text-align: center; font-size: clamp(18px, 4vw, 45px); flex: 1; display: flex; align-items: center; justify-content: center; }
        .card-bottom { text-align: right; font-size: clamp(9px, 1.8vw, 20px); line-height: 1; transform: rotate(180deg); }

        /* Tableau cascading */
        .tableau-col { position: relative; width: var(--card-width); min-height: calc(100vh - 280px); height: auto; }
        .tableau-col .card { position: absolute; top: 0; left: 0; }

        /* Dragging */
        #drag-layer {
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            pointer-events: none;
            z-index: 1000;
        }

        .card.dragging {
            box-shadow: 0 15px 35px rgba(255, 255, 255, 0.4), 0 0 20px rgba(255, 255, 255, 0.6);
            transform: scale(1.05);
            cursor: grabbing;
            transition: none !important;
        }

        /* --- MODALS --- */
        #win-modal {
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.85);
            z-index: 2000;
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(10px);
        }

        .win-content {
            text-align: center;
            background: linear-gradient(135deg, #2c3e50, #3498db);
            padding: 50px 80px;
            border-radius: 20px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 0 50px rgba(255,215,0,0.3);
            border: 2px solid rgba(255,255,255,0.2);
            animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .cup-anim {
            font-size: 100px;
            margin-bottom: 20px;
            display: none;
            filter: drop-shadow(0 0 20px rgba(255,215,0,0.8));
            animation: floatCup 2s ease-in-out infinite;
        }

        @keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
        @keyframes floatCup { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-20px) scale(1.1); } }

        .win-title { font-family: 'Cinzel', serif; font-size: 40px; margin: 0 0 20px 0; color: #f1c40f; }
        .win-stats { font-size: 22px; margin-bottom: 30px; }
        
        .reset-btn {
            background: #f1c40f; color: #2c3e50;
            border: none; padding: 15px 40px;
            font-size: 20px; font-weight: bold; border-radius: 30px;
            cursor: pointer; box-shadow: 0 5px 15px rgba(241, 196, 15, 0.4);
            transition: transform 0.2s;
        }

        
        
        .reset-btn:hover { transform: scale(1.05); }

        /* Hint highlight */
        .hint-highlight {
            box-shadow: 0 0 0 3px #f1c40f, 0 0 20px rgba(241,196,15,0.8) !important;
            animation: hintPulse 0.7s ease-in-out infinite alternate;
        }
        @keyframes hintPulse {
            from { box-shadow: 0 0 0 3px #f1c40f, 0 0 15px rgba(241,196,15,0.6); }
            to   { box-shadow: 0 0 0 4px #ff9f43, 0 0 30px rgba(255,159,67,0.9); }
        }

        #hint-text {
            position: absolute;
            bottom: -28px;
            left: 50%;
            transform: translateX(-50%);
            white-space: nowrap;
            font-size: 13px;
            font-weight: 700;
            color: #f1c40f;
            text-shadow: 0 1px 4px rgba(0,0,0,0.8);
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.3s;
        }
        #hint-text.visible { opacity: 1; }

        #deadlock-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2100;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.deadlock-content {
    text-align: center;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    padding: 50px 80px;
    border-radius: 20px;
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    animation: popIn 0.4s ease;
}

.deadlock-title {
    font-family: 'Cinzel', serif;
    font-size: 38px;
    color: #74b9ff;
    margin-bottom: 20px;
}

.deadlock-text {
    font-size: 20px;
    margin-bottom: 30px;
    color: #dfe6e9;
}
.deadlock-content {
    position: relative;
}

.deadlock-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: transparent;
    border: none;
    color: #dfe6e9;
    font-size: 26px;
    cursor: pointer;
    transition: 0.3s ease;
}

.deadlock-close:hover {
    color: #74b9ff;
    transform: scale(1.15);
}