/* ========== 全局样式 - 水墨风格 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'KaiTi', 'STKaiti', '楷体', 'SimSun', '宋体', serif;
    background: #e8e0d5;
    color: #2c2c2c;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    touch-action: none;
}

#gameContainer {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #e8e0d5;
}

/* ========== 画面切换 ========== */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ========== 游戏首页 ========== */
#homeScreen {
    background: #e8e0d5;
    flex-direction: column;
}

.home-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 80% 60% at 50% 40%, rgba(180,170,150,0.3) 0%, transparent 70%),
        radial-gradient(ellipse 100% 80% at 50% 100%, rgba(139,119,101,0.2) 0%, transparent 60%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
}

/* 顶部信息栏 */
.top-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: flex-start;
    z-index: 10;
}

.energy-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.6);
    padding: 8px 15px;
    border-radius: 20px;
    color: #ffd700;
}

.energy-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: #ffd700;
    clip-path: polygon(50% 0%, 60% 40%, 100% 40%, 70% 65%, 80% 100%, 50% 75%, 20% 100%, 30% 65%, 0% 40%, 40% 40%);
}

.energy-value {
    font-size: 14px;
    font-weight: bold;
}

.btn-add {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 标题区域 */
.title-area {
    text-align: center;
    padding: 50px 20px 20px;
    z-index: 1;
}

.game-title {
    font-size: 42px;
    color: #8B4513;
    letter-spacing: 8px;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.game-rank {
    font-size: 16px;
    color: #666;
    margin-bottom: 10px;
    letter-spacing: 4px;
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.star {
    font-size: 28px;
    color: #DAA520;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.star.empty {
    color: #ccc;
}

/* 棋盘预览 */
.board-preview {
    padding: 20px;
    z-index: 1;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 50px);
    gap: 4px;
    background: #d4c9b8;
    padding: 8px;
    border-radius: 4px;
    border: 2px solid #8B7355;
}

.preview-cell {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f0e8;
    border: 1px solid #8B7355;
    font-size: 24px;
    color: #2c2c2c;
    font-family: 'KaiTi', 'STKaiti', '楷体', serif;
}

.preview-cell.empty {
    background: #e8e0d5;
}

/* 角色插画 */
.character-art {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

.art-zhaoyun {
    font-size: 80px;
    animation: bounce 2s ease-in-out infinite;
}

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

/* 开始游戏按钮 */
.start-section {
    padding: 20px;
    z-index: 1;
}

.btn-start {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 200px;
    padding: 15px 30px;
    background: linear-gradient(135deg, #8B4513, #A0522D);
    border: 3px solid #654321;
    border-radius: 8px;
    color: #fff;
    font-size: 20px;
    font-family: 'KaiTi', 'STKaiti', '楷体', serif;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.4);
    transition: all 0.3s;
}

.btn-start:active {
    transform: scale(0.95);
}

.btn-icon {
    font-size: 24px;
}

.btn-energy {
    font-size: 18px;
}

/* 底部功能按钮 */
.bottom-menu {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: rgba(0,0,0,0.1);
    z-index: 10;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 20px;
}

.menu-icon {
    font-size: 32px;
}

.menu-text {
    font-size: 12px;
    color: #666;
}

/* ========== 游戏画面 ========== */
#gameScreen {
    background: #e8e0d5;
    flex-direction: column;
}

/* 顶部 HUD */
.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: rgba(232, 224, 213, 0.95);
    border-bottom: 1px solid rgba(44, 44, 44, 0.1);
    z-index: 10;
}

.hud-left, .hud-right {
    display: flex;
    gap: 12px;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #2c2c2c;
}

.hud-icon {
    font-size: 16px;
}

.hud-value {
    font-size: 16px;
    font-weight: bold;
}

.hud-center {
    text-align: center;
}

.score-value {
    font-size: 20px;
    color: #2c2c2c;
    font-weight: bold;
}

/* 游戏主区域 */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 400px;
}

/* 棋盘区域 */
.board-container {
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 220px;
    background: #e8e0d5;
}

#gameCanvas {
    background: #d4c9b8;
    border: 2px solid #8B7355;
    border-radius: 4px;
    display: block;
    width: 240px;
    height: 200px;
}

/* 底部手牌区 */
.hand-container {
    background: rgba(232, 224, 213, 0.95);
    border-top: 1px solid rgba(44, 44, 44, 0.1);
    padding: 8px;
}

.recruit-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.btn-recruit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: #2c2c2c;
    color: #f0ece4;
    border: none;
    border-radius: 2px;
    font-size: 13px;
    cursor: pointer;
    font-family: 'KaiTi', 'STKaiti', '楷体', serif;
    letter-spacing: 2px;
}

.btn-recruit:active {
    background: #444;
}

.btn-recruit:disabled {
    background: #bbb;
}

.recruit-icon {
    font-size: 16px;
}

.hand-area {
    display: flex;
    gap: 6px;
    padding: 8px;
    min-height: 55px;
    overflow-x: auto;
    justify-content: center;
    flex-wrap: wrap;
}

.hand-card {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f0e8;
    border: 1.5px solid #2c2c2c;
    border-radius: 2px;
    font-size: 22px;
    color: #2c2c2c;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    position: relative;
    font-family: 'KaiTi', 'STKaiti', '楷体', serif;
}

.hand-card:active {
    transform: scale(0.92);
}

.hand-card.selected {
    border-color: #8B0000;
    background: #fff;
    transform: translateY(-4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hand-card.general {
    background: #f8f4ec;
    border-color: #8B4513;
    color: #8B4513;
}

.hand-card .card-level {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9px;
    color: #666;
}

/* ========== 游戏结束 ========== */
#gameOverScreen {
    background: rgba(232, 224, 213, 0.95);
    flex-direction: column;
}

.gameover-content {
    text-align: center;
    padding: 30px 20px;
    max-width: 350px;
    width: 90%;
}

.gameover-content h2 {
    font-size: 26px;
    color: #2c2c2c;
    margin-bottom: 18px;
    letter-spacing: 4px;
}

.gameover-score {
    margin-bottom: 18px;
}

.gameover-score .score-label {
    font-size: 13px;
    color: #888;
    display: block;
    margin-bottom: 4px;
}

.gameover-score .score-value {
    font-size: 38px;
    color: #2c2c2c;
    font-weight: bold;
}

.gameover-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    color: #2c2c2c;
    font-weight: bold;
}

.gameover-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 6px;
}

.btn {
    padding: 10px 28px;
    border: none;
    border-radius: 2px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'KaiTi', 'STKaiti', '楷体', serif;
    display: inline-block;
    letter-spacing: 2px;
}

.btn-primary {
    background: #2c2c2c;
    color: #f0ece4;
}

.btn-secondary {
    background: transparent;
    color: #2c2c2c;
    border: 1px solid #999;
}

/* ========== 排行榜 ========== */
#rankingScreen {
    background: rgba(232, 224, 213, 0.95);
    flex-direction: column;
}

.ranking-content {
    text-align: center;
    padding: 30px 20px;
    max-width: 400px;
    width: 90%;
}

.ranking-content h2 {
    font-size: 24px;
    color: #2c2c2c;
    margin-bottom: 20px;
}

.ranking-list {
    background: rgba(255,255,255,0.5);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.ranking-item:last-child {
    border-bottom: none;
}

.rank-num {
    width: 30px;
    font-weight: bold;
    color: #8B4513;
}

.rank-name {
    flex: 1;
    text-align: left;
}

.rank-score {
    font-weight: bold;
    color: #DAA520;
}

/* ========== 武器背包 ========== */
#backpackScreen {
    background: rgba(232, 224, 213, 0.95);
    flex-direction: column;
}

.backpack-content {
    text-align: center;
    padding: 30px 20px;
    max-width: 400px;
    width: 90%;
}

.backpack-content h2 {
    font-size: 24px;
    color: #2c2c2c;
    margin-bottom: 20px;
}

.backpack-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: rgba(255,255,255,0.5);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.backpack-item {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f0e8;
    border: 1.5px solid #8B7355;
    border-radius: 4px;
    font-size: 12px;
    color: #2c2c2c;
    font-family: 'KaiTi', 'STKaiti', '楷体', serif;
}

.backpack-item.empty {
    background: #e8e0d5;
    border-style: dashed;
}

/* ========== 响应式 ========== */
@media (min-width: 768px) {
    #gameContainer {
        max-width: 420px;
        margin: 0 auto;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
    }
}

@media (max-width: 375px) {
    .game-title {
        font-size: 32px;
        letter-spacing: 4px;
    }
    .preview-grid {
        grid-template-columns: repeat(4, 40px);
    }
    .preview-cell {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    .btn-start {
        width: 180px;
        padding: 12px 25px;
        font-size: 18px;
    }
}
