:root {
    /* --- NEW COLOR PALETTE (Extracted from Cover Image) --- */
    --bg-color: #FFF0F5;     /* Lavender Blush - matches the rug */
    --primary: #FF6B97;      /* Vibrant Pink - matches the "Play" button */
    --secondary: #2C2F4A;    /* Midnight Blue - matches the window view */
    --accent: #FFD27F;       /* Gold/Amber - matches chandelier & sparkles */
    
    --text-color: #4A2828;   /* Deep Mahogany - matches the woodwork/fireplace */
    
    --card-bg: #FFFFFF;
    --card-back: #F08CA6;    /* Dusty Rose - matches the curtains */
    
    --green-felt: rgba(255, 255, 255, 0.4);
    
    /* Warmer shadow to match the room lighting */
    --shadow: 0 4px 15px rgba(74, 40, 40, 0.15); 
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }




html {
    /* MATCHED COLOR: Dark Mahogany/Wood from the ceiling of bg image */
    background-color: #2b1d1d; 
    
    /* Prevents rubber-banding so the game feels like an 'app' */
    overscroll-behavior: none;
}

body {
    font-family: 'Quicksand', sans-serif;
    color: var(--text-color);
    
    /* Transparent so the wallpaper shows through */
    background-color: transparent;
    
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Background Wallpaper --- */
body::before {
    content: "";
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    
    z-index: -1; 
    
    background-image: url('https://raw.githubusercontent.com/yunadata/yunadata.github.io/refs/heads/main/spooder-solitaire-bg.webp');
    background-position: center center;
    background-size: cover; 
    background-repeat: no-repeat;
}





/* --- Nav --- */
nav {
    padding: 1rem 2rem;
    background: rgba(255,255,255,0.5);
    backdrop-filter: blur(5px);
    position: sticky; top: 0; z-index: 100;
    border-bottom: 0px solid white;
}
.nav-container { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; }
.logo { font-weight: 700; cursor: pointer; color: var(--text-color); font-size: 1.0rem; }
.btn-small { text-decoration: none; color: var(--text-color); background: rgba(255,107,151,0.2); padding: 5px 15px; border-radius: 20px; font-size: 0.9rem; font-weight: 600; }

/* --- Game Layout --- */
main {
    display: flex;
    flex-direction: column; 
    align-items: center;    
    padding: 20px;
    min-height: calc(100vh - 70px); 
    gap: 40px; 
}

.game-container {
    width: 100%; 
    max-width: 1200px;
    height: 85vh; 
    min-height: 600px; 
    background: rgba(255,255,255,0.6);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(74, 40, 40, 0.15); 
    display: flex; 
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(5px);
    border: 2px solid white;
    position: relative;
    flex-shrink: 0; 
}

.watermark {
    position: absolute;
    bottom: 15px;
    left: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    opacity: 0.2; 
    pointer-events: none; 
    z-index: 50;
}

/* Header */
.game-header {
    padding: 15px 20px;
    background: rgba(255,255,255,0.7);
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 2px solid rgba(255,255,255,0.8);
}

.game-title { font-size: 1.5rem; color: var(--text-color); margin-bottom: 5px; font-weight: 800; }
.game-title i { color: var(--primary); }

.stats-bar { display: flex; gap: 20px; font-size: 0.9rem; font-weight: 700; color: var(--text-color); }
.stat .label { color: #8C6A6A; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }

.header-right { display: flex; gap: 10px; }

/* --- Updated Buttons to Match Pixel Art Style --- */
.btn-game {
    border: 2px solid var(--text-color); /* Pixel art outline */
    padding: 8px 16px; 
    border-radius: 12px;
    cursor: pointer; 
    font-family: 'Quicksand', sans-serif; 
    font-weight: 700;
    transition: 0.2s;
    box-shadow: 2px 2px 0px var(--text-color); /* Retro hard shadow */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

.btn-game:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.btn-game.undo { 
    background: #FFF8E1; /* Cream */
    color: var(--text-color); 
}

.btn-game.restart { 
    background: var(--primary); 
    color: white; 
    border-color: #9E3555;
    box-shadow: 2px 2px 0px #9E3555;
}

.btn-game.leaderboard-btn { 
    background: var(--secondary); 
    color: white; 
    border-color: #1A1C30;
    box-shadow: 2px 2px 0px #1A1C30;
}

/* Action/Play Button */
.btn-game.action {
    background: linear-gradient(to bottom, #FF8FAB, #FF6B97); 
    color: white;  
    border: 2px solid white;
    outline: 2px solid var(--text-color);
    box-shadow: 0 4px 10px rgba(255, 107, 151, 0.4);
}
.btn-game.action:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

/* --- Board --- */
#game-board {
    flex: 1;
    position: relative;
    padding: 10px;
    overflow: hidden; 
}

/* Top Row (Stock + Foundations) */
.top-row {
    height: 100px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 10px;
}

.stock-pile {
    width: 70px; height: 96px;
    border: 2px dashed rgba(74, 40, 40, 0.2);
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s;
}
.stock-pile:active { transform: scale(0.95); }
.stock-pile::after { content: 'Stock'; position: absolute; top: 105%; width: 100%; text-align: center; font-size: 10px; color: #8C6A6A; font-weight: 600;}

.foundations-row {
    display: flex; gap: 10px;
}
.foundation-slot {
    width: 70px; height: 96px;
    border: 2px solid rgba(74, 40, 40, 0.1);
    background: rgba(255,255,255,0.4);
    border-radius: 8px;
    position: relative;
}

/* Tableau (Columns) */
.tableau-grid {
    display: flex;
    justify-content: space-between;
    height: calc(100% - 110px);
    padding: 0 10px;
}

.column {
    flex: 1;
    margin: 0 2px;
    position: relative;
    min-height: 200px;
    border-radius: 5px 5px 0 0;
}

/* --- Cards (Updated Visuals) --- */
.card {
    width: 100%; 
    max-width: 80px; 
    aspect-ratio: 2.5 / 3.5;
    
    background: linear-gradient(135deg, #ffffff 0%, #FFF5F8 100%);
    border: 1px solid rgba(74, 40, 40, 0.15);
    border-radius: 8px; 
    box-shadow: 
        1px 1px 0px rgba(74, 40, 40, 0.05),
        2px 2px 3px rgba(74, 40, 40, 0.1); 
        
    position: absolute; 
    display: flex; flex-direction: column;
    font-size: 14px;
    transition: transform 0.1s; 
    z-index: 1;
    overflow: hidden;
}

.card:hover {
    filter: brightness(1.02);
}

/* NEW: Spooder Web Card Back */
.card.face-down {
    background-color: var(--card-back);
    /* Subtle geometric web pattern */
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.3) 2px, transparent 2.5px),
        repeating-linear-gradient(45deg, rgba(255,255,255,0.15) 0, rgba(255,255,255,0.15) 1px, transparent 1px, transparent 10px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,0.15) 0, rgba(255,255,255,0.15) 1px, transparent 1px, transparent 10px);
    
    border: 2px solid white;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}
.card.face-down .card-content { display: none; }

.card-content {
    padding: 2px 5px;
    display: flex; flex-direction: column; height: 100%;
    pointer-events: none; 
}

.card-top { 
    text-align: left; 
    font-weight: 800;
    line-height: 1.1;
}

.card-center { 
    position: absolute;
    top: 55%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    font-size: 50px; 
    opacity: 0.2; 
    pointer-events: none;
    z-index: 0;
}
/* Tweaked red to match the pink theme slightly better */
.suit-red { color: #E05A80; } 
.suit-black { color: #2C2F4A; }

/* Dragging State */
.card.dragging {
    z-index: 9999 !important;
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(74, 40, 40, 0.3);
    pointer-events: none; 
    opacity: 1;
}

/* Foundation Completed King Style */
.foundation-slot .card-center {
    font-size: 24px;
    font-weight: bold;
	opacity: 0.5;
    color: var(--primary);
}

/* --- Animations --- */
@keyframes flyIn {
    0% { transform: translate(-200px, -200px) scale(0.5); opacity: 0; }
    100% { transform: translate(0, 0) scale(1); opacity: 1; }
}

.card.dealt-anim {
    animation: flyIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* --- Overlays --- */
.overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 240, 245, 0.5);
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.hidden { display: none !important; }

.overlay-content {
    background: white; padding: 40px; border-radius: 20px;
    box-shadow: 0 10px 40px rgba(74, 40, 40, 0.2);
    text-align: center; max-width: 500px; width: 90%;
    border: 1px solid white;
}

.overlay-content h1, 
.overlay-content h2 { 
    color: var(--text-color); 
    margin-bottom: 10px; 
    font-weight: 800;
}
.overlay-content p { color: #8C6A6A; margin-bottom: 30px; font-weight: 600;}

/* Difficulty Buttons */
.difficulty-options { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
.diff-btn {
    background: #FFF5F8; border: 1px solid transparent;
    padding: 15px; border-radius: 12px; cursor: pointer;
    min-width: 100px; transition: 0.2s;
	color: var(--text-color);
}
.diff-btn:hover { 
    border-color: white; 
    background: #FFE6EE; 
    transform: translateY(-5px); 
    box-shadow: 0 5px 15px rgba(255, 107, 151, 0.2);
}
.diff-icon { font-size: 24px; margin-bottom: 5px; }

.diff-btn h3 {
    color: var(--text-color);
    margin-bottom: 5px;
}

/* --- Enhanced Leaderboard Modal --- */
.overlay-content.large { 
    max-width: 550px; 
    padding: 30px; 
    height: 600px;
    display: flex;
    flex-direction: column;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-shrink: 0; }
.close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-color); transition: 0.2s;}
.close-btn:hover { color: var(--primary); transform: rotate(90deg); }

.tabs { display: flex; gap: 15px; margin-bottom: 20px; border-bottom: 2px solid #f0f0f0; padding-bottom: 0; flex-shrink: 0; }
.tab-btn { 
    background: none; 
    border: none; 
    padding: 10px 15px; 
    cursor: pointer; 
    color: #aaa; 
    font-weight: 700; 
    font-size: 1rem;
    position: relative;
    top: 2px;
    transition: 0.3s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { 
    color: var(--primary); 
    border-bottom: 3px solid var(--primary); 
}

/* List Container */
#leaderboard-list { 
    flex: 1; 
    overflow-y: auto; 
    padding-right: 10px; 
}

#leaderboard-list::-webkit-scrollbar { width: 6px; }
#leaderboard-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 3px; }
#leaderboard-list::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

/* --- Leaderboard Rows --- */
.score-row {
    display: grid;
    grid-template-columns: 50px 1fr 80px; 
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
    padding: 12px 15px;
    border-radius: 15px;
    border: 1px solid rgba(74, 40, 40, 0.1);
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.score-row:hover {
    transform: translateY(-2px) scale(1.01);
    background: white;
    box-shadow: 0 5px 15px rgba(74, 40, 40, 0.1);
}

.rank-col {
    font-weight: 800;
    font-size: 1.2rem;
    color: #b2bec3;
    text-align: center;
}

.player-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    padding-left: 10px;
}

.player-name {
    font-weight: 700;
    color: var(--text-color);
    font-size: 1rem;
    margin-bottom: 2px;
}

.player-meta {
    font-size: 0.75rem;
    color: #8C6A6A;
    display: flex;
    gap: 12px;
}

.player-meta i { margin-right: 4px; color: var(--primary); }

.score-col {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.main-score {
    font-weight: 800;
    color: var(--primary);
    font-size: 1.2rem;
}

.sub-score {
    font-size: 0.7rem;
    color: #8C6A6A;
    text-transform: uppercase;
    font-weight: 600;
}

/* --- Top 3 Special Styles (Updated to Room Palette) --- */

/* 1st Place: Gold (Chandelier) */
.score-row.rank-1 {
    background: linear-gradient(135deg, #FFFDF5, #FFFFFF);
    border: 2px solid var(--accent);
}
.rank-1 .rank-col { font-size: 1.6rem; color: #E0BC5C; text-shadow: 1px 1px 0 rgba(0,0,0,0.1); }
.rank-1 .main-score { color: #E0BC5C; }

/* 2nd Place: Silver (Spider Web) */
.score-row.rank-2 {
    background: linear-gradient(135deg, #F8FAFC, #FFFFFF);
    border: 2px solid #CFD8DC;
}
.rank-2 .rank-col { font-size: 1.5rem; color: #90A4AE; }
.rank-2 .main-score { color: #78909C; }

/* 3rd Place: Bronze (Woodwork) */
.score-row.rank-3 {
    background: linear-gradient(135deg, #FFF0EB, #FFFFFF);
    border: 2px solid #E6B0AA;
}
.rank-3 .rank-col { font-size: 1.4rem; color: #D4887A; }
.rank-3 .main-score { color: #D4887A; }

/* Input group */
.input-group { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }
input { padding: 10px; border: 1px solid #ddd; border-radius: 20px; font-family: inherit; }
input:focus {
    outline: none; 
    border: 2px solid var(--primary); 
    box-shadow: 0 0 10px rgba(255, 107, 151, 0.3); 
}

/* --- How to Play Section --- */
#how-to-play {
    width: 100%;
    max-width: 1200px; 
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 2px solid white;
}

#how-to-play h2 {
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: var(--text-color);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.instructions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.instruction-card {
    background: rgba(255, 255, 255, 0.85);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(74, 40, 40, 0.05);
    transition: transform 0.3s;
    border: 1px solid white;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.instruction-card:hover {
    transform: translateY(-5px);
    background: white;
}

.instruction-card .icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: var(--secondary); 
    background: rgba(44, 47, 74, 0.1);
    padding: 15px;
    border-radius: 50%;
}

.instruction-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-color);
    font-weight: 700;
}

.instruction-card p {
    font-size: 0.95rem;
    color: #6D4C4C;
    line-height: 1.6;
}

.scoring-list {
    list-style: none;
    width: 100%;
    text-align: left;
    padding-left: 20px;
}

.scoring-list li {
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
    display: flex;
    justify-content: space-between;
}
.scoring-list li:last-child { border-bottom: none; }

/* Play Again Button */
.btn-game.replay {
    background: transparent;
    border: 2px solid var(--secondary); 
    color: var(--secondary);
    margin-top: 15px;
    width: auto;
    padding: 10px 30px;
    display: inline-block;
    box-shadow: 2px 2px 0 var(--secondary);
}
.btn-game.replay:hover {
    background: var(--secondary);
    color: white;
    transform: translateY(-3px);
    box-shadow: none;
}

footer {
    text-align: center;
    padding: 20px;
    font-size: 0.9rem;
    color: white;
    width: 100%;
    margin-top: 20px; 
    opacity: 0.8;
}

/* --- Mobile Adjustments --- */
@media (max-width: 768px) {
	/* NEW: Fix Leaderboard Cut-off */
    .overlay-content.large {
        width: 95%;          /* Use more screen width (was 90%) */
        padding: 20px 10px;  /* Drastically reduce padding (was 30px) */
    }

    .score-row {
        /* Adjust grid: 
           - Rank: 50px -> 35px 
           - Name: 1fr (takes remaining space)
           - Score: 80px -> 70px 
        */
        grid-template-columns: 35px 1fr 70px; 
        padding: 10px 8px;   /* Reduce internal row padding */
        gap: 5px;            /* Reduce gap between columns */
    }

    /* Scale down text slightly to fit better */
    .rank-col { font-size: 1rem; }
    .main-score { font-size: 1rem; }
    .player-name { font-size: 0.9rem; }
	
    .tableau-grid { overflow-x: auto; padding-bottom: 10px; justify-content: flex-start; }
    .column { min-width: 45px; flex: none; width: 10%; } 
    .card { width: 40px; font-size: 10px; }
    .card-center { font-size: 16px; }
    
    .game-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    .header-right { width: 100%; justify-content: space-between; }
    .game-title { font-size: 1.2rem; }
	
    .top-row {
        height: 60px; 
        padding: 0 5px;
    }

    .stock-pile, .foundation-slot {
        width: 34px;  
        height: 48px; 
        border-width: 1px; 
    }

    .foundations-row {
        gap: 2px; 
    }

    .stock-pile::after {
        font-size: 8px;
        top: 100%;
    }
	
    .foundation-slot .card-center {
        font-size: 14px; 
    }
	
    nav {
        position: static;
        border-bottom: none;
    }
}





/* --- Cookie Banner Fixes --- */
#btn-reopen-settings {

    /* White background with 80% opacity */
    background-color: rgba(255, 255, 255, 0.1) !important; 
    
    /* Frosted glass effect */
    backdrop-filter: blur(10px) !important; 
    
    /* Adds a soft shadow so the white button doesn't disappear */
    box-shadow: 0 2px 10px rgba(74, 40, 40, 0.1) !important;
}


#btn-accept {
    /* Text color changed to white */
    color: white !important;
}

/* Ensure the text stays white on hover */
#btn-accept:hover {
    color: white !important;
}
