/* 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;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

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

.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;
    width: 100%;
}

/* 顶部信息栏 */
.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: flex-start;
    padding: 16px 24px;
    flex: 1;
    position: relative;
}

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

.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 张 */
/* 重叠量由 margin 控制，grid 中逐张右移 */
.ai-cards {
    display: grid;
    grid-template-columns: repeat(10, 36px);
    column-gap: 0;
    row-gap: 6px;
    padding: 2px 0;
    max-width: 240px;
}

/* 逐张牌右移重叠，使每行看上去紧凑 */
.ai-cards .card-back {
    width: 36px;
    height: 52px;
    margin-right: -22px;
    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;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.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: nowrap;
    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 {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    padding: 0 24px 16px;
    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;
}

/* ---- 游戏特色：折叠按钮 ---- */
.features-section {
    margin-bottom: 0;
}

.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 {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding: 32px 12px 12px;
    flex: 1;
    min-width: 0;
    min-height: 120px;
}

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

/* 手牌较多时进一步收缩，避免溢出 */
.hand-area.many-cards .card {
    margin-right: -12px;
}

/* 最后一张牌保留正常间距 */
.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%;
}

.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);
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .game-title {
        font-size: 42px;
        letter-spacing: 4px;
    }

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

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

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

    .hand-area .card {
        margin-right: -6px;
    }
    .hand-area.many-cards .card {
        margin-right: -10px;
    }
    .hand-area.many-cards .card:last-child {
        margin-right: 0;
    }

    .mode-btn, .difficulty-btn {
        min-width: 100px;
        padding: 14px 16px;
        font-size: 14px;
    }

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

    .ai-cards {
        grid-template-columns: repeat(10, 26px);
        max-width: 180px;
    }

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

/* 滚动条 */
.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-entry-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    background: linear-gradient(135deg, #2a4a7f, #1a3a6f);
    border: 2px solid var(--accent-blue);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.online-entry-btn:hover {
    background: linear-gradient(135deg, #3a5a8f, #2a4a7f);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(66, 165, 245, 0.4);
}

/* 联机大厅容器 */
.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);
}

/* 加入房间输入 */
.online-join h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
}

.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-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin: 8px 0 16px;
}

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

/* 房间大厅 */
.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; }
}
