/* ============================================================
   style.css - 安徽麻将游戏样式（传统牌面版）
   ============================================================ */

/* ---- 基础重置 ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
    background: #1a5c2a;
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ---- 顶部信息栏 ---- */
#game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: linear-gradient(135deg, #0d3318, #1a5c2a);
    border-bottom: 2px solid #2a8a4a;
    flex-shrink: 0;
}
#game-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #ffd700;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}
.header-info { display: flex; align-items: center; gap: 20px; font-size: 14px; }
.header-info strong { color: #ffd700; font-size: 16px; }
.btn-new-game {
    padding: 6px 16px;
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}
.btn-new-game:hover { background: #e74c3c; }

/* ---- 主游戏区域 ---- */
#game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 6px;
    gap: 4px;
    min-height: 0;
}
#middle-row { display: flex; flex: 1; gap: 4px; min-height: 0; }
#center-table { flex: 1; position: relative; border-radius: 8px; overflow: hidden; }
.table-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, #1e7a3a 0%, #155a28 70%, #0d3318 100%);
    border: 2px solid #2a8a4a;
    border-radius: 8px;
}

/* ---- 玩家区域 ---- */
.player-area { position: relative; border-radius: 6px; transition: box-shadow 0.3s; }
.player-area.active-player { box-shadow: 0 0 12px 3px rgba(255, 215, 0, 0.5); }
.player-area-ai { background: rgba(0,0,0,0.15); padding: 6px; border-radius: 6px; }
.ai-label { font-size: 12px; color: #aed581; margin-bottom: 4px; font-weight: 600; }
.ai-top { display: flex; flex-direction: column; align-items: center; }
.ai-side { width: 120px; display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.ai-hand-horizontal { display: flex; gap: 1px; justify-content: center; flex-wrap: wrap; }
.ai-hand-vertical { display: flex; flex-wrap: wrap; gap: 1px; justify-content: center; }
.ai-melds { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 4px; }

.player-area-human {
    background: rgba(0,0,0,0.25);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.human-hand-row { display: flex; align-items: flex-end; gap: 16px; justify-content: center; width: 100%; }
.player-hand { display: flex; gap: 2px; justify-content: center; flex-wrap: wrap; }
.player-melds { display: flex; gap: 8px; flex-shrink: 0; }

/* ================================================================
   牌面样式 — SVG 图片渲染 + 仿真牌底
   ================================================================ */

/* ---- 牌壳通用 ---- */
.tile {
    width: 42px;
    height: 58px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* 正面牌底 — 仿真白色象牙质感 */
.tile-face-up {
    background: linear-gradient(175deg, #fefefe 0%, #f5f0e0 40%, #ebe5d0 100%);
    border: 1.5px solid #c8bfa0;
    box-shadow:
        0 2px 3px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -1px 0 rgba(0,0,0,0.05);
}

/* 牌面图案 SVG */
.tile-img {
    width: 80%;
    height: 80%;
    display: block;
    object-fit: contain;
    pointer-events: none;
}

/* 牌背 */
.tile-face-down {
    width: 28px;
    height: 38px;
    background: linear-gradient(175deg, #fefefe 0%, #f5f0e0 40%, #ebe5d0 100%);
    border: 1.5px solid #c8bfa0;
    box-shadow:
        0 2px 3px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -1px 0 rgba(0,0,0,0.05);
}
.tile-face-down .tile-img {
    width: 100%;
    height: 100%;
    border-radius: 3px;
}

.tile-clickable { cursor: pointer; }
.tile-clickable:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.9);
    border-color: #ffd700;
    z-index: 2;
}
.tile-drawn { margin-left: 12px; }

/* 小牌 */
.tile-small { width: 32px; height: 44px; }

/* 胡牌高亮 */
.tile-win-tile {
    border: 2px solid #ffd700 !important;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

/* ---- 副子 ---- */
.meld-group { display: flex; gap: 1px; align-items: flex-end; position: relative; }
.meld-group-small .tile { width: 24px; height: 34px; }
.meld-group-small .tile-face-down { width: 22px; height: 30px; }
.meld-label { font-size: 10px; color: #aaa; text-align: center; margin-top: 2px; }

/* ---- 弃牌区域 ---- */
.discard-area { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; min-height: 30px; justify-content: center; }
.discard-area-bottom { max-width: 80%; }
.discard-area-top { max-width: 80%; }
.discard-area-side { max-width: 100%; }
.discard-area .tile { width: 26px; height: 36px; }

/* ---- 动作按钮 ---- */
.action-bar { display: flex; gap: 10px; justify-content: center; min-height: 36px; align-items: center; }
.action-btn {
    padding: 8px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 2px;
}
.action-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.action-btn:active { transform: translateY(0); }
.action-hu { background: linear-gradient(135deg, #ffd700, #ffab00); color: #333; }
.action-peng { background: linear-gradient(135deg, #43a047, #2e7d32); color: #fff; }
.action-gang, .action-an_gang, .action-bu_gang { background: linear-gradient(135deg, #1e88e5, #1565c0); color: #fff; }
.action-pass { background: linear-gradient(135deg, #757575, #616161); color: #fff; }
.action-hint { color: #ffd700; font-size: 14px; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- 游戏日志 ---- */
#game-log-container { background: rgba(0,0,0,0.3); border-top: 1px solid #2a8a4a; flex-shrink: 0; }
.log-header { padding: 4px 12px; font-size: 12px; color: #aed581; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.1); }
.game-log { height: 80px; overflow-y: auto; padding: 4px 12px; font-size: 12px; line-height: 1.6; }
.log-line { color: #ccc; }
.game-log::-webkit-scrollbar { width: 4px; }
.game-log::-webkit-scrollbar-track { background: transparent; }
.game-log::-webkit-scrollbar-thumb { background: #2a8a4a; border-radius: 2px; }

/* ---- 弹出层 ---- */
.game-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
}
.game-overlay.visible { opacity: 1; pointer-events: auto; }
.overlay-content {
    background: linear-gradient(135deg, #1a3a1a, #0d2810);
    border: 2px solid #ffd700;
    border-radius: 12px;
    padding: 24px 32px;
    text-align: center;
    max-width: 560px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.overlay-win h2, .overlay-draw h2 {
    color: #ffd700; font-size: 28px; margin-bottom: 16px;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}
.win-hand { display: flex; gap: 2px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.win-melds { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.win-meld-tag { background: rgba(255,255,255,0.15); padding: 4px 10px; border-radius: 4px; font-size: 13px; }
.win-score { margin: 12px 0; }
.score-total { font-size: 24px; color: #ffd700; font-weight: 700; margin-bottom: 8px; }
.score-breakdown { font-size: 13px; color: #aed581; line-height: 1.8; }
.btn-restart {
    padding: 10px 32px;
    background: linear-gradient(135deg, #ffd700, #ffab00);
    color: #333; border: none; border-radius: 8px;
    font-size: 18px; font-weight: 700; cursor: pointer; margin-top: 12px;
    transition: transform 0.15s;
}
.btn-restart:hover { transform: scale(1.05); }

/* ---- 响应式 ---- */
@media (max-width: 800px) {
    .tile { width: 36px; height: 50px; }
    .tile-small { width: 26px; height: 36px; }
    .tile-face-down { width: 24px; height: 32px; }
    .ai-side { width: 90px; }
    .action-btn { padding: 6px 16px; font-size: 14px; }
    #game-header h1 { font-size: 18px; }
    .que-btn { padding: 10px 20px !important; font-size: 14px !important; }
}

/* ---- 定缺选择UI ---- */
.que-choosing-hint {
    color: #ffd700;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}
.que-btn-group {
    display: flex;
    gap: 14px;
    justify-content: center;
}
.que-btn {
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.2s;
}
.que-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.que-wan { background: linear-gradient(135deg, #e53935, #c62828); color: #fff; }
.que-tiao { background: linear-gradient(135deg, #43a047, #2e7d32); color: #fff; }
.que-tong { background: linear-gradient(135deg, #1e88e5, #1565c0); color: #fff; }
.que-suggested { border-color: #ffd700; box-shadow: 0 0 10px rgba(255,215,0,0.4); }
.que-count { font-size: 12px; font-weight: 400; margin-left: 4px; opacity: 0.85; }

/* ---- 定缺标签 ---- */
.que-label {
    font-size: 12px;
    color: #ffd700;
    background: rgba(255,215,0,0.12);
    padding: 2px 10px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 1px;
    align-self: flex-start;
    margin-bottom: 2px;
}

/* ---- 游戏规则按钮 ---- */
.btn-rules {
    padding: 6px 16px;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}
.btn-rules:hover { background: #43a047; }

/* ---- 游戏规则弹窗 ---- */
.overlay-rules {
    text-align: left;
    max-height: 80vh;
    overflow-y: auto;
}
.overlay-rules h2 {
    color: #ffd700;
    font-size: 24px;
    margin-bottom: 16px;
    text-align: center;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}
.overlay-rules h3 {
    color: #aed581;
    font-size: 16px;
    margin: 14px 0 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 4px;
}
.rules-body ul {
    list-style: disc;
    padding-left: 20px;
    margin: 0;
}
.rules-body li {
    color: #ddd;
    font-size: 13px;
    line-height: 1.8;
}
.rules-body b { color: #ffd700; }
.overlay-rules .btn-restart { display: block; margin: 20px auto 0; }
