@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;600;700&family=ZCOOL+XiaoWei&display=swap");

:root {
    --bg0: #0f1f17;
    --bg1: #163528;
    --felt: #1a5c3a;
    --felt-deep: #0d3d26;
    --gold: #d4a84b;
    --gold-soft: #f0d78c;
    --cream: #f3ebe0;
    --danger: #c44536;
    --ink: #102018;
    --muted: #a8c4b4;
    --panel: rgba(12, 28, 20, 0.88);
    --line: rgba(212, 168, 75, 0.35);
    --font-display: "ZCOOL XiaoWei", "STKaiti", "KaiTi", serif;
    --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--cream);
    background:
        radial-gradient(ellipse at 20% 0%, rgba(212,168,75,0.18), transparent 45%),
        radial-gradient(ellipse at 80% 100%, rgba(40,120,80,0.35), transparent 50%),
        linear-gradient(160deg, var(--bg0), var(--bg1) 55%, #0a1610);
}

.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }

.brand { text-align: center; margin-bottom: 36px; }
.brand-mark {
    font-size: 28px;
    letter-spacing: 10px;
    color: var(--gold);
    animation: float 3.5s ease-in-out infinite;
}
.brand h1 {
    font-family: var(--font-display);
    font-size: clamp(42px, 8vw, 72px);
    font-weight: 400;
    margin: 8px 0 4px;
    color: var(--gold-soft);
    letter-spacing: 0.2em;
}
.tagline { color: var(--muted); margin: 0; letter-spacing: 0.12em; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.lobby-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(8px);
}

.panel h2 {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--gold);
    margin: 0 0 18px;
    font-size: 26px;
}

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 14px;
}

input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.35);
    color: var(--cream);
    font-size: 15px;
    outline: none;
}

input:focus { border-color: var(--gold); }

.btn {
    appearance: none;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: var(--cream);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: transform .12s ease, background .15s ease, border-color .15s, box-shadow .15s, filter .15s;
    box-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--gold);
    box-shadow: 0 6px 14px rgba(0,0,0,0.28);
}

.btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.97);
    box-shadow: 0 1px 0 rgba(0,0,0,0.3);
    filter: brightness(1.08);
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn.primary {
    background: linear-gradient(145deg, #e0b35a, #b8862f 55%, #8a6420);
    border-color: rgba(240,215,140,0.45);
    color: #1a1205;
    font-weight: 700;
    box-shadow: 0 3px 0 #5c4214, 0 6px 16px rgba(212,168,75,0.25);
}

.btn.primary:hover:not(:disabled) {
    box-shadow: 0 5px 0 #5c4214, 0 10px 20px rgba(212,168,75,0.35);
}

.btn.primary:active:not(:disabled) {
    box-shadow: 0 1px 0 #5c4214;
}

.panel .btn.primary {
    width: 100%;
    margin-top: 8px;
}

.btn.danger {
    background: linear-gradient(145deg, rgba(196,69,54,0.55), rgba(120,30,24,0.75));
    border-color: rgba(240,160,150,0.45);
    box-shadow: 0 3px 0 rgba(80,20,16,0.8);
}

.btn.ghost {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.12);
}

.btn.pulse {
    animation: btnPulse 1.4s ease-in-out infinite;
}

.btn.attn {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px rgba(212,168,75,0.35);
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 3px 0 rgba(0,0,0,0.25), 0 0 0 0 rgba(212,168,75,0.35); }
    50% { box-shadow: 0 3px 0 rgba(0,0,0,0.25), 0 0 0 6px rgba(212,168,75,0); }
}

.negotiate-bar {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(212,168,75,0.12);
    border: 1px solid rgba(212,168,75,0.35);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gold-soft);
}
.negotiate-bar.hidden { display: none !important; }
.negotiate-bar .btn { width: auto; min-width: 0; padding: 6px 12px; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    justify-content: center;
}

.actions .btn {
    min-width: 96px;
    padding: 12px 18px;
    font-size: 15px;
}

.hint {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin-top: 28px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    background: #1e2e24;
    border: 1px solid var(--gold);
    color: var(--gold-soft);
    padding: 12px 20px;
    border-radius: 999px;
    z-index: 50;
    animation: pop .25s ease;
}

.toast.hidden { display: none; }

@keyframes pop {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.table-page {
    max-width: 960px;
    display: grid;
    gap: 16px;
}

.table-tools {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tools-pop {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.tools-pop.hidden { display: none; }
#btn-more { display: none; }
.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    min-width: 0;
    width: auto;
}

@media (min-width: 641px) {
    #btn-more { display: none !important; }
    .tools-pop,
    .tools-pop.hidden {
        display: flex !important;
        position: static;
        background: transparent;
        border: 0;
        box-shadow: none;
        padding: 0;
        min-width: 0;
        flex-direction: row;
    }
    .log-toggle {
        display: flex;
        pointer-events: none;
        margin-bottom: 8px;
        cursor: default;
    }
    .log-toggle-hint { display: none; }
}

.log-panel {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 12px 14px;
    max-height: 180px;
    overflow: auto;
}
.log-toggle {
    display: none;
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--gold);
    font-size: 14px;
    font-weight: 600;
    padding: 0;
    text-align: left;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
}
.log-toggle-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}
.log-body { display: block; }

.log-panel h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--gold);
    font-weight: 600;
}

#logs {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: var(--muted);
}

#logs li {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* 积分明细 */
.ledger-overlay {
    position: fixed;
    inset: 0;
    z-index: 140;
    background: rgba(0,0,0,0.72);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
.ledger-overlay.hidden { display: none; }
.ledger-panel {
    width: min(520px, 100%);
    max-height: min(78vh, 640px);
    background: linear-gradient(180deg, #163528, #0d1f18);
    border: 1px solid rgba(212,168,75,0.35);
    border-radius: 18px 18px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    animation: sheetUp 0.28s ease;
}
@keyframes sheetUp {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
}
.ledger-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.ledger-head h3 { margin: 0; color: var(--gold-soft); font-size: 18px; }
.ledger-tabs { display: flex; gap: 6px; }
.ledger-tab {
    border: 1px solid rgba(255,255,255,0.12);
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}
.ledger-tab.active {
    color: #1a1208;
    background: linear-gradient(120deg, #ffe7a0, #f0c14b);
    border-color: transparent;
}
.ledger-summary {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--muted);
}
.ledger-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}
.ledger-list li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 13px;
}
.ledger-list .ledger-reason { color: var(--cream); }
.ledger-list .ledger-meta { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.ledger-list .ledger-delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.ledger-list .ledger-delta.gain { color: #6dffa8; }
.ledger-list .ledger-delta.loss { color: #ff8f7a; }
.ledger-empty { text-align: center; color: var(--muted); padding: 28px 8px; }

@media (min-width: 641px) {
    .ledger-overlay { align-items: center; padding: 20px; }
    .ledger-panel { border-radius: 16px; max-height: 70vh; }
}

.table-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.back { color: var(--muted); text-decoration: none; }
.room-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 14px; }
.room-meta strong { color: var(--gold-soft); }

.pot-banner {
    background:
        radial-gradient(circle at 50% 30%, rgba(255,255,255,0.08), transparent 55%),
        linear-gradient(180deg, var(--felt), var(--felt-deep));
    border: 2px solid rgba(212,168,75,0.4);
    border-radius: 999px;
    padding: 18px 28px;
    text-align: center;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.35);
    animation: glow 4s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: inset 0 0 40px rgba(0,0,0,0.35), 0 0 0 rgba(212,168,75,0); }
    50% { box-shadow: inset 0 0 40px rgba(0,0,0,0.35), 0 0 24px rgba(212,168,75,0.15); }
}

.pot { font-size: 22px; color: var(--gold-soft); }
.status-msg { margin: 6px 0; font-size: 15px; }
.bet-info { font-size: 13px; color: var(--muted); }

.seats {
    /* 座位由 .oval-table 绝对定位，不再用网格 */
}

.seat {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 14px;
    min-height: 140px;
    transition: border-color .2s, transform .2s;
}

.seat.current {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(212,168,75,0.3);
}

.seat.folded { opacity: 0.45; }
.seat.me { border-style: dashed; border-color: rgba(240,215,140,0.5); }

.badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(212,168,75,0.2);
    color: var(--gold);
    white-space: nowrap;
}

.card {
    position: relative;
    width: 42px;
    height: 58px;
    border-radius: 7px;
    background: linear-gradient(160deg, #fffdf8, #f0e6d4);
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.35),
        inset 0 0 0 1px rgba(0,0,0,0.08);
    overflow: hidden;
    user-select: none;
}

.card.face { font-size: 0; }
.card.red, .card.red .c-corner, .card.red .c-pip { color: #c44536; }
.card .c-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-size: 10px;
    color: #1a1a1a;
    font-weight: 700;
}
.card .c-corner i { font-style: normal; font-size: 11px; }
.card .c-corner b { font-weight: 700; font-size: 10px; }
.card .c-corner.tl { top: 3px; left: 4px; }
.card .c-corner.br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.card .c-pip {
    font-size: 18px;
    color: #1a1a1a;
    line-height: 1;
}

.card.back {
    background:
        radial-gradient(circle at 30% 30%, rgba(240,215,140,0.25), transparent 40%),
        repeating-linear-gradient(45deg, #6b1f2a 0 5px, #8b2a38 5px 10px);
    color: transparent;
    border: 2px solid #e6c76a;
}

.card.anim-deal {
    animation: deal .35s ease both;
}

@keyframes deal {
    from { transform: translateY(-12px) scale(0.9); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.my-area {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    position: relative;
    z-index: 10;
}

.my-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    align-items: baseline;
}

.hand-type { color: var(--gold); font-weight: 700; }

.my-cards {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 12px 0 18px;
}

.my-cards .card {
    width: 72px;
    height: 100px;
}
.my-cards .card .c-pip { font-size: 28px; }
.my-cards .card .c-corner i { font-size: 13px; }
.my-cards .card .c-corner b { font-size: 12px; }

.raise-box, .compare-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

#compare-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.hidden { display: none !important; }

@media (max-width: 640px) {
    html, body.room-body {
        height: 100%;
        overflow: hidden;
    }
    .page.table-page {
        height: 100dvh;
        height: 100vh;
        max-width: none;
        margin: 0;
        padding: 0;
        gap: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .table-top {
        flex: 0 0 auto;
        padding: 6px 8px;
        gap: 6px;
        min-height: 40px;
    }
    .room-meta { font-size: 11px; gap: 6px; flex: 1; }
    .room-meta span:nth-child(n+4) { display: none; }
    .back { font-size: 14px; padding: 4px 2px; }
    #btn-more { display: inline-flex; }
    .tools-pop {
        position: absolute;
        right: 0;
        top: calc(100% + 4px);
        z-index: 30;
        background: rgba(10, 22, 16, 0.96);
        border: 1px solid rgba(212,168,75,0.35);
        border-radius: 12px;
        padding: 8px;
        flex-direction: column;
        align-items: stretch;
        min-width: 112px;
        box-shadow: 0 10px 28px rgba(0,0,0,0.45);
    }
    .tools-pop .btn { width: 100%; justify-content: center; }
    .btn-sm { padding: 6px 10px; font-size: 12px; min-width: 0; }
    .table-stage {
        flex: 1 1 auto;
        height: auto !important;
        min-height: 0 !important;
        max-height: none;
    }
    .felt-oval { left: 2%; right: 2%; top: 4%; bottom: 10%; border-width: 6px; }
    .pot-banner { border-radius: 14px; padding: 8px 10px !important; min-width: 120px; }
    .pot { font-size: 15px; }
    .status-msg { font-size: 11px; margin: 4px 0; }
    .bet-info, .my-stats-inline { font-size: 10px; }
    .deal-hash-tag { font-size: 9px; opacity: 0.7; }
    .abs-seat { width: 92px; padding: 6px; gap: 4px; border-radius: 10px; }
    .abs-seat .seat-cards .card { width: 24px; height: 34px; }
    .abs-seat .c-pip { font-size: 10px; }
    .abs-seat .c-corner { display: none; }
    .seat-name { font-size: 10px; }
    .seat-chips, .seat-flags { font-size: 9px; }
    .seat-self { width: auto; min-width: 88px; padding: 5px 7px; }
    .seat-avatar { width: 24px; height: 24px; font-size: 11px; }

    .my-area {
        position: relative;
        flex: 0 0 auto;
        z-index: 20;
        border-radius: 14px 14px 0 0;
        padding: 8px 10px 52px;
        margin: 0;
        box-shadow: 0 -6px 20px rgba(0,0,0,0.35);
    }
    .my-info {
        font-size: 12px;
        gap: 6px;
        margin-bottom: 6px;
        flex-wrap: wrap;
    }
    .my-cards { gap: 6px; margin-bottom: 8px; }
    .my-cards .card { width: 48px; height: 68px; }
    .my-cards .card .c-pip { font-size: 18px; }
    .my-cards .card .c-corner { font-size: 8px; }
    .actions { gap: 6px; }
    .actions .btn {
        min-width: 0;
        padding: 10px 8px;
        font-size: 13px;
        flex: 1 1 30%;
    }

    .log-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 25;
        max-height: none;
        margin: 0;
        border-radius: 14px 14px 0 0;
        padding: 0;
        background: rgba(12, 26, 20, 0.97);
        border: 1px solid rgba(212,168,75,0.3);
        border-bottom: 0;
        overflow: hidden;
        transform: translateY(calc(100% - 40px));
        transition: transform 0.28s ease;
        box-shadow: 0 -8px 28px rgba(0,0,0,0.4);
    }
    .log-panel.open { transform: translateY(0); }
    .log-toggle {
        display: flex;
        padding: 10px 14px;
        min-height: 40px;
    }
    .log-body {
        display: block;
        max-height: 38vh;
        overflow: auto;
        padding: 0 14px calc(14px + env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
    }
    .log-panel:not(.open) .log-body { pointer-events: none; }

    .lobby-panels { grid-template-columns: 1fr; }
    .brand h1 { letter-spacing: 0.12em; }
    .rub-slot { width: 96px; height: 134px; }
    .rub-face .c-pip { font-size: 34px; }
}

@media (max-width: 400px) {
    .abs-seat { width: 84px; }
    .my-cards .card { width: 44px; height: 62px; }
    .actions .btn { padding: 9px 6px; font-size: 12px; }
}

/* ===== Oval table / relative seats ===== */
.room-body {
    overscroll-behavior: none;
}

.table-stage {
    position: relative;
    height: 560px;
    border-radius: 20px;
    overflow: visible;
    background: transparent;
    border: none;
    box-shadow: none;
}

.felt-oval {
    position: absolute;
    left: 6%;
    right: 6%;
    top: 8%;
    bottom: 14%;
    border-radius: 50% / 46%;
    overflow: hidden;
    z-index: 1;
    background:
        radial-gradient(ellipse at 50% 42%, #2a8a55 0%, #176b3d 40%, #0d4528 72%, #082816 100%);
    border: 9px solid #5a3a1a;
    box-shadow:
        inset 0 0 0 3px #c9a24a,
        inset 0 0 55px rgba(0,0,0,0.4),
        0 14px 32px rgba(0,0,0,0.4);
}

.felt-inner {
    position: absolute;
    inset: 12px;
    border-radius: 50% / 46%;
    border: 1px solid rgba(255,255,255,0.07);
    background:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.028) 2px, rgba(0,0,0,0.028) 3px),
        radial-gradient(ellipse at 50% 35%, rgba(255,255,255,0.07), transparent 55%);
    pointer-events: none;
    z-index: 1;
}

.table-stage .pot-banner {
    position: absolute;
    left: 50%;
    top: 48%;
    transform: translate(-50%, -50%);
    z-index: 2;
    min-width: 200px;
    max-width: 78%;
    padding: 12px 18px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 0%, rgba(255,255,255,0.1), transparent 55%),
        rgba(8, 28, 18, 0.78);
    border: 1px solid rgba(212,168,75,0.45);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    animation: none;
}

.deal-hash-tag {
    position: absolute;
    right: 16%;
    bottom: 12%;
    z-index: 2;
    font-size: 11px;
    color: rgba(168,196,180,0.65);
}

.oval-table {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.oval-table .abs-seat {
    pointer-events: auto;
}

.abs-seat {
    position: absolute;
    width: 150px;
    min-height: 0;
    z-index: 4;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: rgba(8, 22, 16, 0.88);
    border: 1px solid rgba(212,168,75,0.3);
    border-radius: 14px;
    padding: 10px;
    backdrop-filter: blur(5px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
    transition: border-color .2s, box-shadow .2s, transform .2s;
}

.abs-seat.current {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px rgba(212,168,75,0.5), 0 8px 20px rgba(212,168,75,0.18);
    z-index: 6;
}

.abs-seat.folded { opacity: 0.42; filter: grayscale(0.3); }

.seat-self {
    width: auto;
    min-width: 118px;
    align-items: center;
    background: rgba(212,168,75,0.16);
    border-color: rgba(212,168,75,0.6);
}

.seat-self .seat-cards { display: none; }

.seat-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: #1a1205;
    background: linear-gradient(145deg, #e0b35a, #8a6420);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}

.seat-body { min-width: 0; flex: 1; }
.seat-name { font-weight: 700; display: flex; justify-content: space-between; gap: 4px; font-size: 13px; }
.seat-chips { color: var(--muted); font-size: 12px; margin: 3px 0; }
.seat-cards { display: flex; gap: 3px; min-height: 0; }
.seat-flags { font-size: 11px; color: var(--muted); margin-top: 4px; }

.btn-sm {
    padding: 7px 11px;
    font-size: 12px;
    border-radius: 8px;
}

.table-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.deal-layer {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    overflow: visible;
}

.fly-card {
    position: absolute;
    left: 50%;
    top: 46%;
    width: 38px;
    height: 54px;
    margin-left: -19px;
    margin-top: -27px;
    border-radius: 6px;
    border: 2px solid #e6c76a;
    background:
        radial-gradient(circle at 30% 25%, rgba(240,215,140,0.35), transparent 45%),
        repeating-linear-gradient(45deg, #6b1f2a 0 5px, #8b2a38 5px 10px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.35);
    animation: flyDeal 0.55s cubic-bezier(.2,.75,.25,1) forwards;
    opacity: 0;
    z-index: 9;
}

@keyframes flyDeal {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.55) rotate(0deg);
    }
    12% { opacity: 1; }
    70% {
        opacity: 1;
        transform: translate(
            calc((var(--tx) - 50%) * 0.92),
            calc((var(--ty) - 46%) * 0.92)
        ) scale(1.02) rotate(var(--spin, 12deg));
    }
    100% {
        opacity: 0.95;
        transform: translate(
            calc(var(--tx) - 50%),
            calc(var(--ty) - 46%)
        ) scale(1) rotate(var(--spin, 12deg));
    }
}

.deal-in {
    animation: dealPop 0.45s ease both;
}

@keyframes dealPop {
    from { transform: translateY(-20px) scale(0.8); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.flip-in {
    animation: flipIn 0.5s ease both;
}

@keyframes flipIn {
    from { transform: rotateY(90deg); opacity: 0.2; }
    to { transform: none; opacity: 1; }
}

/* ===== Win / Lose overlay ===== */
.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.result-card {
    text-align: center;
    padding: 36px 48px;
    border-radius: 20px;
    min-width: 280px;
    transform: scale(0.85);
    animation: resultPop 0.45s cubic-bezier(.2,1.4,.4,1) forwards;
}

@keyframes resultPop {
    to { transform: scale(1); }
}

.result-card.win {
    background: linear-gradient(160deg, #3d2a0a, #1a1205);
    border: 2px solid var(--gold);
    box-shadow: 0 0 40px rgba(212,168,75,0.35);
}

.result-card.lose {
    background: linear-gradient(160deg, #2a1212, #120808);
    border: 2px solid rgba(196,69,54,0.7);
    box-shadow: 0 0 40px rgba(196,69,54,0.25);
}

.result-title {
    font-family: var(--font-display);
    font-size: 42px;
    color: var(--gold-soft);
    letter-spacing: 0.12em;
}

.result-card.lose .result-title { color: #f0a8a0; }

.result-sub {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 14px;
}

.admin-table th, .admin-table td {
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 10px 8px;
    text-align: left;
}

.admin-table .ops { display: flex; flex-wrap: wrap; gap: 6px; }

a.btn {
    display: inline-block;
    text-decoration: none;
    line-height: 1.2;
}

.lock {
    color: var(--gold);
    font-size: 12px;
    border: 1px solid var(--line);
    padding: 1px 6px;
    border-radius: 4px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--muted);
}
.check-row input { width: auto; margin: 0; }

.gain { color: #7dcea0; }
.loss { color: #e5989b; }

.my-stats-inline {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
}

/* ===== Compare ceremony ===== */
.compare-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(212,168,75,0.18), transparent 55%),
        rgba(0,0,0,0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}
.compare-stage {
    width: min(720px, 94vw);
    text-align: center;
    padding: 28px 20px;
}
.compare-title {
    font-family: var(--font-display);
    font-size: 36px;
    color: var(--gold-soft);
    letter-spacing: 0.25em;
    margin-bottom: 28px;
    animation: float 2.5s ease-in-out infinite;
}
.compare-duel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}
.compare-side {
    background: rgba(12,28,20,0.9);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px 18px;
    min-width: 180px;
    transition: transform .35s, box-shadow .35s, border-color .35s;
}
.compare-side.winner {
    border-color: var(--gold);
    box-shadow: 0 0 28px rgba(212,168,75,0.35);
    transform: scale(1.06);
}
.compare-side.loser {
    opacity: 0.55;
    filter: grayscale(0.4);
    transform: scale(0.96);
}
.compare-name {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--cream);
}
.compare-cards {
    display: flex;
    gap: 6px;
    justify-content: center;
    min-height: 64px;
}
.compare-cards .card {
    width: 52px;
    height: 72px;
    font-size: 15px;
}
.compare-hand {
    margin-top: 8px;
    color: var(--gold);
    font-size: 13px;
    min-height: 18px;
}
.compare-vs {
    font-family: var(--font-display);
    font-size: 42px;
    color: var(--gold);
    letter-spacing: 0.1em;
    animation: vsPulse 1.2s ease-in-out infinite;
}
@keyframes vsPulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.12); opacity: 1; }
}
.compare-result-text {
    margin-top: 22px;
    font-size: 20px;
    color: var(--gold-soft);
    letter-spacing: 0.08em;
    min-height: 28px;
}
.compare-flip {
    animation: compareShake 0.55s ease-in-out infinite alternate;
}
@keyframes compareShake {
    from { transform: rotateY(0deg) translateY(0); }
    to { transform: rotateY(18deg) translateY(-4px); }
}

.showdown-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px 28px;
    max-width: 920px;
    margin: 0 auto;
}
.showdown-seat {
    text-align: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.25);
    animation: showdownPop 0.45s ease both;
    min-width: 140px;
}
.showdown-seat.winner {
    box-shadow: 0 0 0 2px rgba(232, 197, 71, 0.85), 0 0 28px rgba(232, 197, 71, 0.35);
    transform: scale(1.04);
}
.showdown-seat.loser {
    opacity: 0.55;
    filter: grayscale(0.35);
}
.showdown-seat .compare-cards .card {
    width: 54px;
    height: 76px;
}
@keyframes showdownPop {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Big hand FX：顺子及以上 ===== */
.hand-fx-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.hand-fx-layer.hidden { display: none !important; }
.compare-stage { position: relative; }

.hand-fx-title {
    font-family: var(--font-display);
    font-size: clamp(42px, 12vw, 72px);
    letter-spacing: 0.28em;
    text-indent: 0.28em;
    font-weight: 700;
    z-index: 2;
    animation: handFxTitleIn 0.55s cubic-bezier(.2,1.4,.4,1) both;
    text-shadow: 0 0 24px currentColor, 0 4px 18px rgba(0,0,0,0.55);
}
.hand-fx-sub {
    margin-top: 8px;
    font-size: 15px;
    letter-spacing: 0.2em;
    color: rgba(255,248,230,0.9);
    z-index: 2;
    animation: fadeIn 0.4s ease 0.15s both;
}
.hand-fx-ring {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0.55;
    animation: handFxRing 1.1s ease-out both;
}
.hand-fx-burst {
    position: absolute;
    inset: -10%;
    opacity: 0.55;
    animation: handFxBurst 1.2s ease-out both;
}
.hand-fx-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
.hand-fx-particles span {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: var(--s);
    height: var(--s);
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
    animation: handFxParticle 1.05s ease-out forwards;
    animation-delay: var(--d);
}

/* 顺子：青绿流光 */
.hand-fx-layer.fx-straight {
    color: #5dffb0;
}
.hand-fx-layer.fx-straight .hand-fx-burst {
    background:
        linear-gradient(90deg, transparent, rgba(93,255,176,0.35), transparent),
        radial-gradient(circle at 50% 50%, rgba(93,255,176,0.25), transparent 60%);
}
.hand-fx-layer.fx-straight .hand-fx-title {
    background: linear-gradient(90deg, #9bffd0, #fff7c2, #5dffb0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 12px rgba(93,255,176,0.7));
}

/* 同花：玫紫花瓣感 */
.hand-fx-layer.fx-flush {
    color: #ff7ad9;
}
.hand-fx-layer.fx-flush .hand-fx-burst {
    background:
        radial-gradient(circle at 30% 40%, rgba(255,122,217,0.35), transparent 45%),
        radial-gradient(circle at 70% 55%, rgba(168,120,255,0.3), transparent 50%);
}
.hand-fx-layer.fx-flush .hand-fx-title {
    background: linear-gradient(120deg, #ff9be0, #c9a6ff, #fff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 14px rgba(255,122,217,0.65));
}

/* 同花顺：金紫双色 */
.hand-fx-layer.fx-straight-flush {
    color: #ffd56a;
}
.hand-fx-layer.fx-straight-flush .hand-fx-burst {
    background:
        conic-gradient(from 0deg, rgba(255,213,106,0.15), rgba(255,122,217,0.25), rgba(93,255,176,0.2), rgba(255,213,106,0.15)),
        radial-gradient(circle at 50% 50%, rgba(255,213,106,0.35), transparent 58%);
    animation: handFxSpinBurst 1.4s ease-out both;
}
.hand-fx-layer.fx-straight-flush .hand-fx-title {
    background: linear-gradient(90deg, #ffe9a0, #fff, #ff9be0, #ffe9a0);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: handFxTitleIn 0.55s cubic-bezier(.2,1.4,.4,1) both, handFxShimmer 1.2s linear 0.2s;
    filter: drop-shadow(0 0 16px rgba(255,213,106,0.8));
}

/* 豹子：赤金炸裂 */
.hand-fx-layer.fx-baozi {
    color: #ffb347;
}
.hand-fx-layer.fx-baozi .hand-fx-burst {
    background:
        radial-gradient(circle at 50% 50%, rgba(255,80,40,0.45), rgba(255,179,71,0.25) 35%, transparent 62%);
}
.hand-fx-layer.fx-baozi .hand-fx-title {
    background: linear-gradient(180deg, #fff6d0, #ffb347, #ff4d2e);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: handFxTitleIn 0.5s cubic-bezier(.2,1.6,.3,1) both, handFxShake 0.45s ease-in-out 0.15s;
    filter: drop-shadow(0 0 20px rgba(255,90,40,0.85));
}
.hand-fx-layer.fx-baozi .hand-fx-ring {
    border-width: 3px;
    box-shadow: 0 0 40px rgba(255,100,40,0.55);
}

@keyframes handFxTitleIn {
    from { opacity: 0; transform: scale(0.4) translateY(20px); filter: blur(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}
@keyframes handFxRing {
    from { transform: scale(0.3); opacity: 0.9; }
    to { transform: scale(2.2); opacity: 0; }
}
@keyframes handFxBurst {
    from { opacity: 0.75; transform: scale(0.6); }
    to { opacity: 0; transform: scale(1.35); }
}
@keyframes handFxSpinBurst {
    from { opacity: 0.8; transform: scale(0.5) rotate(0deg); }
    to { opacity: 0; transform: scale(1.4) rotate(120deg); }
}
@keyframes handFxParticle {
    0% { transform: translate(0,0) scale(1); opacity: 0.9; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}
@keyframes handFxShimmer {
    from { background-position: 0% 50%; }
    to { background-position: 200% 50%; }
}
@keyframes handFxShake {
    0%, 100% { transform: translateX(0) scale(1); }
    25% { transform: translateX(-6px) scale(1.04); }
    75% { transform: translateX(6px) scale(1.04); }
}

.compare-side.big-hand,
.showdown-seat.big-hand {
    position: relative;
}
.compare-side.big-hand::after,
.showdown-seat.big-hand::after {
    content: attr(data-hand-badge);
    position: absolute;
    top: -12px;
    right: -8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #1a1208;
    background: linear-gradient(120deg, #ffe7a0, #f0c14b);
    box-shadow: 0 0 16px rgba(240,193,75,0.55);
    animation: handBadgePop 0.45s cubic-bezier(.2,1.5,.4,1) both;
}
.compare-side.hand-straight::after,
.showdown-seat.hand-straight::after { background: linear-gradient(120deg, #b8ffd9, #5dffb0); }
.compare-side.hand-flush::after,
.showdown-seat.hand-flush::after { background: linear-gradient(120deg, #ffc2ec, #ff7ad9); color: #2a1020; }
.compare-side.hand-straight-flush::after,
.showdown-seat.hand-straight-flush::after {
    background: linear-gradient(120deg, #ffe9a0, #ff9be0, #b8ffd9);
}
.compare-side.hand-baozi::after,
.showdown-seat.hand-baozi::after {
    background: linear-gradient(120deg, #fff0c2, #ff7a3d);
    animation: handBadgePop 0.45s cubic-bezier(.2,1.5,.4,1) both, handFxShake 0.5s ease-in-out 0.2s;
}

.compare-cards.big-glow .card,
.showdown-seat.big-hand .compare-cards .card {
    box-shadow: 0 0 0 1px rgba(255,230,150,0.55), 0 0 18px rgba(255,200,80,0.45);
    animation: cardBigGlow 0.9s ease-in-out infinite alternate;
}
@keyframes cardBigGlow {
    from { filter: brightness(1); }
    to { filter: brightness(1.12); }
}
@keyframes handBadgePop {
    from { opacity: 0; transform: scale(0.4) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.compare-overlay.has-big-hand {
    background:
        radial-gradient(ellipse at 50% 35%, rgba(255,200,80,0.28), transparent 55%),
        rgba(0,0,0,0.78);
}

/* ===== Rub / scratch ===== */
.rub-overlay {
    position: fixed;
    inset: 0;
    z-index: 130;
    background: rgba(5,12,8,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    padding: 16px;
}
.rub-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
    width: min(520px, 94vw);
    text-align: center;
}
.rub-hint {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 16px;
}
.rub-cards {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.rub-slot {
    position: relative;
    width: 110px;
    height: 154px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0,0,0,0.45);
    background: #1a0a0c;
    isolation: isolate;
}
.rub-face {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(160deg, #fffdf8, #f0e6d4);
    color: #1a1a1a;
}
.rub-face.red,
.rub-face.red .c-corner,
.rub-face.red .c-pip { color: #c44536; }
.rub-face .c-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-weight: 700;
}
.rub-face .c-corner i { font-style: normal; font-size: 16px; }
.rub-face .c-corner b { font-size: 14px; }
.rub-face .c-corner.tl { top: 8px; left: 8px; }
.rub-face .c-corner.br { bottom: 8px; right: 8px; transform: rotate(180deg); }
.rub-face .c-pip {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    line-height: 1;
}
.rub-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
    z-index: 2;
    /* 禁止 CSS 底色，否则 destination-out 搓开后仍看不到牌面 */
    background: transparent;
}
.rub-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ===== Stats ===== */
.stats-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stats-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 22px 24px;
    width: min(480px, 92vw);
}
.stats-panel h3 {
    margin: 0 0 10px;
    font-family: var(--font-display);
    color: var(--gold);
    font-weight: 400;
    font-size: 24px;
}
.vote-banner {
    margin-top: 8px;
    font-size: 13px;
    color: var(--gold-soft);
    background: rgba(212,168,75,0.12);
    border: 1px solid rgba(212,168,75,0.3);
    border-radius: 999px;
    padding: 6px 14px;
    display: inline-block;
}

.final-overlay {
    position: fixed;
    inset: 0;
    z-index: 140;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(212,168,75,0.2), transparent 50%),
        rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}
.final-panel {
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: 20px;
    padding: 28px 26px;
    width: min(460px, 92vw);
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.final-title {
    font-family: var(--font-display);
    font-size: 32px;
    color: var(--gold-soft);
    letter-spacing: 0.18em;
}
.final-sub {
    color: var(--muted);
    font-size: 13px;
    margin: 8px 0 18px;
}
.final-rank {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: left;
}
.final-rank li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    margin-bottom: 4px;
}
.final-rank li.me {
    background: rgba(212,168,75,0.12);
    border: 1px solid rgba(212,168,75,0.25);
}
.final-rank .rank-no {
    color: var(--gold);
    font-weight: 700;
    min-width: 28px;
}
.final-rank .rank-name { flex: 1; }
.final-rank .rank-net { font-weight: 700; }
.final-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}


