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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #05141f;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: #ffffff;
}

/* 竖屏阻断提示 */
.rotate-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 99999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.rotate-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: rotatePhone 2s infinite ease-in-out;
}

.rotate-text {
    font-size: 18px;
    color: #ffd54f;
}

@keyframes rotatePhone {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

@media screen and (orientation: portrait) {
    .rotate-mask {
        display: flex;
    }
}

/* 主对战台呢舞台 */
#game-stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: radial-gradient(ellipse at 50% 120%, #177199 0%, #0c4d6b 40%, #07354a 70%, #04202e 100%);
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* 顶部状态栏 */
#game-header {
    width: 100%;
    height: 48px;
    padding: 4px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 20;
}

#hole-cards-container {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 215, 0, 0.35);
}

.hole-title {
    font-size: 10px;
    color: #ffd54f;
    font-weight: bold;
}

.hole-cards-list {
    display: flex;
    gap: 3px;
}

.hole-cards-list .card {
    width: 28px !important;
    height: 38px !important;
    margin-left: 0 !important;
    padding: 1px 2px !important;
    border-radius: 3px !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6) !important;
}

.hole-cards-list .card .card-val { font-size: 9px !important; }
.hole-cards-list .card .card-suit-icon { font-size: 7px !important; }
.hole-cards-list .card .card-center-watermark { font-size: 12px !important; }

/* 胜率预测仪表 */
#win-rate-dashboard {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.win-rate-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.rate-number {
    font-weight: 900;
    color: #40c4ff;
}

.rate-track {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
}

.rate-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff5252 0%, #ffd600 50%, #00e676 100%);
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 难度选择器与房间信息 */
.room-info {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-sound-toggle {
    background: #00838f;
    border: 1px solid #4dd0e1;
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    border-radius: 4px;
    padding: 2px 5px;
    cursor: pointer;
    outline: none;
}

.btn-sound-toggle.muted {
    background: #455a64;
    border-color: #90a4ae;
    color: #cfd8dc;
}

.btn-diagnose {
    background: #d84315;
    border: 1px solid #ff7043;
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    border-radius: 4px;
    padding: 2px 5px;
    cursor: pointer;
    outline: none;
}

.difficulty-picker {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(0, 0, 0, 0.45);
    padding: 2px 5px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.diff-title {
    font-size: 10px;
    color: #81d4fa;
}

.diff-select {
    background: #0d2b3a;
    color: #ffd54f;
    border: 1px solid #ffd54f;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    outline: none;
    padding: 1px 2px;
    cursor: pointer;
}

.badge {
    background: rgba(0, 0, 0, 0.45);
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.gold-text {
    color: #ffd54f !important;
    font-weight: bold;
}

/* 牌桌对战场容器 */
#battle-ground {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}

.seat {
    display: flex;
    align-items: center;
    z-index: 10;
}

.avatar-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 85px;
}

.crown-icon {
    font-size: 22px;
    position: absolute;
    top: -22px;
    display: none;
    animation: bounceCrown 1.5s infinite ease-in-out;
}

.crown-icon.active {
    display: block;
}

@keyframes bounceCrown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.avatar-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.avatar-ring.active-turn {
    box-shadow: 0 0 16px #00e676, 0 0 25px rgba(0, 230, 118, 0.8) !important;
    transform: scale(1.08);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #102a38;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
}

.player-name {
    font-size: 11px;
    font-weight: bold;
    margin-top: 3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.coin-badge {
    font-size: 10px;
    color: #ffecb3;
    margin: 1px 0;
}

.card-count-pill {
    background: #0288d1;
    border: 1px solid #81d4fa;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: bold;
}

.ai-status {
    font-size: 10px;
    color: #ffeb3b;
    min-height: 14px;
}

.reveal-cards-zone {
    display: flex;
    flex-wrap: wrap;
    max-width: 140px;
    gap: -15px;
    margin-top: 5px;
}

.reveal-cards-zone .card {
    width: 24px !important;
    height: 34px !important;
    margin-left: -12px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5) !important;
    padding: 1px !important;
}

.reveal-cards-zone .card:first-child {
    margin-left: 0 !important;
}

.reveal-cards-zone .card .card-val { font-size: 8px !important; }
.reveal-cards-zone .card .card-suit-icon { font-size: 7px !important; }
.reveal-cards-zone .card .card-center-watermark { display: none !important; }

/* ====================================================
   核心升级：三方出牌区独立黄金坐标 (彻底根治整体偏左！)
   ==================================================== */
.discard-zone {
    display: flex;
    align-items: center;
    min-height: 72px;
    z-index: 15;
    pointer-events: none;
}

/* 1. 左电脑出牌区：向内收进，与左头像保持优雅距离 */
.discard-table-left {
    position: absolute;
    left: 125px;
    top: 50%;
    transform: translateY(-50%);
    justify-content: flex-start;
}

/* 2. 右电脑出牌区：与左电脑绝对镜像对称！ */
.discard-table-right {
    position: absolute;
    right: 100px;
    top: 50%;
    transform: translateY(-50%);
    justify-content: flex-end;
}

/* 3. 我方出牌区：严格锁定屏幕 50% 轴线，内部卡牌绝对居中！ */
.discard-me {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    justify-content: center !important; /* 关键：打出的牌 100% 物理死死居中！ */
    width: auto;
    min-width: 50px;
}

.pass-text-art {
    font-size: 22px;
    font-weight: 900;
    color: #ffca28;
    text-shadow: 0 2px 0 #bf360c, 0 3px 6px rgba(0, 0, 0, 0.8);
    letter-spacing: 2px;
}

.center-notification {
    position: absolute;
    top: 28%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    font-weight: 900;
    color: #ffd54f;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 30;
}

/* 底部操作与手牌控制区 */
#player-bottom {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 2px;
    z-index: 50;
}

.action-panel {
    min-height: 42px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

.btn-group {
    display: flex;
    gap: 14px;
}

.hidden {
    display: none !important;
}

.btn-pill {
    min-width: 95px;
    height: 38px;
    border-radius: 19px;
    border: none;
    outline: none;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-pill:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.btn-pill:disabled {
    filter: grayscale(0.85);
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-cyan {
    background: linear-gradient(180deg, #4dd0e1 0%, #0097a7 50%, #00838f 100%);
    color: #ffffff;
    border-top: 1px solid #b2ebf2;
}

.btn-teal {
    background: linear-gradient(180deg, #4db6ac 0%, #00897b 50%, #00695c 100%);
    color: #ffffff;
    border-top: 1px solid #b2dfdb;
}

.btn-gold {
    background: linear-gradient(180deg, #ffca28 0%, #ffa000 50%, #ff8f00 100%);
    color: #4e2600;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
    border-top: 1px solid #fff8e1;
}

/* 悬浮版【记牌器】 */
.card-recorder-bar {
    position: absolute;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    background: rgba(3, 20, 31, 0.92);
    border: 1px solid rgba(255, 202, 40, 0.85);
    border-radius: 6px;
    padding: 2px 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.recorder-toggle-btn {
    background: #0d2b3a;
    border: 1px solid #ffca28;
    color: #ffd54f;
    font-size: 10px;
    font-weight: bold;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    outline: none;
    transition: background 0.2s;
}

.recorder-toggle-btn:active {
    background: #174d68;
}

.recorder-grid {
    display: flex;
    gap: 7px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    margin-left: 6px;
}

.recorder-grid.closed {
    display: none !important;
}

.record-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 12px;
}

.record-label { font-size: 9px; color: #cfd8dc; font-weight: bold; }
.record-count { font-size: 10px; font-weight: 900; color: #ff9800; }
.record-count.zero { color: #455a64; }

/* 我方手牌大号容器 */
.hand-cards-wrapper {
    position: relative;
    width: 98%;
    max-width: 1080px;
    height: 135px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    z-index: 50;
}

.hand-cards {
    display: flex;
    position: relative;
    height: 100%;
    align-items: flex-end;
}

/* 卡牌基础通用样式 */
.card {
    position: relative;
    background-color: #ffffff;
    border-radius: 5px;
    border: 1px solid #b0bec5;
    box-shadow: -2px 2px 6px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3px 5px;
    cursor: pointer;
    transition: transform 0.1s ease-out;
    color: #212121;
}

.card * {
    pointer-events: none !important;
}

.card:first-child {
    margin-left: 0 !important;
}

/* 手牌专属：大号饱满 (82 × 118px) */
.hand-cards .card {
    width: 82px;
    height: 118px;
    margin-left: -44px;
    padding: 4px 6px;
    border-radius: 6px;
    box-shadow: -2px 4px 10px rgba(0, 0, 0, 0.5);
}

.hand-cards .card .card-val {
    font-size: 20px;
    font-weight: 900;
    font-family: Arial, sans-serif;
}

.hand-cards .card .card-suit-icon {
    font-size: 16px;
    margin-top: 2px;
}

.hand-cards .card .card-center-watermark {
    font-size: 34px;
}

.hand-cards .card.joker-card .card-top .card-val {
    font-size: 13px;
}

.hand-cards .card.selected {
    transform: translateY(-26px) !important;
    border: 2px solid #ffd600;
    box-shadow: 0 0 18px rgba(255, 214, 0, 0.95), -2px 8px 12px rgba(0, 0, 0, 0.6);
}

/* 出牌区专属：小巧精致 (48 × 68px) */
.discard-zone .card {
    width: 48px !important;
    height: 68px !important;
    margin-left: -24px !important;
    padding: 2px 3px !important;
    border-radius: 4px !important;
    box-shadow: -1px 2px 4px rgba(0, 0, 0, 0.5) !important;
}

.discard-zone .card .card-val { font-size: 12px !important; }
.discard-zone .card .card-suit-icon { font-size: 9px !important; }
.discard-zone .card .card-center-watermark { font-size: 18px !important; }
.discard-zone .card.joker-card .card-top .card-val { font-size: 8px !important; }

.card.card-back {
    background: repeating-linear-gradient(45deg, #0277bd, #0277bd 6px, #01579b 6px, #01579b 12px);
    border: 2px solid #ffffff;
}

.card.suit-heart, .card.suit-diamond { color: #d32f2f; }
.card.suit-spade, .card.suit-club { color: #212121; }
.card.joker-black { color: #37474f; }
.card.joker-red { color: #d50000; }

.card .card-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
}

.card .card-center-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.16;
}

.card.joker-card .card-top .card-val {
    writing-mode: vertical-rl;
    font-weight: bold;
}

/* 左下角我方浮动信息岛 */
.self-float-island {
    position: absolute;
    bottom: 6px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.45);
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 60;
}

.self-crown {
    top: -18px;
    left: 4px;
}

.avatar-ring-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: box-shadow 0.3s ease;
}

.avatar-ring-sm.active-turn {
    box-shadow: 0 0 14px #ffd54f, 0 0 20px rgba(255, 213, 79, 0.8) !important;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0f3042;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
}

.self-meta {
    display: flex;
    flex-direction: column;
}

.self-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.self-name { font-size: 10px; font-weight: bold; }
.self-role-tag { font-size: 9px; color: #ffca28; }
.coin-tag { font-size: 9px; color: #ffecb3; }

.self-status-tips {
    position: absolute;
    bottom: 3px;
    right: 14px;
    font-size: 11px;
    color: #ffd54f;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* 诊断弹窗 */
.diagnose-card {
    background: #0d2b3a;
    border: 2px solid #40c4ff;
    border-radius: 10px;
    width: 90%;
    max-width: 480px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
}

.diagnose-title {
    font-size: 16px;
    color: #40c4ff;
    text-align: center;
}

.diag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.diag-input {
    flex: 1;
    background: #04141e;
    border: 1px solid #37474f;
    color: #ffd54f;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.diag-logs {
    background: #020b10;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 8px;
    font-family: monospace;
    font-size: 11px;
    height: 120px;
    overflow-y: auto;
    color: #a7ffeb;
    white-space: pre-wrap;
    line-height: 1.4;
}

.diag-btns {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* 结算弹窗 */
.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.settlement-card {
    background: #0a2533;
    border: 2px solid #ffd54f;
    border-radius: 12px;
    width: 320px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.9);
}

.win-title {
    font-size: 22px;
    color: #ffd54f;
    margin-bottom: 12px;
}

.settle-content {
    width: 100%;
    margin-bottom: 16px;
}

.settle-row {
    display: flex;
    justify-content: space-between;
    margin: 6px 0;
    font-size: 13px;
}

.settle-row .highlight { color: #00e676; }