body.poker-page {
    --surface: #f7fbff;
    --card-w: clamp(2.4rem, 6vh, 4.4rem);
    --card-h: calc(var(--card-w) * 1.42);
    --felt-1: #0e5c46;
    --felt-2: #0a4234;
    --table-rim: #8a5a2b;
}

.poker-page [hidden] {
    display: none !important;
}

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

.poker-shell {
    width: min(100%, 1400px);
    margin: 8px auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.8rem 0.9rem 0.9rem;
    border: 1px solid rgba(122, 31, 43, 0.30);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(122, 31, 43, 0.10), rgba(122, 31, 43, 0.04));
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(22px);
    text-align: center;
    min-height: 0;
    overflow: hidden;
}

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

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

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

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

#title {
    margin: 0;
    font-size: clamp(1.3rem, 3.2vh, 1.8rem);
}

.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.8rem;
}

/* ---- Setup ------------------------------------------------------------- */

.match-setup {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem;
    border: 1px solid rgba(122, 31, 43, 0.22);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
}

.setup-label {
    color: var(--muted-color);
    font-size: 0.78rem;
    font-weight: 800;
    text-align: center;
}

.setup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    align-items: center;
}

.setup-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 44px;
    min-width: 88px;
    padding: 0.3rem 0.55rem;
    color: var(--primary-strong);
    border: 2px solid transparent;
    border-radius: 10px;
    background: rgba(122, 31, 43, 0.08);
    font-weight: 700;
    font-size: 0.78rem;
}

.setup-option .chip {
    width: 1.7rem;
}

.setup-option.is-selected {
    border-color: #7a1f2b;
    background: rgba(122, 31, 43, 0.16);
    box-shadow: 0 0 0 3px rgba(122, 31, 43, 0.12);
}

.button-secondary {
    color: var(--primary-strong);
    background: rgba(15, 118, 110, 0.12);
}

/* ---- Table -------------------------------------------------------------- */

.poker-table {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    min-height: 0;
    padding: 0.4rem;
    border-radius: 999px;
    border: 6px solid var(--table-rim);
    background:
        radial-gradient(ellipse at center, rgba(255, 255, 255, 0.06) 0 38%, transparent 39%),
        radial-gradient(ellipse at center, var(--felt-1) 0 60%, var(--felt-2) 100%);
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35), 0 3px 8px rgba(15, 23, 42, 0.25);
    position: relative;
    overflow: hidden;
}

.pot-hud {
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.22rem 0.7rem;
    border-radius: 999px;
    color: #ffe9b3;
    background: rgba(0, 0, 0, 0.30);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.pot-hud .pot-amount {
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    color: #ffd76e;
}

.pot-chip-rack {
    display: flex;
    align-items: center;
}

.pot-chip-rack .chip + .chip {
    margin-left: -0.42rem;
}

/* Seats: a grid ring inside the oval felt */
.seats {
    position: absolute;
    inset: 0.5rem 2.2rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr auto 1fr;
    pointer-events: none;
}

.seat {
    pointer-events: auto;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.15rem;
    padding: 0.2rem;
    min-width: 0;
    min-height: 0;
}

.seat--top-left { grid-area: 1 / 1; align-self: start; }
.seat--top-mid { grid-area: 1 / 2; align-self: start; }
.seat--top-right { grid-area: 1 / 3; align-self: start; }
.seat--mid-left { grid-area: 2 / 1; align-self: center; justify-self: start; }
.seat--mid-right { grid-area: 2 / 3; align-self: center; justify-self: end; }
.seat--bottom-left { grid-area: 3 / 1; align-self: end; }
.seat--bottom-mid { grid-area: 3 / 2; align-self: end; }
.seat--bottom-right { grid-area: 3 / 3; align-self: end; }

.seat.is-turn .seat-name {
    outline: 2px solid #ffd76e;
    outline-offset: 1px;
    background: rgba(0, 0, 0, 0.42);
}

.seat.is-folded .seat-cards,
.seat.is-folded .seat-bank {
    opacity: 0.35;
}

.seat.is-out {
    opacity: 0.45;
    filter: grayscale(0.6);
}

.seat-name {
    max-width: 100%;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    color: #f3efe4;
    background: rgba(0, 0, 0, 0.30);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.seat-bank {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #ffe9b3;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.seat-bank .chip {
    width: 1.05rem;
    font-size: 0.4rem;
}

.seat-hand {
    display: flex;
    gap: 0.18rem;
    min-height: var(--card-h);
    max-width: 100%;
    overflow: visible;
}

.seat--human .seat-hand {
    gap: 0.28rem;
    padding-top: 0.55rem;
    overflow: visible;
}

/* Community cards (holdem) */
.community {
    display: flex;
    justify-content: center;
    gap: 0.28rem;
    min-height: var(--card-h);
    padding: 0.3rem 0.5rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.22);
    box-shadow: inset 0 0 0 1px rgba(255, 231, 158, 0.25);
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    touch-action: pan-x;
    scrollbar-width: thin;
}

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

/* ---- Controls ------------------------------------------------------------ */

.controls,
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: center;
    align-items: center;
}

.controls {
    min-height: 40px;
}

#status {
    color: var(--secondary-strong);
    font-weight: 800;
    font-size: 0.9rem;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    background: rgba(16, 185, 129, 0.14);
    text-align: center;
    width: 100%;
}

#bettingActions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
}

.chip-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 48px;
    min-width: 96px;
    padding: 0.35rem 0.6rem;
}

.chip-action .chip {
    width: 1.8rem;
}

.chip-action:disabled,
#foldBtn:disabled,
#callBtn:disabled,
#allInBtn:disabled,
#confirmDrawBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#allInBtn {
    background: linear-gradient(135deg, #b42332, #7a1f2b);
    color: #fff;
}

.chip-toggle {
    border: 2px solid transparent;
}

.chip-toggle.is-picked {
    border-color: #ffd76e;
    box-shadow: 0 0 0 3px rgba(255, 215, 110, 0.25);
}

/* Card faces intentionally match the visual treatment in solitaire/game.css. */
.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.18rem;
    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.3rem;
    left: 0.32rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 0.9;
    font-size: 0.66rem;
    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.32rem;
    bottom: 0.3rem;
    transform: rotate(180deg);
}

.card-pip-area {
    position: absolute;
    inset: 1.3rem 0.3rem 1.3rem;
}

.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: grid;
    place-items: center;
    width: 1em;
    height: 1em;
    font-size: calc(var(--card-w) * 0.18);
    line-height: 1;
}

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

.suit-mark {
    display: block;
    width: 1em;
    height: 1em;
    overflow: visible;
    fill: currentColor;
}

.card-corner .suit-mark {
    width: 0.95em;
    height: 0.95em;
    margin-top: 0.05em;
}

.face-suit .suit-mark {
    width: 1em;
    height: 1em;
    margin: 0 auto;
}

.card.red,
.card.suit-hearts,
.card.suit-diamonds { color: #c41e3a; }

.card.black,
.card.suit-spades,
.card.suit-clubs { color: #111827; }

.card.is-selectable {
    cursor: pointer;
    touch-action: manipulation;
}

.card.is-picked {
    z-index: 3;
    transform: translateY(-0.45rem);
    border-color: #ffd76e;
    box-shadow:
        0 0 0 3px #ffd76e,
        0 8px 14px rgba(0, 0, 0, 0.38);
}

.card.is-picked::after {
    position: absolute;
    inset: 0;
    z-index: 4;
    border: 2px solid #ffd76e;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 215, 110, 0.22), transparent 42%);
    content: '';
    pointer-events: none;
}

.card.back {
    color: transparent;
    border-color: #4a1220;
    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, #7a1f2b, #4a1220);
    box-shadow:
        inset 0 0 0 3px rgba(255, 255, 255, 0.36),
        inset 0 0 0 5px rgba(74, 18, 32, 0.8),
        0 2px 4px rgba(15, 23, 42, 0.22);
}

/* Face cards share the solitaire treatment (J/Q/K art). */
.card-pip-area.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.14rem;
    border: 1px solid currentColor;
    border-radius: 2px;
    content: '';
    opacity: 0.38;
}

.face-crown {
    position: absolute;
    top: 7%;
    left: 0;
    width: 100%;
    color: var(--face-b, #d8a63c);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: calc(var(--card-w) * 0.15);
    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, #2c79a9) 0 30%, var(--face-b, #d8a63c) 31% 69%, var(--face-a, #2c79a9) 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.14);
    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.16rem;
    bottom: 0.1rem;
    color: var(--face-b, #d8a63c);
    font-size: calc(var(--card-w) * 0.12);
    line-height: 1;
    z-index: 3;
}

/* Chips: same treatment as black-jack */
.chip {
    --chip-color: #168447;
    --chip-edge: #0b5b2f;
    display: inline-grid;
    place-items: center;
    width: 2.05rem;
    aspect-ratio: 1;
    flex: 0 0 auto;
    border: 2px solid var(--chip-edge);
    border-radius: 50%;
    color: #fff;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.26) 0 18%, transparent 19% 50%, rgba(0, 0, 0, 0.10) 51% 58%, transparent 59%),
        repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.78) 0deg 10deg, transparent 10deg 45deg),
        var(--chip-color);
    box-shadow:
        inset 0 0 0 3px var(--chip-color),
        inset 0 0 0 5px rgba(255, 255, 255, 0.62),
        0 2px 4px rgba(15, 23, 42, 0.25);
    font-size: 0.62rem;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

.chip--1 {
    --chip-color: #168447;
    --chip-edge: #075c30;
}

.chip--5 {
    --chip-color: #c8ced7;
    --chip-edge: #717b89;
    color: #17202a;
    text-shadow: 0 1px rgba(255, 255, 255, 0.7);
}

.chip--10 {
    --chip-color: #e6ad18;
    --chip-edge: #9a6700;
    color: #4b3400;
    text-shadow: 0 1px rgba(255, 255, 255, 0.55);
}

.chip--25 {
    --chip-color: #7a1f2b;
    --chip-edge: #4a1220;
}

/* ---- Match-over overlay --------------------------------------------------- */

.matchover-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(10, 25, 20, 0.55);
    backdrop-filter: blur(3px);
    z-index: 10;
}

.matchover-card {
    display: grid;
    gap: 0.6rem;
    justify-items: center;
    padding: 1rem 1.4rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
    text-align: center;
}

.matchover-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-strong);
}

/* ---- Small screens --------------------------------------------------------- */

@media (max-width: 760px) {
    .app-main > .poker-shell {
        min-height: 0;
        padding: 0.6rem;
        border-radius: 22px;
    }

    #playSurface {
        gap: 0.35rem;
    }

    .poker-header {
        align-items: center;
        text-align: center;
        justify-content: center;
        flex-direction: column;
        gap: 0.4rem;
    }

    .status-pill {
        display: none;
    }

    .poker-table {
        border-width: 5px;
        border-radius: 26px;
    }
}

@media (max-width: 520px) {
    body.poker-page {
        --card-w: clamp(2.05rem, 13vw, 2.8rem);
        --card-h: calc(var(--card-w) * 1.42);
    }

    .app-main > .poker-shell {
        gap: 0.35rem;
        padding: 0.4rem;
    }

    .poker-kicker,
    .poker-subtitle {
        display: none;
    }

    .match-setup {
        gap: 0.4rem;
        padding: 0.5rem;
    }

    .setup-option {
        min-height: 42px;
        min-width: 0;
        flex: 1 1 40%;
        padding: 0.25rem 0.4rem;
        font-size: 0.7rem;
    }

    .setup-option .chip {
        width: 1.4rem;
    }

    .pot-hud {
        font-size: 0.68rem;
        padding: 0.18rem 0.55rem;
    }

    .pot-hud .pot-amount {
        font-size: 0.85rem;
    }

    .seat-name {
        font-size: 0.55rem;
        padding: 0.1rem 0.4rem;
    }

    .seat-bank {
        font-size: 0.62rem;
    }

    .seat-bank .chip {
        width: 0.85rem;
        font-size: 0.34rem;
    }

    .chip-action {
        min-width: 0;
        flex: 1 1 30%;
        min-height: 46px;
        font-size: 0.7rem;
        flex-direction: column;
        gap: 0.1rem;
    }

    .chip-action .chip {
        width: 1.5rem;
    }

    #title {
        font-size: 1.25rem;
    }

    .controls,
    .actions {
        gap: 0.3rem;
    }

    #foldBtn,
    #callBtn,
    #allInBtn {
        flex: 1 1 0;
        min-width: 0;
        font-size: 0.85rem;
        min-height: 46px;
    }
}

@media (max-width: 520px) and (max-height: 760px) {
    body.poker-page .app-footer {
        display: none;
    }
}

/* Respect reduced motion: no seat pulse animation is defined, but keep the
   hook so future animations stay compliant. */
@media (prefers-reduced-motion: reduce) {
    .seat,
    .card,
    .chip {
        transition: none !important;
        animation: none !important;
    }
}
