:root {
    --card-width: 70px;
    --card-height: 98px;
    --card-gap: 10px;
}

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

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

.game-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: transparent;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.game-nav a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all var(--transition-normal);
}

.game-nav a:hover {
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
}

.game-nav a.active {
    color: var(--accent-gold);
    font-weight: var(--font-weight-bold);
}

.game-nav .nav-divider {
    color: var(--text-primary);
    opacity: 0.5;
}

.game-nav .nav-home {
    font-size: 1.1rem;
}

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

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.game-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--accent-color);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

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

.controls button {
    padding: 8px 16px;
    background: var(--button-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: white;
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.controls button:hover {
    background: var(--button-hover);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.controls button:active {
    transform: scale(0.95);
}

.score {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-color);
}

.game-board {
    background: var(--table-color);
    border: 2px solid var(--table-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.05);
}

.top-row {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.foundations {
    display: flex;
    gap: var(--card-gap);
}

.foundation {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 6px;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background: rgba(0,0,0,0.15);
    position: relative;
}

.foundation[data-suit="hearts"]::before {
    content: '♥';
}

.foundation[data-suit="diamonds"]::before {
    content: '♦';
}

.foundation[data-suit="clubs"]::before {
    content: '♣';
}

.foundation[data-suit="spades"]::before {
    content: '♠';
}

.foundation::before {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.12);
}

.foundation.ace-placed {
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.3);
}

.tableau {
    display: flex;
    gap: var(--card-gap);
    min-height: 400px;
}

.tableau-column {
    flex: 1;
    position: relative;
    min-height: var(--card-height);
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 6px;
    position: absolute;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card.face-down .card-front {
    display: none;
}

.card.face-up .card-back {
    display: none;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.card.dragging {
    opacity: 0.4;
    z-index: 1000;
}

#drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 2147483647;
    opacity: 0.9;
}

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.card-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    z-index: 2;
}

.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--card-back);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.05) 10px,
        rgba(255, 255, 255, 0.05) 20px
    );
    border: 2px solid #3a5a7a;
    z-index: 1;
}

.card.red .card-front {
    color: #d62828;
}

.card.black .card-front {
    color: #1a1a1a;
}

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

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

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

.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.win-overlay.show {
    display: flex;
}

.win-message {
    background: linear-gradient(145deg, #1e3a2f 0%, #0f2318 100%);
    border: 2px solid var(--accent-color);
    padding: 40px 60px;
    border-radius: 12px;
    text-align: center;
    animation: popIn 0.3s ease-out;
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.2);
}

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

.win-message h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--accent-color);
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

.win-message p {
    font-size: 1.25rem;
    margin-bottom: 20px;
}

.win-message button {
    padding: 12px 30px;
    background: var(--button-bg);
    border: 1px solid var(--accent-color);
    border-radius: 6px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.win-message button:hover {
    background: #5faa70;
}

.rules-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.rules-overlay.show {
    display: flex;
}

.rules-content {
    background: linear-gradient(145deg, #1e3a2f 0%, #0f2318 100%);
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: popIn 0.3s ease-out;
}

.rules-content h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--accent-color);
    text-align: center;
}

.rules-section {
    margin-bottom: 20px;
}

.rules-section h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.rules-section p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #ccc;
}

.rules-section ul {
    margin-left: 20px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #ccc;
}

.rules-section li {
    margin-bottom: 4px;
}

.rules-content button {
    display: block;
    width: 100%;
    padding: 12px 30px;
    background: var(--button-bg);
    border: 1px solid var(--accent-color);
    border-radius: 6px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s;
}

.rules-content button:hover {
    background: #5faa70;
}

@media (max-width: 700px) {
    :root {
        --card-width: 45px;
        --card-height: 63px;
        --card-gap: 6px;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .game-header h1 {
        width: 100%;
        text-align: center;
    }

    .tableau {
        min-height: 250px;
    }

    .card-face {
        padding: 3px;
        font-size: 0.6rem;
    }

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