/* 延边画图 · 全局样式 */
:root {
    --felt-1: #1c6b47;
    --felt-2: #0b3b28;
    --felt-3: #07271b;
    --gold: #e7c873;
    --gold-deep: #b8912f;
    --cream: #f6eedb;
    --red: #c0392b;
    --ink: #1d1810;
    --panel: rgba(7, 30, 21, 0.82);
    --panel-line: rgba(231, 200, 115, 0.28);
    --text: #eef6f0;
    --muted: #9db9aa;
    --ok: #4ccf8a;
    --danger: #ff8b7e;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 50% -10%, #1f6e4a 0%, #0a3323 45%, #051910 100%) fixed;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

.boot {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    letter-spacing: 3px;
    font-size: 18px;
}

/* 顶栏 */
.app-header {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 24px;
    background: linear-gradient(180deg, rgba(4, 24, 16, 0.95), rgba(4, 24, 16, 0.72));
    border-bottom: 1px solid var(--panel-line);
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(8px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--gold);
    white-space: nowrap;
}

.logo .logo-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(160deg, #c0392b, #7b1f16);
    border: 1px solid rgba(231, 200, 115, 0.6);
    display: grid;
    place-items: center;
    font-size: 16px;
    color: #ffe9b0;
}

.nav {
    display: flex;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.nav a {
    padding: 8px 14px;
    border-radius: 9px;
    color: #cfe3d7;
    font-size: 14px;
    white-space: nowrap;
}

.nav a:hover { background: rgba(255, 255, 255, 0.07); }
.nav a.active { background: rgba(231, 200, 115, 0.16); color: var(--gold); }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.coin {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    background: radial-gradient(circle at 35% 30%, #ffe9a8, #c99a2e 70%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
}

.gold-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(231, 200, 115, 0.12);
    border: 1px solid rgba(231, 200, 115, 0.4);
    color: var(--gold);
    font-weight: 700;
    font-size: 14px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    font-size: 14px;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(160deg, #2e7d5b, #164a34);
    border: 1px solid rgba(231, 200, 115, 0.4);
    display: grid;
    place-items: center;
    font-size: 13px;
    color: #ffe9b0;
    flex-shrink: 0;
}

.avatar.big { width: 52px; height: 52px; font-size: 20px; }

/* 通用布局 */
.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 22px 20px 40px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 15px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 1px;
    margin-bottom: 14px;
}

.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.hidden { display: none !important; }

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: linear-gradient(180deg, #f3d78e, #cb9f37);
    color: #2a1d04;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
    white-space: nowrap;
}

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn.ghost {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(231, 200, 115, 0.45);
    color: var(--gold);
}

.btn.red { background: linear-gradient(180deg, #e05b4c, #a8281b); color: #fff4e6; }
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; }

/* 输入 */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: 0.5px; }

.input, select.input, textarea.input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.input:focus { border-color: rgba(231, 200, 115, 0.65); box-shadow: 0 0 0 3px rgba(231, 200, 115, 0.12); }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.7; }

/* 登录注册 */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
    gap: 20px;
    padding: 40px 7vw;
    position: relative;
    overflow: hidden;
}

.auth-deco {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.9;
}

.auth-deco .float-card {
    position: absolute;
    width: 96px;
    filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45));
    animation: floaty 7s ease-in-out infinite;
}

@keyframes floaty {
    0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); }
    50% { transform: translateY(-16px) rotate(var(--rot, 0deg)); }
}

.auth-hero { position: relative; z-index: 1; }
.auth-hero h1 {
    font-size: 46px;
    margin: 0 0 12px;
    letter-spacing: 6px;
    color: var(--gold);
    text-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.auth-hero p { color: #c6dccd; line-height: 1.9; max-width: 460px; font-size: 14px; }
.auth-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.auth-tags span {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    color: #ffe9b0;
    background: rgba(231, 200, 115, 0.1);
    border: 1px solid rgba(231, 200, 115, 0.35);
}

.auth-card { position: relative; z-index: 1; width: 100%; max-width: 420px; margin-left: auto; }
.auth-tabs { display: flex; gap: 6px; background: rgba(0, 0, 0, 0.24); border-radius: 12px; padding: 5px; margin-bottom: 20px; }
.auth-tabs button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
}
.auth-tabs button.active { background: rgba(231, 200, 115, 0.16); color: var(--gold); font-weight: 700; }

/* 大厅 */
.lobby-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 320px;
    gap: 16px;
    align-items: start;
}

.news-list .news-item { padding: 10px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.08); }
.news-list .news-item:last-child { border-bottom: none; }
.news-item h4 { margin: 0 0 6px; font-size: 13px; color: #ffe9b0; font-weight: 600; }
.news-item p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-line;
}

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}
.tabs button.active { border-color: rgba(231, 200, 115, 0.6); color: var(--gold); background: rgba(231, 200, 115, 0.1); }

.room-list { display: flex; flex-direction: column; gap: 8px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.room-row {
    display: grid;
    grid-template-columns: 1.4fr 80px 90px 1fr 82px;
    gap: 8px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
}
.room-row:hover { border-color: rgba(231, 200, 115, 0.35); background: rgba(255, 255, 255, 0.06); }
.room-row .room-name { font-weight: 600; color: #f4eee0; display: flex; align-items: center; gap: 6px; }
.room-row .lock { color: var(--gold); font-size: 11px; }
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.08);
    color: #d8e8de;
    white-space: nowrap;
}
.badge.playing { background: rgba(192, 57, 43, 0.24); color: #ffb6aa; }
.badge.waiting { background: rgba(76, 207, 138, 0.16); color: #93edc0; }
.badge.gold { background: rgba(231, 200, 115, 0.14); color: var(--gold); }

.quick-box .seg { display: flex; gap: 6px; margin-bottom: 12px; }
.quick-box .seg button {
    flex: 1;
    padding: 9px 0;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}
.quick-box .seg button.active { border-color: rgba(231, 200, 115, 0.6); color: var(--gold); background: rgba(231, 200, 115, 0.1); }

.stat-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.08); font-size: 13px; }
.stat-row:last-child { border-bottom: none; }
.stat-row b { color: #ffe9b0; }

/* 房间 */
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.room-head h2 { margin: 0; font-size: 22px; color: var(--gold); letter-spacing: 2px; }
.seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.seat {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.035);
    padding: 18px 14px;
    text-align: center;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.seat.occupied { border-color: rgba(231, 200, 115, 0.35); background: rgba(231, 200, 115, 0.06); }
.seat .avatar { width: 46px; height: 46px; font-size: 17px; }
.seat .seat-name { font-weight: 700; font-size: 15px; }
.seat .seat-gold { color: var(--gold); font-size: 13px; }
.seat .seat-tag { font-size: 11px; color: var(--muted); }
.seat.empty { border-style: dashed; color: var(--muted); font-size: 13px; }

.rule-list { font-size: 13px; color: var(--muted); line-height: 1.9; padding-left: 18px; margin: 0; }
.rule-list li::marker { color: var(--gold); }

/* 牌桌 */
.game-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 14px;
    padding: 14px 18px 18px;
    height: calc(100vh - 64px);
    min-height: 620px;
}

.game-main {
    position: relative;
    border-radius: 22px;
    border: 1px solid rgba(231, 200, 115, 0.28);
    background:
        radial-gradient(circle at 50% 42%, rgba(46, 160, 108, 0.4), transparent 62%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.014) 0 2px, transparent 2px 30px),
        linear-gradient(160deg, #217a53, #0c3f2b 58%, #072418);
    box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55), var(--shadow);
    display: flex;
    flex-direction: column;
    padding: 16px 18px;
    overflow: hidden;
}

.board-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: #d7eadf; }
.board-top .crumbs { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.board-top .chip {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.opponents { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; padding: 10px 0 4px; }
.opponent {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 168px;
}
.opponent.turn { border-color: rgba(255, 218, 126, 0.85); box-shadow: 0 0 0 2px rgba(255, 218, 126, 0.2), 0 0 22px rgba(255, 218, 126, 0.22); }
.opponent .op-name { font-size: 13px; font-weight: 600; }
.opponent .op-meta { font-size: 11px; color: var(--muted); }
.opponent .op-score { margin-left: auto; text-align: right; }
.opponent .op-score b { display: block; color: var(--gold); font-size: 17px; }

.op-hand { display: flex; }
.op-hand .mini-back { width: 20px; margin-left: -12px; }
.op-hand .mini-back:first-child { margin-left: 0; }

.board-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 26px;
    position: relative;
    min-height: 260px;
    padding: 10px 0;
}

.table-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 10px;
    max-width: 720px;
}

.table-card-wrap { transition: transform 0.15s ease; }
.table-card-wrap:hover { transform: translateY(-4px); }
.table-card-wrap.hidden-card { opacity: 0.85; }

.deck-area { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.deck-pile { position: relative; width: 72px; height: 100px; }
.deck-pile .card { position: absolute; inset: 0; }
.deck-pile .card:nth-child(2) { transform: translate(4px, -4px); }
.deck-pile .card:nth-child(3) { transform: translate(8px, -8px); }
.deck-count { font-size: 12px; color: var(--muted); }

/* 牌堆翻牌动画 */
.flip-anim { position: absolute; inset: 0; z-index: 30; perspective: 600px; pointer-events: none; animation: flipFade 0.35s ease 1.2s forwards; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: flipReveal 0.55s ease-in-out forwards; }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-front { transform: rotateY(180deg); }
@keyframes flipReveal { from { transform: rotateY(0deg); } to { transform: rotateY(180deg); } }
@keyframes flipFade { to { opacity: 0; } }

/* 机器人标识与聊天面板 */
.bot-tag { display: inline-block; margin-left: 5px; padding: 1px 6px; border-radius: 6px; font-size: 10px; color: #9fd8ff; background: rgba(80, 160, 220, 0.18); border: 1px solid rgba(80, 160, 220, 0.35); vertical-align: middle; }
.chat-panel { display: flex; flex-direction: column; }
.chat-list { height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.chat-msg .chat-nick { font-size: 11px; color: var(--muted); }
.chat-msg .chat-text { max-width: 100%; padding: 5px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); font-size: 13px; word-break: break-all; }
.chat-msg.me { align-items: flex-end; }
.chat-msg.me .chat-text { background: rgba(212, 175, 55, 0.25); color: #ffe9b0; }
.chat-input { display: flex; gap: 6px; margin-top: 8px; }
.chat-input input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.15); background: rgba(0, 0, 0, 0.25); color: #eaf5ee; font-size: 13px; outline: none; }
.chat-input input:focus { border-color: rgba(212, 175, 55, 0.5); }

/* 加倍选择 */
.mult-picker { margin: 14px 0 10px; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); border: 1px solid rgba(255, 255, 255, 0.08); }
.mult-title { font-size: 13px; color: #d7eadf; margin-bottom: 10px; }
.mult-title .small { margin-left: 8px; }
.mult-options { display: flex; gap: 8px; flex-wrap: wrap; }
.mult-btn { padding: 8px 18px; border-radius: 9px; border: 1px solid rgba(242, 217, 139, 0.35); background: transparent; color: #eaf5ee; font-size: 13px; cursor: pointer; transition: all 0.15s ease; }
.mult-btn:hover:not(:disabled) { border-color: rgba(242, 217, 139, 0.8); color: #ffe9b0; }
.mult-btn.active { background: linear-gradient(180deg, #f3d47c, #c99a2e); border-color: transparent; color: #2b1d05; font-weight: 700; }
.mult-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.seat-mult { margin-top: 4px; font-size: 11px; color: var(--muted); }
.seat-mult.on { color: #ffd873; font-weight: 700; }
.mult-tag { display: inline-block; font-style: normal; font-size: 10px; color: #ffb4a0; font-weight: 700; margin-left: 4px; }

.turn-banner {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    padding: 8px 20px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.48);
    border: 1px solid rgba(231, 200, 115, 0.45);
    font-size: 13px;
    color: #ffe9b0;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}
.turn-banner.mine { background: rgba(231, 200, 115, 0.18); box-shadow: 0 0 22px rgba(231, 200, 115, 0.25); }

.my-area { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 12px; }
.my-meta { display: flex; align-items: center; gap: 14px; font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.my-meta .score-num { color: var(--gold); font-size: 20px; font-weight: 800; }

.hand-row { display: flex; justify-content: center; align-items: flex-end; gap: 8px; min-height: 118px; flex-wrap: wrap; padding-bottom: 4px; }
.hand-card {
    width: 80px;
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease;
    position: relative;
}
.hand-card:hover { transform: translateY(-14px); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.45)); }
.hand-card.disabled { cursor: not-allowed; opacity: 0.6; }
.hand-card.disabled:hover { transform: none; }
.hand-card.playable::after {
    content: "可吃";
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 10px;
    background: #e7c873;
    color: #2a1d04;
    font-weight: 700;
}

.captured-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.captured-bar .cap-card { width: 34px; }

.game-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.side-panel { padding: 14px; }
.score-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 10px;
    font-size: 13px;
}
.score-line.turn { background: rgba(231, 200, 115, 0.12); }
.score-line .sl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-line .sl-score { color: var(--gold); font-weight: 700; }
.score-line .sl-gold { color: var(--muted); font-size: 11px; }

.log-box { flex: 1; overflow-y: auto; font-size: 12px; line-height: 1.8; color: #b8d2c4; min-height: 120px; }
.log-box div { padding: 3px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.05); }
.log-box div:last-child { color: #ffe9b0; }

/* 牌 */
.card { display: block; position: relative; width: 100%; height: auto; border-radius: 6px; overflow: hidden; }
.card svg { display: block; width: 100%; height: auto; }
.card-img-wrap { background: #fbf4e2; }
.card-img { display: block; width: 100%; height: auto; }
.card-point { position: absolute; top: 4px; right: 4px; background: rgba(43,33,23,0.88); color: #ffe08a; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; pointer-events: none; z-index: 2; }
.bonus-tag { display: block; font-style: normal; font-size: 10px; color: #ffd873; font-weight: 400; margin-top: 2px; }

/* 洗牌动画 */
.shuffle-overlay { position: fixed; inset: 0; z-index: 3000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: rgba(4, 22, 15, 0.85); backdrop-filter: blur(3px); transition: opacity 0.35s ease; pointer-events: none; }
.shuffle-overlay.fade { opacity: 0; pointer-events: none; }
.shuffle-stage { position: relative; width: 120px; height: 168px; }
.shuffle-card { position: absolute; left: 0; top: 0; width: 110px; opacity: 0; animation: shuffleIn 0.45s cubic-bezier(0.2, 0.7, 0.3, 1.1) forwards; }
.shuffle-card .card { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); }
.shuffle-overlay.deal .shuffle-stage { animation: shuffleSway 0.35s ease-in-out; }
.shuffle-text { color: #f2d98b; font-size: 15px; letter-spacing: 6px; font-weight: 700; }
@keyframes shuffleIn {
    0% { transform: translate(var(--from), -40px) rotate(var(--rot)); opacity: 0; }
    55% { opacity: 1; }
    100% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
}
@keyframes shuffleSway {
    0% { transform: translateX(0) rotate(0); }
    30% { transform: translateX(-8px) rotate(-4deg); }
    65% { transform: translateX(8px) rotate(4deg); }
    100% { transform: translateX(0) rotate(0); }
}

/* 结果 */
.result-head { text-align: center; margin-bottom: 14px; }
.result-head h2 { margin: 0 0 6px; font-size: 26px; color: var(--gold); letter-spacing: 3px; }
.result-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.result-line {
    display: grid;
    grid-template-columns: 34px 1fr 62px 90px;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 14px;
}
.result-line.win { background: rgba(231, 200, 115, 0.14); border: 1px solid rgba(231, 200, 115, 0.4); }
.result-line .rk { color: var(--muted); font-weight: 700; text-align: center; }
.result-line .rs { color: var(--gold); font-weight: 800; font-size: 17px; text-align: right; }
.result-line .rg { text-align: right; font-size: 13px; }
.result-line .rg.plus { color: var(--ok); }
.result-line .rg.minus { color: var(--danger); }

/* 会员中心 */
.member-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.profile-card { text-align: center; }
.profile-card .avatar.big { margin: 0 auto 12px; }
.profile-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.profile-gold { font-size: 32px; color: var(--gold); font-weight: 800; margin: 14px 0 2px; }
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.preset-row button {
    padding: 8px 14px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: #d9e9df;
    font-size: 13px;
    cursor: pointer;
}
.preset-row button.active { border-color: rgba(231, 200, 115, 0.7); color: var(--gold); background: rgba(231, 200, 115, 0.1); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 10px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.07); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.data tr:hover td { background: rgba(255, 255, 255, 0.03); }
table.data td.right { text-align: right; }
table.data td.center { text-align: center; }

.empty-tip { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }

/* 管理后台 */
.admin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { padding: 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07); }
.stat-card .k { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.stat-card .v { font-size: 24px; font-weight: 800; color: var(--gold); }

.admin-section { margin-bottom: 16px; }

/* 弹窗 */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(2, 12, 8, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
    padding: 20px;
    backdrop-filter: blur(3px);
}
.modal {
    width: 520px;
    max-width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    background: linear-gradient(170deg, #103a29, #082418);
    border: 1px solid rgba(231, 200, 115, 0.4);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal h3 { margin: 0 0 16px; color: var(--gold); font-size: 18px; letter-spacing: 1px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal.wide { width: 680px; }

/* 提示 */
#toast-layer { position: fixed; top: 78px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 13px;
    background: rgba(8, 34, 24, 0.95);
    border: 1px solid rgba(231, 200, 115, 0.45);
    color: #ffe9b0;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.2s ease;
}
.toast.err { border-color: rgba(255, 120, 105, 0.6); color: #ffb6aa; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.plus { color: var(--ok); }
.minus { color: var(--danger); }

.page.game-shell { max-width: none; padding: 14px 18px; }
.game-shell .game-page { height: calc(100vh - 64px - 28px); }

@media (max-width: 1080px) {
    .lobby-grid { grid-template-columns: 1fr; }
    .auth-page { grid-template-columns: 1fr; padding: 28px 20px; }
    .auth-card { margin: 0 auto; }
    .auth-hero h1 { font-size: 34px; }
    .game-page { grid-template-columns: 1fr; height: auto; }
    .game-shell .game-page { height: auto; min-height: 0; }
    .game-main { overflow: visible; }
    .game-side { flex-direction: row; }
    .game-side .side-panel { flex: 1; }
    .member-grid { grid-template-columns: 1fr; }
    .admin-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .app-header { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px 14px; }
    .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .nav a { padding: 6px 10px; font-size: 13px; }
}

@media (max-width: 720px) {
    .app-header { padding: 0 12px; gap: 10px; }
    .logo { font-size: 16px; letter-spacing: 1px; }
    .logo .logo-mark { width: 28px; height: 28px; }
    .nav a { padding: 7px 9px; font-size: 12px; }
    .user-chip span.uname { display: none; }
    .room-row { grid-template-columns: 1fr 62px 70px 70px; }
    .room-row .room-owner { display: none; }
    .game-main { padding: 12px; }
    .hand-card { width: 62px; }
    .table-grid { gap: 7px; }
    .game-side { flex-direction: column; }
}

/* 手机横屏：牌桌压缩为单屏，不出滚动条 */
@media (orientation: landscape) and (max-height: 560px) {
    .app-header {
        height: 42px;
        flex-wrap: nowrap;
        gap: 10px;
        padding: 0 10px;
    }
    .logo { font-size: 13px; letter-spacing: 1px; gap: 6px; }
    .logo .logo-mark { width: 20px; height: 20px; font-size: 11px; border-radius: 6px; }
    .nav { order: 0; flex: 1; flex-basis: auto; }
    .nav a { padding: 4px 8px; font-size: 11px; }
    .header-right { gap: 8px; }
    .gold-pill { padding: 3px 8px; font-size: 12px; }
    .user-chip span.uname { display: none; }
    .header-right .btn { padding: 4px 8px; font-size: 11px; }

    .page.game-shell { max-width: none; padding: 6px 8px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
    .game-shell .game-page {
        grid-template-columns: minmax(0, 1fr) 208px;
        gap: 8px;
        height: calc(100vh - 54px);
        height: calc(100dvh - 54px);
        min-height: 0;
        padding: 0;
    }

    .game-main { padding: 8px 10px; border-radius: 14px; overflow: hidden; }
    .board-top { font-size: 10px; gap: 6px; }
    .board-top .chip { padding: 2px 7px; }
    .opponents { gap: 8px; padding: 4px 0 2px; flex-wrap: nowrap; overflow-x: auto; }
    .opponent { min-width: 0; padding: 4px 9px; gap: 7px; border-radius: 10px; flex-shrink: 0; }
    .opponent .avatar { width: 26px; height: 26px; font-size: 11px; }
    .opponent .op-name { font-size: 11px; }
    .opponent .op-meta { font-size: 10px; }
    .opponent .op-score b { font-size: 13px; }
    .op-hand { display: none; }

    .board-center { gap: 12px; min-height: 0; padding: 2px 0; }
    .table-grid { gap: 5px; max-width: 100%; }
    .table-grid .table-card-wrap { width: 44px !important; }
    .deck-pile { width: 44px; height: 61px; }
    .deck-count { font-size: 10px; }
    .turn-banner { font-size: 11px; padding: 4px 12px; bottom: 2px; }

    .my-area { padding-top: 6px; }
    .my-meta { font-size: 11px; gap: 8px; margin-bottom: 4px; }
    .my-meta .score-num { font-size: 15px; }
    .my-meta .avatar { width: 22px; height: 22px; font-size: 11px; }
    .hand-row {
        gap: 3px;
        min-height: 0;
        flex-wrap: nowrap;
        justify-content: center;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 2px;
    }
    .hand-card {
        flex: 0 0 auto;
        width: clamp(30px, calc((100vw - 268px) / 10 - 3px), 52px);
        touch-action: manipulation;
    }
    .hand-card:hover { transform: none; filter: none; }
    .hand-card.playable { filter: drop-shadow(0 0 6px rgba(231, 200, 115, 0.85)); }
    .hand-card.playable::after { top: -5px; padding: 0 4px; font-size: 9px; }
    .captured-bar { font-size: 10px; }
    .captured-bar .cap-card { width: 24px; }

    .game-side { flex-direction: column; gap: 6px; overflow-y: auto; }
    .game-side > .side-panel { flex: 0 0 auto; }
    .side-panel { padding: 7px 9px; }
    .panel-title { font-size: 11px; margin-bottom: 4px; }
    .score-line { padding: 4px 5px; gap: 6px; font-size: 11px; }
    .score-line .avatar { width: 20px; height: 20px; font-size: 10px; }
    .score-line .sl-gold { font-size: 10px; }
    .score-line .sl-score { font-size: 11px; }
    .bonus-tag { font-size: 9px; }
    .chat-panel { flex: 0 0 auto; }
    .chat-list { height: 92px; flex: none; font-size: 11px; gap: 4px; }
    .chat-msg .chat-nick { font-size: 10px; }
    .chat-msg .chat-text { font-size: 11px; padding: 3px 8px; }
    .chat-input { margin-top: 5px; }
    .chat-input input { padding: 5px 8px; font-size: 11px; }
    .chat-input .btn { padding: 5px 9px; font-size: 11px; }
    .log-box { min-height: 0; font-size: 11px; line-height: 1.6; }
}

/* 更矮的横屏（如 568×320、640×360）：进一步让位给牌桌 */
@media (orientation: landscape) and (max-height: 400px) {
    .game-shell .game-page { grid-template-columns: minmax(0, 1fr) 176px; }
    .game-side > .panel:nth-child(3) { display: none; }
    .chat-list { height: 66px; }
    .board-top > .crumbs:last-child { display: none; }
    .my-meta { margin-bottom: 2px; }
    .table-grid .table-card-wrap { width: 40px !important; }
    .deck-pile { width: 40px; height: 55px; }
}
