body.solitaire-page {
    --surface: #f7fbff;
    --card-w: clamp(3.55rem, 7.8vh, 4.85rem);
    --card-h: calc(var(--card-w) * 1.4);
    --cascade-peek: clamp(0.9rem, 1.65vh, 1.18rem);
}

.app-main > .solitaire-shell {
    display: grid;
    align-items: stretch;
    align-content: stretch;
    width: min(100%, 1180px);
    height: 100%;
    min-height: 0;
    justify-content: stretch;
}

.solitaire-shell {
    width: min(100%, 1180px);
    margin: 8px auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0.55rem;
    padding: 0.7rem 0.85rem 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(22px);
    text-align: center;
    min-height: 0;
    overflow: hidden;
}

.solitaire-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    text-align: left;
}

.solitaire-kicker {
    margin: 0 0 0.1rem;
    color: var(--highlight-color);
    font-weight: 800;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.solitaire-subtitle {
    margin: 0;
    color: var(--muted-color);
    font-size: 0.88rem;
}

#title {
    margin: 0;
    font-size: clamp(1.25rem, 2.2vh, 1.7rem);
}

.status-pill {
    flex: 0 0 auto;
    padding: 0.55rem 0.75rem;
    border-radius: 999px;
    color: var(--primary-strong);
    background: rgba(37, 99, 235, 0.09);
    font-weight: 800;
    font-size: 0.82rem;
}

#narrowNotice {
    display: grid;
    place-items: center;
    min-height: 60%;
    padding: 2rem;
    text-align: center;
}

#narrowNotice p {
    margin: 0 0 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
    max-width: min(100%, 420px);
}

#narrowNotice a {
    display: inline-block;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-strong));
    text-decoration: none;
    font-weight: 800;
}

#playSurface {
    display: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 0.5rem;
    text-align: left;
    grid-template-rows: auto auto minmax(0, 1fr);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-start;
    align-items: center;
}

.controls select,
.controls button {
    flex: 0 0 auto;
    font-weight: 800;
}

#status {
    color: var(--secondary-strong);
    font-weight: 800;
    font-size: 0.95rem;
    margin-left: auto;
}

#table {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.45rem;
    align-items: start;
    min-height: 0;
    overflow: auto;
}

#stock {
    grid-column: 1 / 2;
    grid-row: 1;
}

#waste {
    grid-column: 2 / 3;
    grid-row: 1;
}

#foundations {
    grid-column: 4 / 8;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
    justify-items: center;
}

#tableau {
    grid-column: 1 / 8;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.45rem;
    align-items: start;
    justify-items: center;
    min-height: 0;
}

.pile {
    position: relative;
    justify-self: center;
    width: var(--card-w);
    min-height: var(--card-h);
    border-radius: 7px;
    border: 1.5px dashed rgba(148, 163, 184, 0.42);
    background: rgba(37, 99, 235, 0.04);
}

.tableau-col:not(:empty) {
    border-color: transparent;
    background: transparent;
}

.pile:empty {
    min-height: var(--card-h);
}

#foundations .pile,
#stock,
#waste {
    min-height: var(--card-h);
}

.tableau-col {
    aspect-ratio: unset;
    min-height: var(--card-h);
    align-self: start;
    overflow: visible;
}

.card {
    position: relative;
    display: grid;
    place-items: center;
    width: var(--card-w);
    height: var(--card-h);
    margin-inline: auto;
    overflow: hidden;
    isolation: isolate;
    z-index: 0;
    border: 1px solid #b8b4ad;
    border-radius: 8px;
    background-color: #fffefb;
    background: linear-gradient(145deg, #fffefb 0%, #f4f0e8 100%);
    opacity: 1;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.95),
        0 2px 4px rgba(15, 23, 42, 0.18),
        0 1px 1px rgba(15, 23, 42, 0.12);
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    user-select: none;
    touch-action: none;
}

.card::before {
    position: absolute;
    inset: 0.2rem;
    z-index: 0;
    border: 1px solid rgba(132, 126, 115, 0.42);
    border-radius: 5px;
    content: '';
    pointer-events: none;
}

.card > * {
    z-index: 1;
}

.card-corner {
    position: absolute;
    top: 0.34rem;
    left: 0.35rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 0.9;
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    z-index: 3;
}

.card-corner small {
    font-size: 0.82em;
    line-height: 0.9;
}

.card-corner--br {
    top: auto;
    left: auto;
    right: 0.35rem;
    bottom: 0.34rem;
    transform: rotate(180deg);
}

.card-pip-area {
    position: absolute;
    inset: 1.42rem 0.35rem 1.42rem;
}

.number-art {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    align-items: center;
    justify-items: center;
}

.card-pip {
    display: block;
    font-size: calc(var(--card-w) * 0.17);
    line-height: 1;
}

.rank-1 .card-pip {
    font-size: calc(var(--card-w) * 0.38);
}

.face-card-area {
    display: grid;
    place-items: center;
}

.face-art {
    position: relative;
    width: 76%;
    height: 90%;
    overflow: hidden;
    border: 1px solid currentColor;
    border-radius: 4px;
    background:
        linear-gradient(135deg, transparent 47%, rgba(255, 255, 255, 0.46) 48% 52%, transparent 53%),
        linear-gradient(45deg, transparent 47%, rgba(255, 255, 255, 0.32) 48% 52%, transparent 53%),
        #f6e9c8;
    background-color: #f6e9c8;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.78);
}

.face-art::before {
    position: absolute;
    inset: 50% 0 auto;
    border-top: 1px solid currentColor;
    content: '';
    opacity: 0.28;
}

.face-art::after {
    position: absolute;
    inset: 0.16rem;
    border: 1px solid currentColor;
    border-radius: 2px;
    content: '';
    opacity: 0.38;
}

.card.rank-11 { --face-a: #2c79a9; --face-b: #d8a63c; }
.card.rank-12 { --face-a: #b63b5c; --face-b: #e0ae38; }
.card.rank-13 { --face-a: #55418d; --face-b: #d49b32; }

.face-crown {
    position: absolute;
    top: 7%;
    left: 0;
    width: 100%;
    color: var(--face-b);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: calc(var(--card-w) * 0.16);
    line-height: 1;
    text-align: center;
    z-index: 1;
}

.face-j .face-crown::before { content: '♞'; }
.face-q .face-crown::before { content: '♛'; }
.face-k .face-crown::before { content: '♚'; }

.face-head {
    position: absolute;
    top: 24%;
    left: 36%;
    width: 28%;
    aspect-ratio: 1;
    border: 1px solid rgba(91, 51, 35, 0.45);
    border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, #ffe6c6 0 25%, #e4a77f 27% 100%);
    z-index: 1;
}

.face-body {
    position: absolute;
    bottom: 6%;
    left: 16%;
    width: 68%;
    height: 48%;
    border: 1px solid rgba(40, 32, 38, 0.42);
    border-radius: 52% 52% 8% 8%;
    background: linear-gradient(90deg, var(--face-a) 0 30%, var(--face-b) 31% 69%, var(--face-a) 70% 100%);
    z-index: 1;
}

.face-body::before {
    position: absolute;
    top: -1px;
    left: 35%;
    width: 30%;
    height: 38%;
    border-right: 1px solid rgba(40, 32, 38, 0.42);
    border-bottom: 1px solid rgba(40, 32, 38, 0.42);
    background: #fff8e8;
    content: '';
    transform: rotate(45deg);
}

.face-suit {
    position: absolute;
    top: 54%;
    left: 0;
    width: 100%;
    color: rgba(255, 255, 255, 0.88);
    font-size: calc(var(--card-w) * 0.15);
    line-height: 1;
    text-align: center;
    text-shadow: 0 1px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.face-initial {
    position: absolute;
    right: 0.18rem;
    bottom: 0.12rem;
    color: var(--face-b);
    font-size: calc(var(--card-w) * 0.12);
    line-height: 1;
    z-index: 3;
}

.card.red {
    color: #b42332;
}

.card.black {
    color: #18212b;
}

.card.back {
    color: transparent;
    border-color: #173b63;
    background:
        radial-gradient(circle at center, transparent 0 35%, rgba(255, 255, 255, 0.16) 36% 39%, transparent 40%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 7px),
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 7px),
        linear-gradient(135deg, #174d7c, #0d3158);
    box-shadow:
        inset 0 0 0 3px rgba(255, 255, 255, 0.36),
        inset 0 0 0 5px rgba(13, 49, 88, 0.8),
        0 2px 4px rgba(15, 23, 42, 0.22);
}

.tableau-col .card {
    margin-top: calc(var(--cascade-peek) - var(--card-h));
}

.tableau-col .card:first-child {
    margin-top: 0;
}

button.pile {
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

button.pile:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

#waste {
    display: flex;
    align-items: flex-start;
}

#waste .card {
    flex: 0 0 var(--card-w);
}

#waste .card + .card {
    margin-left: calc(var(--card-w) * -0.62);
}

.card.selected {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.card.dragging {
    opacity: 0.35;
}

.drag-ghost {
    position: absolute;
    z-index: 1400;
    pointer-events: none;
    filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.28));
}

.drag-ghost .card {
    margin-top: calc(var(--cascade-peek) - var(--card-h));
}

.drag-ghost .card:first-child {
    margin-top: 0;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.45);
    transition: opacity 0.25s ease;
    backdrop-filter: blur(12px);
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.congratulations {
    max-width: min(86vw, 420px);
    padding: 1.35rem;
    border-radius: 28px;
    text-align: center;
    background: #ffffff;
    box-shadow: var(--shadow-card);
    transform: rotate(-2deg);
}

.congratulations h2 {
    color: var(--primary-strong);
    margin-top: 0;
}

@media (min-width: 900px) {
    #playSurface {
        display: grid;
    }

    #narrowNotice {
        display: none;
    }
}

@media (max-width: 760px) {
    .solitaire-shell {
        min-height: 0;
        padding: 0.65rem;
        border-radius: 22px;
    }

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

    .status-pill,
    .solitaire-subtitle {
        display: none;
    }

    .controls {
        gap: 0.4rem;
        justify-content: center;
    }

    #status {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 520px) {
    .solitaire-shell {
        gap: 0.45rem;
        padding: 0.45rem;
    }

    .solitaire-kicker {
        display: none;
    }

    #title {
        font-size: 1.35rem;
    }
}
