:root {
    --card-bg: #ffffff;
    --card-border: var(--border-color);
    --card-shadow: var(--shadow-sm);
    --red-suit: #ef4444;
    --black-suit: #1e293b;
    --card-radius: 6px;
    --card-back-bg: #334155;

    /* Responsive sizing based on viewport */
    --card-width: 12vw;
    --card-height: 17vw;
    --card-gap: 1.5vw;
    --tableau-offset: 16px;
}

[data-theme="dark"] {
    --card-bg: var(--bg-secondary);
    --card-border: var(--border-color);
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --red-suit: #fb7185;
    --black-suit: #f1f5f9;
    --card-back-bg: #475569;
}

/* Level Select Style - Standardized */
.stat-select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 12px;
    border-radius: 12px;
    -webkit-appearance: none;
    appearance: none;
    text-align: center;
    text-align-last: center;
    width: 100%;
    min-height: 28px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .stat-select {
    background: var(--panel-bg);
}

.stat-select:hover {
    border-color: var(--text-secondary);
    background: var(--bg-secondary);
}

.stat-select:focus {
    outline: none;
    border-color: var(--game-accent);
}

.game-surface {
    padding: 12px 8px;
    background: var(--bg-secondary);
    overflow-x: hidden;
    overflow-y: auto;
}

.table {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-area {
    display: flex;
    justify-content: space-between;
    height: var(--card-height);
}

.stock-waste-container,
.foundations {
    display: flex;
    gap: var(--card-gap);
}

.tableau {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    min-height: 300px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.92));
    backdrop-filter: blur(6px);
    color: var(--text-primary);
    text-align: center;
}

[data-theme="dark"] .loading-overlay {
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.9));
}

.loading-card-stack {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.loading-cards {
    position: relative;
    width: clamp(140px, 38vw, 200px);
    height: clamp(200px, 56vw, 260px);
}

.loading-card {
    width: clamp(120px, 35vw, 180px);
    height: clamp(160px, 48vw, 240px);
    border-radius: 12px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.3);
    position: absolute;
    transform-origin: center;
}

.loading-card.card-a {
    transform: translate(-18px, -18px) rotate(-6deg);
    opacity: 0.7;
}

.loading-card.card-b {
    transform: translate(8px, -8px) rotate(4deg);
    opacity: 0.85;
}

.loading-card.card-c {
    position: relative;
    transform: translate(0, 0) rotate(0deg);
    animation: shuffle-pulse 1.2s ease-in-out infinite;
    background: linear-gradient(135deg, #1f2937, #0b1120);
}

.loading-text {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

@keyframes shuffle-pulse {
    0% {
        transform: translate(0, 0) rotate(0deg);
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.3);
    }
    50% {
        transform: translate(6px, -6px) rotate(2deg);
        box-shadow: 0 22px 50px rgba(15, 23, 42, 0.4);
    }
    100% {
        transform: translate(0, 0) rotate(0deg);
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.3);
    }
}

.column {
    width: var(--card-width);
    position: relative;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--card-radius);
    min-height: var(--card-height);
}

.pile {
    width: var(--card-width);
    height: var(--card-height);
    border: 1px dashed var(--border-color);
    border-radius: var(--card-radius);
    position: relative;
}

.pile.foundation {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    color: var(--text-secondary);
    opacity: 0.3;
}

/* Card Base */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    position: absolute;
    box-shadow: var(--card-shadow);
    padding: 4px;
    cursor: grab;
    user-select: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card.red {
    color: var(--red-suit);
}

.card.black {
    color: var(--black-suit);
}

.card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
    font-weight: 800;
    text-align: center;
    font-variant-numeric: lining-nums tabular-nums;
}

.card-corner.top {
    top: 4px;
    left: 4px;
}

.card-corner.bottom {
    bottom: 4px;
    right: 4px;
    transform: rotate(180deg);
}

.card-corner .rank {
    font-size: 13px;
}

.card-corner .suit-symbol {
    font-size: 10px;
}

.card-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.suit-symbol.center {
    font-size: 24px;
}

.face-letter {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 2px;
}

/* Minimal Back */
.card-back {
    background: var(--card-back-bg);
    border: 1.5px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card-back::after {
    content: "";
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.empty-slot {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: var(--text-secondary);
    opacity: 0.4;
}

.placeholder-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.2;
}

/* Responsive */
@media (min-width: 600px) {
    :root {
        --card-width: 64px;
        --card-height: 90px;
        --card-gap: 12px;
        --tableau-offset: 24px;
    }
}

@media (max-width: 600px) {
    :root {
        --card-width: 12.5vw;
        --card-height: 18vw;
        --card-gap: 1vw;
        --tableau-offset: 14px;
    }

    .card {
        padding: 2px;
    }

    .card-corner.top {
        top: 3px;
        left: 3px;
    }

    .card-corner.bottom {
        display: none;
    }

    .card-corner .rank {
        font-size: 10px;
        line-height: 1;
    }

    .card-corner .suit-symbol {
        font-size: 9px;
        line-height: 1;
    }

    .suit-symbol.center {
        font-size: 18px;
    }

    .face-letter {
        font-size: 16px;
    }

    .stat-select {
        font-size: 11px;
        padding: 1px 4px;
        min-height: 22px;
    }
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.9);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 4000;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
}

.drag-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.9;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

/* Animation Effects */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.animate-shake {
    animation: shake 0.2s ease-in-out 0s 2;
}

.animate-fly-ghost {
    pointer-events: none;
    z-index: 5000;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
