:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --primary: #3b82f6;
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --table-green: #065f46;
    --card-width: 65px;
    --card-height: 95px;
    --card-spacing: 28px; /* Vertical overlap in tableau */
}

body {
    background-color: var(--bg-dark);
    color: white;
    font-family: 'Outfit', sans-serif;
    margin: 0;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
    position: relative;
    z-index: 10;
}

.game-header { text-align: center; }
.game-header h1 { font-size: 2.5rem; margin: 1rem 0 0 0; }

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    margin: 2rem auto;
    text-align: center;
}

.btn-group { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.5rem; }

.score-board {
    display: flex; justify-content: space-around; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 0.5rem; border: 1px solid var(--glass-border); align-items: stretch;
}
.score-card { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 1rem; flex: 1; }
.score-label { font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }
.score-value { font-size: 1.5rem; font-weight: 700; color: #10b981; }

/** Table Area */
.freecell-table {
    background: var(--table-green);
    border-radius: 12px;
    padding: 2rem 1rem;
    margin-top: 1rem;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.5);
    min-height: 550px;
    position: relative;
}

@media (max-width: 700px) {
    .freecell-table { padding: 1rem 0.5rem; min-height: 400px; }
}

.top-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.freecells-area { display: flex; gap: 8px; }
.foundations-area { display: flex; gap: 8px; }

.tableau-area {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    min-height: 350px;
}

/* Slots */
.card-slot {
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 6px;
    position: relative;
    box-sizing: border-box;
}

.foundation-slot::after {
    content: '★';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    color: rgba(255,255,255,0.1);
}

.free-slot::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

/** Cards CSS */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background: white;
    border-radius: 6px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.4);
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px;
    box-sizing: border-box;
    position: absolute; /* absolutely positioned within their slots */
    border: 1px solid #ccc;
    font-family: Arial, sans-serif;
    cursor: grab;
    touch-action: none; /* Prevent scroll on touch-drag */
    will-change: transform;
}
.card:active { cursor: grabbing; box-shadow: 5px 5px 15px rgba(0,0,0,0.5); z-index: 1000 !important; }

.card.red { color: #ef4444; }
.card.black { color: #0f172a; }

.card-top {
    font-size: 1rem; font-weight: bold; line-height: 1;
    display: flex; flex-direction: column; align-items: center; align-self: flex-start;
}
.card-bottom {
    font-size: 1rem; font-weight: bold; line-height: 1;
    display: flex; flex-direction: column; align-items: center; align-self: flex-end;
    transform: rotate(180deg);
}
.card-suit { font-size: 1.1rem; margin-top: -2px; }
.card-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0.3;
}

/* Dragging state */
.dragging {
    opacity: 0.9;
    z-index: 9999 !important;
    transition: none !important;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
    :root {
        --card-width: 40px;
        --card-height: 60px;
        --card-spacing: 20px;
    }
    .game-container { padding: 1rem 0.2rem; }
    .card-top, .card-bottom { font-size: 0.8rem; }
    .card-suit { font-size: 0.9rem; }
    .card-center { font-size: 1.4rem; }
    .top-row, .tableau-area { gap: 2px; }
    .freecells-area, .foundations-area { gap: 2px; }
}
