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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 25px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2em;
    margin: 0;
}

/* Hide back-link in header - it's now in the menu */
.back-link {
    display: none;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.stats-bar {
    display: flex;
    gap: 30px;
    font-size: 1.2em;
}

.stat {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
}

header button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

header button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

header select {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
}

/* Game Board */
.game-board {
    background: rgba(255, 255, 255, 0.05);
    padding: 30px;
    padding-bottom: 200px; /* Extra space for cascading cards */
    border-radius: 15px;
    backdrop-filter: blur(10px);
    margin-bottom: 40px; /* Space at bottom of page */
}

.top-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    gap: 20px;
}

.stock-waste {
    display: flex;
    gap: 15px;
}

.foundations {
    display: flex;
    gap: 15px;
}

.card-pile {
    width: 80px;
    min-height: 112px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
}

.card-pile.can-drop {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

.pile-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    text-align: center;
}

.pile-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    color: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.stock-pile {
    cursor: pointer;
}

.stock-pile:hover {
    border-color: rgba(255, 255, 255, 0.6);
}

.stock-pile.empty {
    border-style: solid;
    cursor: pointer;
}

.stock-pile.empty:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Tableau */
.tableau {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.tableau-pile {
    flex: 1;
    min-height: 200px;
    max-width: 80px;
}

/* Card Positioning in Piles */
.card-pile .card {
    position: absolute;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: none; /* Prevent default touch behaviors */
    -webkit-user-select: none;
    user-select: none;
}

.card-pile .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.card-pile .card.dragging {
    cursor: grabbing;
    opacity: 0.7;
    z-index: 1000;
}

/* Touch-specific styles */
@media (hover: none) and (pointer: coarse) {
    .card-pile .card {
        /* Larger tap targets on mobile */
        min-width: 60px;
        min-height: 85px;
    }

    .card-pile .card:active {
        transform: scale(1.05);
    }
}

.waste-pile .card {
    left: 0;
}

.foundation-pile .card {
    left: 0;
}

.tableau-pile .card {
    left: 0;
}

/* Tableau cascade effect - cards stack vertically */
.tableau-pile .card {
    top: 0;
}

.tableau-pile .card.face-down {
    cursor: default;
}

/* Win Overlay */
.game-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.game-overlay.active {
    display: flex;
}

.overlay-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.overlay-content h1 {
    font-size: 3em;
    margin-bottom: 20px;
}

.overlay-content .stats {
    margin: 30px 0;
    font-size: 1.3em;
}

.overlay-content .stats p {
    margin: 10px 0;
}

.overlay-content button {
    background: white;
    color: #667eea;
    border: none;
    padding: 15px 40px;
    font-size: 1.2em;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.overlay-content button:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .tableau {
        gap: 10px;
    }

    .tableau-pile {
        max-width: 80px;
    }

    header {
        flex-direction: column;
        gap: 15px;
    }

    .header-left,
    .header-center,
    .header-right {
        width: 100%;
        justify-content: center;
    }

    .stats-bar {
        gap: 15px;
        font-size: 1em;
    }
}

@media (max-width: 768px) {
    .game-board {
        padding: 15px;
    }

    .top-row {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .tableau {
        flex-wrap: wrap;
    }

    .card-pile {
        width: 55px;
        min-height: 77px;
    }

    .tableau-pile {
        max-width: 55px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .overlay-content {
        padding: 30px;
        max-width: 90%;
    }

    .overlay-content h1 {
        font-size: 2em;
    }
}
