/* 像素部落战争 - 样式表 */

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

body {
    font-family: 'Courier New', monospace;
    background: #1a1a2e;
    overflow: hidden;
    touch-action: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
}

/* HUD - 顶部资源栏 */
#top-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 5px 10px;
    border-bottom: 2px solid #4CAF50;
    z-index: 10;
}

.resource-group {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #fff;
}

.resource-icon {
    font-size: 18px;
}

#population-display {
    color: #FFC107;
}

.level-info {
    font-size: 16px;
    font-weight: bold;
    color: #4CAF50;
}

/* HUD - 底部建造菜单 */
#build-menu {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 2px solid #4CAF50;
    z-index: 10;
    overflow-x: auto;
    overflow-y: hidden;
}

.menu-scroll {
    display: flex;
    height: 100%;
    padding: 5px;
    gap: 8px;
    min-width: min-content;
}

.build-btn {
    flex: 0 0 auto;
    width: 70px;
    height: 70px;
    background: linear-gradient(145deg, #2a2a3e, #1a1a2e);
    border: 2px solid #4CAF50;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.build-btn:active {
    transform: scale(0.95);
    background: #4CAF50;
}

.build-btn:hover {
    border-color: #8BC34A;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

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

.btn-label {
    font-size: 10px;
    color: #fff;
    margin-top: 2px;
    text-align: center;
}

.btn-cost {
    font-size: 8px;
    color: #FFC107;
    margin-top: 2px;
}

/* 训练菜单 */
#train-menu {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #4CAF50;
    border-radius: 10px;
    padding: 10px;
    z-index: 20;
    min-width: 280px;
}

.train-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.train-btn {
    width: 65px;
    height: 65px;
    background: linear-gradient(145deg, #2a2a3e, #1a1a2e);
    border: 2px solid #2196F3;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.train-btn:active {
    transform: scale(0.95);
    background: #2196F3;
}

#close-train-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #F44336;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 开始菜单 */
#start-menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a3e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

#start-menu h1 {
    font-size: 32px;
    color: #4CAF50;
    margin-bottom: 40px;
    text-shadow: 3px 3px 0 #000;
    text-align: center;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.menu-buttons button {
    padding: 15px 40px;
    font-size: 18px;
    font-family: inherit;
    background: linear-gradient(145deg, #4CAF50, #388E3C);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 0 #2E7D32;
    transition: all 0.1s;
}

.menu-buttons button:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #2E7D32;
}

.controls-info {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #4CAF50;
}

.controls-info p {
    color: #fff;
    font-size: 14px;
    margin: 5px 0;
    text-align: center;
}

/* 关卡选择 */
#level-select-menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a3e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

#level-select-menu h2 {
    font-size: 28px;
    color: #4CAF50;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0 #000;
}

.level-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

.level-btn {
    width: 100px;
    height: 80px;
    background: linear-gradient(145deg, #2196F3, #1976D2);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 4px 0 #0D47A1;
    transition: all 0.1s;
}

.level-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #0D47A1;
}

.level-btn small {
    font-size: 12px;
    opacity: 0.8;
}

#back-to-menu-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-family: inherit;
    background: #616161;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
}

/* 结果界面 */
#result-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.result-content {
    background: #2a2a3e;
    padding: 30px;
    border-radius: 15px;
    border: 3px solid #4CAF50;
    text-align: center;
    max-width: 90%;
}

#result-title {
    font-size: 36px;
    margin-bottom: 20px;
}

#result-stars {
    font-size: 42px;
    margin-bottom: 20px;
}

#result-stats {
    color: #fff;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.8;
}

.result-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.result-buttons button {
    padding: 12px 25px;
    font-size: 14px;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
}

#retry-btn {
    background: linear-gradient(145deg, #FF9800, #F57C00);
}

#next-level-btn {
    background: linear-gradient(145deg, #4CAF50, #388E3C);
}

#menu-btn {
    background: linear-gradient(145deg, #2196F3, #1976D2);
}

/* 消息弹窗 */
#message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.message-content {
    background: #2a2a3e;
    padding: 20px 30px;
    border-radius: 10px;
    border: 2px solid #FFC107;
    text-align: center;
}

#message-text {
    color: #fff;
    font-size: 16px;
    margin-bottom: 15px;
}

#message-btn {
    padding: 8px 20px;
    font-size: 14px;
    font-family: inherit;
    background: #FFC107;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* 响应式设计 */
@media (max-width: 480px) {
    #top-hud {
        height: 40px;
        font-size: 12px;
    }

    .resource-icon {
        font-size: 14px;
    }

    #build-menu {
        height: 70px;
    }

    .build-btn {
        width: 60px;
        height: 60px;
    }

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

    #train-menu {
        min-width: 240px;
    }

    .train-btn {
        width: 55px;
        height: 55px;
    }

    #start-menu h1 {
        font-size: 24px;
    }

    .level-btn {
        width: 80px;
        height: 70px;
        font-size: 14px;
    }
}

@media (max-height: 600px) {
    #top-hud {
        height: 35px;
    }

    #build-menu {
        height: 60px;
    }

    .build-btn {
        width: 50px;
        height: 50px;
    }

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

    .btn-label {
        font-size: 8px;
    }
}

/* 横屏优化 */
@media (orientation: landscape) {
    #train-menu {
        bottom: 10px;
        right: 10px;
        left: auto;
        transform: none;
    }
}

/* 暂停按钮 */
.hud-btn {
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    font-size: 20px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 8px;
    touch-action: manipulation;
}

/* 暂停覆盖层 */
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.pause-content {
    text-align: center;
    color: white;
}

.pause-content h2 {
    margin-bottom: 20px;
    font-size: 28px;
}

.menu-btn {
    display: block;
    margin: 10px auto;
    padding: 12px 30px;
    font-size: 18px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    min-width: 200px;
    touch-action: manipulation;
}

.menu-btn:hover {
    background: #388E3C;
}
