/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh;
    color: #fff;
}

/* Screen Management */
.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* Settings Screen */
.settings-container {
    max-width: 600px;
    margin: auto;
    padding: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    text-align: center;
}

.settings-container h1 {
    font-size: 3.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.settings-container h2 {
    font-size: 2rem;
    margin-bottom: 40px;
    font-weight: normal;
    opacity: 0.9;
}

.setting-group {
    margin-bottom: 30px;
}

.setting-group label {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.setting-btn {
    padding: 15px 30px;
    font-size: 1.3rem;
    border: 3px solid #fff;
    background: transparent;
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 150px;
    min-height: 60px;
}

.setting-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.setting-btn.active {
    background: #fff;
    color: #2c3e50;
    font-weight: bold;
}

.primary-btn {
    margin-top: 20px;
    padding: 20px 50px;
    font-size: 1.8rem;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    min-height: 70px;
    display: block;
    width: 100%;
    text-decoration: none;
    text-align: center;
}

.primary-btn:hover {
    background: #c0392b;
    transform: scale(1.03);
    box-shadow: 0 5px 20px rgba(231, 76, 60, 0.5);
}

.primary-btn:focus {
    outline: 4px solid #f39c12;
    outline-offset: 3px;
}

.secondary-btn {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid #fff;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.03);
    box-shadow: none;
}

.rules-summary {
    background: rgba(255,255,255,0.1); border-radius: 12px;
    padding: 18px 22px; margin: 20px 0; text-align: left;
}
.rules-summary h3 { font-size: 1.3rem; margin-bottom: 10px; }
.rules-summary ul { list-style: none; }
.rules-summary li { font-size: 1.05rem; padding: 5px 0; opacity: 0.9; }
.rules-summary li::before { content: '• '; color: #f39c12; font-weight: bold; }

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.header-left h1 {
    font-size: 2rem;
}

#move-counter {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
}

.header-right {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 15px 25px;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.9);
    color: #1a472a;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    min-height: 55px;
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}

.action-btn:hover {
    background: #fff;
    transform: scale(1.05);
}

a.action-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.action-btn.hidden {
    display: none;
}

/* Game Area */
.game-area {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 120px;
}

/* Top Row */
.top-row {
    display: flex;
    justify-content: space-between;
    gap: 30px;
}

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

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

/* Card Pile Base Styles */
.card-pile,
.foundation-pile,
.tableau-pile {
    width: 120px;
    min-height: 168px;
    border-radius: 12px;
    position: relative;
}

.foundation-pile,
.stock-pile,
.waste-pile {
    background: rgba(0, 0, 0, 0.3);
    border: 4px dashed rgba(255, 255, 255, 0.4);
}

.empty-pile-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    opacity: 0.6;
    pointer-events: none;
}

.foundation-pile[data-suit="hearts"] .empty-pile-marker,
.foundation-pile[data-suit="diamonds"] .empty-pile-marker {
    color: #ff3333;
}

.foundation-pile[data-suit="clubs"] .empty-pile-marker,
.foundation-pile[data-suit="spades"] .empty-pile-marker {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.stock-pile {
    cursor: pointer;
}

.stock-pile:hover {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
}

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

.tableau-pile {
    background: rgba(0, 0, 0, 0.15);
    border: 3px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
}

/* Cards */
.card {
    width: 120px;
    height: 168px;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
    flex-shrink: 0;
}

.card:hover:not(.face-down) {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.card.face-down {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    border: 4px solid #fff;
    cursor: default;
}

.card.face-down::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.1) 10px,
        rgba(255, 255, 255, 0.1) 20px
    );
}

.card.face-up {
    background: #fff;
    border: 4px solid #333;
}

.card.face-up.red {
    color: #cc0000;
}

.card.face-up.black {
    color: #000;
}

.card-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
}

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.card-corner.top-left {
    align-self: flex-start;
}

.card-corner.bottom-right {
    align-self: flex-end;
    transform: rotate(180deg);
    margin-top: auto;
}

.card-value {
    font-size: 1.8rem;
    font-weight: bold;
}

.card-suit {
    font-size: 1.5rem;
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.5rem;
}

.card-center svg {
    width: 65px;
    height: 85px;
}

.card-center.figure-card {
    font-size: inherit;
}

/* Responsive figure sizing */
@media (max-width: 1200px) {
    .card-center svg {
        width: 55px;
        height: 70px;
    }
}

/* Card in tableau - stacked */
.tableau-pile .card {
    margin-bottom: -130px;
}

.tableau-pile .card:last-child {
    margin-bottom: 0;
}

.tableau-pile .card.face-down {
    margin-bottom: -145px;
}

/* Card in waste - stacked for draw 3 */
.waste-pile .card {
    position: absolute;
    top: 0;
    left: 0;
}

/* Selected card */
.card.selected {
    box-shadow: 0 0 0 6px #ffd700, 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-8px);
    z-index: 100;
}

/* Hint highlight */
.card.hint {
    animation: hint-pulse 1s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(0, 255, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(0, 255, 0, 0.3);
    }
}

/* Valid drop target */
.valid-drop {
    box-shadow: 0 0 0 6px #00ff00;
}

/* Foundation and Tableau drop zones */
.foundation-pile.valid-drop,
.tableau-pile.valid-drop {
    background: rgba(0, 255, 0, 0.3);
    border-color: #00ff00;
}

/* Win Screen */
.win-container {
    max-width: 500px;
    margin: auto;
    padding: 60px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    text-align: center;
}

.win-container h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.win-container p {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

/* Lose Screen */
.lose-container {
    max-width: 500px;
    margin: auto;
    padding: 60px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    text-align: center;
}

.lose-container h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    color: #ff6b6b;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.lose-container p {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

/* Responsive */
@media (max-width: 1200px) {
    .card,
    .card-pile,
    .foundation-pile,
    .tableau-pile {
        width: 100px;
        min-height: 140px;
    }

    .card {
        height: 140px;
    }

    .tableau-pile .card {
        margin-bottom: -110px;
    }

    .tableau-pile .card.face-down {
        margin-bottom: -125px;
    }

    .card-value {
        font-size: 1.5rem;
    }

    .card-suit {
        font-size: 1.2rem;
    }

    .card-center {
        font-size: 2.8rem;
    }
}

@media (max-width: 900px) {
    .game-area {
        padding: 15px;
        gap: 80px;
    }

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

    .tableau {
        flex-wrap: wrap;
    }

    .game-header {
        justify-content: center;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
        gap: 10px;
    }
}
