:root {
    --bg: #0b1220;
    --card: #111827;
    --card-light: #1f2937;
    --accent: #22c55e;
    --accent-2: #38bdf8;
    --text: #f8fafc;
    --muted: #94a3b8;
    --glass: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --card-width: clamp(58px, 7vw, 84px);
    --card-height: calc(var(--card-width) * 1.4);
    --card-gap: 18px;
}

body {
    margin: 0;
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top, #1f2937 0%, #0b1220 50%, #020617 100%);
}

.solitaire-container {
    max-width: 980px;
    margin: 20px auto;
    padding: 20px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.9));
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.solitaire-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.solitaire-header h1 {
    margin: 0;
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #fbbf24, #f472b6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.solitaire-icon {
    font-size: 2.2rem;
}

.solitaire-back-btn {
    padding: 10px 18px;
    border-radius: 14px;
    background: rgba(51, 65, 85, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.solitaire-back-btn:hover {
    transform: translateX(-4px);
    background: rgba(51, 65, 85, 0.9);
}

.solitaire-subtitle {
    margin: 6px 0 12px 0;
    color: var(--muted);
}

.solitaire-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
}

.stat-item strong {
    font-size: 1.4rem;
    letter-spacing: normal;
}

.solitaire-board {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.stock-waste,
.foundations {
    display: flex;
    gap: 14px;
    align-items: center;
}

.pile {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 14px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    background: rgba(15, 23, 42, 0.6);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pile.empty::after {
    content: '';
    width: 60%;
    height: 70%;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tableau {
    display: grid;
    grid-template-columns: repeat(7, var(--card-width));
    gap: var(--card-gap);
    overflow-x: auto;
    padding-bottom: 8px;
}

.tableau-column {
    position: relative;
    min-height: calc(var(--card-height) * 2.5);
    border-radius: 16px;
    border: 2px dashed rgba(255, 255, 255, 0.12);
    padding: 6px;
    background: rgba(15, 23, 42, 0.35);
}

.solitaire-board.deal-anim .card {
    animation: dealIn 0.35s ease both;
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 14px;
    position: absolute;
    left: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 10px;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    user-select: none;
    touch-action: none;
}

.card.red {
    color: #ef4444;
}

.card.face-down {
    background: radial-gradient(circle at top left, #60a5fa 0%, #2563eb 45%, #1e3a8a 100%);
    color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.card.face-down .corner,
.card.face-down .suit {
    opacity: 0;
}

.card .corner {
    font-size: 0.95rem;
}

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

.card.from-stock {
    animation: drawFromStock 0.35s ease both;
}

.card .suit {
    font-size: 1.4rem;
    align-self: center;
}

.card.selected,
.card.stack-selected {
    transform: translateY(-6px);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.8), 0 16px 30px rgba(0, 0, 0, 0.4);
}

.drag-container {
    cursor: grabbing !important;
}

.drop-target {
    border-color: rgba(34, 197, 94, 0.8) !important;
    background: rgba(34, 197, 94, 0.15) !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.4), inset 0 0 20px rgba(34, 197, 94, 0.2);
    animation: pulse-drop 0.8s ease-in-out infinite;
}

@keyframes pulse-drop {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.4), inset 0 0 20px rgba(34, 197, 94, 0.2);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.6), inset 0 0 30px rgba(34, 197, 94, 0.3);
    }
}

.solitaire-controls {
    display: flex;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.solitaire-controls button {
    padding: 12px 18px;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.solitaire-controls button.primary {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #0b1220;
}

.solitaire-controls button.ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.solitaire-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.solitaire-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #e2e8f0;
    display: none;
}

.solitaire-message.show {
    display: block;
}

@keyframes dealIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes drawFromStock {
    from {
        opacity: 0;
        transform: translateX(-16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.records-area {
    margin-top: 14px;
}

.records-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.records-card h3 {
    margin: 0;
    font-size: 1.1rem;
}

.records-empty {
    color: var(--muted);
    margin: 0;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
}

.record-highlight {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 0.9rem;
}

.record-highlight strong {
    color: var(--text);
}

.solitaire-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.solitaire-modal.hidden {
    display: none;
}

.solitaire-modal-content {
    background: #0f172a;
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    max-width: min(360px, 90vw);
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-subtitle {
    color: var(--muted);
    margin: 0 0 8px 0;
}

.solitaire-modal-content input {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
}

.solitaire-modal-content button {
    padding: 12px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #fbbf24, #f472b6);
    color: #0b1220;
    font-weight: 800;
    cursor: pointer;
}

@media (max-width: 900px) {
    .tableau {
        gap: 10px;
    }

    .tableau-column {
        min-height: calc(var(--card-height) * 2.2);
    }
}

@media (max-width: 700px) {
    .solitaire-container {
        margin: 16px auto;
        padding: 16px;
    }

    .solitaire-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .solitaire-modal-content {
        padding: 16px;
        max-width: 95vw;
    }

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

/* Mobile responsiveness additions */
@media (max-width: 768px) {
    :root {
        --card-gap: 10px;
    }

    .solitaire-controls button,
    .solitaire-back-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .tableau {
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    :root {
        --card-width: clamp(42px, 10.5vw, 56px);
        --card-gap: 6px;
    }

    .solitaire-container {
        padding: 12px;
    }

    .tableau {
        gap: var(--card-gap);
    }

    .tableau-column {
        padding: 4px;
        min-height: calc(var(--card-height) * 2);
    }
}
