/* 基础样式 */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Microsoft YaHei", sans-serif;
}

/* 星空背景 - 随等级变化密度 */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #000;
    background-image: radial-gradient(2px 2px at 20px 30px, #fff, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 40px 70px, #fff, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 50px 160px, #fff, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 90px 40px, #fff, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 130px 80px, #fff, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 160px 120px, #fff, rgba(0, 0, 0, 0));
    background-repeat: repeat;
    background-size: 200px 200px;
    transition: background-size 1s ease;
}

/* 大炮样式 */
#cannon {
    position: absolute;
    width: 80px;
    height: 80px;
    /*background-color: #666;*/
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
}

#cannon::before {
    content: '';
    position: absolute;
    width: 40px;
    height: 10px;
    background-color: #f3f3f3;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#cannon::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 40px;
    background-color: #f3f3f3;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* 被击中效果 */
.hit-effect {
    animation: hit 0.5s;
}

@keyframes hit {
    0% {
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 0, 0, 1);
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    }
}

/* 汉字目标样式 */
.target {
    position: absolute;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 5px;
    background-color: rgba(0, 128, 255, 0.7);
    cursor: default;
    transition: all 0.1s;
    z-index: 5;
    user-select: none;
    white-space: nowrap;

    -webkit-text-stroke: 0.5px #000;
    text-stroke: 0.5px #000;
    text-shadow:
            0.5px 0.5px 0 #000,
            -0.5px -0.5px 0 #000,
            0.5px -0.5px 0 #000,
            -0.5px 0.5px 0 #000;
}


#game-container .target:nth-child(21n+1) {
    background-color: #b3b0f6;
}

#game-container .target:nth-child(21n+2) {
    background-color: #f792e5;
}

#game-container .target:nth-child(21n+3) {
    background-color: #ebc53c;
}

#game-container .target:nth-child(21n+4) {
    background-color: #b0d5f5;
}

#game-container .target:nth-child(21n+5) {
    background-color: #ffa646;
}

#game-container .target:nth-child(21n+6) {
    background-color: #888;
}

#game-container .target:nth-child(21n+7) {
    background-color: #7fdcfb;
}

#game-container .target:nth-child(21n+8) {
    background-color: #959fff;
}

#game-container .target:nth-child(21n+9) {
    background-color: #a6da6d;
}

#game-container .target:nth-child(21n+10) {
    background-color: #91BEDA;
}

#game-container .target:nth-child(21n+11) {
    background-color: #ff7f58;
}
#game-container .target:nth-child(21n+12) {
    background-color: #66bcff;
}

#game-container .target:nth-child(21n+13) {
    background-color: #68d46d;
}

#game-container .target:nth-child(21n+14) {
    background-color: #f58797;
}

#game-container .target:nth-child(21n+15) {
    background-color: #d983ee;
}

#game-container .target:nth-child(21n+16) {
    background-color: #9ed96a;
}

#game-container .target:nth-child(21n+17) {
    background-color: #68d9c2;
}

#game-container .target:nth-child(21n+18) {
    background-color: #77d46a;
}

#game-container .target:nth-child(21n+19) {
    background-color: #7fdcfb;
}

#game-container .target:nth-child(21n+20) {
    background-color: #ffa646;
}

#game-container .target:nth-child(21n+21) {
    background-color: #6d86b3;
}

/* 目标高亮样式 */
.target-partial {
    background-color: rgba(255, 255, 0, 0.7);
}

.target-complete {
    background-color: rgba(0, 255, 0, 0.7);
}

/* 输入区域样式 - 优化居中对齐和美化 */
#input-container {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 20;
    padding: 0 20px;
}

#input-area {
    width: 100%;
    max-width: 600px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 0.7;
}

#word-input {
    font-size: 22px;
    text-align: center;
    height: 55px;
    border: 3px solid #337ab7;
    border-radius: 25px;
    box-shadow: 0 0 15px rgba(51, 122, 183, 0.7);
    width: 100%;
}

#input-prompt {
    color: #ddd;
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
}

/* 状态面板 - 添加图标后的布局 */
.stats-container {
    position: fixed;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 0 20px;
    z-index: 20;
    flex-wrap: wrap;
}

.stats-card {
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    padding: 10px 15px;
    color: white;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    text-align: center;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.stats-icon {
    font-size: 18px;
}

.stats-label {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 3px;
}

.stats-value {
    font-size: 22px;
    font-weight: bold;
}

.lives-value {
    color: #ff4444;
    text-shadow: 0 0 5px rgba(255, 68, 68, 0.7);
}

.level-value {
    color: #ffcc00;
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.7);
}

.score-value {
    color: #00ffcc;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.7);
}

.time-value {
    color: #7cb305;
    text-shadow: 0 0 5px rgba(124, 179, 5, 0.7);
}

.metrics-container {
    position: fixed;
    bottom: 150px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    z-index: 20;
    padding: 0 20px;
}

.metric-card {
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    padding: 8px 15px;
    color: white;
    min-width: 120px;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.5;
}

/* 炮弹样式 - 加快速度 */
.projectile {
    position: absolute;
    width: 8px;
    height: 8px;
    /*background-color: #ffcc00;*/
    border-radius: 50%;
    z-index: 15;
    /*box-shadow: 0 0 8px rgba(255, 204, 0, 1);*/
}

/* 爆炸特效 - 增强视觉效果 */
.explosion {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    z-index: 20;
    animation: explode 0.6s;
    box-shadow: 0 0 30px rgba(255, 165, 0, 0.8);
}

/* 大炮等级颜色效果 */
.cannon-level-1, .projectile-1 {
    background-color: #3498db;
    box-shadow: 0 0 10px rgb(52, 151, 218, 0.8);
}

.cannon-level-5, .projectile-5 {
    background-color: #2ecc71;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.8);
}

.cannon-level-10, .projectile-10 {
    background-color: #f39c12;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.8);
}

.cannon-level-15, .projectile-15 {
    background-color: #e74c3c;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.8);
}

.cannon-level-20, .projectile-20 {
    background-color: #9b59b6;
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.8);
}

@keyframes explode {
    0% {
        transform: scale(0);
        background-color: rgba(255, 255, 0, 1);
    }
    30% {
        transform: scale(1.8);
        background-color: rgba(255, 165, 0, 0.9);
    }
    70% {
        transform: scale(2.2);
        background-color: rgba(255, 69, 0, 0.7);
    }
    100% {
        transform: scale(2.5);
        background-color: rgba(255, 0, 0, 0);
    }
}

/* 爆炸碎片效果 */
.explosion-shard {
    position: absolute;
    background-color: rgba(255, 215, 0, 0.8);
    border-radius: 3px;
    z-index: 20;
}

@keyframes shard-fly {
    0% {
        transform: scale(1) translate(0, 0);
        opacity: 1;
    }
    100% {
        transform: scale(0.5) translate(var(--dx), var(--dy));
        opacity: 0;
    }
}

/* 提示层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

#start-screen h1 {
    font-size: 48px;
    margin-bottom: 30px;
    text-shadow: 0 0 10px #fff;
    animation: fadeIn 1s;
}

#start-screen p {
    font-size: 24px;
    margin-bottom: 40px;
    text-align: center;
    max-width: 80%;
    animation: fadeIn 1s 0.3s forwards;
    opacity: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-start {
    font-size: 24px;
    padding: 15px 40px;
    background-color: #337ab7;
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    animation: fadeIn 1s 0.6s forwards;
    opacity: 0;
}

.btn-start:hover {
    background-color: #286090;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(40, 96, 144, 0.8);
}

/* 暂停提示 */
#pause-screen {
    display: none;
    text-align: center;
}

#pause-screen h2 {
    font-size: 48px;
    color: #fff;
    text-shadow: 0 0 20px #ffcc00;
    animation: blink 1.5s infinite;
    margin: 0 0 20px 0;
}

#pause-screen p {
    font-size: 24px;
    margin: 0;
    color: #ddd;
}

@keyframes blink {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

/* 游戏结束屏幕 */
#game-over-screen {
    display: none;
    text-align: center;
    padding: 0 20px;
}

#game-over-screen h2 {
    font-size: 56px;
    margin-bottom: 40px;
    color: #ff4444;
    text-shadow: 0 0 15px rgba(255, 68, 68, 0.8);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.game-over-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.stat-item {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 20px;
    min-width: 200px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    opacity: 0;
    animation: statFadeIn 0.5s forwards;
}

@keyframes statFadeIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.stat-item:nth-child(1) {
    animation-delay: 0.2s;
}

.stat-item:nth-child(2) {
    animation-delay: 0.4s;
}

.stat-item:nth-child(3) {
    animation-delay: 0.6s;
}

.stat-item:nth-child(4) {
    animation-delay: 0.8s;
}

.stat-item h3 {
    font-size: 18px;
    margin: 0 0 10px 0;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.stat-item .value {
    font-size: 32px;
    font-weight: bold;
    margin: 0;
}

#final-level-value {
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
}

#final-score-value {
    color: #00ffcc;
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.7);
}

#final-time-value {
    color: #7cb305;
    text-shadow: 0 0 10px rgba(124, 179, 5, 0.7);
}

#final-speed-value {
    color: #2196f3;
    text-shadow: 0 0 10px rgba(33, 150, 243, 0.7);
}

#final-accuracy-value {
    color: #4caf50;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.7);
}

.restart-prompt {
    margin-top: 20px;
    color: #aaa;
    font-size: 18px;
    animation: fadeIn 1s 1s forwards;
    opacity: 0;
}

/* 等级提升特效 */
#level-up {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffcc00;
    font-size: 72px;
    font-weight: bold;
    z-index: 150;
    display: none;
    text-shadow: 0 0 20px #ffcc00;
    animation: levelUp 2s;
}

@keyframes levelUp {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}

/* 初始进攻提示 */
#initial-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff4444;
    font-size: 36px;
    font-weight: bold;
    z-index: 200;
    display: none;
    text-shadow: 0 0 15px #ff4444;
    text-align: center;
    padding: 0 20px;
    animation: alertPulse 1s infinite alternate;
}

@keyframes alertPulse {
    from {
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* 响应式调整 */
@media (max-width: 768px) {
    #cannon {
        width: 60px;
        height: 60px;
    }

    .target {
        font-size: 18px;
        padding: 3px 8px;
    }

    .stats-container {
        gap: 10px;
    }

    .stats-card, .metric-card {
        padding: 8px 10px;
        min-width: auto;
        flex: 1;
        justify-content: center;
    }

    .stats-value {
        font-size: 18px;
    }

    .game-over-stats {
        grid-template-columns: 1fr;
    }

    .stat-item {
        min-width: auto;
    }

    #start-screen h1 {
        font-size: 36px;
    }

    #start-screen p {
        font-size: 18px;
    }

    #initial-alert {
        font-size: 24px;
    }

    #level-up {
        font-size: 54px;
    }

    #pause-screen h2 {
        font-size: 36px;
    }

    #pause-screen p {
        font-size: 20px;
    }

    .metrics-container {
        bottom: 140px;
    }
}