/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a3d1e;
    font-family: "Microsoft YaHei", "SimHei", sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ========== 标题栏 ========== */
#header {
    background: rgba(0, 0, 0, 0.55);
    color: #ffd700;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    border-bottom: 2px solid rgba(240, 208, 96, 0.3);
}

#header h1 {
    font-size: 28px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#game-info {
    display: flex;
    gap: 30px;
    font-size: 18px;
    color: #e0e0e0;
    font-weight: bold;
}

/* ========== 麻将桌面 ========== */
#table {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 6px 12px;
    position: relative;
    background: #0d4a28;
    background-image:
        radial-gradient(ellipse at 50% 50%, #145c32 0%, #0a3d1e 70%);
}

/* ========== 玩家区域通用 ========== */
.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 4px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    margin-bottom: 4px;
    border: 1px solid rgba(240, 208, 96, 0.2);
}

.player-name {
    color: #ffd700;
    font-size: 17px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.player-score {
    font-size: 14px;
    font-weight: bold;
    color: #4cff4c;
    min-width: 40px;
    text-align: center;
}

.player-que {
    font-size: 15px;
    color: #ff4444;
    font-weight: bold;
}

.player-hu-flag {
    font-size: 15px;
    color: #ffd700;
    font-weight: bold;
}

/* ========== 手牌区域 ========== */
.hand-area {
    display: flex;
    justify-content: center;
    gap: 3px;
    min-height: 90px;
    flex-wrap: nowrap;
}

/* ========== 副露区域（碰/杠/吃） ========== */
.meld-area {
    display: flex;
    justify-content: center;
    gap: 16px;
    min-height: 36px;
    margin: 4px 0;
}

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

/* ========== 出牌区域 ========== */
.discard-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    min-height: 36px;
    max-width: 520px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
}

/* ========== 上下左右布局 ========== */
.top {
    flex-direction: column;
    margin-bottom: 6px;
}

#middle-row {
    display: flex;
    flex: 1;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.left, .right {
    width: 160px;
    flex-direction: column;
}

.bottom {
    flex-direction: column;
    margin-top: 6px;
}

/* ========== 中央信息区 ========== */
#center-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#center-message {
    background: rgba(0, 0, 0, 0.6);
    color: #ffd700;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(240, 208, 96, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ========== 牌面样式 ========== */
.tile {
    width: 56px;
    height: 78px;
    background: #fffef5;
    border: 2px solid #c8a050;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: default;
    font-weight: bold;
    box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.35);
    user-select: none;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    position: relative;
    overflow: hidden;
}

.tile::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border: 1px solid rgba(200, 160, 80, 0.2);
    border-radius: 5px;
    pointer-events: none;
}

.tile:hover {
    box-shadow: 3px 5px 12px rgba(0, 0, 0, 0.45);
}

/* 牌面数字 */
.tile .tile-number {
    font-size: 26px;
    line-height: 1;
}

/* 牌面花色字 */
.tile .tile-suit {
    font-size: 16px;
    line-height: 1;
    margin-top: 3px;
}

/* 牌面 SVG（条子/筒子图案） */
.tile .tile-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* 万 - 红色 */
.tile-wan .tile-number,
.tile-wan .tile-suit {
    color: #cc2222;
}

/* 条 - 绿色（万子文字不需要，条子用SVG） */
/* 筒 - 蓝色（万子文字不需要，筒子用SVG） */

/* 可点击的手牌 */
.tile.clickable {
    cursor: pointer;
}

.tile.clickable:hover {
    transform: translateY(-6px);
    box-shadow: 3px 6px 14px rgba(0, 0, 0, 0.5);
}

/* 选中的牌 */
.tile.selected {
    transform: translateY(-18px);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.9);
    border-color: #ffd700;
    border-width: 3px;
}

/* 牌背 */
.tile-back {
    width: 44px;
    height: 64px;
    background: linear-gradient(135deg, #3a6eb0, #2a4e80);
    border: 2px solid #1a3e70;
    border-radius: 8px;
    box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
}

.tile-back::after {
    content: "🀄";
    font-size: 22px;
    opacity: 0.6;
}

/* 出牌区的牌 */
.discard-area .tile {
    width: 40px;
    height: 56px;
    font-size: 10px;
    border: 1.5px solid #c8a050;
    border-radius: 6px;
}

.discard-area .tile .tile-number {
    font-size: 20px;
}

.discard-area .tile .tile-suit {
    font-size: 12px;
}

/* 小尺寸牌标记（出牌区用） */
.tile-small .tile-number {
    font-size: 18px;
}

.tile-small .tile-suit {
    font-size: 10px;
}

/* 副露区的牌 */
.meld-area .tile {
    width: 44px;
    height: 62px;
    border: 1.5px solid #c8a050;
    border-radius: 6px;
}

.meld-area .tile .tile-number {
    font-size: 22px;
}

.meld-area .tile .tile-suit {
    font-size: 13px;
}

/* 副露尺寸牌标记 */
.tile-meld .tile-number {
    font-size: 20px;
}

.tile-meld .tile-suit {
    font-size: 12px;
}

/* AI手牌区 - 适度放大 */
#hand-1 .tile-back,
#hand-2 .tile-back,
#hand-3 .tile-back {
    width: 36px;
    height: 52px;
    border-radius: 6px;
}

#hand-1 .tile-back::after,
#hand-2 .tile-back::after,
#hand-3 .tile-back::after {
    font-size: 18px;
}

/* ========== 操作按钮区 ========== */
#action-bar {
    background: rgba(0, 0, 0, 0.55);
    padding: 12px;
    display: flex;
    justify-content: center;
    gap: 18px;
    min-height: 70px;
    align-items: center;
    border-top: 2px solid rgba(240, 208, 96, 0.3);
}

.action-btn {
    padding: 12px 32px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.action-btn:hover {
    transform: scale(1.08);
    filter: brightness(1.15);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.hu-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.pong-btn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.kong-btn {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.chow-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.pass-btn {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.swap-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.start-btn {
    background: linear-gradient(135deg, #ffd700, #d4a020);
    color: #333;
    font-size: 24px;
    padding: 14px 48px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.start-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ========== 开始游戏覆盖层 ========== */
#start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

#start-box {
    background: linear-gradient(135deg, #0d4a28, #062a14);
    border: 3px solid #ffd700;
    border-radius: 24px;
    padding: 50px 70px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

#start-box h2 {
    color: #ffd700;
    font-size: 44px;
    margin-bottom: 12px;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5);
}

#start-box p {
    color: #e0e0e0;
    font-size: 20px;
    margin-bottom: 36px;
}

/* ========== 弹窗 ========== */
#modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(3px);
}

#modal-box {
    background: linear-gradient(135deg, #0d4a28, #062a14);
    border: 3px solid #ffd700;
    border-radius: 20px;
    padding: 36px 50px;
    text-align: center;
    min-width: 360px;
    max-width: 580px;
    color: #ffd700;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

#modal-title {
    font-size: 28px;
    margin-bottom: 18px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

#modal-content {
    color: #e8e8e8;
    font-size: 18px;
    margin-bottom: 24px;
    line-height: 1.7;
}

#modal-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.modal-btn {
    padding: 10px 26px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #ffd700, #d4a020);
    color: #333;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.modal-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.modal-btn.red {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
}

.modal-btn.green {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
}

.modal-btn.blue {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #fff;
}

/* 缺门选择按钮 */
.que-btn {
    width: 100px;
    height: 64px;
    font-size: 22px;
    font-weight: bold;
    border: 3px solid;
    border-radius: 12px;
    cursor: pointer;
    background: #fffef5;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.que-btn.wan {
    color: #cc2222;
    border-color: #cc2222;
}

.que-btn.tiao {
    color: #228b22;
    border-color: #228b22;
}

.que-btn.tong {
    color: #2266cc;
    border-color: #2266cc;
}

.que-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.7);
}

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

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

.tile.played {
    animation: slideUp 0.3s ease-out;
}

/* 高亮最后出牌 */
.tile.last-discard {
    border-color: #ffd700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.9);
    border-width: 3px;
}

/* ========== 响应式 ========== */
@media (max-width: 1100px) {
    .tile {
        width: 48px;
        height: 68px;
    }

    .tile .tile-number {
        font-size: 22px;
    }

    .tile .tile-suit {
        font-size: 14px;
    }

    .tile-back {
        width: 38px;
        height: 56px;
    }

    .discard-area .tile {
        width: 34px;
        height: 48px;
    }

    .discard-area .tile .tile-number {
        font-size: 18px;
    }

    .discard-area .tile .tile-suit {
        font-size: 11px;
    }

    .meld-area .tile {
        width: 38px;
        height: 54px;
    }

    .meld-area .tile .tile-number {
        font-size: 20px;
    }

    .meld-area .tile .tile-suit {
        font-size: 11px;
    }

    #hand-1 .tile-back,
    #hand-2 .tile-back,
    #hand-3 .tile-back {
        width: 32px;
        height: 46px;
    }
}

@media (max-width: 850px) {
    .tile {
        width: 42px;
        height: 60px;
    }

    .tile .tile-number {
        font-size: 20px;
    }

    .tile .tile-suit {
        font-size: 12px;
    }

    .tile-back {
        width: 34px;
        height: 50px;
    }

    .discard-area .tile {
        width: 30px;
        height: 42px;
    }

    .discard-area .tile .tile-number {
        font-size: 16px;
    }

    .discard-area .tile .tile-suit {
        font-size: 10px;
    }

    .meld-area .tile {
        width: 34px;
        height: 48px;
    }

    .meld-area .tile .tile-number {
        font-size: 18px;
    }

    .meld-area .tile .tile-suit {
        font-size: 10px;
    }

    #hand-1 .tile-back,
    #hand-2 .tile-back,
    #hand-3 .tile-back {
        width: 28px;
        height: 40px;
    }

    .action-btn {
        padding: 10px 24px;
        font-size: 18px;
    }
}
