/**
 * wx_mojang - 国标麻将游戏样式
 * 雀魂麻将(Mahjong Soul)风格 · 横屏优先 · 暗色主题
 */

/* ====== CSS 变量 ====== */
:root {
    --bg-deep: #0d1117;
    --bg-page: #141b2d;
    --bg-table: #1a3a2a;
    --bg-table-dark: #0d2818;
    --bg-panel: rgba(0, 0, 0, 0.55);
    --bg-panel-hover: rgba(0, 0, 0, 0.7);
    --bg-card: #1e293b;
    --text-primary: #e8edf5;
    --text-secondary: #8899aa;
    --text-muted: #5a6a7a;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --accent-gold: #f5b342;
    --accent-purple: #a855f7;
    --accent-orange: #f97316;
    --border-light: rgba(255, 255, 255, 0.08);
    --border-med: rgba(255, 255, 255, 0.15);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-tile: 0 2px 4px rgba(0, 0, 0, 0.25);
    --shadow-tile-hover: 0 4px 12px rgba(0, 0, 0, 0.35);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 20px;
    --tile-width: 44px;
    --tile-height: 62px;
    --tile-font: 15px;
    --tile-gap: 2px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* ====== 全局 ====== */
* { box-sizing: border-box; }
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    overflow: hidden;
    height: 100dvh;
    width: 100dvw;
    user-select: none;
    -webkit-user-select: none;
}

.mj-page {
    height: 100dvh;
    width: 100dvw;
    overflow: hidden;
    position: relative;
    background: linear-gradient(160deg, #0d1520 0%, #141b2d 40%, #1a2332 100%);
}

/* ====== 顶部导航（绿色渐变） ====== */
.mj-nav {
    width: 100%;
    margin: 0;
    height: 60px;
    background: linear-gradient(135deg, #1b7a3d 0%, #0d5c2e 100%);
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 5000;
    box-shadow: 0 2px 20px rgba(13, 92, 46, 0.3);
    transition: background 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.mj-nav.scrolled {
    background: linear-gradient(135deg, #1b7a3df2 0%, #0d5c2eff 100%);
    box-shadow: 0 4px 24px rgba(13, 92, 46, 0.4);
}
.mj-nav-inner {
    width: 100%;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}
.mj-nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.mj-nav-icon { font-size: 22px; line-height: 1; }
.mj-nav-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
    margin: 0;
    white-space: nowrap;
}
.mj-nav-right {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}
/* 导航按钮（ddz风格胶囊） */
.mj-nav-right .nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 34px;
    border-radius: 17px;
    padding: 0 12px;
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
    flex-shrink: 0;
}
.mj-nav-right .nav-btn:hover {
    background: rgba(255,255,255,0.3);
}
.mj-nav-right .nav-btn:active {
    transform: scale(0.95);
}
.mj-nav-right .nav-btn.nav-home-btn {
    background: rgba(255,255,255,0.2);
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.3);
}
.mj-nav-right .nav-btn.nav-home-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}
/* 用户信息胶囊 */
.mj-nav-right .nav-user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    border-radius: 17px;
    padding: 0 10px;
    background: rgba(0,0,0,0.25);
    flex-shrink: 0;
    max-width: 180px;
}
.mj-nav-right .nav-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,215,0,0.7);
    flex-shrink: 0;
}
.mj-nav-right .nav-avatar-placeholder {
    font-size: 16px;
    line-height: 24px;
}
.mj-nav-right .nav-user-name {
    font-size: 13px;
    color: #fff;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* 积分胶囊 */
.mj-nav-right .nav-score {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 34px;
    border-radius: 17px;
    padding: 0 10px;
    background: rgba(0,0,0,0.25);
    cursor: pointer;
    flex-shrink: 0;
}
.mj-nav-right .nav-score:hover {
    background: rgba(0,0,0,0.4);
}
.mj-nav-right .nav-score-label {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
}
.mj-nav-right .nav-score-value {
    font-size: 14px;
    font-weight: bold;
    color: #ffd700;
}

/* ====== 按钮（保留通用按钮，导航按钮用上方的nav-btn） ====== */
.mj-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}
.mj-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.mj-btn:active { transform: translateY(0); filter: brightness(0.95); }

.mj-btn-primary { background: linear-gradient(135deg, #4a7cf7, #3b82f6); color: #fff; }
.mj-btn-success { background: linear-gradient(135deg, var(--accent-green), #16a34a); color: #fff; }
.mj-btn-danger { background: linear-gradient(135deg, var(--accent-red), #dc2626); color: #fff; }
.mj-btn-gold { background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange)); color: #fff; }
.mj-btn-outline {
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border-med);
    color: var(--text-secondary);
    backdrop-filter: blur(4px);
}
.mj-btn-outline:hover { border-color: var(--accent-blue); color: var(--accent-blue); background: rgba(59,130,246,0.1); }

.mj-btn-sm { padding: 4px 12px; font-size: 11px; }
.mj-btn-xs { padding: 3px 8px; font-size: 10px; }

/* ====== 雀魂牌桌主布局 ====== */
.mj-game-area {
    position: relative;
    width: 100%;
    height: 100dvh;
    padding-top: 60px;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-areas:
        "info info info"
        "oppopp oppopp oppopp"
        "left center right"
        "bottom bottom bottom";
    overflow: hidden;
}

/* 中央区域 */
.mj-center-zone {
    grid-area: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    min-height: 0;
}

/* 番型图鉴标签 */
.fan-tab {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #ccc;
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
}
.fan-tab:hover {
    background: rgba(255,255,255,0.15);
}

/* 出牌区（河） */
.mj-river {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    gap: 3px;
    width: 100%;
    max-width: 340px;
    max-height: 160px;
    overflow-y: auto;
    padding: 12px;
    background: rgba(0,0,0,0.25);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    position: relative;
}

.mj-river::-webkit-scrollbar {
    width: 3px;
}
.mj-river::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.mj-river-tile {
    width: 32px;
    height: 44px;
    flex-shrink: 0;
    pointer-events: none;
}

.mj-river-tile .tile-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 结算界面4人分数表 */
.player-scores {
    margin: 8px 0;
    padding: 8px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
}
.player-score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 3px 0;
}
.ps-name {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ps-score {
    font-size: 12px;
    font-weight: 700;
    min-width: 50px;
    text-align: right;
}
.ps-score.positive { color: #2ecc71; }
.ps-score.negative { color: #e74c3c; }

/* 信息栏 */
.mj-top-bar {
    grid-area: info;
    display: flex;
    align-items: center;
    justify-content:center;
    gap: 20px;
    padding: 6px 16px;
    padding-top: calc(6px + var(--safe-top));
    background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, transparent 100%);
    z-index: 10;
    font-size: 12px;
}

.mj-top-bar .stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.3);
    padding: 3px 12px;
    border-radius: var(--radius-pill);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-light);
}

.mj-top-bar .stat-value {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 13px;
}

/* ====== 玩家区域 ====== */
.mj-player-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    position: relative;
}

/* 上家（对面） */
.mj-player-opponent {
    grid-area: oppopp;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
    z-index: 5;
}

/* 下家（左）和上家（右）— 头像居中，手牌横向在旁 */
.mj-player-left {
    grid-area: left;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding-left: 14px;
    position: relative;
}
.mj-player-right {
    grid-area: right;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 6px;
    padding-right: 14px;
    position: relative;
}

/* 自己（底） */
.mj-player-self {
    grid-area: bottom;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 12px;
    padding-bottom: calc(12px + var(--safe-bottom));
    background: linear-gradient(0deg, rgba(0,0,0,0.5) 0%, transparent 100%);
    z-index: 10;
    position: relative;
}

/* 玩家顶部栏（头像 + 出牌按钮 + melds 横向排列） */
.mj-player-self .player-top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 700px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 玩家顶部栏内的melds横向 */
.mj-player-self .mj-melds {
    flex-direction: row;
    gap: 4px;
}

/* ====== 玩家信息卡 ====== */
.player-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    background: rgba(0,0,0,0.45);
    border-radius: var(--radius-pill);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border-light);
    white-space: nowrap;
}

.player-card .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-med);
    flex-shrink: 0;
    background: var(--bg-card);
}

.player-card .avatar-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4a7cf7, #6c5ce7);
    border: 2px solid var(--border-med);
    flex-shrink: 0;
    font-size: 14px;
}

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

.player-card .score {
    font-size: 11px;
    color: var(--accent-gold);
    font-weight: 600;
}

.player-card .hand-count {
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(0,0,0,0.3);
    padding: 1px 6px;
    border-radius: 8px;
}

/* 当前出牌/操作指示 */
.player-card.active-turn {
    border-color: var(--accent-gold);
    box-shadow: 0 0 16px rgba(245,179,66,0.35), inset 0 0 8px rgba(245,179,66,0.08);
    animation: turnGlow 1.5s ease-in-out infinite;
}

@keyframes turnGlow {
    0%, 100% { box-shadow: 0 0 16px rgba(245,179,66,0.35), inset 0 0 8px rgba(245,179,66,0.08); }
    50% { box-shadow: 0 0 24px rgba(245,179,66,0.5), inset 0 0 12px rgba(245,179,66,0.12); }
}

/* 左/右侧玩家卡片（竖排固定在横向容器中 — melds在卡片内） */
.mj-player-left .player-card,
.mj-player-right .player-card {
    flex-direction: column;
    padding: 6px 4px;
    text-align: center;
    gap: 2px;
    border-radius: var(--radius-md);
    width: auto;
    min-width: 56px;
    max-width: 110px;
    flex-shrink: 0;
    flex-grow: 0;
}

/* 左右AI卡片内的melds — 每组1行，组间垂直排列，用小牌避免溢出 */
.mj-player-left .player-card .mj-melds,
.mj-player-right .player-card .mj-melds {
    flex-direction: column;
    gap: 1px;
    padding: 1px 0;
    width: 100%;
    align-items: center;
}
.mj-player-left .player-card .mj-meld-group,
.mj-player-right .player-card .mj-meld-group {
    justify-content: center;
}
.mj-player-left .player-card .mj-meld-tile,
.mj-player-right .player-card .mj-meld-tile {
    width: 20px;
    height: 28px;
    font-size: 7px;
}
.mj-player-left .player-card .mj-meld-tile.mj-meld-claimed,
.mj-player-right .player-card .mj-meld-tile.mj-meld-claimed {
    margin: 0 1px;
}
.mj-player-left .player-card .name,
.mj-player-right .player-card .name {
    max-width: 100%;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mj-player-left .player-card .hand-count,
.mj-player-right .player-card .hand-count {
    font-size: 10px;
}
.mj-player-left .player-card .avatar,
.mj-player-right .player-card .avatar,
.mj-player-left .player-card .avatar-placeholder,
.mj-player-right .player-card .avatar-placeholder {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

/* 左/右侧手牌 — 竖向排列（头像旁边） */
.mj-player-left .player-hand,
.mj-player-right .player-hand {
    flex-direction: column;
    align-items: center;
    min-height: auto;
    gap: 3px;
    margin-top: 0;
}

/* 对家AI的副露区 */
.mj-player-opponent .mj-melds {
    flex-direction: row;
}

/* ====== 手牌 ====== */
.player-hand {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--tile-gap);
    padding: 2px 4px;
    min-height: var(--tile-height);
    position: relative;
}

/* 上家AI手牌间距 */
.mj-player-opponent .player-hand {
    gap: 2px;
}

/* 底栏手牌容器 — 顶部留空间给选中牌上弹 */
.mj-player-self .hand-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    max-width: 700px;
    justify-content: center;
    padding-top: 14px;
}

.mj-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tile-width);
    height: var(--tile-height);
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s ease;
    position: relative;
    flex-shrink: 0;
    line-height: 1;
    will-change: transform;
    backface-visibility: hidden;
}

.tile-img {
    width: var(--tile-width);
    height: var(--tile-height);
    object-fit: contain;
    display: block;
    pointer-events: none;
}
.tile-img-sm {
    width: 38px;
    height: 54px;
}
.tile-img-xs {
    width: 32px;
    height: 46px;
}
.tile-img-back {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.mj-tile:hover {
    transform: translateY(-4px);
    z-index: 2;
}

/* 新摸到的牌动画 */
.mj-tile.just-drawn {
    animation: tileDrawIn 0.4s ease-out;
}

@keyframes tileDrawIn {
    0% { transform: translateY(-30px) scale(0.8); opacity: 0.5; }
    60% { transform: translateY(2px) scale(1.02); }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.mj-tile.selected {
    transform: translateY(-12px);
    z-index: 3;
}

.mj-tile .tile-label {
    font-size: var(--tile-font);
    font-weight: 700;
    position: relative;
    z-index: 1;
}

/* 结算界面的赢家牌型展示 */
.settlement-hand {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    margin: 8px 0;
    padding: 6px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
}
.settlement-hand .mj-tile-sm {
    width: 32px;
    height: 46px;
    cursor: default;
    pointer-events: none;
}
.settlement-hand .mj-tile-win {
    position: relative;
}
.settlement-hand .mj-tile-win .tile-img {
    box-shadow: 0 0 12px 4px rgba(241, 196, 15, 0.8);
    border-radius: 4px;
    animation: win-tile-pulse 1.4s ease-in-out infinite alternate;
}
@keyframes win-tile-pulse {
    from { box-shadow: 0 0 8px 2px rgba(241, 196, 15, 0.5); }
    to   { box-shadow: 0 0 16px 6px rgba(241, 196, 15, 0.95); }
}
.settlement-hand .mj-tile-win::after {
    content: '胡';
    position: absolute;
    top: -10px;
    right: -10px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 8px rgba(231,76,60,0.6);
    z-index: 5;
    pointer-events: none;
}

/* 结算界面的副露（吃碰杠）展示 */
.settlement-melds {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin: 4px 0 2px 0;
}
.settlement-meld-group {
    display: flex;
    gap: 1px;
    padding: 2px 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
}
.settlement-meld-group .mj-tile-sm {
    width: 28px;
    height: 40px;
    cursor: default;
    pointer-events: none;
}

/* 选中牌时显示剩余张数标记 */
.mj-tile .tile-remain {
    position: absolute;
    bottom: -8px;
    right: -6px;
    background: #e53935;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 14px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    z-index: 10;
    line-height: 1;
    white-space: nowrap;
}

/* 花色颜色 */
.mj-tile.suit-wan .tile-label { color: #d32f2f; }
.mj-tile.suit-tiao .tile-label { color: #2e7d32; }
.mj-tile.suit-tong .tile-label { color: #1565c0; }
.mj-tile.suit-feng .tile-label { color: #6a1b9a; }
.mj-tile.suit-jian .tile-label { color: #e65100; }

/* AI手牌数量标记 */
.ai-hand-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent-gold);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    z-index: 1;
}

/* 牌背 */
.mj-tile-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tile-width);
    height: var(--tile-height);
    flex-shrink: 0;
    position: relative;
}

.mj-tile-back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 2px;
}

/* 小号牌背（对手手牌） */
.mj-tile-back-sm {
    width: 28px;
    height: 40px;
}
.mj-tile-back-sm .ai-hand-badge { font-size: 12px; }

/* 极小牌背（顶部对手） */
.mj-tile-back-xs {
    width: 22px;
    height: 32px;
}
.mj-tile-back-xs .ai-hand-badge { font-size: 10px; }

/* AI手牌数量标记 — 在牌背中间 */
.ai-hand-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-gold);
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.6);
    z-index: 1;
    pointer-events: none;
}
.mj-tile-sm {
    width: 32px;
    height: 46px;
    font-size: 11px;
}

/* 最近出的牌标记（高亮） */
.mj-river-tile.latest {
    border-color: var(--accent-gold);
    box-shadow: 0 0 6px rgba(245,179,66,0.3);
}

/* ====== 吃碰杠显示区 ====== */
.mj-melds {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.mj-meld-group {
    display: flex;
    gap: 1px;
}

.mj-meld-tile {
    width: 32px;
    height: 46px;
    cursor: default;
    pointer-events: none;
}

.mj-meld-tile .tile-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 横置牌（从别家吃碰杠来的牌） */
.mj-meld-claimed {
    transform: rotate(90deg);
    margin: 0 2px;
}

/* 副露区 */
.mj-melds {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 2px 0;
}

.mj-meld-group {
    display: flex;
    align-items: center;
    gap: 1px;
}

/* ====== 操作按钮区（浮层 — 牌河下方显示） ====== */
.mj-action-bar {
    position: fixed;
    bottom: calc(140px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 50;
    background: rgba(0,0,0,0.7);
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-med);
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

/* 听牌提示区 */
.mj-ting-indicator {
    position: fixed;
    bottom: calc(195px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(231,76,60,0.4);
    animation: tingPulse 1.5s ease-in-out infinite;
}
@keyframes tingPulse {
    0%, 100% { opacity: 0.9; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

.mj-action-btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    line-height: 1;
    letter-spacing: 1px;
}

.mj-action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}
.mj-action-btn:active {
    transform: translateY(0);
}

.mj-action-btn.hu {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: #fff;
    animation: huPulse 1s ease-in-out infinite;
}

@keyframes huPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,71,87,0.4); }
    50% { box-shadow: 0 0 20px rgba(255,71,87,0.7); }
}

.mj-action-btn.peng {
    background: linear-gradient(135deg, var(--accent-green), #2ed573);
    color: #fff;
}

.mj-action-btn.chi {
    background: linear-gradient(135deg, var(--accent-blue), #5352ed);
    color: #fff;
}

.mj-action-btn.gang {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: #fff;
}

.mj-action-btn.pass {
    background: rgba(255,255,255,0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-med);
}

.mj-action-btn.draw {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    color: #fff;
    animation: drawPulse 1.5s ease-in-out infinite;
}

@keyframes drawPulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(245,179,66,0.3); }
    50% { box-shadow: 0 2px 20px rgba(245,179,66,0.5); }
}

.mj-action-btn.hint,
.mj-action-btn.cancel {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

/* ====== 按钮行（摸牌/出牌/提示/取消） ====== */
.mj-game-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

/* 表情弹窗气泡 */
.speech-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    margin-bottom: 10px;
}
.speech-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0,0,0,0.85);
}
.speech-animate {
    animation: speechPopIn 0.3s ease-out;
}
@keyframes speechPopIn {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    70% { transform: translateX(-50%) scale(1.1); }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ====== 气泡台词 ====== */
.mj-bubble {
    position: absolute;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    white-space: nowrap;
    animation: bubbleIn 0.3s ease-out;
    pointer-events: none;
    z-index: 30;
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

@keyframes bubbleIn {
    from { opacity: 0; transform: scale(0.8) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.mj-bubble.top { top: -30px; left: 50%; transform: translateX(-50%); }
.mj-bubble.left { left: -120px; top: 50%; transform: translateY(-50%); }
.mj-bubble.right { right: -120px; top: 50%; transform: translateY(-50%); }
.mj-bubble.bottom { bottom: 60px; left: 50%; transform: translateX(-50%); }

/* ====== Toast ====== */
.mj-toast {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    z-index: 200;
    pointer-events: none;
    animation: toastIn 0.25s ease-out, toastOut 0.3s ease-in 1.7s forwards;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-light);
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translate(-50%, -50%) scale(1.1) translateY(-10px); }
}

/* ====== 胡牌特效 ====== */
.mj-win-effect {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle, rgba(255,215,0,0.25), transparent 70%);
    z-index: 150;
    pointer-events: none;
    animation: winFlash 0.6s ease-out;
}

@keyframes winFlash {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

/* ====== 弹窗（ddz 风格完全迁移） ====== */
.hidden { display: none !important; }

/* 结果类弹窗（ddz .result-modal） */
.mj-result-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 4000;
}
.mj-result-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    color: white;
    border: 2px solid #ffd700;
    min-width: 300px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

/* 列表类弹窗（ddz .leaderboard-modal） */
.mj-list-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 4000;
}
.mj-list-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    padding: 25px;
    color: white;
    border: 2px solid #ffd700;
    min-width: 300px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}
.mj-list-content .list-title {
    font-size: 22px; font-weight: bold; text-align: center; margin-bottom: 15px; color: #ffd700;
}
.mj-list-content .list-body {
    max-height: 350px; overflow-y: auto;
}

/* 弹窗按钮 */
.mj-list-content .btn {
    padding: 6px 14px; border: none; border-radius: 20px; cursor: pointer;
    font-size: 13px; transition: all 0.2s ease; white-space: nowrap;
}
.mj-list-content .btn:active { transform: scale(0.95); }
.mj-list-content .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white;
}
.mj-list-content .btn-secondary {
    background: rgba(255,255,255,0.2); color: white;
}

/* 排行榜项（ddz .leaderboard-item） */
.leaderboard-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 15px; background: rgba(255, 255, 255, 0.1);
    border-radius: 10px; margin-bottom: 8px;
}
.leaderboard-item:nth-child(1) { background: linear-gradient(135deg, #f39c12, #e67e22); }
.leaderboard-item:nth-child(2) { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }
.leaderboard-item:nth-child(3) { background: linear-gradient(135deg, #cd7f32, #b8860b); }
.leaderboard-item .rank { font-weight: bold; width: 30px; }
.leaderboard-item .player-name { flex: 1; text-align: left; margin-left: 10px; display: flex; align-items: center; gap: 6px; }
.leaderboard-item .lb-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.leaderboard-item .lb-stats { font-size: 12px; color: #aaa; margin-right: 10px; }
.leaderboard-item .player-score { font-weight: bold; color: #ffd700; }
.leaderboard-item.ai-item { opacity: 0.85; border-left: 3px solid #667eea; }

/* 积分流水项（ddz .score-log-*） */
.score-log-list { max-height: 350px; overflow-y: auto; padding: 5px 0; }
.score-log-item {
    display: flex; align-items: center; padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08); gap: 8px; font-size: 13px;
}
.score-log-item:last-child { border-bottom: none; }
.score-log-item .log-reason { flex: 1; color: #ccc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-log-item .log-time { color: #666; font-size: 11px; white-space: nowrap; min-width: 90px; text-align: center; }
.score-log-item .log-change { min-width: 50px; text-align: right; font-family: 'Courier New', monospace; }

/* 商城/背包商品项（ddz .shop-item） */
.shop-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 10px; margin-bottom: 6px;
    background: rgba(255,255,255,0.06);
}
.shop-filter-btn, .inv-filter-btn {
    font-size: 10px; padding: 3px 8px; border-radius: 12px;
    border: none; cursor: pointer; transition: all 0.2s; white-space: nowrap;
    background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8);
}
.shop-filter-btn.active, .inv-filter-btn.active {
    background: #ffd700; color: #1a1a2e; font-weight: 600;
}

/* 购物反馈弹窗 */
.shop-feedback-icon { font-size: 48px; margin-bottom: 5px; }

/* ====== loading容器（ddz 风格） ====== */
#loadingContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#loadingContainer.hidden { display: none !important; }
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    margin-top: 15px;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
}
.shop-feedback-title { font-size: 24px; font-weight: bold; margin-bottom: 10px; }
.shop-feedback-msg { font-size: 14px; color: #ccc; margin-bottom: 15px; }

/* 原有通用弹窗保留（结算用） */
.mj-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.mj-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #ffd700;
    border-radius: 20px;
    padding: 25px;
    max-width: 500px;
    width: 90vw;
    min-width: 300px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.mj-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.mj-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #ffd700;
}
.mj-modal-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.mj-modal-close:hover { color: #fff; }
.mj-modal-body { padding: 0; }

/* ====== 结算弹窗（ddz 风格） ====== */
.settlement-modal { text-align: center; }
.settlement-modal .result-icon { font-size: 56px; margin-bottom: 8px; }
.settlement-modal .result-text {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 6px;
}
.settlement-modal .result-text.win { color: #2ecc71; }
.settlement-modal .result-text.lose { color: #e74c3c; }
.settlement-modal .score-change {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 14px;
}
.settlement-modal .score-change.positive { color: #2ecc71; }
.settlement-modal .score-change.negative { color: #e74c3c; }
.settlement-modal .fan-detail {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 18px;
}
.settlement-modal .fan-item {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    padding: 3px 10px;
    border-radius: 12px;
    margin: 2px;
    font-size: 11px;
    border: 1px solid rgba(255,255,255,0.15);
    cursor: help;
    position: relative;
}

/* ====== 排行榜（ddz 风格） ====== */
.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.ranking-table td {
    padding: 10px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ranking-table tbody tr {
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
}
.ranking-table tbody tr:hover td { background: rgba(255,255,255,0.03); }
.rank-num { font-size: 14px; font-weight: 700; text-align: center; }
.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }
.score-num { color: #ffd700; font-weight: 700; }

/* ====== 商城/背包（ddz 风格） ====== */
.shop-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 6px;
    background: rgba(255,255,255,0.06);
    border: none;
    transition: background 0.2s;
}
.shop-item:hover { background: rgba(255,255,255,0.1); }

/* 商城描述：默认2行展开，可点击展开全部 */
.shop-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}
.shop-desc[data-expanded="true"] {
    -webkit-line-clamp: unset;
    display: block;
}
.shop-filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    justify-content: center;
}
.shop-filter-btn, .inv-filter-btn {
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.8);
}
.shop-filter-btn.active, .inv-filter-btn.active {
    background: #ffd700;
    color: #1a1a2e;
    font-weight: 600;
}
.shop-filter-btn:hover, .inv-filter-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* ====== 积分加成指示器 ====== */
.mj-buff-indicator {
    position: absolute;
    top: calc(var(--safe-top) + 48px);
    right: 12px;
    background: linear-gradient(135deg, #f59e0b, #e67e22);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    z-index: 50;
    box-shadow: 0 2px 10px rgba(243,156,18,0.3);
    animation: buffPulse 2s ease-in-out infinite;
    white-space: nowrap;
}

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

/* ====== 工具类 ====== */
.text-center { text-align: center; }
.hidden { display: none; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }

/* ====== 欢迎界面（绿色渐变） ====== */
.login-screen {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1b7a3d 0%, #0d5c2e 50%, #083d1e 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    padding: 20px;
}

.login-container {
    background: rgba(30, 30, 40, 0.95);
    border-radius: 20px;
    padding: 35px;
    min-width: 400px;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    box-sizing: border-box;
}

.login-container .game-subtitle {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 28px;
    font-weight: 500;
}

.login-container .login-subtitle {
    font-size: 15px;
    text-align: center;
    margin-bottom: 8px;
    color: #aaa;
    font-weight: 500;
}

.login-container .start-btn {
    display: block;
    width: 100%;
    margin: 16px 0;
    padding: 14px 24px;
    background: linear-gradient(135deg, #219d53 0%, #147c3e 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 2px;
    box-shadow: 0 4px 16px rgba(13, 92, 46, 0.35);
    -webkit-appearance: none;
    appearance: none;
}

.login-container .start-btn:active {
    transform: scale(0.97);
}

.login-container .start-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

/* ====== 欢迎界面用户信息（已登录） ====== */
.welcome-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
}
.welcome-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid #667eea;
    object-fit: cover;
}
.welcome-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}
.welcome-score {
    font-size: 14px;
    color: #bbb;
}
.welcome-score strong {
    color: #f1c40f;
    font-size: 18px;
}

/* ====== 欢迎界面操作按钮组（商城/背包/充值） ====== */
.welcome-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.welcome-action-btn {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}
.welcome-action-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.welcome-action-btn:active {
    transform: scale(0.97);
}

/* ====== 欢迎界面：公告与最近更新 ====== */
.welcome-modules {
    margin-top: 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.welcome-notice,
.welcome-updates {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 14px 16px;
}

.welcome-notice .module-title,
.welcome-updates .module-title {
    font-size: 13px;
    font-weight: 600;
    color: #f1c40f;
    margin-bottom: 8px;
}

.welcome-notice .module-body {
    font-size: 13px;
    color: #ddd;
    line-height: 1.6;
    max-height: calc(1.6em * 5);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
}
.welcome-notice .module-body::-webkit-scrollbar {
    width: 4px;
}
.welcome-notice .module-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.welcome-updates .module-body {
    font-size: 12px;
    color: #bbb;
    line-height: 1.8;
    max-height: calc(1.8em * 5);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
}
.welcome-updates .module-body::-webkit-scrollbar {
    width: 4px;
}
.welcome-updates .module-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.welcome-updates .update-item {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.welcome-updates .update-item:last-child {
    border-bottom: none;
}

.welcome-updates .module-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* ====== 欢迎界面：登录表单（未登录用户） ====== */
.login-container .login-tip {
    background: rgba(100, 150, 200, 0.2);
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 16px;
    text-align: left;
    font-size: 12px;
    color: #8cb4d8;
    line-height: 1.6;
}
.login-container .login-error {
    color: #e74c3c;
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
}
.login-container .btn-redirect-login {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
    transition: all 0.2s;
}
.login-container .btn-redirect-login:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}
.login-container .btn-guest {
    display: block;
    width: 100%;
    padding: 12px 24px;
    background: transparent;
    color: #aaa;
    border: 1px solid #444;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    box-sizing: border-box;
}
.login-container .btn-guest:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-color: #888;
}

/* 响应式：竖屏登录欢迎界面 */
@media (orientation: portrait) {
    .login-screen {
        top: 50px;
    }
    .login-container {
        padding: 24px 20px;
        min-width: unset;
        width: 100%;
        max-width: 360px;
    }
    .login-container .game-subtitle { font-size: 12px; }
    .login-container .login-subtitle { font-size: 13px; margin-bottom: 6px; }
    .login-container .start-btn { font-size: 16px; padding: 14px 20px; }
    .welcome-action-btn { font-size: 12px; padding: 8px 6px; }
}

@media (orientation: portrait) and (max-width: 400px) {
    .login-screen {
        top: 44px;
    }
    .login-container {
        padding: 18px 14px;
    }
    .login-container .game-subtitle { font-size: 11px; }
    .login-container .login-subtitle { font-size: 13px; margin-bottom: 6px; }
}

/* ====== 响应式 - 竖屏适配 ====== */
@media (orientation: portrait) {
    :root {
        --tile-width: 32px;
        --tile-height: 46px;
        --tile-font: 11px;
    }

    /* 竖屏简化导航 — 仅保留图标 */
    .mj-nav { height: 50px; }
    .mj-game-area { padding-top: 50px; }
    .mj-nav-icon { font-size: 18px; }
    .mj-nav-title { display: none; }
    .mj-nav-title::before { content: none; }
    .mj-nav-right .nav-user-name { display: none; }
    .mj-nav-right .nav-score-label { display: none; }
    .mj-nav-right .nav-user-info { display: none; }
    /* 竖屏导航按钮只显示 emoji */
    .nav-btn-text { display: none; }

    /* 竖屏手牌容器 — 允许横向滚动 */
    .mj-player-self .hand-wrapper {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-top: 10px;
        justify-content: center;
        padding-left: 4px;
        padding-right: 4px;
    }
    .mj-player-self .hand-wrapper::-webkit-scrollbar {
        height: 2px;
    }
    .mj-player-self .hand-wrapper::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.1);
        border-radius: 1px;
    }

    .mj-game-area {
        grid-template-columns: 1fr 2fr 1fr;
        grid-template-rows: auto auto 1fr auto;
        grid-template-areas:
            "info info info"
            "oppopp oppopp oppopp"
            "left center right"
            "bottom bottom bottom";
    }

    .mj-center-zone {
        padding: 10px 6px;
    }

    .mj-river {
        max-width: 260px;
        min-height: 80px;
        padding: 8px;
    }

    .mj-river-tile {
        width: 26px;
        height: 36px;
        font-size: 9px;
    }

    .mj-tile-back-sm {
        width: 24px;
        height: 34px;
    }
    .mj-tile-back-xs {
        width: 18px;
        height: 26px;
    }

    .mj-action-bar {
        bottom: calc(100px + var(--safe-bottom));
        gap: 6px;
        padding: 8px 14px;
    }
    .mj-action-btn {
        padding: 8px 14px;
        font-size: 12px;
    }

    .player-card .avatar,
    .player-card .avatar-placeholder {
        width: 26px;
        height: 26px;
    }
    .mj-player-left .player-card .avatar,
    .mj-player-right .player-card .avatar,
    .mj-player-left .player-card .avatar-placeholder,
    .mj-player-right .player-card .avatar-placeholder {
        width: 30px;
        height: 30px;
    }
}

/* ====== 响应式 - 小屏竖屏 ====== */
@media (orientation: portrait) and (max-width: 400px) {
    :root {
        --tile-width: 32px;
        --tile-height: 46px;
        --tile-font: 11px;
    }

    .mj-nav { height: 44px; }
    .mj-game-area { padding-top: 44px; }
    .mj-nav-title { font-size: 12px; }
    .mj-nav-title::before { content: none; }
    .mj-nav-right { gap: 4px; }
    .mj-nav-right .nav-btn { height: 28px; padding: 0 8px; font-size: 11px; }
    .mj-nav-right .nav-user-info { height: 28px; padding: 0 6px; }
    .mj-nav-right .nav-avatar { width: 18px; height: 18px; }
    .mj-nav-right .nav-score { height: 28px; padding: 0 6px; }
    .mj-nav-right .nav-score-value { font-size: 12px; }

    .mj-center-zone {
        padding: 8px 4px;
    }

    .mj-river {
        max-width: 200px;
        min-height: 60px;
        padding: 6px;
    }
    .mj-river-tile {
        width: 22px;
        height: 30px;
        font-size: 8px;
    }

    .mj-tile-back-sm {
        width: 20px;
        height: 28px;
    }
    .mj-tile-back-xs {
        width: 14px;
        height: 20px;
    }

    .mj-action-bar {
        bottom: calc(80px + var(--safe-bottom));
        gap: 4px;
        padding: 6px 10px;
    }
    .mj-action-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .mj-nav { height: 40px; }
    .mj-game-area { padding-top: 40px; }

    .player-card { font-size: 10px; padding: 2px 6px 2px 2px; }
    .player-card .avatar,
    .player-card .avatar-placeholder {
        width: 22px;
        height: 22px;
    }
}

/* ====== 响应式 - 横屏小屏 ====== */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --tile-width: 34px;
        --tile-height: 48px;
        --tile-font: 12px;
    }

    .mj-center-zone {
        padding: 10px 6px;
    }

    .mj-river {
        max-width: 260px;
        min-height: 70px;
        padding: 8px;
    }
    .mj-river-tile {
        width: 24px;
        height: 34px;
        font-size: 9px;
    }

    .mj-tile-back-sm {
        width: 22px;
        height: 32px;
    }
    .mj-tile-back-xs {
        width: 16px;
        height: 24px;
    }

    .mj-action-bar {
        bottom: calc(90px + var(--safe-bottom));
        gap: 6px;
        padding: 8px 14px;
    }
    .mj-action-btn {
        padding: 8px 14px;
        font-size: 12px;
    }

    .player-card { padding: 2px 8px 2px 2px; }
    .player-card .avatar,
    .player-card .avatar-placeholder {
        width: 22px;
        height: 22px;
    }
    .mj-player-left .player-card,
    .mj-player-right .player-card {
        width: 48px;
        padding: 4px;
    }
    .mj-player-left .player-card .avatar,
    .mj-player-right .player-card .avatar,
    .mj-player-left .player-card .avatar-placeholder,
    .mj-player-right .player-card .avatar-placeholder {
        width: 28px;
        height: 28px;
    }
}

/* ====== 暗杠选择弹窗 ====== */
.angang-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}
.angang-tile {
    width: 40px;
    height: 56px;
    font-size: 13px;
}

/* ====== 对手信息头像+名字+分数横排 ====== */
.mj-player-opponent .player-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mj-player-opponent .player-card {
    flex-direction: row;
}

/* ====== 空状态占位图 ====== */
.mj-placeholder-art {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    opacity: 0.15;
    pointer-events: none;
}
