* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", sans-serif
}

html {
    font-size: 16px;
}

body {
    background: #0b1026;
    color: #fff;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

/* 战斗区域自适应高度 */
.battle-container {
    height: 32vh;
    position: relative;
    background: #101836;
}

#battleCanvas {
    width: 100%;
    height: 100%;
    display: block
}

.status-wrap {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 9;
    align-items: flex-start;
}

.player-info, .enemy-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 90px;
}

.player-power-wrap {
    align-items: flex-start
}

.enemy-power-wrap {
    align-items: flex-end
}

.life-bar {
    width: 100px;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #fff;
    display: flex
}

.life-current {
    height: 100%;
    transition: width .3s ease, background-color .3s ease
}

.life-bg {
    height: 100%;
    background: #333;
    flex: 1
}

.role-name {
    font-size: 13px;
    margin-bottom: 2px;
    color: #fff;
    white-space: nowrap;
}

.power-bar {
    width: 10px;
    height: 70px;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .4);
    background: rgba(34, 34, 34, .5);
    display: flex;
    flex-direction: column-reverse;
    opacity: .8
}

.power-current {
    width: 100%;
    transition: height .2s ease, background-color .2s ease;
    opacity: .9
}

.type-container {
    flex: 1;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.target-text {
    font-size: 24px;
    color: #fff;
    background: #1a244a;
    padding: 12px;
    border-radius: 8px;
    line-height: 1.4;
    min-height: 60px;
    width: 100%;
    text-align: left;
    word-break: break-all;
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
}

.next-text {
    color: #6c6b6b;
    padding: 8px 12px;
    min-height: 30px;
    width: 100%;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 14px;
}

.space-placeholder {
    width: 8px;
    border-bottom: 2px solid rgb(255 255 255 / 15%);
}

.correct {
    color: #2ed573;
    font-weight: bold;
}

.error {
    color: #ff4757;
    font-weight: bold;
    background-color: rgba(255, 71, 87, 0.15);
    border-radius: 2px;
}

.space-placeholder.correct {
    border-bottom: 2px solid #2ed573;
}

.space-placeholder.error {
    border-bottom: 2px solid #ff4757;
}

.typing-stats {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #ccc;
    padding: 6px 8px;
    background: #151d3e;
    border-radius: 6px;
    flex-wrap: wrap;
    gap: 4px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.input-box {
    width: 100%;
    height: 44px;
    font-size: 16px;
    padding: 0 12px;
    border: none;
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: #000;
}

.input-box:disabled {
    background: #666;
    cursor: not-allowed
}

.tips {
    font-size: 14px;
    color: #ccc;
    text-align: center;
    min-height: 20px;
}

.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .95);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 999;
    gap: 15px;
    padding: 15px;
}

.result-title {
    font-size: 32px;
    font-weight: bold;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.win {
    color: #2ed573;
    text-shadow: 0 0 15px rgba(46, 213, 115, 0.4);
}

.lose {
    color: #ff4757;
    text-shadow: 0 0 15px rgba(255, 71, 87, 0.4);
}

.stats-box {
    background: linear-gradient(145deg, #151d3e, #1e2a5a);
    padding: 15px;
    border-radius: 12px;
    width: 100%;
    max-width: 700px;
    border: 1px solid #2a345a;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.stats-title {
    font-size: 18px;
    text-align: center;
    margin-bottom: 15px;
    color: #fff;
    font-weight: bold;
    letter-spacing: 1px;
}

.battle-stats-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-direction: column;
}

.player-stats, .enemy-stats {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.player-stats {
    border-left: 3px solid #2ed573;
}

.enemy-stats {
    border-left: 3px solid #ff4757;
}

.side-title {
    font-size: 16px;
    margin-bottom: 10px;
    font-weight: bold;
    text-align: center;
}

.player-title {
    color: #2ed573;
}

.enemy-title {
    color: #ff4757;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 5px 0;
    border-bottom: 1px solid #2a345a;
}

.time-stats {
    text-align: center;
    font-size: 14px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-top: 8px;
}

.result-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    width: 100%;
    justify-content: center;
}

.restart-btn, .more-game-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    flex: 1;
    max-width: 160px;
}

.restart-btn {
    background: #1e90ff;
    color: #fff;
}

.restart-btn:hover {
    background: #379eff;
    transform: translateY(-2px);
}

.more-game-btn {
    background: #ff9f43;
    color: #fff;
}

.more-game-btn:hover {
    background: #ffb06b;
    transform: translateY(-2px);
}

@media (min-width: 768px) {
    .battle-container {
        height: 38vh;
    }

    .life-bar {
        width: 140px;
        height: 12px;
    }

    .power-bar {
        height: 90px;
        width: 12px;
    }

    .role-name {
        font-size: 15px;
    }
}

@media (min-width: 1024px) {
    .battle-container {
        height: 40vh;
    }
}