/* 基础样式 - 简化核心样式，确保兼容性 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    user-select: none;
}

body {
    background: linear-gradient(135deg, #0a192f 0%, #112240 100%);
    height: 100vh;
    position: relative;
    font-family: "Helvetica Neue", Arial, sans-serif;
    color: white;
}

/* 网格背景 */
.grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 30px 30px;
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    animation: gridMove 30s linear infinite;
    z-index: 1;
}

@keyframes gridMove {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: -300px -300px;
    }
}

/* 游戏容器 - 确保居中且尺寸稳定 */
.game-container {
    position: relative;
    width: 90vw;
    height: 70vh;
    margin: 0 auto;
    /*border: 3px solid;*/
    /*border-image: linear-gradient(45deg, #ff6b6b, #ffda79, #6bcb77, #4ecdc4, #45b7d1, #7765e3, #c594c5) 1;*/
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    z-index: 2;
    top: 50%;
    transform: translateY(-50%);
    overflow: hidden;
}

/* 击球区 - 固定位置，确保可见 */
.hit-zone {
    position: absolute;
    right: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    height: 280px;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    z-index: 1;
    animation: pulse-zone 3s infinite ease-in-out;
}

.hit-zone::after {
    content: "击球区";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    font-weight: bold;
}

@keyframes pulse-zone {
    0%, 100% {
        opacity: 0.7;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.05);
    }
}

/* 倒计时进度条 - 确保初始隐藏，触发时显示 */
.countdown-progress-container {
    position: absolute;
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    margin: 5px;
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.countdown-progress-container.visible {
    opacity: 0.7;
}

.countdown-progress {
    height: 100%;
    display: flex;
    width: 100%;
}

.progress-segment {
    height: 100%;
    flex: 1;
}

.progress-early {
    background: #ff9800;
}

.progress-perfect {
    background: #4caf50;
}

.progress-late {
    background: #f44336;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    transition: width 0.1s linear;
}

/* 标题 - 确保居中 */
.game-title {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3.5rem;
    font-weight: bold;
    background: linear-gradient(90deg, #ff6b6b, #ffda79, #6bcb77, #4ecdc4, #45b7d1, #7765e3, #c594c5);
    background-size: 1400% 1400%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;0
    z-index: 3;
    animation: titlePulse 5s ease infinite;
}

/* 状态面板 - 确保布局稳定 */
.game-stats {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 3;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stat-item {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
}

.stat-item .glyphicon {
    margin-right: 5px;
}

.stat-item .num{
    font-weight: bold;
    font-size: 2.2rem;
    color: #f8f809;
    padding: 0px 5px;
}

.lives {
    display: flex;
    gap: 5px;
}

.life {
    color: #ff6b6b;
}

.life.lost {
    color: #444;
    opacity: 0.5;
}

/* 操作说明 - 确保底部显示 */
.instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    z-index: 3;
    max-width: 80%;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1.2rem;
}

/* 角色 - 固定位置，确保可见 */
.opponent, .player {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 120px;
    z-index: 3;
}

.opponent {
    left: 50px;
}

.player {
    right: 50px;
}

/* 角色动画 */
.opponent-throw {
    animation: throw 0.5s ease-in-out;
}

.player-hit {
    animation: hit 0.3s ease-in-out;
}

.player-miss {
    animation: playerMiss 0.5s ease-in-out;
}

@keyframes throw {
    0% {
        transform: translateY(-50%) rotate(0deg);
    }
    50% {
        transform: translateY(-50%) rotate(-15deg) translateX(10px);
    }
    100% {
        transform: translateY(-50%) rotate(0deg);
    }
}

@keyframes hit {
    0% {
        transform: translateY(-50%) rotate(0deg);
    }
    50% {
        transform: translateY(-50%) rotate(30deg) translateX(-15px);
    }
    100% {
        transform: translateY(-50%) rotate(0deg);
    }
}

@keyframes playerMiss {
    0%, 100% {
        transform: translateY(-50%) rotate(0deg);
    }
    25% {
        transform: translateY(-50%) rotate(-5deg) translateX(5px);
    }
    50% {
        transform: translateY(-50%) rotate(5deg) translateX(-5px);
    }
    75% {
        transform: translateY(-50%) rotate(-5deg) translateX(5px);
    }
}

/* 棒球 - 确保样式稳定，动画正常 */
.baseball {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 2.2rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 2px 3px rgba(255, 255, 255, 0.3), 0 0 15px rgba(255, 255, 255, 0.6);
    text-shadow: 1px 1px 0 #545c66, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
    color: #fff;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.baseball.active {
    opacity: 1;
}

.baseball.countdown {
    animation: countdownPulse 1s infinite ease-in-out;
}

@keyframes countdownPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* 提示元素 - 确保显示位置正确 */
.countdown-display {
    position: absolute;
    font-size: 3.5rem;
    font-weight: bold;
    color: rgba(245, 197, 53, 0.7);
    z-index: 4;
    opacity: 0;
}

.countdown-display.visible {
    opacity: 1;
    animation: countPulse 1s ease-in-out;
}

.timing-feedback, .missed-notification, .homerun-notification {
    position: absolute;
    font-weight: bold;
    z-index: 4;
    pointer-events: none;
}

.timing-feedback {
    font-size: 1.8rem;
    animation: fadeUp 1.5s ease-out;
}

.missed-notification {
    color: #ff6b6b;
    font-size: 1.5rem;
    animation: fadeAway 1.5s ease-out;
}

.homerun-notification {
    color: #ffda79;
    font-size: 2.5rem;
    animation: homerun 2s ease-out;
    text-shadow: 0 0 10px rgba(255, 218, 121, 0.8);
}

/* 动画效果 */
@keyframes countPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes fadeUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

@keyframes fadeAway {
    0%, 30% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

@keyframes homerun {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* 特效元素 */
.hit-effect, .explosion-particle, .particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 4;
}

.hit-effect {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

.explosion-particle {
    background: #ff6b6b;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.8);
}

.particle {
    background: #ffda79;
}

/* 暂停提示 */
.pause-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.8);
    z-index: 5;
    opacity: 0;
    visibility: hidden;
}

.pause-message.show {
    opacity: 1;
    visibility: visible;
    animation: pulse 2s infinite ease-in-out;
}

/* 遮罩层 - 确保显示层级正确 */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.game-overlay.show {
    opacity: 1;
    visibility: visible;
}

.overlay-content {
    background: rgba(17, 34, 64, 0.9);
    padding: 0px 10%;
    border-radius: 15px;
    border: 2px solid;
    border-image: linear-gradient(45deg, #ff7e5f, #feb47b, #fffc00, #00ff66, #00ffff, #9966ff, #ff33cc) 1;
    max-width: 100vw;
    height: 100vh;
    text-align: center;
}

.game-overlay h2 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    background: linear-gradient(90deg, #ff7e5f, #feb47b, #fffc00, #00ff66, #00ffff, #9966ff, #ff33cc);
    background-size: 1400% 1400%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: titlePulse 5s ease infinite;
}

@keyframes titlePulse {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.game-overlay p {
    font-size: 2rem;
    color: white;
    /*text-align: left;*/
    margin-bottom: 20px;
}

.overlay-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-overlay button {
    padding: 10px 20px;
    font-size: 2rem;
    border: none;
    border-radius: 30px;
    background: linear-gradient(45deg, #45b7d1, #7765e3);
    color: white;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.game-overlay button:hover {
    transform: scale(1.05);
}

/* 设置项样式 */
.settings-group {
    margin: 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 10px;
}

.settings-group h3 {
    color: #4ecdc4;
    margin-top: 0;
    margin-bottom: 10px;
    /*font-size: 1.3rem;*/
}

.settings-options {
    display: flex;
    flex-wrap: wrap;
    gap: 60px;
    justify-content: center;
    align-items: center;
}

.settings-group label {
    display: flex;
    align-items: center;
    color: white;
    cursor: pointer;
    font-size: 1.8rem;
}

.settings-group input {
    margin-right: 8px;
    transform: scale(1.2);
}

.stats-summary {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
    padding: 30px 0px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

/* 响应式调整 - 确保移动端正常显示 */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
        top: 40px;
    }

    .stat-item {
        padding: 5px 10px;
        font-size: 1.2rem;
    }

    .opponent, .player {
        width: 60px;
        height: 90px;
    }

    .hit-zone {
        right: 60px;
        width: 220px;
        height: 220px;
    }

    .instructions {
        font-size: 0.8rem;
        padding: 8px 15px;
    }
}

@media (max-width: 480px) {
    .game-stats {
        top: 60px;
        right: 10px;
        flex-direction: column;
        gap: 5px;
    }

    .hit-zone {
        right: 40px;
        width: 180px;
        height: 180px;
    }

    .pause-message {
        font-size: 2rem;
    }
}