.card-table.spider-table {
    --game-toolbar-bg: #103f49;
    --spider-card-min: 72px;
    --spider-column-gap: clamp(6px, 0.65vw, 14px);
    --spider-step: clamp(30px, 3.2vw, 48px);
    --spider-rank-size: clamp(20px, 2.2vw, 36px);
    --spider-suit-size: clamp(17px, 1.8vw, 28px);
    --spider-pip-size: clamp(10px, 1.2vw, 24px);
    min-width: 0;
    padding: 18px 16px 22px;
    border: 1px solid #ba9d62;
    border-radius: 22px;
    background: radial-gradient(ellipse at 50% 28%, #29878a 0, #175660 46%, #103440 100%);
    box-shadow: 0 18px 44px #15384925, inset 0 0 0 4px #0b35475e, inset 0 0 70px #081f3790;
    color: #fff5dd;
}

.spider-table .spider-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-bottom: 12px;
}

.spider-table .spider-room {
    color: #ffe2a7;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.spider-table .spider-room > span {
    font-size: 24px;
    color: #e8c378;
    margin-right: 4px;
    vertical-align: -1px;
}

.spider-table .spider-room small {
    margin-left: 8px;
    color: #c5ded8;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
}

.spider-table .spider-status {
    margin-left: auto;
    flex: 1 1 160px;
    color: #d0e2da;
    font-size: 14px;
    text-align: right;
}

.spider-table .spider-topbar button,
.spider-table .spider-actions button {
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid #eed59a;
    border-radius: 24px;
    background: linear-gradient(#fff9e7, #e6d1a1);
    box-shadow: inset 0 2px #ffffff9c, 0 4px #08273d66;
    color: #644d2c;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
}

.spider-table .spider-topbar button {
    background: #092f425c;
    border-color: #cce0d54d;
    box-shadow: none;
    color: #d5e7e0;
    font-weight: 650;
}

.spider-table .spider-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-bottom: 6px;
}

.spider-table .spider-actions {
    display: flex;
    flex: 1 1 300px;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.spider-table .spider-actions button.is-on {
    background: linear-gradient(#ffe4a0, #f0b958);
    border-color: #fadb89;
    color: #693c15;
}

.spider-table .spider-actions button:hover,
.spider-table .spider-topbar button:hover {
    filter: brightness(1.08);
}

.spider-table button:focus-visible,
.spider-table .spider-board:focus-visible {
    outline: 3px solid #ffe29f;
    outline-offset: 2px;
}

/* Only the tableau scrolls sideways. Actions, stock and fullscreen stay put. */
.spider-table .spider-board {
    display: block;
    position: relative;
    z-index: 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    padding: 14px 3px 10px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-color: #adcac3 #0d3c49;
}

.spider-table .spider-cols {
    display: grid;
    grid-template-columns: repeat(10, minmax(var(--spider-card-min), 1fr));
    gap: var(--spider-column-gap);
    width: 100%;
    min-width: calc(10 * var(--spider-card-min) + 9 * var(--spider-column-gap));
    min-height: 0;
    align-items: start;
}

.spider-table .spider-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.spider-table .spider-col.is-empty::before {
    content: '';
    display: block;
    width: 100%;
    aspect-ratio: 5 / 7;
}

.spider-table .pcard {
    display: block;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: auto;
    aspect-ratio: 5 / 7;
    padding: 0;
    overflow: hidden;
    border: 1px solid #cbbd98;
    border-radius: 6px;
    color: #17283d;
    background: linear-gradient(125deg, #fff 15%, #fffdf5 65%, #ede7da);
    box-shadow: 1px 2px 4px #001b3d55;
    font-family: Arial, Helvetica, sans-serif;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

/* Normal-flow cards make pile height follow width, rotation and fullscreen.
   Percentage block margins resolve against column width: 140% is card height. */
.spider-table .spider-col .pcard {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    aspect-ratio: 5 / 7;
    cursor: pointer;
}

.spider-table .spider-col .pcard + .pcard {
    margin-top: calc(-140% + var(--spider-step));
}

.spider-table .pcard.red {
    color: #ce273c;
}

.spider-table .pcard > * {
    pointer-events: none;
}

.spider-table .pcard.back {
    border: 2px solid #fdf4dd;
    background: #154baf url("../game/assets/paodekuai/card-back.svg") center / cover;
    color: transparent;
    box-shadow: 0 3px 5px #05172c65;
    cursor: default;
}

.spider-table .pcard.back.is-thick {
    box-shadow: 3px 2px 0 #123e86, 6px 4px 0 #0c326c;
}

.spider-table #spider-deal {
    cursor: pointer;
}

.spider-table #spider-deal:disabled {
    opacity: 0.38;
    cursor: default;
    box-shadow: none;
}

.spider-table .spider-corner {
    position: absolute;
    left: 4%;
    top: 4px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    line-height: 1;
}

/* All ranks share lining/tabular numerals and the same baseline and font size.
   The two-digit rank 10 gets the same 1.2em box, never a smaller font. */
.spider-table .pcard .spider-corner b {
    display: block;
    width: 1.2em;
    height: 1em;
    font: 700 var(--spider-rank-size) / 1 Arial, Helvetica, sans-serif;
    font-variant-numeric: lining-nums tabular-nums;
    font-feature-settings: "lnum" 1, "tnum" 1;
    letter-spacing: -0.025em;
    text-align: center;
}

.spider-table .pcard .spider-corner i {
    display: block;
    align-self: center;
    width: 1em;
    height: 1em;
    font: normal var(--spider-suit-size) / 1 Georgia, "Times New Roman", serif;
    text-align: center;
}

.spider-table .spider-corner-bottom {
    left: auto;
    top: auto;
    right: 4%;
    bottom: 4px;
    transform: rotate(180deg);
}

.spider-table .spider-pips {
    position: absolute;
    inset: 28% 16% 28%;
}

.spider-table .spider-pip {
    position: absolute;
    font: normal var(--spider-pip-size) / 1 Georgia, "Times New Roman", serif;
    transform: translate(-50%, -50%);
}

.spider-table .spider-pip.is-flipped {
    transform: translate(-50%, -50%) rotate(180deg);
}

.spider-table .spider-ace {
    position: absolute;
    left: 50%;
    top: 50%;
    font: normal clamp(36px, 4.5vw, 76px) / 1 Georgia, "Times New Roman", serif;
    transform: translate(-50%, -50%);
}

.spider-table .spider-court {
    position: absolute;
    left: 20%;
    top: 25%;
    width: 60%;
    height: 50%;
    object-fit: contain;
    border: 1px solid #cab77775;
    border-radius: 2px;
    background: #f7ecd8;
}

.spider-table .pcard.is-selected {
    outline: 2px solid #ffd269;
    outline-offset: 0;
    transform: translateY(-10px);
    background: linear-gradient(#fff8db, #fffdf3 55%, #f1e5c2);
    box-shadow: 0 0 11px #ffda7055, 1px 5px 7px #061d39aa;
}

.spider-table .spider-reserve,
.spider-table .spider-stock,
.spider-table .spider-done {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: auto;
    gap: 12px;
}

.spider-table .spider-reserve {
    --spider-rank-size: 14px;
    --spider-suit-size: 12px;
    flex: 0 1 auto;
    min-width: 0;
    gap: 18px;
}

.spider-table .spider-stock span {
    white-space: nowrap;
    font-size: 13px;
}

.spider-table .spider-stock button.pcard,
.spider-table .spider-foundation,
.spider-table .spider-done .pcard {
    flex: 0 0 44px;
    width: 44px;
    height: 62px;
    aspect-ratio: auto;
}

.spider-table .spider-done {
    gap: 0;
}

.spider-table .spider-done .pcard + .pcard {
    margin-top: 0;
    margin-left: -27px;
}

.spider-table .spider-foundation {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #e4c78277;
    border-radius: 6px;
    color: #d7dfb8;
    font-size: 12px;
    letter-spacing: 0.12em;
}

.spider-table .spider-note {
    margin: 8px 0 0;
    color: #c8ddd4;
    font-size: 13px;
    line-height: 1.6;
}

@media (max-width: 600px) {
    .card-table.spider-table {
        padding: 12px 8px 14px;
        border-radius: 14px;
    }

    .spider-table .spider-room small {
        display: none;
    }

    .spider-table .spider-topbar {
        gap: 6px 8px;
    }

    .spider-table .spider-topbar button,
    .spider-table .spider-actions button {
        padding-inline: 10px;
    }

    .spider-table .spider-status {
        order: 2;
        margin-left: 0;
        flex-basis: 100%;
        text-align: left;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    .card-table.spider-table {
        padding: 8px 10px 10px;
    }

    .spider-table .spider-topbar {
        margin-bottom: 4px;
    }

    .spider-table .spider-room small {
        display: none;
    }

    .spider-table .spider-controls {
        gap: 6px 12px;
        margin-bottom: 0;
    }

    .spider-table .spider-actions {
        flex-basis: 300px;
        gap: 6px;
    }

    .spider-table .spider-board {
        padding-top: 12px;
    }

    .spider-table .spider-note {
        margin-top: 4px;
    }
}

/* Only the tableau owns overflow; toolbar, stock and actions stay in view. */
.game-page .card-table.spider-table {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    min-height: 0;
    gap: 6px;
    overflow: hidden;
    padding: 10px 12px;
    --spider-step: clamp(28px, 3.1vw, 42px);
}
.spider-table .spider-topbar, .spider-table .spider-controls { min-width: 0; margin: 0; }
.spider-table .spider-controls { gap: 6px 14px; }
.spider-table .spider-board { min-height: 0; height: 100%; overflow: auto; overscroll-behavior: contain; padding-top: 12px; }
.spider-table .spider-note { margin: 0; font-size: 12px; line-height: 1.4; }
@media (max-width: 600px) {
    .game-page .card-table.spider-table { padding: 8px; gap: 5px; }
    .spider-table .spider-topbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 6px; }
    .spider-table .spider-room { font-size: 15px; }
    .spider-table .spider-room > span { font-size: 18px; }
    .spider-table .spider-status { order: 0; font-size: 12px; text-align: right; }
    .spider-table .spider-topbar button { min-width: 0; padding-inline: 8px; }
    .spider-table .spider-actions { flex-basis: 100%; flex-wrap: nowrap; gap: 5px; }
    .spider-table .spider-actions button { flex: 1 1 0; min-width: 44px; padding-inline: 4px; font-size: 13px; }
    .spider-table .spider-reserve { gap: 12px; }
    .spider-table .spider-stock button.pcard, .spider-table .spider-foundation, .spider-table .spider-done .pcard { width: 44px; height: 52px; }
}
@media (orientation: landscape) and (max-height: 600px) {
    .game-page .card-table.spider-table { padding: 6px 10px; gap: 3px; --spider-step: 28px; --spider-rank-size: 20px; --spider-suit-size: 17px; }
    .spider-table .spider-topbar { gap: 6px; }
    .spider-table .spider-status { font-size: 12px; }
    .spider-table .spider-controls { flex-wrap: nowrap; }
    .spider-table .spider-actions { flex: 1 1 auto; flex-wrap: nowrap; }
    .spider-table .spider-actions button { padding-inline: 10px; }
    .spider-table .spider-stock button.pcard, .spider-table .spider-foundation, .spider-table .spider-done .pcard { width: 44px; height: 44px; }
    .spider-table .spider-reserve { gap: 10px; }
    .spider-table .spider-note { font-size: 11px; }
}
