/* 1. Global Layout */
body {
    background-color: #ffffff;
    color: #333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding-bottom: 80px; /* Space for the fixed footer */
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

#game-container {
    width: 95vw;
    max-width: 1200px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 2. Tableaus (Layout for Player & Opponent) */
.tableau {
    display: flex;
    justify-content: space-between; /* Pushes side areas to edges, work piles to center */
    align-items: flex-start;
    width: 100%;
}

.opponent {
    border-bottom: 2px dashed #ccc;
    padding-bottom: 20px;
}

#player-tableau {
    border-top: 2px dashed #ccc;
    padding-top: 20px;
}

/* Groupings within tableaus */
.side-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 220px; /* Fixed width keeps center stable */
}

/* Ensures side-by-side layout for Deck/Waste if in same area */
#opp-deck-area, #deck-area {
    flex-direction: row;
    justify-content: center;
}

.work-piles {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-grow: 1;
}

/* 3. Common Foundation Area */
#common-area {
    text-align: center;
    background-color: #f4f8fb;
    border-radius: 12px;
    padding: 15px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

#common-area h3 {
    margin-top: 0;
    color: #555;
}

#foundations {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.foundation {
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
    background-color: rgba(255, 255, 255, 0.5); /* Slight tint */
    border: 2px dashed #ccc;
}

/* Specific suit backgrounds (using your existing asset naming) */
.f-hearts { background-image: url('assets/cards/hearts_ghost.png'); }
.f-clubs { background-image: url('assets/cards/clubs_ghost.png'); }
.f-diamonds { background-image: url('assets/cards/diamonds_ghost.png'); }
.f-spades { background-image: url('assets/cards/spades_ghost.png'); }

/* 4. Piles & Cards */
.pile {
    width: 100px;
    height: 140px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: #fcfcfc;
    position: relative;
    box-sizing: border-box;
}

/* Foundations look slightly different */
.pile.foundation {
    border-style: dashed;
    border-color: #aaa;
}

.card-image {
    width: 100px;
    height: 140px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: block;
    cursor: grab;
    position: absolute;
    top: 0;
    left: 0;
}

.card-image:active {
    cursor: grabbing;
}

/* Cascading Cards in Work Piles */
.pile.work {
    background-color: transparent;
    border-style: dashed;
}

.work .card-image {
    /* Uses the --card-index variable set dynamically in client.js */
    top: calc(var(--card-index) * 25px); 
}

/* 5. UI Elements */
.nerts-counter {
    font-size: 0.9rem;
    font-weight: bold;
    color: #555;
    margin-top: 5px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* 6. Footer Controls */
#controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #333;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    z-index: 100;
}

#controls input, #controls select, #controls button {
    padding: 8px 12px;
    border-radius: 4px;
    border: none;
    font-size: 1rem;
}

#controls button {
    background-color: #4CAF50;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

#controls button:hover {
    background-color: #45a049;
}