.app {
    max-width: 1200px;
    margin: 24px auto;
    padding: 20px;
    margin-top: 8rem;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    color: #fff;
    margin-bottom: 15px;
}

@media (max-width: 600px) {
    .app {
        margin-top: 6rem;
    }
}

.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.stats {
    display: flex;
    gap: 20px;
    color: #fff;
    font-size: 1.1em;
}

.play {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s, box-shadow 0.2s;
}

.play:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.secondary-button {
    background: linear-gradient(135deg, #666, #555);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s, box-shadow 0.2s;
}

.secondary-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(100, 100, 100, 0.4);
}

.secondary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.solitaire-board {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px;
    background: rgba(0, 80, 0, 0.3);
    border-radius: 15px;
    min-height: 600px;
}

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

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

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

.pile {
    width: 80px;
    height: 112px;
    border-radius: 8px;
    position: relative;
}

.card-placeholder {
    width: 100%;
    height: 100%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    color: rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
}

.card-placeholder.empty {
    font-size: 1em;
}

.stock {
    cursor: pointer;
}

.stock:hover .card-placeholder {
    border-color: rgba(255, 255, 255, 0.5);
}

.tableau {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex: 1;
}

.tableau-pile {
    flex: 1;
    min-height: 300px;
    background: rgba(0, 0, 0, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.15);
}

.card {
    width: 80px;
    height: 112px;
    border-radius: 8px;
    position: absolute;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #fff, #f3f6fb);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    color: #212121 !important;
}

.card.face-down {
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #1a237e 100%);
    cursor: default;
}

.card.face-down::before {
    content: '🂠';
    font-size: 3em;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.8;
}

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

.card.selected {
    box-shadow: 0 0 0 3px #FFD700, 0 8px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(-5px);
}

.card.dragging {
    z-index: 1000 !important;
    opacity: 0.9;
    transform: scale(1.05);
}

.card-content {
    padding: 5px 8px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

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

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

.card-rank {
    font-size: 1.2em;
    font-weight: bold;
}

.card-suit {
    font-size: 1em;
}

.card.red {
    color: #d32f2f !important;
}

.card.black {
    color: #212121 !important;
}

/* Ensure card colors override any global white text rules
   that may be applied in the main stylesheet. Using higher
   specificity with the `.app` container and targeting all
   descendants guarantees the correct color inside cards. */
.app .card.red:not(.face-down),
.app .card.red:not(.face-down) *,
.card.red:not(.face-down),
.card.red:not(.face-down) * {
    color: #d32f2f !important;
}

.app .card.black:not(.face-down),
.app .card.black:not(.face-down) *,
.card.black:not(.face-down),
.card.black:not(.face-down) * {
    color: #212121 !important;
}

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

.foundation.valid-drop,
.tableau-pile.valid-drop {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
}

.message {
    text-align: center;
    margin-top: 20px;
    font-size: 1.5em;
    color: #FFD700;
    min-height: 40px;
}

footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 20px;
    padding: 10px;
}

/* Card Move Animation */
@keyframes cardMove {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(var(--move-x), var(--move-y)) scale(1.1);
        opacity: 0.9;
    }
    100% {
        transform: translate(var(--move-x), var(--move-y)) scale(1);
        opacity: 1;
    }
}

.card.animating {
    animation: cardMove 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2000 !important;
}

/* Win Animations - Microsoft Solitaire Style */
@keyframes cardBounce {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(calc(-100vh - 200px)) rotate(calc(var(--card-index) * 45deg));
        opacity: 0;
    }
}

@keyframes cardFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 200px)) rotate(calc(var(--card-index) * -30deg + 180deg));
        opacity: 0;
    }
}

@keyframes cardSpiral {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(
            calc(var(--spiral-x) * 200px),
            calc(var(--spiral-y) * -100vh - 200px)
        ) rotate(calc(var(--card-index) * 120deg)) scale(0.3);
        opacity: 0;
    }
}

.card.winning {
    animation: cardBounce 2s ease-out forwards;
}

.card.winning-fall {
    animation: cardFall 1.5s ease-in forwards;
}

.card.winning-spiral {
    animation: cardSpiral 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* Pulse effect for clickable cards */
@keyframes cardPulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(76, 175, 80, 0.6), 0 0 15px rgba(76, 175, 80, 0.4);
    }
}

.card.can-auto-move {
    animation: cardPulse 1.5s ease-in-out infinite;
}

/* Solve button highlight */
@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    }
    50% {
        box-shadow: 0 6px 25px rgba(255, 215, 0, 0.6), 0 0 20px rgba(255, 215, 0, 0.4);
    }
}

#solve-btn {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    animation: buttonGlow 2s ease-in-out infinite;
}

#solve-btn:hover {
    background: linear-gradient(135deg, #FFA500, #FFD700);
}

/* Responsive */
@media (max-width: 768px) {
    .pile {
        width: 50px;
        height: 70px;
    }
    
    .card {
        width: 50px;
        height: 70px;
    }
    
    .card-rank {
        font-size: 0.9em;
    }
    
    .card-suit {
        font-size: 0.8em;
    }
    
    .card-center {
        font-size: 1.5em;
    }
    
    .card-placeholder {
        font-size: 1.5em;
    }
    
    .top-row {
        flex-direction: column;
        align-items: center;
    }
    
    .foundations {
        order: -1;
    }
    
    .game-controls {
        flex-direction: column;
    }
    
    .stats {
        flex-direction: column;
        gap: 5px;
    }
}

@media (max-width: 500px) {
    .pile {
        width: 42px;
        height: 59px;
    }
    
    .card {
        width: 42px;
        height: 59px;
    }
    
    .foundations {
        gap: 5px;
    }
    
    .tableau {
        gap: 3px;
    }
}
