/* style.css - 棋艺小精灵样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

:root {
    --bg-dark: #1a1d2e;
    --bg-darker: #14162a;
    --bg-card: #252840;
    --bg-card-hover: #2d3050;
    --text-primary: #e8eaf6;
    --text-secondary: #9fa8da;
    --text-muted: #5c6bc0;
    --accent-red: #ef5350;
    --accent-green: #66bb6a;
    --accent-gold: #ffd54f;
    --accent-blue: #42a5f5;
    --accent-purple: #ab47bc;
    --card-white: #f5f5f5;
    --card-red: #e53935;
    --card-black: #1a1a2e;
    --border-color: #3d4068;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
    --radius: 10px;
}

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    /* 移动端：去掉点击高亮与双击缩放延迟 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* 菜单 / 联机 / 结算 界面在窄屏上允许纵向滚动 */
#menu-screen, #online-screen, #end-screen {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: block;
}

/* ============ 菜单界面 ============ */
#menu-screen {
    display: none;
    background: linear-gradient(135deg, #1a1d2e 0%, #1e3a5f 50%, #2a1f3d 100%);
    align-items: center;
    justify-content: center;
}

#menu-screen.active {
    display: flex;
}

.menu-container {
    text-align: center;
    max-width: 600px;
    width: 90%;
    padding: 40px;
}

.game-title {
    font-size: 64px;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd54f, #ff7043, #ab47bc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: 8px;
    text-shadow: 0 0 40px rgba(255, 213, 79, 0.3);
}

.game-subtitle {
    color: var(--text-muted);
    font-size: 18px;
    margin-bottom: 50px;
    letter-spacing: 2px;
}

.menu-section {
    margin-bottom: 35px;
}

.menu-section h3 {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.btn-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn, .difficulty-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 18px 28px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 16px;
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

.mode-btn:hover, .difficulty-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.mode-btn.active, .difficulty-btn.active {
    background: linear-gradient(135deg, #3949ab, #5c6bc0);
    border-color: var(--accent-blue);
    box-shadow: 0 4px 15px rgba(66, 165, 245, 0.3);
}

.mode-desc, .diff-desc {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 4px;
}

.start-btn {
    background: linear-gradient(135deg, #ff7043, #f4511e);
    color: white;
    border: none;
    padding: 18px 60px;
    border-radius: var(--radius);
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
    letter-spacing: 4px;
    box-shadow: 0 8px 25px rgba(244, 81, 30, 0.4);
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(244, 81, 30, 0.5);
}

/* ============ 游戏界面 ============ */
#game-screen {
    background: radial-gradient(ellipse at center, #1e2a45 0%, #14162a 70%);
}

.game-board {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
}

/* 顶部信息栏 */
.top-bar {
    padding: 8px 24px;
    background: rgba(0, 0, 0, 0.3);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.game-info {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 1px;
}

/* 上方玩家区域 */
.top-players {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    padding: 16px 24px;
    flex: 1;
    position: relative;
}

.player-area {
    position: relative;
    min-width: 210px;
}

/* 两侧 AI 在各自这一行里上下居中，中间的中央出牌区撑满剩余高度 */
.player-left, .player-right {
    align-self: center;
}

/* 两侧 AI 打出的牌挂在这块内容的下方（不占高度）：
   既不参与居中计算（不会把头像顶偏），出牌张数变化也不会让这块内容移动 */
.player-left .played-cards,
.player-right .played-cards {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    /* 万一出现超长牌型，不要整条拉到画面外（完整牌型牌桌中央也会显示） */
    max-height: 180px;
    overflow: hidden;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.player-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.player-role {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.role-landlord {
    background: linear-gradient(135deg, #ff7043, #f4511e);
    color: white;
}

.role-farmer {
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: white;
}

.card-count {
    color: var(--accent-gold);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.player-area.current-turn {
    /* 高亮当前出牌玩家 */
}

.player-area.current-turn .player-header {
    animation: glow 1.5s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 5px rgba(255, 213, 79, 0.5); }
    50% { text-shadow: 0 0 20px rgba(255, 213, 79, 0.8); }
}

.player-area.thinking::after {
    content: '思考中...';
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--accent-blue);
    font-size: 12px;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* AI 牌背：每行固定 10 张自动换行 */
/* 农民 17 张：第一行 10 张、第二行 7 张 */
/* 地主 20 张：两行各 10 张 */
/* 列宽 14px + 牌宽 36px → 每张露出 14px，形成扇形叠放 */
.ai-cards {
    display: grid;
    grid-template-columns: repeat(10, 14px);
    column-gap: 0;
    row-gap: 6px;
    padding: 2px 0;
    width: 162px;
    max-width: 162px;
    /* 预留两行牌背的高度：AI 手牌减少到一行时整块不会跟着塌下去 */
    min-height: 110px;
}

/* 牌背比列宽大，逐张右移覆盖，形成叠放效果 */
.ai-cards .card-back {
    width: 36px;
    height: 52px;
    margin-right: 0;
    background: linear-gradient(135deg, #3949ab, #1a237e);
    border: 1px solid #5c6bc0;
    border-radius: 4px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}

/* 每行最后一张不要负margin，避免被隐藏 */
.ai-cards .card-back:nth-child(10n) {
    margin-right: 0;
}

/* 通用牌背(底牌等) */
.card-back {
    display: inline-block;
    background: linear-gradient(135deg, #3949ab, #1a237e);
    border: 1px solid #5c6bc0;
    border-radius: 4px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.card-back.small-card {
    width: 36px;
    height: 52px;
}

/* 出牌区域：撑满上下两个玩家之间的高度，内容垂直居中 */
.center-play-area {
    flex: 1;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    position: relative;
    z-index: 0;
}

/* 中央"牌桌"底纹，避免中间出现大片空白 */
.center-play-area::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92%, 440px);
    height: min(38%, 240px);
    border-radius: 50%;
    background: radial-gradient(ellipse at center,
        rgba(255, 255, 255, 0.07) 0%,
        rgba(255, 255, 255, 0.02) 55%,
        rgba(255, 255, 255, 0) 78%);
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.05);
    pointer-events: none;
    z-index: -1;
}

/* 底牌固定显示在牌桌上方正中，出牌内容在牌桌中央 */
#center-bottom-cards {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin-bottom: 0;
}

.center-played {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.play-label {
    font-size: 13px;
    color: var(--accent-gold);
    font-weight: 600;
}

.play-cards-row {
    display: flex;
    gap: 0;
    /* 长顺子/连对放不下时折行，避免溢出到两侧玩家区或产生横向滚动 */
    flex-wrap: wrap;
    row-gap: 4px;
    justify-content: center;
    align-items: center;
}

/* 出牌区内的多张牌：紧贴重叠 */
.play-cards-row .card.small-card {
    margin-right: -18px;
    box-shadow: -1px 2px 4px rgba(0,0,0,0.4);
}

.play-cards-row .card.small-card:last-child {
    margin-right: 0;
}

.card.card-back.small-card {
    width: 36px;
    height: 52px;
    background: linear-gradient(135deg, #3949ab, #1a237e);
    border: 1px solid #5c6bc0;
    border-radius: 4px;
}

.card.card-back.small-card::after {
    width: 16px;
    height: 16px;
}

.played-cards .card.played-card {
    width: 40px;
    height: 56px;
    margin-right: -10px;
}

.played-cards .card.played-card .card-rank {
    font-size: 16px;
}

.played-cards .card.played-card .card-suit-top,
.played-cards .card.played-card .card-suit-bottom {
    font-size: 11px;
}

.bottom-cards {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.bottom-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 4px;
}

.played-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    align-items: center;
    min-height: 80px;
    padding: 8px;
}

.pass-indicator {
    color: var(--accent-red);
    font-size: 20px;
    font-weight: 700;
    padding: 10px 24px;
    border: 2px dashed var(--accent-red);
    border-radius: 8px;
    opacity: 0.85;
}

/* 中央临时动作提示（出牌/不出） */
.action-toast {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    margin-top: 8px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.action-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ============ 卡牌样式 ============ */
.card {
    width: 56px;
    height: 80px;
    background: var(--card-white);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
    overflow: hidden;
}

.card.small-card {
    width: 36px;
    height: 52px;
}

.card.small-card .card-rank {
    font-size: 14px;
}

.card.small-card .card-suit-top,
.card.small-card .card-suit-bottom {
    font-size: 10px;
}

.card.red-card {
    color: var(--card-red);
}

.card.black-card {
    color: var(--card-black);
}

.card-suit-top {
    position: absolute;
    top: 4px;
    left: 5px;
    font-size: 16px;
}

.card-rank {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.card-suit-bottom {
    position: absolute;
    bottom: 4px;
    right: 5px;
    font-size: 16px;
    transform: rotate(180deg);
}

.card.big-joker {
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    color: var(--card-red);
}

.card.small-joker {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    color: var(--card-black);
}

.joker-text {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.card.card-back {
    background: linear-gradient(135deg, #3949ab, #1a237e);
    border: 2px solid #5c6bc0;
}

.card.card-back * {
    display: none;
}

.card.card-back::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: radial-gradient(circle, #7986cb, #3949ab);
    border-radius: 50%;
    border: 2px solid #9fa8da;
}

/* ============ 手牌区域 ============ */
.bottom-player {
    /* 操作栏的高度：底部始终留出这么大的空位，按钮出现时手牌不再上移 */
    --controls-h: 74px;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    padding: 0 24px calc(8px + var(--controls-h));
    gap: 16px;
    flex-wrap: wrap;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
    position: relative;
}

/* ============ 玩家头像 ============ */
.player-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a3142, #3d4660);
    border: 2px solid var(--accent-gold, #ffd54f);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.player-avatar.current-turn {
    box-shadow: 0 0 0 3px var(--accent-gold, #ffd54f),
                0 0 16px rgba(255, 213, 79, 0.6);
    animation: avatarPulse 1.2s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

/* 顶部玩家头像小一些 */
.player-left .player-avatar,
.player-right .player-avatar {
    width: 40px;
    height: 40px;
    font-size: 22px;
}

.player-left .player-header,
.player-right .player-header {
    flex-direction: column;
    gap: 4px;
}

.player-left .player-info,
.player-right .player-info {
    align-items: center;
}

/* ============ 菜单头像选择（折叠式） ============ */
.avatar-section {
    margin-bottom: 24px;
}

/* 折叠状态下的切换按钮：当前头像 + 提示 + 箭头 */
.avatar-toggle {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 213, 79, 0.25);
    border-radius: 14px;
    padding: 10px 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
    width: 100%;
    box-sizing: border-box;
}

.avatar-toggle:hover {
    background: rgba(255, 213, 79, 0.08);
    border-color: rgba(255, 213, 79, 0.5);
    transform: translateY(-1px);
}

.avatar-toggle.open {
    border-color: var(--accent-gold, #ffd54f);
    background: rgba(255, 213, 79, 0.06);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.avatar-current {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a3142, #3d4660);
    border: 2px solid var(--accent-gold, #ffd54f);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(255, 213, 79, 0.35);
}

.avatar-current img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-info {
    flex: 1;
    text-align: left;
}

.avatar-label {
    color: var(--text-primary, #fff);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
}

.avatar-hint {
    color: var(--text-muted, #9aa3b2);
    font-size: 12px;
    margin-top: 2px;
}

.avatar-arrow {
    color: var(--accent-gold, #ffd54f);
    font-size: 18px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.avatar-toggle.open .avatar-arrow {
    transform: rotate(180deg);
}

/* 展开的面板：默认隐藏 */
.avatar-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
    opacity: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--accent-gold, #ffd54f);
    border-top: none;
    border-radius: 0 0 14px 14px;
    width: 100%;
    box-sizing: border-box;
    padding: 0 14px;
}

.avatar-panel.open {
    max-height: 280px;
    opacity: 1;
    padding: 14px;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.avatar-option {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a3142, #3d4660);
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
    padding: 0;
    margin: 0 auto;
}

.avatar-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 213, 79, 0.6);
}

.avatar-option.selected {
    border-color: var(--accent-gold, #ffd54f);
    box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.4),
                0 0 12px rgba(255, 213, 79, 0.6);
    transform: scale(1.08);
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-upload-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.avatar-upload-btn {
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 213, 79, 0.4);
    border-radius: 6px;
    color: var(--text-primary, #fff);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    display: inline-block;
}

.avatar-upload-btn:hover {
    background: rgba(255, 213, 79, 0.15);
    border-color: var(--accent-gold, #ffd54f);
}

/* ============ 折叠选项行：游戏特色 + 头像 同一水平线 ============ */
.menu-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* 行内每个区块等宽、可换行 */
.menu-row > .menu-section {
    flex: 1 1 240px;
    min-width: 220px;
    margin-bottom: 0;
}

/* ---- 游戏特色：折叠按钮 ---- */
/* 首页暂时不展示「游戏特色」折叠块，删掉 display:none 即可恢复 */
.features-section {
    margin-bottom: 0;
    display: none;
}

.features-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 213, 79, 0.25);
    border-radius: 14px;
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
    width: 100%;
    box-sizing: border-box;
}

.features-toggle:hover {
    background: rgba(255, 213, 79, 0.08);
    border-color: rgba(255, 213, 79, 0.5);
    transform: translateY(-1px);
}

.features-toggle.open {
    border-color: var(--accent-gold, #ffd54f);
    background: rgba(255, 213, 79, 0.06);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.features-toggle .feature-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: auto;
}

.features-toggle-label {
    flex: 1;
    text-align: left;
    color: var(--text-primary, #fff);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
}

.features-arrow {
    color: var(--accent-gold, #ffd54f);
    font-size: 18px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.features-toggle.open .features-arrow {
    transform: rotate(180deg);
}

/* 展开的特色列表面板 */
.features-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
    opacity: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--accent-gold, #ffd54f);
    border-top: none;
    border-radius: 0 0 14px 14px;
    width: 100%;
    box-sizing: border-box;
    padding: 0 14px;
}

.features-panel.open {
    max-height: 320px;
    opacity: 1;
    padding: 14px;
}

.features-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.features-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: var(--text-secondary, #cfd2dc);
    font-size: 13px;
    letter-spacing: 0.5px;
    text-align: left;
    transition: all 0.2s ease;
}

.features-list li:hover {
    background: rgba(255, 213, 79, 0.06);
    border-color: rgba(255, 213, 79, 0.3);
    transform: translateX(2px);
}

.features-list .feature-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.player-bottom {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
    min-width: 110px;
    flex-shrink: 0;
}

/* 底部玩家的 header 水平排列：头像 + 名字身份 在同一行 */
.player-bottom .player-header {
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.player-bottom .player-info {
    align-items: flex-start;
    gap: 2px;
}

.player-bottom .card-count {
    /* 排在头像右侧，与手牌同一水平线 */
    padding-bottom: 4px;
}

.hand-area {
    /* 与各断点下 .card 的实际宽度保持一致，供 CSS 计算重叠量：
       >768px 56px / <=768px 50px / <=359px 44px / 横屏 40px */
    --card-w: 56px;
    /* 选中牌上浮高度：要大到把「花色 + 点数」整块抬到相邻牌上边缘之上 */
    --card-lift: 36px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    flex-wrap: nowrap;
    /* 张数再多也自动重叠铺满一行，不需要左右滑动。
       用 clip 而不是 hidden：clip 不会纵向裁掉选中牌抬起的那一段，
       也不支持横向滚动；不支持 clip 的老浏览器会退回上面的 hidden。 */
    overflow-x: hidden;
    overflow-x: clip;
    overflow-y: visible;
    padding: 32px 12px 12px;
    flex: 1;
    min-width: 0;
    min-height: 120px;
}

.hand-area .card {
    transition: transform 0.18s ease, box-shadow 0.18s ease, margin 0.18s ease;
}

/* 最后一张牌保留正常间距 */
.hand-area .card:last-child {
    margin-right: 0;
}

/* many-cards 时最后一张牌也按比例回收一点 */
.hand-area.many-cards .card:last-child {
    margin-right: 0;
}

/* hover 与 selected 状态：弹出到原位并上移 */
.hand-area .card:hover {
    margin-right: 4px;
    transform: translateY(-10px);
    z-index: 10;
}

.hand-area .card.selected {
    margin-right: 4px;
    transform: translateY(-22px);
    box-shadow: 0 4px 20px rgba(255, 213, 79, 0.55);
    border: 2px solid var(--accent-gold);
    z-index: 5;
}

.hand-area .card.selected:hover {
    transform: translateY(-26px);
}

.hand-area .card.hint {
    animation: hintPulse 0.8s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
    50% { box-shadow: 0 2px 20px rgba(102, 165, 245, 0.7); }
}

/* ============ 操作栏 ============ */
.action-bar, .bidding-bar, .openhand-bar {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    flex-basis: 100%;
    width: 100%;
    /* 叠在 .bottom-player 底部预留出的空位里（高度由 --controls-h 预留）：
       出现/消失都不参与排版，手牌不会被它挤得上下移动 */
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    z-index: 20;
}

.action-btn {
    padding: 12px 32px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.6);
    transform: none !important;
    box-shadow: none !important;
}

.play-btn {
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: white;
}

.play-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 187, 106, 0.4);
}

.pass-btn {
    background: linear-gradient(135deg, #78909c, #546e7a);
    color: white;
}

.pass-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(120, 144, 156, 0.4);
}

.hint-btn {
    background: linear-gradient(135deg, #42a5f5, #1e88e5);
    color: white;
}

.hint-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(66, 165, 245, 0.4);
}

/* ============ 叫分栏 ============ */
.bidding-info {
    color: var(--accent-gold);
    font-size: 16px;
    font-weight: 600;
    margin-right: 16px;
}

.bid-buttons {
    display: flex;
    gap: 10px;
}

.bid-btn {
    padding: 10px 24px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.bid-btn:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.bid-btn:disabled, .bid-btn.disabled-btn {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ============ 结束界面 ============ */
#end-screen {
    display: none;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
}

#end-screen.active {
    display: flex;
}

.end-container {
    text-align: center;
    background: var(--bg-card);
    padding: 50px 60px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    animation: endAppear 0.5s ease;
}

@keyframes endAppear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

#end-title {
    font-size: 48px;
    font-weight: 900;
    margin-bottom: 16px;
    letter-spacing: 6px;
}

#end-title.win {
    color: var(--accent-gold);
    text-shadow: 0 0 30px rgba(255, 213, 79, 0.5);
}

#end-title.lose {
    color: var(--accent-red);
}

#end-detail {
    color: var(--text-secondary);
    font-size: 18px;
    margin-bottom: 8px;
}

.spring-text {
    color: var(--accent-gold);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.end-scores {
    margin: 20px 0;
    padding: 16px 32px;
    background: var(--bg-darker);
    border-radius: var(--radius);
}

#end-score {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.end-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

/* ============ Toast ============ */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 16px 32px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    border: 1px solid var(--border-color);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* 首页居中提示会压住房间号输入框，改为偏上显示 */
#menu-screen.active ~ #toast {
    top: 22%;
}

/* 滚动条 */
.hand-area::-webkit-scrollbar {
    height: 6px;
}

.hand-area::-webkit-scrollbar-track {
    background: transparent;
}

.hand-area::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* ============ 顶部栏增强 ============ */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    position: relative;
}

.top-bar-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.top-bar-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
}

#btn-history { right: 12px; }
#btn-sound { right: 72px; }
#btn-sound.sound-off { opacity: 0.4; text-decoration: line-through; }

/* ============ 倍数显示 ============ */
.multiplier-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
}

.mult-total {
    background: linear-gradient(135deg, #ff7043, #f4511e);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
}

.mult-breakdown {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============ 倒计时条 ============ */
.timer-bar {
    display: none;
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.timer-bar.active {
    display: block;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #66bb6a, #42a5f5);
    transition: width 1s linear;
    border-radius: 2px;
}

.timer-bar.urgent .timer-fill {
    background: linear-gradient(90deg, #ef5350, #ff7043);
    animation: timerPulse 0.5s ease-in-out infinite;
}

.timer-text {
    position: absolute;
    right: 8px;
    top: -18px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

.timer-bar.urgent .timer-text {
    color: var(--accent-red);
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============ 明牌选择栏 ============ */
.openhand-bar {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
}

.openhand-info {
    color: var(--accent-gold);
    font-size: 16px;
    font-weight: 600;
}

.openhand-buttons {
    display: flex;
    gap: 10px;
}

/* 明牌标识 */
.openhand-badge {
    background: linear-gradient(135deg, #ffd54f, #ff9800);
    color: #1a1a2e;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    margin-top: 8px;
    animation: badgeGlow 1.5s ease-in-out infinite;
}

@keyframes badgeGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 213, 79, 0.4); }
    50% { box-shadow: 0 0 20px rgba(255, 213, 79, 0.8); }
}

/* 明牌时AI手牌 */
.open-hand-card {
    width: 24px !important;
    height: 34px !important;
    margin-right: -14px !important;
    border-radius: 3px !important;
}

.open-hand-card .card-rank {
    font-size: 11px !important;
}

.open-hand-card .card-suit-top,
.open-hand-card .card-suit-bottom {
    font-size: 8px !important;
}

/* 中央消息提示 */
.center-message {
    color: var(--accent-gold);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.5s ease;
}

/* ============ 洗牌动画 ============ */
.shuffle-deck {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 130px;
    position: relative;
    perspective: 600px;
}

.shuffle-card {
    position: absolute;
    width: 60px;
    height: 88px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%);
    border: 2px solid #5c6bc0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5),
                inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: rgba(255, 255, 255, 0.4);
    backface-visibility: hidden;
    animation: shuffleFly 1.1s ease-in-out infinite;
}

/* 5 张牌错开时间，模拟连续翻飞 */
.shuffle-card:nth-child(1) { animation-delay: 0s; }
.shuffle-card:nth-child(2) { animation-delay: 0.12s; }
.shuffle-card:nth-child(3) { animation-delay: 0.24s; }
.shuffle-card:nth-child(4) { animation-delay: 0.36s; }
.shuffle-card:nth-child(5) { animation-delay: 0.48s; }

@keyframes shuffleFly {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 0.7;
        z-index: 1;
    }
    20% {
        transform: translate(-50px, -40px) rotate(-180deg) scale(1.05);
        opacity: 1;
        z-index: 5;
    }
    50% {
        transform: translate(0, 0) rotate(-360deg) scale(1);
        opacity: 0.9;
        z-index: 3;
    }
    80% {
        transform: translate(50px, -40px) rotate(-540deg) scale(1.05);
        opacity: 1;
        z-index: 5;
    }
    100% {
        transform: translate(0, 0) rotate(-720deg) scale(1);
        opacity: 0.7;
        z-index: 1;
    }
}

.shuffle-label {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--accent-gold, #ffd54f);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 4px;
    text-shadow: 0 0 12px rgba(255, 213, 79, 0.5);
    animation: shuffleText 1.1s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes shuffleText {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ============ 出牌飞入动画 ============ */
.played-card.fly-in {
    animation: flyIn 0.4s ease forwards;
    opacity: 0;
}

@keyframes flyIn {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.6);
    }
    60% {
        opacity: 1;
        transform: translateY(4px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============ 出牌历史面板 ============ */
.history-panel {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    width: 320px;
    max-height: 80vh;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px 0 0 10px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    z-index: 100;
    overflow-y: auto;
    flex-direction: column;
}

.history-panel.show {
    display: flex;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.history-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
}

.history-close:hover {
    color: var(--accent-red);
}

/* 记牌器 */
.card-counter-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.counter-title {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.counter-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.counter-cell {
    text-align: center;
    padding: 4px 2px;
    background: var(--bg-darker);
    border-radius: 4px;
    border: 1px solid transparent;
}

.counter-cell.gone {
    opacity: 0.3;
}

.counter-cell.full {
    border-color: var(--accent-green);
}

.counter-point {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.counter-remaining {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
}

.counter-cell.gone .counter-remaining {
    color: var(--accent-red);
}

/* 出牌历史列表 */
.history-list {
    padding: 8px 16px;
    overflow-y: auto;
    flex: 1;
}

.history-list-title {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

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

.history-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 12px;
}

.hist-player {
    color: var(--accent-blue);
    font-weight: 600;
    min-width: 50px;
}

.hist-cards {
    color: var(--text-primary);
    flex: 1;
    word-break: break-all;
}

.hist-type {
    color: var(--accent-gold);
    font-size: 11px;
}

.pass-entry .hist-action {
    color: var(--accent-red);
    font-style: italic;
}

/* ============ 结束界面增强 ============ */
.end-multiplier {
    margin: 12px 0;
    padding: 12px 20px;
    background: var(--bg-darker);
    border-radius: var(--radius);
}

.mult-detail-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.mult-detail-item {
    background: var(--bg-card);
    color: var(--accent-gold);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

.mult-detail-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-red);
    text-align: center;
}

.end-total-score {
    color: var(--text-muted) !important;
    font-size: 16px !important;
    margin-top: 8px;
}

/* 结束界面剩余手牌 */
.end-hands {
    margin: 16px 0;
    max-height: 300px;
    overflow-y: auto;
}

.end-hands-title {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: center;
}

.end-hand-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg-darker);
    border-radius: 8px;
    flex-wrap: wrap;
}

.end-hand-row.winner-row {
    border: 2px solid var(--accent-gold);
    background: rgba(255, 213, 79, 0.1);
}

.end-hand-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    padding-top: 2px;
}

.end-hand-role {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.end-hand-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
    flex: 1;
}

.end-card {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    background: var(--card-white);
}

.end-card.red-card { color: var(--card-red); }
.end-card.black-card { color: var(--card-black); }

.end-hand-count {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 4px;
}

.all-played {
    color: var(--accent-gold);
    font-weight: 700;
    font-size: 14px;
}

/* 结束界面适配小屏 */
.end-container {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ==================== 联机模式样式 ==================== */

/* 联机大厅容器 */
.online-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

.online-title {
    font-size: 32px;
    color: var(--text-primary);
    margin-bottom: 24px;
    letter-spacing: 4px;
}

/* 创建/加入选择 */
.online-choice {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.online-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.online-action-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.online-action-icon {
    font-size: 40px;
}

.online-action-label {
    font-size: 18px;
    font-weight: 700;
}

.online-action-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 加入房间输入 */
.room-code-input {
    width: 200px;
    padding: 16px;
    font-size: 36px;
    font-weight: 800;
    text-align: center;
    letter-spacing: 12px;
    text-transform: uppercase;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    outline: none;
}

.room-code-input:focus {
    border-color: var(--accent-blue);
}

/* 房间大厅 */
.online-lobby {
    text-align: center;
}

.lobby-room-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.lobby-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.lobby-code {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--accent-gold);
    background: var(--bg-card);
    padding: 8px 24px;
    border-radius: var(--radius);
    border: 2px solid var(--accent-gold);
}

.copy-btn {
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.copy-btn:hover {
    background: var(--bg-card-hover);
}

.copy-btn.copied {
    color: var(--accent-green);
    border-color: var(--accent-green);
}

.lobby-server-info {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 20px;
}

.online-lobby h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 16px;
}

.lobby-players {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.lobby-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.lobby-player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: var(--bg-darker);
}

.lobby-player-info {
    flex: 1;
    text-align: left;
}

.lobby-player-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.lobby-player-tag {
    font-size: 12px;
    color: var(--text-muted);
}

.lobby-player-status {
    font-size: 13px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 6px;
}

.lobby-player-status.ready {
    color: var(--accent-green);
    background: rgba(102, 187, 106, 0.15);
}

.lobby-player-status.waiting {
    color: var(--text-muted);
    background: rgba(92, 107, 192, 0.15);
}

.lobby-player-status.empty {
    color: var(--text-muted);
    background: transparent;
}

/* AI 难度选择器 */
.lobby-ai-difficulty {
    margin: 16px 0;
    padding: 12px 16px;
    background: rgba(92, 107, 192, 0.1);
    border-radius: 10px;
}

.lobby-ai-difficulty h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.lobby-difficulty-group {
    display: flex;
    gap: 8px;
}

.lobby-difficulty-btn {
    flex: 1;
    padding: 8px 4px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.lobby-difficulty-btn:hover {
    background: var(--bg-card-hover);
}

.lobby-difficulty-btn.active {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(255, 213, 79, 0.1);
}

.lobby-difficulty-btn .diff-desc {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

.lobby-btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.back-menu-btn {
    display: block;
    margin: 24px auto 0;
    padding: 8px 24px;
    font-size: 14px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.back-menu-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* 联机等待提示 */
.online-waiting-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 32px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 16px;
    z-index: 9999;
    text-align: center;
}

.online-waiting-toast .dots {
    display: inline-block;
    animation: dotsPulse 1.4s infinite;
}

@keyframes dotsPulse {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* 联机断线提示 */
.online-disconnect-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: var(--accent-red);
    color: white;
    text-align: center;
    font-size: 14px;
    z-index: 10000;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ==================== 聊天系统 ==================== */

/* --- 聊天气泡（玩家头像上方） --- */
.chat-bubble {
    position: absolute;
    background: #fff;
    border: 2px solid #4a90d9;
    border-radius: 12px;
    padding: 6px 14px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    max-width: 200px;
    text-overflow: ellipsis;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.chat-bubble.show {
    opacity: 1;
    animation: bubblePop 0.3s ease;
}

.chat-bubble.emoji {
    font-size: 32px;
    padding: 4px 8px;
    border-color: #f0a040;
}

/* 气泡小箭头 */
.chat-bubble::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

/* player-0 (底部) 气泡在上方 */
#player-0 .chat-bubble {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    margin-bottom: 4px;
}
#player-0 .chat-bubble::after {
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-top-color: #4a90d9;
}

/* player-1 (右侧) 气泡在左上方 */
#player-1 .chat-bubble {
    bottom: 100%;
    right: 0;
    transform: translateY(-8px);
    margin-bottom: 4px;
}
#player-1 .chat-bubble::after {
    top: 100%;
    right: 20px;
    border-top-color: #4a90d9;
}

/* player-2 (左侧) 气泡在右上方 */
#player-2 .chat-bubble {
    bottom: 100%;
    left: 0;
    transform: translateY(-8px);
    margin-bottom: 4px;
}
#player-2 .chat-bubble::after {
    top: 100%;
    left: 20px;
    border-top-color: #4a90d9;
}

@keyframes bubblePop {
    0% { transform: scale(0.5) translateY(0); opacity: 0; }
    50% { transform: scale(1.1) translateY(-4px); opacity: 1; }
    100% { transform: scale(1) translateY(-8px); opacity: 1; }
}

/* player-0 气泡居中修正 */
#player-0 .chat-bubble.show {
    animation: bubblePopCenter 0.3s ease;
}
@keyframes bubblePopCenter {
    0% { transform: translateX(-50%) scale(0.5) translateY(0); opacity: 0; }
    50% { transform: translateX(-50%) scale(1.1) translateY(-4px); opacity: 1; }
    100% { transform: translateX(-50%) scale(1) translateY(-8px); opacity: 1; }
}

/* --- 快捷聊天面板 --- */
.quick-chat-panel {
    display: none;
    position: fixed;
    bottom: 180px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 2px solid #4a90d9;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 500;
    width: 360px;
    max-width: 90vw;
    overflow: hidden;
}

.quick-chat-panel.show {
    display: block;
    animation: chatPanelSlideUp 0.25s ease;
}

@keyframes chatPanelSlideUp {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.quick-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(135deg, #4a90d9, #357abd);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    gap: 4px;
}

.quick-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.quick-chat-close:hover { opacity: 0.7; }

.quick-chat-history-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    margin-right: auto;
}
.quick-chat-history-btn:hover { opacity: 0.7; }


.quick-chat-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.quick-chat-tab {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: #f5f5f5;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.quick-chat-tab.active {
    background: #fff;
    color: #4a90d9;
    border-bottom: 2px solid #4a90d9;
}

.quick-chat-content {
    display: none;
    padding: 12px;
}
.quick-chat-content.active {
    display: block;
}

.quick-msg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.quick-msg-btn {
    padding: 8px 4px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    background: #f9f9f9;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}
.quick-msg-btn:hover {
    background: #4a90d9;
    color: #fff;
    border-color: #4a90d9;
    transform: translateY(-2px);
}
.quick-msg-btn:active {
    transform: translateY(0);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-btn {
    padding: 6px;
    border: none;
    border-radius: 6px;
    background: #f5f5f5;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}
.emoji-btn:hover {
    background: #e8f0fe;
    transform: scale(1.2);
}

/* --- 游戏内聊天记录侧边栏 --- */
.game-chat-sidebar {
    display: none;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: #fff;
    box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    z-index: 400;
    flex-direction: column;
}

.game-chat-sidebar.show {
    display: flex;
    animation: sidebarSlideIn 0.25s ease;
}

@keyframes sidebarSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.game-chat-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #4a90d9, #357abd);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}

.game-chat-sidebar-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}
.game-chat-sidebar-close:hover { opacity: 0.7; }

.game-chat-sidebar-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.game-chat-msg {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    word-break: break-word;
}
.game-chat-msg .msg-sender {
    font-weight: 700;
    color: #4a90d9;
    margin-right: 4px;
}
.game-chat-msg.me {
    background: #e8f5e9;
}
.game-chat-msg.me .msg-sender {
    color: #2e7d32;
}
.game-chat-msg.other {
    background: #f5f5f5;
}
.game-chat-msg.system {
    text-align: center;
    color: #999;
    font-size: 12px;
    background: none;
    padding: 2px;
}

/* --- 大厅聊天面板 --- */
.lobby-chat {
    margin-top: 16px;
    border: 1px solid #d0d0d0;
    border-radius: 12px;
    overflow: hidden;
    background: #fafafa;
}

.lobby-chat-header {
    padding: 8px 14px;
    background: linear-gradient(135deg, #4a90d9, #357abd);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.lobby-chat-log {
    height: 180px;
    overflow-y: auto;
    padding: 10px 14px;
    background: #fff;
}

.lobby-chat-input-row {
    display: flex;
    padding: 8px;
    gap: 6px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

.lobby-chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.lobby-chat-input:focus {
    border-color: #4a90d9;
}

.lobby-chat-send-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: #4a90d9;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.lobby-chat-send-btn:hover {
    background: #357abd;
}

.lobby-chat-quick {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
    background: #fafafa;
}

.lobby-quick-btn {
    padding: 4px 10px;
    border: 1px solid #ccc;
    border-radius: 12px;
    background: #fff;
    color: #555;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.lobby-quick-btn:hover {
    background: #e8f0fe;
    border-color: #4a90d9;
    color: #4a90d9;
}

/* --- 顶部栏聊天按钮 --- */
#btn-game-chat {
    position: relative;
}

#btn-game-chat.has-new::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #f44336;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
}

/* ============ 响应式：手机 / 平板竖屏 ============ */
@media (max-width: 768px) {

    /* ---------- 菜单界面 ---------- */
    #menu-screen {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .menu-container {
        margin: auto;
        width: 100%;
        max-width: 520px;
        padding: 24px 16px;
    }

    .game-title {
        font-size: 38px;
        letter-spacing: 4px;
        margin-bottom: 4px;
    }

    .game-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
        letter-spacing: 1px;
    }

    .menu-section {
        margin-bottom: 18px;
    }

    .menu-section h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .btn-group {
        gap: 8px;
    }

    .mode-btn, .difficulty-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 12px 6px;
        font-size: 14px;
    }

    .mode-desc, .diff-desc {
        font-size: 11px;
    }

    .start-btn {
        width: 100%;
        padding: 16px 0;
        font-size: 20px;
        letter-spacing: 2px;
        margin-top: 12px;
    }

    /* 折叠选项行：窄屏改为上下堆叠 */
    .menu-row {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 18px;
    }

    .menu-row > .menu-section {
        flex: 1 1 auto;
        min-width: 0;
    }

    .features-panel.open {
        max-height: 260px;
    }

    .features-list li {
        font-size: 12px;
        padding: 6px 10px;
        gap: 8px;
    }

    .avatar-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
    }

    .avatar-option {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }

    /* ---------- 顶部信息栏 ---------- */
    .top-bar {
        padding: 6px 10px;
        gap: 6px;
        min-height: 36px;
        justify-content: flex-start;
    }

    .game-info {
        font-size: 11px;
        letter-spacing: 0;
        flex: 1 1 auto;
        min-width: 0;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .multiplier-bar {
        margin-left: 0;
        flex-shrink: 0;
        gap: 4px;
    }

    .mult-total {
        font-size: 11px;
        padding: 2px 8px;
    }

    /* 倍数明细太长，窄屏只保留总倍数 */
    .mult-breakdown {
        display: none;
    }

    .top-bar-btn {
        position: static;
        top: auto;
        transform: none;
        flex-shrink: 0;
        padding: 4px 8px;
        font-size: 11px;
    }

    #btn-history, #btn-sound, #btn-game-chat {
        position: static;
        right: auto;
        top: auto;
        transform: none;
    }

    /* ---------- 倒计时条 ---------- */
    /* 窄屏上倒计时数字会压到顶部按钮，只保留进度条 */
    .timer-bar {
        height: 3px;
        overflow: hidden;
    }

    .timer-text {
        display: none;
    }

    /* ---------- 上方两个 AI 玩家 ---------- */
    .top-players {
        padding: 8px 10px;
    }

    .player-area {
        min-width: 96px;
    }

    .player-avatar {
        width: 34px;
        height: 34px;
        font-size: 20px;
    }

    .player-left .played-cards,
    .player-right .played-cards {
        max-height: 120px;
    }

    .player-left .player-avatar,
    .player-right .player-avatar {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .player-name {
        font-size: 12px;
    }

    .player-role {
        font-size: 10px;
        padding: 1px 5px;
    }

    .card-count {
        font-size: 11px;
        margin-bottom: 4px;
    }

    /* 牌背：10 张一行，列宽 8px、牌宽 30px → 每张露出 8px 形成扇形叠放，
       容器宽度 = 9*8 + 30 = 102px，不会溢出屏幕 */
    .ai-cards {
        grid-template-columns: repeat(10, 8px);
        width: 102px;
        max-width: 102px;
        row-gap: 4px;
        min-height: 88px;
    }

    .ai-cards .card-back {
        width: 30px;
        height: 42px;
        margin-right: 0;
        border-radius: 3px;
    }

    /* 明牌时需要看清点数，适当放宽间距 */
    .ai-cards:has(.open-hand-card) {
        grid-template-columns: repeat(10, 12px);
        width: 128px;
        max-width: 128px;
    }

    .open-hand-card {
        width: 20px !important;
        height: 28px !important;
        margin-right: 0 !important;
    }

    .open-hand-card .card-rank {
        font-size: 10px !important;
    }

    .open-hand-card .card-suit-top,
    .open-hand-card .card-suit-bottom {
        font-size: 7px !important;
    }

    /* ---------- 中央出牌区 ---------- */
    .center-play-area {
        min-height: 110px;
        padding: 0 4px;
    }

    .bottom-cards {
        gap: 4px;
        margin-bottom: 6px;
    }

    .bottom-label {
        font-size: 11px;
    }

    .center-played {
        margin-top: 6px;
        gap: 4px;
        max-width: 100%;
    }

    .play-label {
        font-size: 11px;
    }

    .play-cards-row .card.small-card {
        margin-right: -14px;
    }

    .center-message {
        font-size: 14px;
        padding: 10px;
    }

    .action-toast {
        font-size: 12px;
        padding: 4px 12px;
    }

    .pass-indicator {
        font-size: 15px;
        padding: 6px 14px;
    }

    .shuffle-deck {
        width: 100px;
        height: 84px;
    }

    .shuffle-card {
        width: 38px;
        height: 54px;
        font-size: 20px;
    }

    .shuffle-label {
        font-size: 13px;
        bottom: -24px;
        letter-spacing: 2px;
    }

    /* ---------- 卡牌尺寸 ---------- */
    .card {
        width: 50px;
        height: 72px;
        border-radius: 6px;
    }

    .card-rank {
        font-size: 18px;
    }

    .card-suit-top, .card-suit-bottom {
        font-size: 12px;
    }

    .card-suit-top {
        top: 3px;
        left: 4px;
    }

    .card-suit-bottom {
        bottom: 3px;
        right: 4px;
    }

    .card.small-card {
        width: 32px;
        height: 46px;
    }

    .card.small-card .card-rank {
        font-size: 12px;
    }

    .card.small-card .card-suit-top,
    .card.small-card .card-suit-bottom {
        font-size: 9px;
    }

    .card-back.small-card,
    .card.card-back.small-card {
        width: 32px;
        height: 46px;
    }

    .card.card-back::after {
        width: 18px;
        height: 18px;
    }

    .joker-text {
        font-size: 13px;
    }

    .played-cards {
        min-height: 0;
        padding: 4px;
        gap: 1px;
    }

    .played-cards .card.played-card {
        width: 30px;
        height: 42px;
        margin-right: -12px;
    }

    .played-cards .card.played-card .card-rank {
        font-size: 12px;
    }

    .played-cards .card.played-card .card-suit-top,
    .played-cards .card.played-card .card-suit-bottom {
        font-size: 8px;
    }

    /* ---------- 底部玩家区：纵向堆叠 ---------- */
    .bottom-player {
        /* 手机上明牌栏最高（91px），按它预留，三条栏切换时高度一致 */
        --controls-h: 98px;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 0 8px calc(8px + var(--controls-h) + env(safe-area-inset-bottom, 0px));
        max-width: 100%;
    }

    .player-bottom {
        min-width: 0;
        flex-shrink: 0;
        align-self: stretch;
        justify-content: center;
        align-items: center;
        gap: 8px;
    }

    .player-bottom .card-count {
        padding-bottom: 0;
        font-size: 12px;
        margin-bottom: 0;
    }

    /* 自己上一次出的牌已在牌桌中央显示，窄屏不再重复占一行 */
    .player-bottom .played-cards {
        display: none;
    }

    /* 手牌：单行排布，重叠量由「按张数自适应」规则计算（见文件末尾） */
    .hand-area {
        --card-w: 50px;
        /* 抬起后仍在手牌区自己的空间里，不会压到上方的信息行 */
        --card-lift: 30px;
        padding: 34px 4px 4px;
        min-height: 110px;
    }

    .hand-area .card:hover {
        transform: translateY(-6px);
    }

    .hand-area .card.selected {
        transform: translateY(-14px);
    }

    .hand-area .card.selected:hover {
        transform: translateY(-16px);
    }

    /* ---------- 操作栏 ---------- */
    .action-bar, .bidding-bar, .openhand-bar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 8px;
        flex-basis: auto;
    }

    .action-btn {
        flex: 1 1 0;
        min-width: 0;
        max-width: 150px;
        padding: 12px 8px;
        font-size: 15px;
    }

    .bidding-info {
        flex: 1 1 100%;
        font-size: 14px;
        margin-right: 0;
        text-align: center;
    }

    .bid-buttons {
        flex: 1 1 100%;
        gap: 6px;
    }

    .bid-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 4px;
        font-size: 14px;
    }

    .openhand-info {
        flex: 1 1 100%;
        font-size: 14px;
        text-align: center;
    }

    .openhand-buttons {
        flex: 1 1 100%;
        gap: 10px;
        justify-content: center;
    }

    .openhand-buttons .action-btn {
        max-width: 160px;
    }

    /* ---------- 结算界面 ---------- */
    .end-container {
        margin: auto;
        width: 94%;
        max-width: 100%;
        padding: 24px 16px;
    }

    #end-title {
        font-size: 32px;
        letter-spacing: 3px;
    }

    #end-detail {
        font-size: 15px;
    }

    .spring-text {
        font-size: 16px;
    }

    .end-scores {
        margin: 12px 0;
        padding: 12px 16px;
    }

    #end-score {
        font-size: 18px;
    }

    .end-total-score {
        font-size: 14px !important;
    }

    .end-multiplier {
        padding: 10px 12px;
    }

    .mult-detail-item {
        font-size: 12px;
        padding: 3px 8px;
    }

    .mult-detail-total {
        font-size: 16px;
    }

    .end-hands {
        max-height: 30vh;
    }

    .end-hand-row {
        padding: 6px 8px;
        gap: 8px;
    }

    .end-hand-name {
        min-width: 60px;
        font-size: 13px;
    }

    .end-card {
        font-size: 11px;
        padding: 2px 4px;
    }

    .end-buttons {
        flex-wrap: wrap;
        gap: 10px;
    }

    .end-buttons .action-btn {
        flex: 1 1 120px;
        max-width: none;
    }

    /* ---------- 联机大厅 ---------- */
    .online-container {
        width: 100%;
        max-width: 100%;
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .online-title {
        font-size: 24px;
        margin-bottom: 16px;
        letter-spacing: 2px;
    }

    .online-choice {
        flex-direction: column;
        gap: 12px;
    }

    .online-action-btn {
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 14px 16px;
    }

    .online-action-icon {
        font-size: 28px;
    }

    .online-action-label {
        font-size: 16px;
    }

    .online-action-desc {
        font-size: 12px;
    }

    .room-code-input {
        width: 100%;
        max-width: 240px;
        padding: 12px;
        font-size: 28px;
        letter-spacing: 8px;
    }

    .lobby-room-code {
        gap: 8px;
        flex-wrap: wrap;
    }

    .lobby-code {
        font-size: 28px;
        letter-spacing: 4px;
        padding: 6px 14px;
    }

    .lobby-player {
        padding: 10px 12px;
        gap: 10px;
    }

    .lobby-player-avatar {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }

    .lobby-player-name {
        font-size: 15px;
    }

    .lobby-btn-row {
        gap: 8px;
    }

    .lobby-btn-row .action-btn {
        flex: 1 1 100px;
        max-width: none;
    }

    .lobby-chat-log {
        height: 120px;
    }

    .lobby-chat-input {
        font-size: 16px; /* iOS 聚焦时 >=16px 才不会自动放大页面 */
    }

    .back-menu-btn {
        margin: 16px auto 0;
    }

    /* ---------- 浮层面板：窄屏铺满 ---------- */
    .history-panel {
        top: 0;
        right: 0;
        width: 100%;
        max-width: 100vw;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border-right: none;
        z-index: 800;
    }

    .counter-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .game-chat-sidebar {
        width: 100%;
        max-width: 100vw;
    }

    .quick-chat-panel {
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-width: 100vw;
        transform: none;
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        z-index: 800;
    }

    .quick-chat-panel.show {
        animation: chatPanelSlideUpMobile 0.25s ease;
    }

    .quick-msg-grid {
        grid-template-columns: 1fr 1fr;
    }

    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .emoji-btn {
        font-size: 20px;
        padding: 4px;
    }

    .chat-bubble {
        max-width: 130px;
        font-size: 13px;
        padding: 4px 10px;
    }

    .chat-bubble.emoji {
        font-size: 24px;
        padding: 3px 6px;
    }

    .toast {
        font-size: 14px;
        padding: 12px 20px;
        max-width: 80vw;
        text-align: center;
    }
}

@keyframes chatPanelSlideUpMobile {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 触屏设备：去掉鼠标悬停残留效果 */
@media (max-width: 768px) and (hover: none) {
    .mode-btn:hover, .difficulty-btn:hover,
    .action-btn:hover, .bid-btn:hover {
        transform: none;
    }
}

/* ============ 矮屏：手机横屏、以及高度不足的桌面窗口 ============ */
@media (max-height: 520px) and (orientation: landscape), (min-width: 769px) and (max-height: 660px) {
    .top-bar {
        padding: 4px 10px;
        min-height: 30px;
    }

    .top-players {
        padding: 4px 10px;
    }

    .player-avatar {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .player-left .player-avatar,
    .player-right .player-avatar {
        width: 28px;
        height: 28px;
        font-size: 15px;
    }

    /* AI 牌背：7px 列宽 + 18px 牌宽 → 每行 10 张叠放 */
    .ai-cards {
        grid-template-columns: repeat(10, 7px);
        width: 81px;
        max-width: 81px;
        min-height: 58px;
    }

    .ai-cards .card-back {
        width: 18px;
        height: 26px;
        margin-right: 0;
    }

    .center-play-area {
        min-height: 76px;
    }

    /* 横屏纵向空间紧张，各家上次出的牌统一由牌桌中央显示 */
    .player-area .played-cards {
        display: none;
    }

    .played-cards {
        min-height: 0;
        padding: 2px;
    }

    /* 横屏高度紧张，底牌回到正常流中，避免压住出牌内容 */
    #center-bottom-cards {
        position: static;
        transform: none;
        margin-bottom: 8px;
    }

    .card {
        width: 40px;
        height: 56px;
    }

    .hand-area {
        --card-w: 40px;
        --card-lift: 18px;
        padding: 14px 4px 2px;
        min-height: 76px;
    }

    .action-bar, .bidding-bar, .openhand-bar {
        padding: 6px 8px;
        gap: 8px;
        /* 矮屏纵向空间紧张，三条栏都压成一行，保证不超过预留高度 */
        flex-wrap: nowrap;
    }

    .bidding-info, .openhand-info {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12px;
    }

    .bid-btn {
        padding: 8px 10px;
        font-size: 13px;
    }

    .action-btn {
        padding: 8px;
        font-size: 14px;
    }

    .bottom-player {
        --controls-h: 62px;
        padding-bottom: calc(4px + var(--controls-h));
    }

    .menu-container {
        padding: 12px 16px;
    }

    .game-title {
        font-size: 30px;
    }

    .end-hands {
        max-height: 22vh;
    }
}

/* ============ 超窄屏（<=359px）：压缩两侧 AI，给牌桌留出宽度 ============ */
@media (max-width: 359px) {
    .player-area {
        min-width: 80px;
    }

    .ai-cards {
        grid-template-columns: repeat(10, 6px);
        width: 80px;
        max-width: 80px;
        min-height: 80px;
    }

    .ai-cards .card-back {
        width: 26px;
        height: 38px;
    }

    .card.small-card,
    .card-back.small-card,
    .card.card-back.small-card {
        width: 26px;
        height: 38px;
    }

    .card.small-card .card-rank {
        font-size: 11px;
    }

    .card.small-card .card-suit-top,
    .card.small-card .card-suit-bottom {
        font-size: 8px;
    }

    .card.card-back::after {
        width: 14px;
        height: 14px;
    }

    .bottom-cards {
        gap: 4px;
    }

    .bottom-label {
        font-size: 10px;
        margin-right: 2px;
    }

    .card {
        width: 44px;
        height: 62px;
    }

    .card-rank {
        font-size: 16px;
    }

    .card-suit-top, .card-suit-bottom {
        font-size: 12px;
    }

    .hand-area {
        --card-w: 44px;
        --card-lift: 26px;
        padding: 30px 4px 4px;
    }

    .hand-area.tight .card-rank {
        font-size: 14px;
    }

    .hand-area.tight .card-suit-top {
        font-size: 10px;
    }

    .hand-area.tight .joker-text {
        width: 12px;
        font-size: 12px;
    }
}

/* ============ 手牌自适应：任何宽度下都单行显示，不需要左右滑动 ============
   重叠量 = (容器宽 - 张数 x 牌宽) / (张数 - 1)，min(0px, …) 保证张数少时不拉开间距。
   --hand-count 由 ui.js 在手牌渲染时写入；--card-w / --card-lift 由上面的断点规则给出。
   悬停、选中都只上浮、不改变间距：既不遮挡相邻牌，也不会把整行挤出容器导致横向滚动。
   间距被压成窄条时（.tight 由 ui.js 实测后添加）点数改到左上角，保证每张牌都读得出来。 */
.hand-area .card:not(:last-child),
.hand-area.many-cards .card:not(:last-child),
.hand-area .card:hover:not(:last-child),
.hand-area .card.selected:not(:last-child),
.hand-area .card.selected:hover:not(:last-child) {
    margin-right: min(0px,
        calc((100% - var(--hand-count, 17) * var(--card-w)) / (var(--hand-count, 17) - 1)));
}

/* 悬停、选中都不置顶：把牌提到上层会盖住右边相邻的牌 */
.hand-area .card:hover,
.hand-area .card.selected,
.hand-area .card.selected:hover {
    z-index: auto;
}

/* 选中的牌整体上浮，抬起的那一段露在整行上方，一眼能看出选中了哪几张 */
.hand-area .card.selected,
.hand-area .card.selected:hover {
    transform: translateY(calc(-1 * var(--card-lift)));
}

.hand-area.tight .card-rank {
    position: absolute;
    top: 15px;
    left: 3px;
    font-size: 16px;
    line-height: 1;
}

.hand-area.tight .card-suit-top {
    top: 2px;
    left: 3px;
    font-size: 11px;
}

.hand-area.tight .card-suit-bottom {
    display: none;
}

.hand-area.tight .joker-text {
    position: absolute;
    top: 3px;
    left: 2px;
    width: 13px;
    font-size: 13px;
    line-height: 1.1;
    text-align: center;
}

/* ============ 极矮屏（<=360px 高）：再压缩一圈，保证底部不被裁 ============ */
@media (max-height: 360px) {
    .bottom-player {
        --controls-h: 56px;
        padding-bottom: calc(2px + var(--controls-h));
    }

    .card {
        width: 36px;
        height: 50px;
    }

    .hand-area {
        --card-w: 36px;
        min-height: 66px;
    }

    .player-bottom {
        padding: 2px 4px;
    }
}

/* ============ 当前只开放「联机模式」 ============
   本地单人/双人/三人模式、难度选择、「开始游戏」按钮先隐藏。
   想恢复本地玩法，把 index.html 里这些元素上的 local-only 类去掉即可。 */
.menu-section.local-only,
.start-btn.local-only {
    display: none;
}

/* 首页上的「创建房间 / 加入房间」 */
.menu-online {
    margin-bottom: 32px;
}

/* 两列等宽：加入卡片里有键盘，不能让内容把宽度撑开 */
.menu-online-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 22px 0 0;
}

.menu-online-choice > .online-action-btn {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 20px 16px;
}

/* 加入卡片带数字键盘会更高，创建卡片内容居中，避免下方大片留白 */
.menu-online-choice #btn-create-room {
    justify-content: center;
}

/* 选中的入口（展开输入框时）高亮 */
.online-action-btn.active {
    border-color: var(--accent-gold);
    background: rgba(255, 213, 79, 0.12);
    transform: translateY(-2px);
}

.online-action-btn.busy {
    opacity: 0.7;
    cursor: progress;
    transform: none;
}

/* 首页「输入房间号」面板（常显，不再展开/收起） */
.inline-join {
    margin-top: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.inline-join-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-join .room-code-input {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-width: 0;
    padding: 10px 12px;
    font-size: 26px;
    letter-spacing: 8px;
    text-indent: 8px;
    border-width: 1px;
}

.join-confirm-btn {
    flex: 0 0 auto;
    padding: 12px 26px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #66bb6a, #43a047);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.join-confirm-btn:hover:not(:disabled) {
    filter: brightness(1.08);
}

.join-confirm-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.join-cancel-btn {
    flex: 0 0 auto;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.join-cancel-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.inline-join-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* 「加入房间」卡片：内含输入框，卡片自身不是按钮，鼠标移入不位移 */
.join-card {
    cursor: default;
    gap: 10px;
    justify-content: center;
}

.join-card:hover {
    background: var(--bg-card);
    border-color: var(--border-color);
    transform: none;
}

.join-card .join-card-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.join-card .inline-join {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin-top: 0;
    padding: 0;
    background: none;
    border: none;
    box-sizing: border-box;
}

/* 自定义数字键盘（不调起系统键盘） */
.number-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.num-key {
    padding: 10px 0;
    font-family: inherit;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.12s, border-color 0.12s, transform 0.08s;
}

.num-key:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-blue);
}

.num-key:active {
    transform: scale(0.95);
    background: rgba(255, 213, 79, 0.2);
    border-color: var(--accent-gold);
}

.num-key-fn {
    font-size: 15px;
    color: var(--text-muted);
}

.num-key-fn:active {
    color: var(--text-primary);
}

.join-card .inline-join .room-code-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    padding: 8px 10px;
    font-size: 22px;
    letter-spacing: 6px;
    text-indent: 6px;
}

.join-card .join-confirm-btn {
    flex: 0 0 auto;
    padding: 10px 18px;
    font-size: 15px;
}

@media (max-width: 768px) {
    .menu-online {
        margin-bottom: 22px;
    }

    .menu-online-choice {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 14px 0 0;
    }

    .menu-online-choice .online-action-btn {
        padding: 14px 16px;
    }

    /* 移动端 .online-action-btn 变成横排，含输入框的卡片仍保持上下排列 */
    .join-card {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .join-card .join-card-head {
        justify-content: flex-start;
    }

    .join-card .inline-join {
        gap: 8px;
    }

    /* 手机上输入框与「加入」各占一行，键盘在下方 */
    .inline-join-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .join-card .inline-join .room-code-input {
        flex: 1 1 100%;
        max-width: none;
        font-size: 20px;
        letter-spacing: 6px;
        text-indent: 6px;
        text-align: center;
    }

    .join-card .join-confirm-btn {
        flex: 1 1 100%;
        padding: 12px 8px;
    }

    .number-pad {
        gap: 6px;
    }

    .num-key {
        padding: 12px 0;
        font-size: 22px;
        border-radius: 12px;
    }

    .num-key-fn {
        font-size: 15px;
    }

    .join-cancel-btn {
        flex: 1 1 0;
        padding: 12px 8px;
    }
}

/* ============ 房间聊天暂时隐藏 ============
   房间页内容太长，先不展示聊天面板；代码保留，删掉这条规则即可恢复。 */
.lobby-chat {
    display: none;
}

/* ============================================================
   视觉升级 V2：深色牌桌质感（玻璃卡片 + 紫金光效）
   只覆盖首页与联机房间，牌桌内部保持原样
   ============================================================ */

:root {
    --glass-top: rgba(255, 255, 255, 0.075);
    --glass-bottom: rgba(255, 255, 255, 0.018);
    --stroke-soft: rgba(255, 255, 255, 0.10);
    --ease-out: cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* ---------- 背景光晕 ---------- */
#menu-screen,
#online-screen {
    background:
        radial-gradient(1200px 720px at 12% -8%, rgba(124, 77, 255, 0.30), transparent 62%),
        radial-gradient(900px 640px at 88% 4%, rgba(41, 182, 246, 0.20), transparent 60%),
        radial-gradient(760px 620px at 50% 112%, rgba(255, 193, 7, 0.12), transparent 62%),
        linear-gradient(165deg, #0d0f1e 0%, #151833 48%, #0c0e1c 100%);
    background-attachment: fixed;
}

/* ---------- 标题 ---------- */
.game-title {
    background: linear-gradient(100deg, #ffe9a8 0%, #ffc451 26%, #ff8a65 54%, #c07ce0 80%, #8f7bff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 8px;
    text-indent: 8px;
    filter: drop-shadow(0 12px 36px rgba(255, 138, 80, 0.28));
}

.game-subtitle {
    color: #96a0d8;
    letter-spacing: 4px;
    opacity: 0.92;
}

/* ---------- 首页两张入口卡 ---------- */
.menu-online-choice > .online-action-btn {
    position: relative;
    overflow: hidden;
    padding: 22px 18px;
    border: 1px solid var(--stroke-soft);
    border-radius: 20px;
    background: linear-gradient(165deg, var(--glass-top), var(--glass-bottom));
    box-shadow:
        0 22px 46px -26px rgba(0, 0, 0, 0.95),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
    transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s;
    animation: cardRise 0.5s var(--ease-out) backwards;
}

.menu-online-choice > .online-action-btn::before {
    content: '';
    position: absolute;
    top: -46%;
    right: -32%;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(143, 123, 255, 0.32), transparent 70%);
    pointer-events: none;
}

.menu-online-choice > .join-card::before {
    background: radial-gradient(circle, rgba(255, 200, 60, 0.26), transparent 70%);
}

.menu-online-choice > .online-action-btn:hover {
    transform: translateY(-4px);
    border-color: rgba(143, 123, 255, 0.42);
    box-shadow:
        0 30px 60px -28px rgba(0, 0, 0, 1),
        0 0 34px -16px rgba(143, 123, 255, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

.menu-online-choice > .join-card:hover {
    border-color: rgba(255, 213, 79, 0.42);
    box-shadow:
        0 30px 60px -28px rgba(0, 0, 0, 1),
        0 0 38px -16px rgba(255, 213, 79, 0.75),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

@keyframes cardRise {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

/* 图标做成发光圆盘 */
.menu-online-choice .online-action-icon {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    font-size: 28px;
    line-height: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.04) 70%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.14),
        0 14px 30px -18px rgba(0, 0, 0, 0.9);
}

.join-card .online-action-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

.menu-online-choice .online-action-label {
    font-size: 19px;
    letter-spacing: 1px;
}

.join-card .online-action-label {
    font-size: 16px;
    letter-spacing: 0.5px;
    color: #ffe9b8;
}

.menu-online-choice .online-action-desc {
    color: #9fa8da;
    font-size: 12.5px;
    letter-spacing: 0.5px;
}

/* ---------- 房间号输入 ---------- */
.join-card .inline-join .room-code-input {
    height: 52px;
    border-radius: 14px;
    background: rgba(6, 8, 18, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: inset 0 3px 14px rgba(0, 0, 0, 0.5);
    color: #ffe082;
    font-weight: 800;
    letter-spacing: 9px;
    text-indent: 9px;
}

.join-card .inline-join .room-code-input::placeholder {
    color: rgba(150, 160, 216, 0.4);
    letter-spacing: 6px;
}

.join-card .join-confirm-btn {
    height: 52px;
    padding: 0 18px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #2a1c00;
    background: linear-gradient(135deg, #ffd977, #ffab2e);
    box-shadow:
        0 12px 26px -14px rgba(255, 171, 46, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.join-card .join-confirm-btn:hover:not(:disabled) {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

/* ---------- 数字键盘 ---------- */
.number-pad {
    gap: 9px;
}

.num-key {
    height: 50px;
    padding: 0;
    font-size: 21px;
    font-weight: 800;
    border-radius: 14px;
    color: #eef1ff;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.035));
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 8px 18px -14px rgba(0, 0, 0, 1);
    transition: transform 0.1s, background 0.15s, border-color 0.15s;
}

.num-key:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.06));
    border-color: rgba(143, 123, 255, 0.5);
}

.num-key:active {
    transform: scale(0.96);
    background: linear-gradient(180deg, rgba(255, 213, 79, 0.30), rgba(255, 171, 46, 0.14));
    border-color: rgba(255, 213, 79, 0.65);
}

.num-key-fn {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #a9b2e4;
}

/* ---------- 头像折叠条 ---------- */
.avatar-section .avatar-toggle {
    padding: 14px 20px;
    border-radius: 18px;
    background: linear-gradient(165deg, var(--glass-top), var(--glass-bottom));
    border: 1px solid var(--stroke-soft);
    box-shadow:
        0 18px 40px -28px #000,
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.avatar-section .avatar-toggle:hover {
    border-color: rgba(143, 123, 255, 0.4);
    box-shadow:
        0 22px 46px -28px #000,
        0 0 30px -18px rgba(143, 123, 255, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ============================================================
   联机房间
   ============================================================ */
.online-container {
    max-width: 520px;
    padding: 28px 20px 44px;
}

.online-title {
    font-size: 26px;
    letter-spacing: 6px;
    color: #ffe9b8;
    text-shadow: 0 8px 28px rgba(255, 180, 80, 0.30);
}

.lobby-room-code {
    gap: 10px;
    margin-bottom: 10px;
}

.lobby-label {
    color: #98a2d8;
    font-size: 13px;
    letter-spacing: 2px;
}

.lobby-code {
    font-size: 44px;
    font-weight: 800;
    letter-spacing: 10px;
    padding: 12px 22px 12px 32px;
    color: #ffd977;
    background: linear-gradient(180deg, rgba(255, 213, 79, 0.12), rgba(255, 171, 46, 0.04));
    border: 1px solid rgba(255, 213, 79, 0.35);
    border-radius: 18px;
    box-shadow:
        inset 0 0 30px rgba(255, 213, 79, 0.10),
        0 0 44px -16px rgba(255, 213, 79, 0.55);
    text-shadow: 0 0 20px rgba(255, 213, 79, 0.45);
}

.copy-btn {
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 13px;
    color: #cfd6ff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.copy-btn:hover {
    background: rgba(255, 213, 79, 0.14);
    border-color: rgba(255, 213, 79, 0.5);
    color: #ffe082;
}

.lobby-server-info {
    display: inline-block;
    margin-bottom: 18px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: #7b85bd;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.online-lobby h3 {
    font-size: 14px;
    letter-spacing: 3px;
    color: #98a2d8;
    margin-bottom: 14px;
}

.lobby-players {
    gap: 12px;
    margin-bottom: 26px;
}

.lobby-player {
    padding: 14px 18px;
    border-radius: 16px;
    background: linear-gradient(165deg, var(--glass-top), var(--glass-bottom));
    border: 1px solid var(--stroke-soft);
    box-shadow:
        0 16px 36px -26px #000,
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: border-color 0.2s, transform 0.2s var(--ease-out);
}

.lobby-player:hover {
    border-color: rgba(143, 123, 255, 0.32);
}

/* 空位用虚线框，和真人座位区分开 */
.lobby-player:has(.lobby-player-status.empty) {
    border-style: dashed;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.015);
}

.lobby-player-avatar {
    width: 46px;
    height: 46px;
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.06),
        0 0 24px -8px rgba(255, 213, 79, 0.55);
}

.lobby-player-name {
    font-size: 16px;
    letter-spacing: 0.5px;
}

.lobby-player-tag {
    font-size: 12px;
    color: #8f9ad4;
    letter-spacing: 0.5px;
}

.lobby-player-status {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.lobby-player-status.ready {
    color: #8ce99a;
    background: rgba(102, 187, 106, 0.16);
    box-shadow: inset 0 0 0 1px rgba(102, 187, 106, 0.30);
}

.lobby-player-status.waiting {
    color: #b0b8e8;
    background: rgba(255, 255, 255, 0.06);
}

.lobby-player-status.empty {
    color: #6f78ad;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.lobby-btn-row {
    gap: 14px;
}

.lobby-btn-row .action-btn {
    min-width: 132px;
    padding: 13px 28px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 1px;
}

.lobby-btn-row .play-btn {
    color: #2a1c00;
    background: linear-gradient(135deg, #ffd977, #ffab2e);
    box-shadow:
        0 14px 30px -16px rgba(255, 171, 46, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.40);
}

.lobby-btn-row .play-btn:hover:not(:disabled) {
    filter: brightness(1.06);
    transform: translateY(-2px);
}

.lobby-btn-row .pass-btn {
    color: #d5dbff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: none;
}

.lobby-btn-row .pass-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.10);
    transform: translateY(-2px);
}

.back-menu-btn {
    margin-top: 20px;
    padding: 9px 26px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #96a0d8;
    background: rgba(255, 255, 255, 0.03);
}

.back-menu-btn:hover {
    color: #fff;
    border-color: rgba(143, 123, 255, 0.5);
    background: rgba(143, 123, 255, 0.10);
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 768px) {
    .game-title {
        letter-spacing: 5px;
        text-indent: 5px;
    }

    .menu-online-choice > .online-action-btn {
        padding: 16px 14px;
        border-radius: 18px;
    }

    .menu-online-choice .online-action-icon {
        width: 52px;
        height: 52px;
        font-size: 24px;
    }

    .join-card .online-action-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .join-card .inline-join .room-code-input {
        height: 48px;
    }

    .join-card .join-confirm-btn {
        height: 46px;
    }

    .num-key {
        height: 46px;
        font-size: 20px;
    }

    .lobby-code {
        font-size: 34px;
        letter-spacing: 8px;
        padding: 10px 16px 10px 24px;
    }

    .online-title {
        font-size: 22px;
        letter-spacing: 4px;
    }

    .lobby-btn-row .action-btn {
        min-width: 0;
        flex: 1 1 40%;
        padding: 12px 10px;
    }
}

/* ---------- 细节修正 ---------- */

/* 房主按钮等宽 */
.lobby-btn-row .action-btn {
    flex: 0 0 auto;
    min-width: 160px;
}

/* 「等待玩家」禁用态：保留淡金色，别糊成一团灰 */
.lobby-btn-row .action-btn:disabled {
    opacity: 0.9;
    filter: none;
    color: #cdb173;
    background: rgba(255, 213, 79, 0.07);
    border: 1px solid rgba(255, 213, 79, 0.22);
    box-shadow: none !important;
}

/* 复制按钮与房号视觉高度对齐 */
.copy-btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
}

/* 创建房间卡：底部补一层暖光，避免大卡片显得空 */
#btn-create-room .online-action-icon {
    width: 72px;
    height: 72px;
    font-size: 32px;
}

#btn-create-room::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -34%;
    width: 230px;
    height: 230px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 213, 79, 0.16), transparent 66%);
    pointer-events: none;
}

/* 房间页内容整体垂直居中（内容超高时仍可滚动） */
#online-screen.active {
    display: flex;
    flex-direction: column;
}

#online-screen .online-container {
    margin: auto;
}

/* ---------- 小屏紧凑布局：尽量一屏放下 ---------- */
@media (max-width: 768px) {
    .menu-online-choice {
        gap: 10px;
    }

    .menu-online-choice > .online-action-btn {
        padding: 12px 14px;
    }

    .menu-online-choice .online-action-icon,
    #btn-create-room .online-action-icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    .join-card .online-action-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    /* 输入框和「加入」同一行，省掉一整行高度 */
    .inline-join-row {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .join-card .inline-join .room-code-input {
        flex: 1 1 auto;
        height: 44px;
        font-size: 18px;
    }

    .join-card .join-confirm-btn {
        flex: 0 0 88px;
        height: 44px;
        padding: 0;
    }

    .number-pad {
        gap: 7px;
    }

    .num-key {
        height: 42px;
        font-size: 19px;
        border-radius: 12px;
    }

    .num-key-fn {
        font-size: 13px;
    }

    .lobby-btn-row .action-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 12px 8px;
    }

    .lobby-player {
        padding: 12px 14px;
    }

    .lobby-player-avatar {
        width: 40px;
        height: 40px;
    }
}

/* 准备页：离线 / 重连中的玩家状态（两种主题通用） */
.lobby-player-status.offline {
    color: #ff8a65;
    background: rgba(255, 138, 101, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 138, 101, 0.30);
}

.lobby-player.offline {
    opacity: 0.6;
}
