/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    -webkit-tap-highlight-color: transparent; /* 消除移动端点击高亮 */
}

/* 移动设备上禁用双击缩放 */
* {
    touch-action: manipulation;
}

/* 背景渐变动画 */
@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 游戏容器 */
.game-container {
    position: relative;
    width: 800px;
    height: 600px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 20px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 107, 107, 0.5);
    overflow: hidden;
    animation: containerGlow 3s ease-in-out infinite alternate;
    max-width: 100vw;
    max-height: 100vh;
    transform-origin: center center;
}

/* 容器发光动画 */
@keyframes containerGlow {
    0% { box-shadow: 0 0 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 107, 107, 0.5); }
    100% { box-shadow: 0 0 60px rgba(0, 0, 0, 0.4), 0 0 40px rgba(255, 107, 107, 0.8); }
}

/* 屏幕通用样式 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    transform: scale(0.95);
    pointer-events: none;
    z-index: 0;
}

.screen:not(.hidden) {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
    z-index: 10;
}

/* 开始屏幕入场动画 */
#start-screen:not(.hidden) {
    animation: startScreenEnter 1s ease-out;
}

@keyframes startScreenEnter {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 游戏屏幕入场动画 */
#game-screen:not(.hidden) {
    animation: gameScreenEnter 0.8s ease-out;
}

@keyframes gameScreenEnter {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 暂停屏幕入场动画 */
#pause-screen:not(.hidden) {
    animation: pauseScreenEnter 0.5s ease-out;
}

@keyframes pauseScreenEnter {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 结束屏幕入场动画 */
#game-over-screen:not(.hidden) {
    animation: endScreenEnter 0.8s ease-out;
}

@keyframes endScreenEnter {
    0% {
        transform: translateY(-50px);
        opacity: 0;
    }
    70% {
        transform: translateY(10px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 屏幕退场动画 */
.screen.fade-out {
    animation: fadeOut 0.3s ease-in;
    opacity: 0;
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

.hidden {
    display: none;
}

/* 标题和文本 */
h1 {
    font-size: 56px;
    color: #fff;
    margin-bottom: 30px;
    text-align: center;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(to right, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textGlow 2s ease-in-out infinite alternate;
}

@keyframes textGlow {
    0% { text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3); }
    100% { text-shadow: 3px 3px 15px rgba(102, 126, 234, 0.8); }
}

h2 {
    font-size: 36px;
    color: #fff;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: 700;
}

p {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.9);
    margin: 15px 0;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

/* 按钮样式 - 现代化渐变按钮 */
.button {
    padding: 15px 35px;
    font-size: 20px;
    font-weight: 700;
    color: white;
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 1;
    min-width: 120px;
    min-height: 44px; /* 确保移动设备上有足够的点击区域 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.6s ease;
    z-index: -1;
}

.button:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #ff8e53, #ff6b6b);
}

.button:hover::before {
    left: 100%;
}

.button:active {
    transform: translateY(-2px) scale(0.98);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

/* 主要按钮（开始游戏）特定样式 */
.button.primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    padding: 20px 45px;
    font-size: 24px;
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4);
}

.button.primary:hover {
    background: linear-gradient(45deg, #764ba2, #667eea);
    box-shadow: 0 18px 35px rgba(102, 126, 234, 0.6);
}

/* 次要按钮（重新开始）样式 */
.button.secondary {
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    box-shadow: 0 12px 25px rgba(79, 172, 254, 0.4);
}

.button.secondary:hover {
    background: linear-gradient(45deg, #00f2fe, #4facfe);
    box-shadow: 0 18px 35px rgba(79, 172, 254, 0.6);
}

/* 危险按钮（退出）样式 */
.button.danger {
    background: linear-gradient(45deg, #f093fb, #f5576c);
    box-shadow: 0 12px 25px rgba(245, 87, 108, 0.4);
}

.button.danger:hover {
    background: linear-gradient(45deg, #f5576c, #f093fb);
    box-shadow: 0 18px 35px rgba(245, 87, 108, 0.6);
}

/* 游戏信息面板 */
.game-info {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
    animation: floatEffect 3s ease-in-out infinite;
    flex-wrap: wrap;
    gap: 10px;
}

/* 浮动效果 */
@keyframes floatEffect {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

.score-container, .lives-container, .level-container {
    display: flex;
    align-items: center;
}

.label {
    font-size: 18px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    margin-right: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.value {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: valuePulse 2s ease-in-out infinite;
}

@keyframes valuePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 分数和生命值显示 */
#score, #lives {
  font-weight: bold;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
}

/* 分数脉冲动画 */
.score-pulse {
  animation: scorePulse 0.6s ease-out;
}

@keyframes scorePulse {
  0% {
    transform: scale(1);
    color: #fff;
  }
  50% {
    transform: scale(1.5);
    color: #ffeb3b;
    text-shadow: 0 0 10px #ffeb3b, 0 0 20px #ffeb3b;
  }
  100% {
    transform: scale(1);
    color: #fff;
  }
}

/* 分数增加效果 */
.score-increase {
  animation: scoreIncrease 0.6s ease-out;
}

@keyframes scoreIncrease {
  0% {
    color: #fff;
  }
  50% {
    color: #4caf50;
    text-shadow: 0 0 10px #4caf50, 0 0 20px #4caf50;
  }
  100% {
    color: #fff;
  }
}

/* 分数减少效果 */
.score-decrease {
  animation: scoreDecrease 0.6s ease-out;
}

@keyframes scoreDecrease {
  0% {
    color: #fff;
  }
  50% {
    color: #f44336;
    text-shadow: 0 0 10px #f44336, 0 0 20px #f44336;
    transform: scale(0.9);
  }
  100% {
    color: #fff;
  }
}

/* 游戏画布 */
#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    background: linear-gradient(180deg, #84fab0 0%, #8fd3f4 100%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

#game-canvas.active {
    opacity: 1;
}

/* 暂停按钮 */
.pause-button {
    position: absolute;
    top: 70px;
    right: 20px;
    z-index: 10;
    padding: 10px 20px;
    font-size: 16px;
    background: linear-gradient(45deg, #fa709a 0%, #fee140 100%);
    border-radius: 25px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.pause-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.3);
}

/* 游戏结束分数显示 */
#final-score, #final-level {
    font-size: 36px;
    color: #fff;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 10px 20px;
    animation: scoreAppear 1s ease-out;
}

@keyframes scoreAppear {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* 响应式设计 */
/* 超大屏幕 */
@media (min-width: 1200px) {
    .game-container {
        width: 800px;
        height: 600px;
    }
    
    h1 {
        font-size: 48px;
    }
    
    h2 {
        font-size: 36px;
    }
    
    .button {
        font-size: 20px;
        padding: 15px 30px;
    }
}

/* 大屏幕 */
@media (max-width: 1199px) and (min-width: 900px) {
    .game-container {
        width: 700px;
        height: 525px;
    }
    
    h1 {
        font-size: 42px;
    }
    
    h2 {
        font-size: 32px;
    }
}

/* 中等屏幕 */
@media (max-width: 899px) and (min-width: 600px) {
    .game-container {
        width: 90vw;
        height: 67.5vw;
    }
    
    h1 {
        font-size: 36px;
    }
    
    h2 {
        font-size: 28px;
    }
    
    .button {
        font-size: 18px;
        padding: 12px 24px;
    }
}

/* 小屏幕/平板竖屏 */
@media (max-width: 599px) and (min-width: 480px) {
    .game-container {
        width: 95vw;
        height: 71.25vw;
    }
    
    h1 {
        font-size: 32px;
    }
    
    h2 {
        font-size: 24px;
    }
    
    .button {
        font-size: 16px;
        padding: 10px 20px;
    }
    
    .game-info {
        font-size: 18px;
        padding: 8px 16px;
    }
}

/* 移动设备 */
@media (max-width: 479px) {
    .game-container {
        width: 100vw;
        height: 75vw;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    
    h1 {
        font-size: 28px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    p {
        font-size: 14px;
    }
    
    .button {
        font-size: 14px;
        padding: 8px 16px;
        margin: 8px;
    }
    
    .game-info {
        font-size: 16px;
        padding: 6px 12px;
        flex-direction: column;
        gap: 5px;
    }
    
    /* 移动设备上简化动画以提高性能 */
    .game-container {
        box-shadow: 0 0 20px rgba(255, 165, 0, 0.5);
        animation: glow 3s ease-in-out infinite alternate;
    }
    
    @keyframes glow {
        from { box-shadow: 0 0 20px rgba(255, 165, 0, 0.5); }
        to { box-shadow: 0 0 30px rgba(255, 165, 0, 0.8); }
    }
}

/* 动画效果增强 */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 添加入场动画的延迟 */
.screen:not(.hidden) h1 {
    animation: textGlow 2s ease-in-out infinite alternate, slideUp 0.6s ease-out;
}

.screen:not(.hidden) h2 {
    animation: slideUp 0.6s ease-out 0.2s both;
}

.screen:not(.hidden) p {
    animation: slideUp 0.6s ease-out 0.4s both;
}

.screen:not(.hidden) .button {
    animation: scaleIn 0.5s ease-out 0.6s both;
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 移动设备上增大点击区域 */
    .button {
        min-height: 44px;
        min-width: 100px;
        touch-action: manipulation;
    }
    
    /* 禁用悬停效果，改为点击效果 */
    .button:hover {
        transform: scale(1);
    }
    
    .button:active {
        transform: scale(0.95);
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
    }
}