/* Full-screen game table — no page scroll */
html.game-root,
html.game-root body {
    height: 100%;
    overflow: hidden;
    margin: 0;
}

.page-game {
    --pile-w: clamp(78px, 10vmin, 118px);
    --pile-h: calc(var(--pile-w) * 1.39);
    --hand-w: clamp(72px, 8.5vw, 108px);
    --hand-h: calc(var(--hand-w) * 1.39);
    --zone-w: clamp(56px, 7vmin, 84px);
    --zone-h: calc(var(--zone-w) * 1.39);
    --opp-card-w: clamp(48px, 5.5vmin, 70px);
    --opp-card-h: calc(var(--opp-card-w) * 1.39);

    height: 100vh;
    max-width: none;
    margin: 0;
    padding: 6px 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page-game .game-header {
    flex: 0 0 auto;
    margin-bottom: 4px;
    padding-bottom: 4px;
}

.page-game .room-meta #rank_label {
    color: #ffd36b;
}

.game-header h1 {
    font-size: 1.15rem;
    margin: 0;
}

.page-game .room-meta {
    font-size: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 0;
}

.page-game .btn-rules {
    padding: 4px 10px;
    font-size: 0.75rem;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.guide-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 56px 12px 12px;
    background: rgba(4, 12, 22, 0.45);
}

.guide-overlay.hidden {
    display: none;
}

.guide-sheet {
    width: min(420px, calc(100vw - 24px));
    max-height: min(78vh, 560px);
    overflow: auto;
    background: linear-gradient(180deg, rgba(10, 28, 46, 0.98) 0%, rgba(6, 16, 28, 0.98) 100%);
    border: 1px solid rgba(255, 211, 107, 0.4);
    border-radius: 10px;
    padding: 16px 16px 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.guide-sheet h3 {
    margin: 0 0 6px;
    color: #ffd36b;
    font-size: 1.05rem;
}

.guide-note {
    margin: 0 0 12px;
    color: #9ec4dc;
    font-size: 0.78rem;
    line-height: 1.4;
}

.guide-matchups {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guide-matchups li {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 211, 107, 0.12);
    border-radius: 8px;
}

.guide-matchups img {
    width: 44px;
    height: calc(44px * 1.39);
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #3a7ab8;
}

.guide-matchup-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.guide-matchup-copy strong {
    color: #e8f0f8;
    font-size: 0.82rem;
}

.guide-matchup-copy span {
    color: #7dcea0;
    font-size: 0.75rem;
    line-height: 1.3;
}

.guide-any {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(44px * 1.39);
    text-align: center;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #ffd36b;
    border: 2px dashed rgba(255, 211, 107, 0.35);
    border-radius: 5px;
    background: rgba(255, 211, 107, 0.08);
}

.guide-sheet [data-guide-close] {
    width: 100%;
    margin: 0;
}

.game-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.action-bar {
    flex: 0 0 auto;
    background: rgba(8, 24, 40, 0.95);
    border: 1px solid rgba(255, 211, 107, 0.25);
    border-radius: 8px;
    padding: 6px 10px;
}

.turn-steps {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.step-pill {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 999px;
    background: #1a3050;
    color: #8ab0cc;
    border: 1px solid #2a4560;
}

.step-pill.active {
    background: rgba(255, 211, 107, 0.2);
    color: #ffd36b;
    border-color: #ffd36b;
    font-weight: 700;
}

.step-pill.done {
    background: rgba(26, 107, 74, 0.35);
    color: #98ffd0;
    border-color: #1a6b4a;
}

.status-chip {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: auto;
}

.status-chip.frozen {
    background: #4a2020;
    color: #ffb0b0;
}

.status-chip.open {
    background: #1a4a30;
    color: #a0ffc0;
}

.status-chip.closed {
    background: #3a3a20;
    color: #ffe0a0;
}

.opponents-label {
    flex: 0 0 auto;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6a8898;
    margin-bottom: 2px;
}

.opponents-strip {
    flex: 0 1 auto;
    display: flex;
    gap: 10px;
    overflow: hidden;
    min-height: 0;
    max-height: min(28vh, 220px);
}

.opp-card {
    flex: 1;
    min-width: 0;
    background: rgba(6, 18, 32, 0.92);
    border: 1px solid #1a3550;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    overflow: hidden;
}

.opp-card.active {
    border-color: #ffd36b;
    box-shadow: 0 0 0 1px rgba(255, 211, 107, 0.25);
}

.opp-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
}

.opp-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    min-width: 0;
}

/* Voyage status badge — rivals + local player header */
.player-status {
    display: inline-block;
    flex: 0 0 auto;
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.35;
    border: 1px solid transparent;
    vertical-align: middle;
}

.player-status.status-port {
    background: rgba(70, 100, 130, 0.5);
    color: #b8d4e8;
    border-color: rgba(120, 160, 190, 0.4);
}

.player-status.status-sea {
    background: rgba(16, 110, 95, 0.5);
    color: #7dffc8;
    border-color: rgba(50, 180, 150, 0.45);
}

.player-status.status-danger {
    background: rgba(150, 40, 28, 0.6);
    color: #ffb090;
    border-color: rgba(230, 100, 50, 0.5);
}

.player-status.status-returned {
    background: rgba(55, 75, 110, 0.45);
    color: #c8d8f0;
    border-color: rgba(110, 140, 180, 0.4);
}

.page-game .room-meta .player-status {
    margin: 0 2px 0 4px;
}

.opp-score {
    color: #ffd36b;
    font-size: 0.78rem;
    flex: 0 0 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Single horizontal row: Voyage then Hold — shrink to fit, never two card rows */
.opp-board {
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: flex-end;
    justify-content: flex-start;
    overflow: hidden;
    box-sizing: border-box;
}

.opp-board-sep {
    flex: 0 0 2px;
    align-self: stretch;
    width: 2px;
    min-width: 2px;
    margin: 2px 1px;
    border-radius: 1px;
    background: rgba(110, 140, 170, 0.45);
}

.opp-row-label {
    display: none;
}

/*
 * Rival board cards: equal flex share — never fan, never stack.
 * Global .card { width:100px } + flex-shrink:0 was keeping cards full-size so
 * they overflowed a narrow .opp-card and looked overlapped. Share the row
 * instead; --fit-card-w from JS is an optional cap when measurement works.
 */
.opp-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: flex-end;
    justify-content: flex-start;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
}

.opp-empty {
    font-size: 0.72rem;
    color: #5a7890;
    font-style: italic;
}

.page-game .opp-board > .card.opp-mini,
.page-game .opp-row > .card.opp-mini,
.page-game .card.opp-mini {
    /* Share remaining width equally (hard anti-overlap). */
    flex: 1 1 0 !important;
    flex-shrink: 1 !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: var(--fit-card-w, var(--opp-card-w)) !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    float: none !important;
    transform: none !important;
    z-index: auto !important;
    box-sizing: border-box;
}

.page-game .opp-board > .card.opp-mini:hover,
.page-game .opp-board > .card.opp-mini:hover:not(.unplayable),
.page-game .opp-row > .card.opp-mini:hover,
.page-game .opp-row > .card.opp-mini:hover:not(.unplayable),
.page-game .card.opp-mini:hover,
.page-game .card.opp-mini:hover:not(.unplayable) {
    transform: none !important;
    z-index: auto !important;
    box-shadow: none !important;
}

.page-game .opp-board > .card.opp-mini img,
.page-game .opp-row > .card.opp-mini img,
.page-game .card.opp-mini img {
    /* Fill the flex slot — beat global .card img { width:100px; height:140px }. */
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    aspect-ratio: 5 / 7;
    border-radius: 5px;
    border: 2px solid #3a7ab8;
    object-fit: cover;
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    float: none !important;
    transform: none !important;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ── Main table: side zones + compact center piles ── */
.game-table {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(140px, 1.05fr) minmax(260px, 0.95fr) minmax(140px, 1.05fr);
    gap: 8px;
    align-items: stretch;
}

.table-center {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(20, 50, 80, 0.45) 0%, rgba(6, 18, 32, 0.2) 70%);
    border: 1px solid rgba(255, 211, 107, 0.2);
    border-radius: 12px;
    padding: 6px 8px;
    min-height: 0;
}

/* ── Draw reveal (center flip) ── */
.draw-reveal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(4, 14, 28, 0.72) 0%, rgba(4, 14, 28, 0.35) 55%, transparent 78%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.draw-reveal.hidden {
    display: none;
}

.draw-reveal.is-visible {
    opacity: 1;
}

.draw-reveal-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transform: translateY(8px) scale(0.92);
    transition: transform 0.25s ease;
}

.draw-reveal.is-visible .draw-reveal-stage {
    transform: translateY(0) scale(1);
}

.draw-reveal-flip {
    position: relative;
    width: calc(var(--pile-w) * 1.15);
    height: calc(var(--pile-h) * 1.15);
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0.05, 0.2, 1);
}

.draw-reveal.is-flipped .draw-reveal-flip {
    transform: rotateY(180deg);
}

.draw-reveal-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}

.draw-reveal-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    border: 3px solid #3a7ab8;
}

.draw-reveal-front {
    transform: rotateY(180deg);
}

.draw-reveal-front img {
    border-color: #ffd36b;
}

.draw-reveal-label {
    min-height: 1.2em;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(8, 24, 40, 0.92);
    border: 1px solid rgba(255, 211, 107, 0.45);
    color: #ffd36b;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease 0.35s, transform 0.25s ease 0.35s;
    text-align: center;
    max-width: min(260px, 70vw);
}

.draw-reveal.is-flipped .draw-reveal-label {
    opacity: 1;
    transform: translateY(0);
}

.draw-reveal.is-flying .draw-reveal-stage {
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.7, 1), opacity 0.45s ease;
    opacity: 0;
    transform: translateY(42vh) scale(0.35);
}

.draw-reveal.is-flying .draw-reveal-label {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.page-game .card.hand-card.just-drawn img {
    border-color: #ffd36b;
    box-shadow:
        0 0 0 2px rgba(255, 211, 107, 0.35),
        0 0 22px rgba(255, 211, 107, 0.55);
    animation: justDrawnPulse 0.9s ease 2;
}

@keyframes justDrawnPulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-12px) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
    .draw-reveal-flip,
    .draw-reveal-stage,
    .draw-reveal-label {
        transition: none !important;
    }

    .draw-reveal.is-flipped .draw-reveal-flip {
        transform: none;
    }

    .draw-reveal-front {
        transform: none;
    }

    .draw-reveal:not(.is-flipped) .draw-reveal-front {
        visibility: hidden;
    }

    .draw-reveal.is-flipped .draw-reveal-back {
        visibility: hidden;
    }

    .page-game .card.hand-card.just-drawn img {
        animation: none;
    }
}

.center-piles {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(12px, 2.5vw, 28px);
    width: 100%;
}

.center-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    align-self: center;
    min-width: min(160px, 28vw);
    margin-bottom: calc(var(--pile-h) * 0.08);
}

.turn-take-cluster {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: min(180px, 100%);
}

.turn-take-cluster #take_btn {
    width: 100%;
    margin: 0;
}

.pile-wrap .pile-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #9ec4dc;
    margin-bottom: 10px;
}

.page-game .pile-stack .card-pile,
.page-game .pile-waste .card-pile,
.page-game .pile-waste .card-pile.waste-pile {
    position: relative;
    width: var(--pile-w);
    height: var(--pile-h);
    margin: 0 auto;
}

.page-game .pile-stack .card-pile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 2px solid #3a7ab8;
    object-fit: cover;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.page-game .pile-stack .pile-count {
    bottom: -8px;
    right: -8px;
    min-width: 28px;
    height: 28px;
    line-height: 28px;
    font-size: 0.85rem;
}

.page-game .card.pile-card {
    width: var(--pile-w);
    height: var(--pile-h);
}

.page-game .card.pile-card img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 2px solid #5a7088;
    object-fit: cover;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.pile-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: 2px dashed rgba(122, 158, 184, 0.35);
    border-radius: 10px;
    color: #5a7890;
    font-size: 0.85rem;
    font-style: italic;
    background: rgba(0, 0, 0, 0.15);
}

.turn-indicator.turn-center {
    align-self: stretch;
    font-size: 0.8rem;
    padding: 8px 10px;
    max-width: none;
    width: 100%;
    line-height: 1.3;
    margin-bottom: 0;
    text-align: center;
    box-sizing: border-box;
}

.zone {
    background: rgba(6, 18, 32, 0.85);
    border: 1px solid #2a4560;
    border-radius: 8px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.zone-side {
    align-self: stretch;
    max-height: none;
    width: 100%;
}

.zone-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #7a9eb8;
    margin-bottom: 6px;
    flex: 0 0 auto;
}

.zone-cards {
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    align-items: flex-end;
    align-content: flex-start;
    overflow: hidden;
}

.zone-empty {
    font-size: 0.72rem;
    color: #5a7890;
    font-style: italic;
    line-height: 1.35;
}

.page-game .card.zone-card {
    width: var(--fit-card-w, var(--zone-w));
    max-width: 100%;
    flex: 0 0 auto;
    flex-shrink: 0;
    margin: 0;
    position: relative;
}

.page-game .card.zone-card:hover,
.page-game .card.zone-card:hover:not(.unplayable) {
    transform: none;
    z-index: auto;
}

.page-game .card.zone-card img {
    width: var(--fit-card-w, var(--zone-w));
    height: var(--fit-card-h, var(--zone-h));
    max-width: 100%;
    border-radius: 7px;
    border: 2px solid #2f6aa8;
    object-fit: cover;
    display: block;
    margin: 0;
}

/* ── Hand — cards shrink to fit, never scroll ── */
.hand-bar {
    flex: 0 0 auto;
    background: rgba(8, 20, 36, 0.95);
    border: 1px solid rgba(255, 211, 107, 0.25);
    border-radius: 10px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 0;
}

.hand-bar .zone-title {
    flex: 0 0 64px;
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.35;
}

#hand {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: clamp(4px, 0.8vw, 8px);
    flex-wrap: nowrap;
    overflow: hidden;
    justify-content: center;
    align-items: flex-end;
    padding: 2px 0;
}

.page-game .card.hand-card {
    width: var(--fit-card-w, var(--hand-w));
    flex: 0 0 auto;
    transition: transform 0.15s ease;
}

.page-game .card.hand-card:hover:not(.unplayable) {
    transform: translateY(-8px) scale(1.03);
    z-index: 2;
}

.page-game .card.hand-card img {
    width: var(--fit-card-w, var(--hand-w));
    height: var(--fit-card-h, var(--hand-h));
    border-radius: 8px;
    border: 2px solid #3a7ab8;
    object-fit: cover;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
    display: block;
}

.page-game .card.hand-card.highlight-sail img {
    border-color: #ffd36b;
    box-shadow: 0 0 18px rgba(255, 211, 107, 0.55);
}

.page-game .card.hand-card.idle-playable img {
    border-color: #ffd36b;
    box-shadow:
        0 0 0 2px rgba(255, 211, 107, 0.4),
        0 0 22px rgba(255, 211, 107, 0.65);
    animation: idlePlayableFlash 1s ease-in-out infinite;
}

@keyframes idlePlayableFlash {
    0%, 100% {
        filter: brightness(1);
        box-shadow:
            0 0 0 2px rgba(255, 211, 107, 0.35),
            0 0 14px rgba(255, 211, 107, 0.4);
        transform: translateY(0) scale(1);
    }
    50% {
        filter: brightness(1.12);
        box-shadow:
            0 0 0 3px rgba(255, 211, 107, 0.7),
            0 0 28px rgba(255, 211, 107, 0.85);
        transform: translateY(-8px) scale(1.04);
    }
}

@media (prefers-reduced-motion: reduce) {
    .page-game .card.hand-card.idle-playable img {
        animation: none;
        filter: brightness(1.1);
    }
}

.page-game .card.hand-card .card-label {
    display: none;
}

.page-game .card.tiny img {
    width: 36px;
    height: 50px;
}

.page-game .card.tiny {
    width: 36px;
}

#continue_round_btn {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 12px 16px;
    font-size: 0.88rem;
    white-space: nowrap;
}

#continue_round_btn.hidden {
    display: none !important;
}

#pass_btn {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 12px 16px;
    font-size: 0.88rem;
    white-space: nowrap;
    border-color: rgba(255, 255, 255, 0.88);
    color: #ffffff;
}

#pass_btn.hidden {
    display: none !important;
}

#take_btn {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 12px 18px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.winner-banner.compact {
    flex: 0 0 auto;
    padding: 6px;
    font-size: 0.85rem;
    margin: 0;
}

.page-game .waiting-panel {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

body.assemble-crew .page-game .waiting-panel,
body.assemble-crew .waiting-panel.panel {
    background: rgba(8, 24, 40, 0.55);
    border-color: rgba(255, 211, 107, 0.28);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

body.assemble-crew .crew-list li {
    background: rgba(6, 18, 32, 0.62);
}

.page-game #game_area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.turn-indicator.turn-yours {
    background: rgba(255, 211, 107, 0.22);
    border-color: #ffd36b;
    color: #ffd36b;
    font-weight: 800;
    animation: turnPulse 1.4s ease infinite;
}

.turn-indicator.turn-cpu {
    background: rgba(100, 160, 255, 0.15);
    border-color: rgba(120, 180, 255, 0.5);
    color: #9ec8ff;
    animation: turnPulse 1s ease infinite;
}

@keyframes turnPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.72; }
}

/* Action popup */
.action-popup {
    position: fixed;
    inset: 0;
    z-index: 360;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.72);
    padding: 16px;
    box-sizing: border-box;
}

.action-popup.hidden {
    display: none !important;
}

.action-popup-card {
    background: linear-gradient(165deg, #0e2840 0%, #061420 100%);
    border: 2px solid rgba(255, 211, 107, 0.5);
    border-radius: 16px;
    padding: 24px 28px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
    animation: actionPopIn 0.3s ease;
}

@keyframes actionPopIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.action-popup-badge {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #8ab0cc;
    margin-bottom: 14px;
}

.action-popup-img {
    width: clamp(100px, 28vw, 140px);
    height: auto;
    border-radius: 10px;
    border: 3px solid #3a7ab8;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    margin: 0 auto 14px;
    display: block;
}

.action-popup-img.hidden {
    display: none;
}

.action-popup-player {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffd36b;
    margin-bottom: 8px;
}

.action-popup-text {
    color: #d4e8f4;
    font-size: 1rem;
    line-height: 1.5;
    margin: 0 0 18px;
}

.action-popup-ok {
    display: none !important;
}

/* Series end — cinematic ascending podium */
/* Round break — scoreboard popup */
.round-score-overlay {
    position: fixed;
    inset: 0;
    z-index: 350;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    background: rgba(4, 12, 22, 0.72);
}

.round-score-overlay.hidden {
    display: none !important;
}

.round-score-sheet {
    width: min(440px, 100%);
    max-height: min(86vh, 640px);
    overflow: auto;
    text-align: center;
    padding: 24px 20px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 211, 107, 0.4);
    background: linear-gradient(165deg, rgba(14, 40, 64, 0.98) 0%, rgba(6, 16, 28, 0.99) 100%);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    animation: actionPopIn 0.35s ease;
}

.round-score-brand {
    font-size: 0.7rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: #ffd36b;
    font-weight: 700;
    margin-bottom: 6px;
}

.round-score-sheet h2 {
    margin: 0 0 6px;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    color: #fff6d6;
}

.round-score-sub {
    margin: 0 0 16px;
    color: #9ec4dc;
    font-size: 0.88rem;
    line-height: 1.4;
}

.round-score-list {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.round-score-row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
    align-items: center;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(8, 24, 40, 0.85);
}

.round-score-row--you {
    border-color: rgba(110, 196, 255, 0.45);
    background: rgba(20, 50, 80, 0.9);
}

.round-score-row--lead {
    border-color: rgba(255, 211, 107, 0.45);
}

.round-score-place {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: #ffd36b;
    background: rgba(255, 211, 107, 0.12);
    border: 1px solid rgba(255, 211, 107, 0.3);
}

.round-score-name {
    font-weight: 700;
    color: #e8f0f8;
    font-size: 0.95rem;
}

.round-score-meta {
    margin-top: 2px;
    font-size: 0.72rem;
    color: #7a9eb8;
}

.round-score-points {
    text-align: right;
}

.round-score-series {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffd36b;
    line-height: 1;
}

.round-score-round {
    margin-top: 3px;
    font-size: 0.72rem;
    color: #7dcea0;
    font-weight: 700;
}

.round-score-goal {
    margin: 0 0 14px;
    font-size: 0.78rem;
    color: #9bb8cc;
}

.round-score-continue {
    width: 100%;
    min-height: 48px;
    margin: 0;
}

.podium-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 18%, rgba(255, 180, 60, 0.22) 0%, transparent 42%),
        radial-gradient(ellipse at 50% 100%, rgba(20, 70, 110, 0.45) 0%, transparent 50%),
        linear-gradient(180deg, #041018 0%, #0a2034 48%, #061018 100%);
}

.podium-overlay.hidden {
    display: none !important;
}

.podium-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(4, 16, 28, 0.75) 0%, transparent 18%, transparent 82%, rgba(4, 16, 28, 0.75) 100%),
        repeating-linear-gradient(
            -12deg,
            transparent 0,
            transparent 18px,
            rgba(255, 211, 107, 0.025) 18px,
            rgba(255, 211, 107, 0.025) 19px
        );
    pointer-events: none;
}

body.podium-open {
    overflow: hidden;
}

.podium-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.podium-confetti-bit {
    position: absolute;
    top: -12px;
    width: 8px;
    height: 12px;
    border-radius: 2px;
    opacity: 0;
    animation: podiumConfettiFall linear forwards;
}

@keyframes podiumConfettiFall {
    0% {
        opacity: 0;
        transform: translate3d(0, -10vh, 0) rotate(0deg);
    }
    12% { opacity: 1; }
    100% {
        opacity: 0;
        transform: translate3d(var(--drift, 40px), 110vh, 0) rotate(520deg);
    }
}

.podium-stage {
    position: relative;
    z-index: 2;
    width: min(560px, 100%);
    max-height: 100%;
    overflow: auto;
    text-align: center;
    padding: 28px 22px 22px;
    border-radius: 18px;
    border: 1px solid rgba(255, 211, 107, 0.45);
    background: linear-gradient(165deg, rgba(14, 40, 64, 0.96) 0%, rgba(6, 16, 28, 0.98) 100%);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 28px 90px rgba(0, 0, 0, 0.65),
        0 0 80px rgba(255, 180, 60, 0.08);
    scrollbar-width: thin;
}

.podium-overlay--intro .podium-stage {
    animation: podiumStageIn 0.7s ease both;
}

@keyframes podiumStageIn {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.podium-brand {
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: #ffd36b;
    margin-bottom: 8px;
    font-weight: 700;
}

.podium-headline {
    margin: 0 0 8px;
    font-size: clamp(1.7rem, 5vw, 2.4rem);
    letter-spacing: 0.04em;
    color: #fff6d6;
    text-shadow: 0 4px 28px rgba(0, 0, 0, 0.55);
}

.podium-sub {
    margin: 0 0 18px;
    color: #9ec4dc;
    font-size: 0.9rem;
    min-height: 1.4em;
}

.podium-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.podium-row {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    align-items: center;
    gap: 12px;
    text-align: left;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(8, 24, 40, 0.85);
    opacity: 0;
    transform: translateY(36px) scale(0.92);
    filter: blur(2px);
}

.podium-row.is-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: none;
    transition:
        opacity 0.35s ease,
        transform 0.55s cubic-bezier(0.2, 0.9, 0.2, 1.15),
        filter 0.35s ease,
        box-shadow 0.45s ease;
}

.podium-row--you {
    border-color: rgba(110, 196, 255, 0.45);
}

.podium-row--bronze {
    border-color: rgba(205, 127, 50, 0.45);
    background: linear-gradient(90deg, rgba(80, 42, 18, 0.55), rgba(8, 24, 40, 0.9));
}

.podium-row--silver {
    border-color: rgba(190, 210, 230, 0.45);
    background: linear-gradient(90deg, rgba(50, 70, 90, 0.55), rgba(8, 24, 40, 0.9));
}

.podium-row--champ {
    border-color: rgba(255, 211, 107, 0.75);
    background: linear-gradient(105deg, rgba(120, 80, 16, 0.55) 0%, rgba(20, 40, 60, 0.92) 55%, rgba(8, 24, 40, 0.95) 100%);
    box-shadow:
        0 0 0 1px rgba(255, 211, 107, 0.25),
        0 12px 40px rgba(255, 180, 60, 0.2);
    animation: podiumChampPulse 1.6s ease-in-out infinite;
}

@keyframes podiumChampPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(255, 211, 107, 0.25), 0 12px 40px rgba(255, 180, 60, 0.18); }
    50% { box-shadow: 0 0 0 2px rgba(255, 211, 107, 0.45), 0 16px 50px rgba(255, 180, 60, 0.35); }
}

.podium-overlay--finale .podium-stage {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 28px 90px rgba(0, 0, 0, 0.65),
        0 0 120px rgba(255, 180, 60, 0.18);
}

.podium-place {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: #ffd36b;
    background: rgba(255, 211, 107, 0.12);
    border: 1px solid rgba(255, 211, 107, 0.35);
}

.podium-row--champ .podium-place {
    font-size: 1.35rem;
    color: #1a1000;
    background: linear-gradient(160deg, #ffe08a, #e8a830);
    border-color: #ffd36b;
}

.podium-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #e8f0f8;
    line-height: 1.25;
}

.podium-role {
    margin-top: 2px;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7a9eb8;
}

.podium-row--champ .podium-role {
    color: #ffd36b;
}

.podium-cpu,
.podium-you-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
}

.podium-cpu {
    color: #9ec4dc;
    border: 1px solid rgba(158, 196, 220, 0.35);
}

.podium-you-tag {
    color: #041018;
    background: #6ec4ff;
}

.podium-scoreblock {
    text-align: right;
    min-width: 72px;
}

.podium-score {
    font-size: 1.55rem;
    font-weight: 800;
    color: #ffd36b;
    line-height: 1;
}

.podium-score-label {
    margin-top: 3px;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7a9eb8;
}

.podium-you {
    margin-top: 16px;
    padding: 14px 12px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 211, 107, 0.28);
    background: rgba(0, 0, 0, 0.25);
}

.podium-you.hidden {
    display: none !important;
}

.podium-you-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #9ec4dc;
}

.podium-you-title {
    margin: 4px 0 10px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffd36b;
}

.podium-you-note {
    margin: 10px 0 0;
    color: #9bb8cc;
    font-size: 0.88rem;
}

.podium-you .rank-plaque {
    margin: 0 auto;
}

.podium-continue {
    margin-top: 18px;
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
}

.podium-continue.hidden {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .podium-row,
    .podium-row.is-in,
    .podium-row--champ,
    .podium-confetti-bit,
    .podium-overlay--intro .podium-stage {
        animation: none !important;
        transition: none !important;
        filter: none !important;
        opacity: 1;
        transform: none;
    }
}

.action-popup-step {
    font-size: 0.82rem;
    color: #9ec8ff;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 0.04em;
}

.game-dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.game-dialog-buttons button {
    min-width: 100px;
}

.modal.game-dialog {
    max-width: 400px;
    text-align: center;
}

.modal.game-dialog p {
    color: #c8dce8;
    line-height: 1.5;
}

.modal.game-dialog h3 {
    color: #ffd36b;
}

.zone-hint {
    font-size: 0.65rem;
    color: #5a7890;
    line-height: 1.3;
    margin: 0 0 6px;
    flex: 0 0 auto;
}

.zone-yours {
    border-color: rgba(255, 211, 107, 0.25);
}

.zone-treasure-panel .zone-title {
    color: #ffd36b;
}

.zone-treasure-panel.zone-flash {
    animation: treasureFlash 0.6s ease 3;
    border-color: #ffd36b;
    box-shadow: 0 0 24px rgba(255, 211, 107, 0.45);
}

@keyframes treasureFlash {
    0%, 100% { background: rgba(6, 18, 32, 0.85); }
    50% { background: rgba(80, 60, 10, 0.55); }
}

/* Card hover tooltip */
.card-tooltip {
    position: fixed;
    z-index: 500;
    max-width: 280px;
    padding: 12px 14px;
    background: rgba(8, 22, 38, 0.97);
    border: 2px solid rgba(255, 211, 107, 0.55);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
    pointer-events: none;
}

.card-tooltip.hidden {
    display: none !important;
}

.card-tooltip-name {
    font-weight: 800;
    color: #ffd36b;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.card-tooltip-pts {
    font-weight: 600;
    color: #98ffd0;
    margin-left: 6px;
    font-size: 0.85rem;
}

.card-tooltip-desc {
    color: #c8dce8;
    font-size: 0.82rem;
    line-height: 1.45;
    margin-bottom: 8px;
}

.card-tooltip-play {
    font-size: 0.78rem;
    color: #7dcea0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
    font-weight: 600;
}

.page-game #game_area.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    .page-game {
        --pile-w: clamp(72px, 16vw, 110px);
        --hand-w: clamp(64px, 10vw, 96px);
        --zone-w: clamp(48px, 10vw, 72px);
        --opp-card-w: clamp(42px, 8vw, 60px);
    }

    .game-table {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .opponents-strip {
        max-height: min(30vh, 200px);
    }

    .center-piles {
        gap: 10px;
    }

    .center-actions {
        min-width: min(150px, 28vw);
        gap: 6px;
        margin-bottom: 0;
    }

    .turn-take-cluster {
        width: min(160px, 100%);
    }

    .turn-indicator.turn-center {
        font-size: 0.75rem;
        padding: 8px 10px;
    }

    #take_btn,
    #pass_btn,
    #continue_round_btn {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
}

@media (max-height: 700px) {
    .page-game {
        --pile-w: clamp(64px, 12vmin, 100px);
        --hand-w: clamp(56px, 8vw, 88px);
        --opp-card-w: clamp(40px, 5vmin, 56px);
    }

    .opponents-strip {
        max-height: min(26vh, 160px);
    }
}

/* Series-end video ad (after 21-point win) */
.post-round-ad-overlay {
    position: fixed;
    inset: 0;
    z-index: 450;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    background: rgba(2, 8, 16, 0.88);
}

.post-round-ad-overlay.hidden {
    display: none !important;
}

.post-round-ad-sheet {
    width: min(560px, 100%);
    max-height: min(92vh, 720px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 211, 107, 0.35);
    background: linear-gradient(165deg, rgba(10, 28, 44, 0.98) 0%, rgba(4, 12, 22, 0.99) 100%);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.post-round-ad-video {
    width: 100%;
    max-height: min(58vh, 420px);
    border-radius: 10px;
    background: #000;
    object-fit: contain;
}

.post-round-ad-caption {
    margin: 0;
    text-align: center;
    font-size: clamp(0.85rem, 2.8vw, 1rem);
    color: #d8e8f8;
    line-height: 1.45;
}

.post-round-ad-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.post-round-ad-actions .btn-gold,
.post-round-ad-actions .btn-secondary {
    flex: 1 1 140px;
    max-width: 240px;
    min-height: 44px;
}

.post-round-ad-actions .btn-gold:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.round-score-continue:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .post-round-ad-sheet {
        padding: 10px;
        gap: 10px;
    }

    .post-round-ad-video {
        max-height: 50vh;
    }

    .post-round-ad-actions {
        flex-direction: column;
    }

    .post-round-ad-actions .btn-gold,
    .post-round-ad-actions .btn-secondary {
        max-width: none;
        width: 100%;
    }
}
