/* 响应式设计 - 移动端优化 */

/* 小屏幕设备 (手机) */
@media (max-width: 576px) {
    body {
        font-size: 14px;
    }
    
    .game-title {
        font-size: 1.8rem;
    }
    
    .game-subtitle {
        font-size: 1rem;
    }
    
    .menu-buttons .btn {
        min-width: 160px;
        font-size: 1rem;
        padding: 0.6rem 1rem;
    }
    
    /* 关卡选择优化 */
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        padding: 0 0.5rem;
    }
    
    .level-button {
        padding: 1rem;
    }
    
    .level-number {
        font-size: 1.2rem;
    }
    
    /* 游戏界面优化 */
    .game-top-ui {
        height: 50px;
        font-size: 0.9rem;
    }
    
    .sun-counter {
        padding: 0.3rem 0.6rem;
    }
    
    .sun-icon {
        width: 25px;
        height: 25px;
    }
    
    #sun-count {
        font-size: 1.1rem;
    }
    
    .plant-selector {
        gap: 0.3rem;
        padding: 0.3rem;
    }
    
    .plant-card {
        min-width: 60px;
        height: 70px;
    }
    
    .plant-icon {
        font-size: 1.5rem;
    }
    
    .plant-cost {
        font-size: 0.6rem;
    }
    
    /* 触摸优化 */
    .btn, .plant-card, .level-button {
        min-height: 44px; /* 触摸友好的最小尺寸 */
    }
    
    /* 波次进度条优化 */
    .wave-progress {
        width: 150px;
        top: 5px;
        right: 5px;
    }
    
    .wave-info {
        padding: 0.3rem;
        font-size: 0.8rem;
    }
    
    /* 铲子工具优化 */
    .shovel-container {
        bottom: 15px;
        right: 15px;
    }
    
    .shovel-tool {
        width: 50px;
        height: 50px;
    }
    
    .shovel-tool i {
        font-size: 1.2rem;
    }
    
    /* 阳光掉落优化 */
    .sun-drop {
        width: 35px;
        height: 35px;
    }
    
    .sun-drop::before {
        font-size: 1.2em;
    }
    
    /* 帮助和设置界面优化 */
    .help-container, .settings-container {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .help-content h4 {
        font-size: 1.1rem;
    }
    
    .help-content li {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* 暂停和游戏结束界面优化 */
    .pause-container, .game-over-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .pause-container h2, .game-over-container h2 {
        font-size: 1.3rem;
    }
}

/* 中等屏幕设备 (平板) */
@media (min-width: 577px) and (max-width: 768px) {
    .game-title {
        font-size: 2.2rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.8rem;
    }
    
    .plant-selector {
        gap: 0.4rem;
    }
    
    .plant-card {
        min-width: 65px;
        height: 75px;
    }
    
    .wave-progress {
        width: 180px;
    }
    
    .shovel-tool {
        width: 55px;
        height: 55px;
    }
}

/* 大屏幕设备 (桌面) */
@media (min-width: 769px) and (max-width: 1024px) {
    .level-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .plant-card {
        min-width: 70px;
        height: 80px;
    }
}

/* 超大屏幕设备 */
@media (min-width: 1025px) {
    .level-grid {
        grid-template-columns: repeat(6, 1fr);
        max-width: 1000px;
    }
    
    .game-title {
        font-size: 3rem;
    }
    
    .help-container, .settings-container {
        max-width: 900px;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
    .game-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .game-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .menu-buttons .btn {
        padding: 0.5rem 1rem;
        margin-bottom: 0.5rem;
    }
    
    .version-info {
        margin-top: 1rem;
    }
    
    /* 游戏界面横屏优化 */
    .game-top-ui {
        height: 45px;
    }
    
    .plant-selector-container {
        padding: 0.3rem;
    }
    
    .plant-card {
        min-width: 55px;
        height: 65px;
    }
    
    .plant-icon {
        font-size: 1.3rem;
    }
    
    .wave-progress {
        width: 140px;
        top: 5px;
    }
    
    .shovel-tool {
        width: 45px;
        height: 45px;
        bottom: 10px;
        right: 10px;
    }
    
    .sun-drop {
        width: 30px;
        height: 30px;
    }
    
    .sun-drop::before {
        font-size: 1em;
    }
}

/* 触摸设备特殊优化 */
@media (hover: none) and (pointer: coarse) {
    /* 移除悬停效果，优化触摸体验 */
    .btn:hover,
    .plant-card:hover,
    .level-button:hover,
    .shovel-tool:hover {
        transform: none;
    }
    
    /* 增加触摸反馈 */
    .btn:active,
    .plant-card:active,
    .level-button:active,
    .shovel-tool:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* 优化触摸目标大小 */
    .plant-card,
    .level-button,
    .sun-drop {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* 触摸友好的间距 */
    .plant-selector {
        gap: 0.5rem;
    }
    
    .level-grid {
        gap: 1rem;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 提高图像和文字清晰度 */
    #game-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .sun-icon,
    .plant-icon {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* 可访问性优化 */
@media (prefers-reduced-motion: reduce) {
    /* 减少动画效果 */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .sun-drop {
        animation: none;
    }
    
    .btn-game:hover {
        transform: none;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .help-container,
    .settings-container,
    .pause-container,
    .game-over-container {
        background: rgba(30, 30, 30, 0.95);
        color: #E0E0E0;
    }
    
    .help-content h4 {
        color: #81C784;
    }
    
    .help-content li {
        background: rgba(76, 175, 80, 0.1);
        border-left-color: #81C784;
    }
    
    .pause-container h2,
    .game-over-container h2 {
        color: #81C784;
    }
    
    .game-stats {
        background: rgba(50, 50, 50, 0.8);
        color: #E0E0E0;
    }
    
    .game-stats h5 {
        color: #81C784;
    }
}

/* 打印样式 */
@media print {
    body {
        background: white !important;
    }
    
    .screen:not(#help-screen) {
        display: none !important;
    }
    
    #help-screen {
        position: static !important;
        background: white !important;
    }
    
    .help-header button {
        display: none !important;
    }
}

/* 键盘导航优化 */
.btn:focus,
.plant-card:focus,
.level-button:focus {
    outline: 3px solid #FF6B35;
    outline-offset: 2px;
}

/* 屏幕阅读器支持 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
} 