/* ── Design Tokens ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@600;700;800&display=swap');

:root {
    /* table */
    --table-bg:       #08000f;
    --felt:           radial-gradient(ellipse at 50% 50%, #2c0e37 0%, #15051d 50%, #08000f 100%);
    --felt-highlight:  rgba(168, 85, 247, .08);

    /* cards */
    --card-w:   72px;
    --card-h:   100px;
    --card-r:   7px;
    --card-bg:  #f5f0e6;
    --card-red: #c0392b;
    --card-blk: #1a1a2e;
    --card-back: linear-gradient(135deg, #3b0764 0%, #0f051d 100%);
    --card-back-pattern: repeating-linear-gradient(
        45deg, transparent, transparent 5px,
        rgba(255,255,255,.03) 5px, rgba(255,255,255,.03) 6px
    );

    /* accents */
    --gold:       #a855f7;
    --gold-light: #d8b4fe;
    --gold-dim:   rgba(168, 85, 247, .35);

    /* glass */
    --glass:        rgba(15, 5, 25, .35);
    --glass-border: rgba(168, 85, 247, .15);
    --glass-strong: rgba(15, 5, 25, .6);

    /* text */
    --txt:      #f3ebff;
    --txt-dim:  rgba(243,235,255,.5);
    --txt-gold: var(--gold);

    /* misc */
    --danger:  #e74c3c;
    --success: #2ecc71;
    --shadow:  0 4px 24px rgba(0,0,0,.65);
    --transition: 300ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%; width: 100%;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--txt);
    background: var(--table-bg);
    -webkit-font-smoothing: antialiased;
    /* Allow touch scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

h1, h2, h3 { font-family: 'Playfair Display', serif; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    color: inherit;
}

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100%; position: absolute; inset: 0; }
.screen.active { display: flex; }

/* ── Menu Screen ───────────────────────────────────────────────────────────── */
#menu-screen {
    background: var(--felt);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    text-align: center;
}

#menu-screen .logo {
    font-family: 'Playfair Display', serif;
    font-size: 72px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 4px;
    text-shadow: none;
    filter: drop-shadow(0 2px 12px rgba(168,85,247,.3));
}

#menu-screen .suit-icons {
    font-size: 28px;
    letter-spacing: 12px;
    color: var(--txt-dim);
    margin-top: -12px;
}

#menu-screen .tagline {
    font-size: 15px;
    font-weight: 300;
    color: var(--txt-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.btn-primary {
    padding: 16px 52px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--gold) 0%, #7e22ce 100%);
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(168,85,247,.35), inset 0 1px 0 rgba(255,255,255,.2);
    transition: transform var(--transition), box-shadow var(--transition);
}
.btn-primary:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 32px rgba(168,85,247,.5), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:active { transform: translateY(0) scale(.98); }

/* ── Game Screen ───────────────────────────────────────────────────────────── */
#game-screen {
    background: var(--felt);
    position: relative;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
}

/* subtle noise overlay */
#game-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

#game-screen > * { position: relative; z-index: 1; }

/* ── Table Layout ──────────────────────────────────────────────────────────── */
#table {
    width: 100%; height: 100%;
    display: grid;
    grid-template-areas:
        ".       north   ."
        "west    center  east"
        ".       south   .";
    grid-template-columns: 140px 1fr 140px;
    grid-template-rows: 150px 1fr 190px;
    padding: 10px;
}

/* ── Player Areas ──────────────────────────────────────────────────────────── */
.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.player-area .player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 20px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: box-shadow var(--transition), border-color var(--transition);
}

.player-area.active-turn .player-info {
    border-color: var(--gold);
    box-shadow: 0 0 16px var(--gold-dim), inset 0 0 8px rgba(212,168,67,.08);
}

.player-info .bid-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 11px;
    background: var(--gold-dim);
    color: var(--gold-light);
    font-size: 11px;
    font-weight: 700;
}

.player-info .tricks-badge {
    font-size: 11px;
    color: var(--txt-dim);
}

#player-north { grid-area: north; }
#player-south { grid-area: south; }
#player-west  { grid-area: west; }
#player-east  { grid-area: east; }

/* ── Hand Containers ───────────────────────────────────────────────────────── */
.hand {
    display: flex;
    position: relative;
}

#player-south .hand {
    justify-content: flex-start;
    align-items: flex-end;
    padding: 4px 8px 2px 8px;
    min-height: var(--card-h);
    /* Always-on horizontal swipe scroller */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 6px;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap;
}
#player-south .hand::-webkit-scrollbar { display: none; }


#player-north .hand {
    justify-content: center;
    margin-bottom: 6px;
}

#player-west .hand,
#player-east .hand {
    flex-direction: column;
    align-items: center;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    width: var(--card-w);
    height: var(--card-h);
    border-radius: var(--card-r);
    position: relative;
    flex-shrink: 0;
    transition: transform 300ms cubic-bezier(.4,0,.2,1),
                box-shadow 300ms ease,
                margin 200ms ease;
    will-change: transform;
}

/* face‑up card */
.card.face-up {
    background: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 1px 2px rgba(0,0,0,.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 5px 6px;
    user-select: none;
}

.card.face-up.red  { color: var(--card-red); }
.card.face-up.black { color: var(--card-blk); }

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-weight: 700;
}
.card-corner .rank { font-size: 14px; }
.card-corner .suit { font-size: 11px; margin-top: -1px; }
.card-corner.bottom {
    align-self: flex-end;
    transform: rotate(180deg);
}

.card-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    pointer-events: none;
    opacity: .35;
}

/* face‑down (AI hand) */
.card.face-down {
    background: var(--card-back);
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    overflow: hidden;
}
.card.face-down::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: calc(var(--card-r) - 2px);
    border: 1px solid rgba(255,255,255,.08);
    background: var(--card-back-pattern);
}

/* south hand — no overlap, each card scroll-snaps */
#player-south .card {
    flex-shrink: 0;
    margin-left: 0 !important;
    scroll-snap-align: start;
    cursor: pointer;
}
#player-south .card:first-child { margin-left: 0; }

#player-south .card.face-up:hover {
    transform: translateY(-14px);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    z-index: 10;
}

#player-south .card.face-up.selected {
    transform: translateY(-22px);
    box-shadow: 0 0 0 2px var(--gold), 0 8px 24px rgba(0,0,0,.4);
    z-index: 11;
}

#player-south .card.face-up.invalid {
    opacity: .4;
    cursor: not-allowed;
}
#player-south .card.face-up.invalid:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* AI hand overlap */
#player-north .card { margin-left: -42px; }
#player-north .card:first-child { margin-left: 0; }

#player-west .card,
#player-east .card {
    margin-top: -62px;
    width: 52px;
    height: 72px;
}
#player-west .card:first-child,
#player-east .card:first-child { margin-top: 0; }

/* ── Trick Area ────────────────────────────────────────────────────────────── */
#trick-area {
    grid-area: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trick-card {
    position: absolute;
    transition: transform 350ms cubic-bezier(.34,1.56,.64,1),
                opacity 250ms ease;
}

/* Position offset for each seat */
.trick-card[data-seat="0"] { transform: translateY(42px); }    /* south */
.trick-card[data-seat="1"] { transform: translateX(-52px); }   /* west  */
.trick-card[data-seat="2"] { transform: translateY(-42px); }   /* north */
.trick-card[data-seat="3"] { transform: translateX(52px); }    /* east  */

/* ── Scoreboard ────────────────────────────────────────────────────────────── */
#scoreboard {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 50;
    min-width: 200px;
    padding: 14px 18px;
    border-radius: 14px;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    font-size: 13px;
}

#scoreboard h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--gold);
    margin-bottom: 10px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.score-row .team-name {
    font-weight: 500;
    font-size: 13px;
}

.score-row .team-score {
    font-weight: 700;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    min-width: 50px;
    text-align: right;
}

.score-row .team-bags {
    font-size: 11px;
    color: var(--txt-dim);
    margin-left: 6px;
    min-width: 36px;
}

.score-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 6px 0;
}

#round-indicator {
    font-size: 11px;
    color: var(--txt-dim);
    text-align: center;
    margin-top: 8px;
}

/* ── Bid Overlay ───────────────────────────────────────────────────────────── */
#bid-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
#bid-overlay.active { display: flex; }

.bid-panel {
    background: rgba(10, 5, 15, .95);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 28px 32px;
    text-align: center;
    box-shadow: var(--shadow);
    max-width: 380px;
    width: 90%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.bid-panel h2 {
    font-size: 22px;
    margin-bottom: 4px;
    color: var(--gold);
}

.bid-panel .bid-subtitle {
    font-size: 13px;
    color: var(--txt-dim);
    margin-bottom: 18px;
}

.bid-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.bid-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--txt);
    font-size: 15px;
    font-weight: 600;
    transition: all 150ms ease;
}
.bid-btn:hover {
    background: var(--gold-dim);
    border-color: var(--gold);
    color: var(--gold-light);
    transform: scale(1.08);
}
.bid-btn:active { transform: scale(.95); }

.bid-nil {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    padding: 10px;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: rgba(231, 76, 60, .12);
    border-color: rgba(231, 76, 60, .25);
    color: #e74c3c;
}
.bid-nil:hover {
    background: rgba(231, 76, 60, .25);
    border-color: #e74c3c;
}

/* AI bid bubble */
.ai-bid-bubble {
    position: absolute;
    padding: 6px 14px;
    border-radius: 12px;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    font-size: 13px;
    font-weight: 600;
    color: var(--gold-light);
    white-space: nowrap;
    animation: bidPop 400ms cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
    z-index: 20;
}

@keyframes bidPop {
    0%   { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Round‑End Overlay ─────────────────────────────────────────────────────── */
#round-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
#round-overlay.active { display: flex; }

.round-panel {
    background: rgba(10, 5, 15, .96);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px 36px;
    text-align: center;
    box-shadow: var(--shadow);
    min-width: 320px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: panelIn 400ms cubic-bezier(.34,1.56,.64,1);
}

@keyframes panelIn {
    0%   { transform: scale(.85) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.round-panel h2 {
    color: var(--gold);
    font-size: 22px;
    margin-bottom: 16px;
}

.round-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.round-result-row .round-team { font-weight: 500; }
.round-result-row .round-score {
    font-weight: 700;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}
.round-result-row .round-score.positive { color: var(--success); }
.round-result-row .round-score.negative { color: var(--danger); }

.round-detail {
    font-size: 12px;
    color: var(--txt-dim);
    margin-top: 2px;
}

.btn-continue {
    margin-top: 20px;
    padding: 12px 40px;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--gold) 0%, #7e22ce 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform var(--transition);
}
.btn-continue:hover { transform: scale(1.05); }

/* ── Game Over Overlay ─────────────────────────────────────────────────────── */
#gameover-screen {
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
}

#gameover-screen .result-title {
    font-family: 'Playfair Display', serif;
    font-size: 48px;
    font-weight: 800;
}
#gameover-screen .result-title.win {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#gameover-screen .result-title.lose { color: var(--danger); }

#gameover-screen .final-score {
    font-size: 20px;
    color: var(--txt-dim);
}

/* ── Trick‑Won Indicator ───────────────────────────────────────────────────── */
.trick-won-flash {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #0a0a0a;
    animation: trickFlash 600ms ease forwards;
    pointer-events: none;
    z-index: 30;
}

@keyframes trickFlash {
    0%   { transform: scale(0); opacity: 0; }
    50%  { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: .8; }
}

/* ── Card Play Animation ───────────────────────────────────────────────────── */
.card.animating {
    position: fixed;
    z-index: 200;
    transition: left 350ms cubic-bezier(.4,0,.2,1),
                top 350ms cubic-bezier(.4,0,.2,1),
                transform 350ms cubic-bezier(.4,0,.2,1);
}

/* ── Dealing animation ─────────────────────────────────────────────────────── */
.card.dealing {
    animation: dealCard 350ms cubic-bezier(.4,0,.2,1) forwards;
}

@keyframes dealCard {
    0%   { opacity: 0; transform: scale(.5) translateY(30px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Turn arrow indicator ──────────────────────────────────────────────────── */
.turn-indicator {
    position: absolute;
    font-size: 18px;
    color: var(--gold);
    animation: pulse 1s ease-in-out infinite;
    z-index: 5;
}

@keyframes pulse {
    0%, 100% { opacity: .5; transform: scale(1); }
    50%      { opacity: 1; transform: scale(1.2); }
}

/* ── Status / Toast ────────────────────────────────────────────────────────── */
#status-bar {
    position: absolute;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    border-radius: 20px;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    font-size: 13px;
    font-weight: 500;
    color: var(--txt);
    white-space: nowrap;
    z-index: 40;
    opacity: 0;
    transition: opacity 250ms ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
#status-bar.visible { opacity: 1; }

/* ── Trick History (mini) ──────────────────────────────────────────────────── */
#trick-counter {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 50;
    padding: 8px 14px;
    border-radius: 12px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    font-size: 12px;
    color: var(--txt-dim);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Spades‑Broken Indicator ───────────────────────────────────────────────── */
#spades-broken {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(26, 26, 46, .7);
    border: 1px solid rgba(100,100,160,.2);
    font-size: 12px;
    color: var(--txt-dim);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 300ms ease;
    opacity: 0;
}
#spades-broken.visible { opacity: 1; }

/* ── Tablet (≤900px) ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    :root { --card-w: 58px; --card-h: 82px; }
    #table {
        grid-template-columns: 100px 1fr 100px;
        grid-template-rows: 120px 1fr 160px;
    }
    #player-south .card { margin-left: -22px; }
    #player-west .card, #player-east .card { width: 42px; height: 58px; margin-top: -44px; }
    .bid-grid { grid-template-columns: repeat(7, 1fr); gap: 4px; }
    #scoreboard { min-width: 170px; padding: 10px 14px; font-size: 12px; }
    #menu-screen .logo { font-size: 48px; }
}

/* ── Mobile Portrait — Full Fit ≤600px ────────────────────────────────────── */
@media (max-width: 600px) {

    html, body {
        width: 100dvw;
        height: 100dvh;
        overflow: hidden !important;
        position: fixed;
        top: 0; left: 0;
    }

    .screen {
        position: fixed !important;
        inset: 0 !important;
        width: 100dvw !important;
        height: 100dvh !important;
        overflow: hidden !important;
    }

    #top-web3-bar {
        height: 36px !important;
        padding: 0 8px !important;
        gap: 4px !important;
    }
    #ogai-balance-pill { padding: 2px 6px !important; font-size: 9px !important; gap: 3px !important; }
    #ogai-balance-val { font-size: 9px !important; }
    #btn-connect-spades-wallet { font-size: 8px !important; padding: 3px 6px !important; border-radius: 8px !important; }
    #local-llm-banner { display: none !important; }
    #multiplayer-room-badge { font-size: 8px !important; padding: 2px 6px !important; top: 40px !important; left: 6px !important; }

    #menu-screen {
        padding-top: 36px !important;
        gap: 10px !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #menu-screen .logo        { font-size: 32px !important; letter-spacing: 2px; }
    #menu-screen .logo-sub    { font-size: 10px !important; }
    #menu-screen .suit-icons  { font-size: 16px !important; letter-spacing: 6px; margin-top: -6px; }
    #menu-screen .tagline     { font-size: 10px !important; }
    .btn-primary              { padding: 12px 22px !important; font-size: 12px !important; }

    #game-screen {
        top: 36px !important;
        height: calc(100dvh - 36px) !important;
        overflow: hidden !important;
        touch-action: manipulation;
    }

    :root {
        --card-w: min(38px, 9vw);
        --card-h: min(55px, 13vw);
        --card-r: 4px;
    }

    #table {
        width: 100%;
        height: 100%;
        grid-template-columns: min(48px, 11.5vw) 1fr min(48px, 11.5vw);
        grid-template-rows: 15dvh 1fr 20dvh;
        padding: 2px;
        gap: 0;
    }

    #player-south .card   { margin-left: -16px; }
    #player-south .card:first-child { margin-left: 0; }
    #player-north .card   { margin-left: -26px; }
    #player-north .card:first-child { margin-left: 0; }
    #player-west .card, #player-east .card { width: min(26px, 6.5vw); height: min(38px, 9vw); margin-top: -28px; }
    #player-west .card:first-child, #player-east .card:first-child { margin-top: 0; }

    .card.face-up      { padding: 2px 3px; }
    .card-corner .rank { font-size: 8px; }
    .card-corner .suit { font-size: 7px; margin-top: 0; }
    .card-center       { font-size: 13px; opacity: 0.2; }

    .trick-card[data-seat=0] { transform: translateY(22px); }
    .trick-card[data-seat=1] { transform: translateX(-28px); }
    .trick-card[data-seat=2] { transform: translateY(-22px); }
    .trick-card[data-seat=3] { transform: translateX(28px); }

    #scoreboard {
        top: 4px; right: 4px; left: auto; bottom: auto;
        min-width: 0; padding: 4px 7px; font-size: 9px; border-radius: 10px;
    }
    #scoreboard h3           { font-size: 8px; margin-bottom: 3px; }
    .score-row               { padding: 1px 0; }
    .score-row .team-name    { font-size: 8px; }
    .score-row .team-score   { font-size: 10px; min-width: 24px; }
    .score-row .team-bags    { font-size: 7px; margin-left: 2px; }
    #round-indicator         { font-size: 7px; margin-top: 3px; }

    #trick-counter {
        top: 4px; left: 4px;
        font-size: 8px; padding: 3px 7px; border-radius: 8px;
    }
    #spades-broken { top: 4px; font-size: 8px; padding: 2px 8px; }

    #status-bar { bottom: calc(var(--card-h) + 24px); font-size: 10px; padding: 4px 12px; }

    .player-area .player-info { font-size: 8px; padding: 2px 5px; border-radius: 10px; }
    .player-info .bid-badge   { min-width: 13px; height: 13px; font-size: 7px; }

    #bid-overlay { touch-action: manipulation; }
    .bid-panel { padding: 12px 10px; max-width: 96vw; width: 96vw; border-radius: 14px; }
    .bid-panel h2         { font-size: 15px; margin-bottom: 2px; }
    .bid-panel .bid-subtitle { font-size: 10px; margin-bottom: 10px; }
    .bid-grid  { grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 8px; }
    .bid-btn   { font-size: 11px; border-radius: 7px; }
    .bid-nil   { font-size: 9px; padding: 6px; }

    .round-panel { padding: 14px 12px; min-width: 0; width: 92vw; border-radius: 14px; }
    .round-panel h2           { font-size: 16px; margin-bottom: 8px; }
    .round-result-row .round-score { font-size: 14px; }
    .btn-continue { padding: 8px 24px; font-size: 11px; margin-top: 12px; }

    #gameover-screen { position: fixed !important; overflow-y: auto; padding-top: 36px; }
    #gameover-screen .result-title { font-size: 32px; }
    #gameover-screen .final-score  { font-size: 14px; }

    #bid-overlay   { position: fixed !important; }
    #round-overlay { position: fixed !important; }

    /* ── Horizontal swipe scroller for south hand ── */
    #player-south {
        grid-area: south;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-end;
        overflow: hidden;
        position: relative;
    }

    #player-south .player-info {
        align-self: center;
        margin-bottom: 2px;
        flex-shrink: 0;
    }

    /* Swipe hint label */
    #player-south::before {
        content: '← SWIPE YOUR HAND →';
        display: block;
        text-align: center;
        font-size: 7px;
        letter-spacing: 1px;
        color: rgba(168,85,247,0.5);
        padding-bottom: 2px;
        flex-shrink: 0;
        order: -1;
    }

    /* The hand becomes a horizontal scroll track */
    #player-south .hand {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        padding: 4px 8px 2px 8px;
        gap: 6px;
        min-height: var(--card-h);
        width: 100%;
        /* hide scrollbar but keep scrolling */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    #player-south .hand::-webkit-scrollbar { display: none; }

    /* Each south card — full size, no overlap, scroll-snap target */
    #player-south .card {
        flex-shrink: 0 !important;
        margin-left: 0 !important;
        scroll-snap-align: start;
        width: var(--card-w) !important;
        height: var(--card-h) !important;
        cursor: pointer;
        transition: transform 200ms ease, box-shadow 200ms ease;
    }

    #player-south .card.face-up:hover,
    #player-south .card.face-up:active {
        transform: translateY(-10px) !important;
        box-shadow: 0 6px 20px rgba(168,85,247,0.4);
    }

    #player-south .card.face-up.selected {
        transform: translateY(-14px) !important;
        box-shadow: 0 0 0 2px #a855f7, 0 6px 20px rgba(168,85,247,0.5);
    }

    #player-south .card.face-up.invalid {
        opacity: 0.4;
        transform: none !important;
    }
}
