* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #0a0a1a, #000010);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1600px;
    max-height: 1000px;
    aspect-ratio: 16/10;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 0 60px rgba(74, 140, 255, 0.3);
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.ui-layer > * {
    pointer-events: auto;
}

.menu-panel {
    background: rgba(10, 10, 30, 0.95);
    border-radius: 20px;
    padding: 40px;
    width: 80%;
    max-width: 700px;
    text-align: center;
    box-shadow: 0 0 40px rgba(74, 140, 255, 0.4),
                inset 0 0 20px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(74, 140, 255, 0.3);
    backdrop-filter: blur(10px);
    transform: translateY(20px);
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 30px;
    color: #6ea0ff;
    text-shadow: 0 0 20px rgba(110, 160, 255, 0.8);
    background: linear-gradient(to right, #6ea0ff, #4cffdf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.btn {
    background: linear-gradient(to bottom, #6ea0ff, #3a70cc);
    color: white;
    border: none;
    border-radius: 50px;
    padding: clamp(12px, 3vw, 18px) clamp(15px, 4vw, 30px);
    margin: 15px 0;
    width: 100%;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3),
                0 0 10px rgba(110, 160, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.btn: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: 0.5s;
}

.btn:hover:before {
    left: 100%;
}

.btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
    background: linear-gradient(to bottom, #606090, #383858);
}

.score-display {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: bold;
    text-shadow: 0 0 15px rgba(110, 160, 255, 0.8);
    margin-top: 20px;
    background: linear-gradient(to bottom, #fff, #a0d0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.high-score {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: #a0a0d0;
    margin: 15px 0;
    text-shadow: 0 0 10px rgba(160, 180, 255, 0.5);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
}

.switch {
    position: relative;
    display: inline-block;
    width: clamp(70px, 15vw, 100px);
    height: clamp(35px, 8vw, 50px);
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #383858;
    transition: .4s;
    border-radius: 50px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.slider:before {
    position: absolute;
    content: "";
    height: calc(100% - 8px);
    width: calc(50% - 8px);
    left: 4px;
    bottom: 4px;
    background: linear-gradient(to bottom, #fff, #ccc);
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

input:checked + .slider {
    background: linear-gradient(to right, #6ea0ff, #3a70cc);
}

input:checked + .slider:before {
    transform: translateX(calc(100% + 8px));
}

.difficulty-selector {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin: 10px 0;
}

.difficulty-btn {
    flex: 1;
    margin: 0 5px;
    padding: clamp(10px, 2vw, 15px) clamp(5px, 2vw, 10px);
    background: rgba(60, 60, 100, 0.7);
    border: none;
    border-radius: 15px;
    color: white;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.difficulty-btn.active {
    background: linear-gradient(to bottom, #6ea0ff, #3a70cc);
    box-shadow: 0 0 15px rgba(110, 160, 255, 0.7);
}

.time-selector {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin: 10px 0;
}

.time-btn {
    flex: 1;
    margin: 0 5px;
    padding: clamp(10px, 2vw, 15px) clamp(5px, 2vw, 10px);
    background: rgba(60, 60, 100, 0.7);
    border: none;
    border-radius: 15px;
    color: white;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.time-btn.active {
    background: linear-gradient(to bottom, #6ea0ff, #3a70cc);
    box-shadow: 0 0 15px rgba(110, 160, 255, 0.7);
}

.page {
    display: none;
}

.active {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.game-ui {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 3;
    padding: 0 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timer-display {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
    margin-top: 10px;
    color: #ffcc00;
    background: linear-gradient(to bottom, #ffcc00, #ff9900);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.instructions {
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    line-height: 1.5;
    margin: 25px 0;
    color: #ccc;
}

.legal-text {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: #888;
    margin-top: 40px;
    line-height: 1.4;
}

.score-notification {
    position: absolute;
    top: 100px;
    right: 30px;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: bold;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
    animation: floatUp 1.5s ease-out forwards;
    z-index: 10;
    pointer-events: none;
}

@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    20% {
        opacity: 1;
        transform: translateY(0);
    }
    80% {
        opacity: 1;
        transform: translateY(-20px);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px);
    }
}

.score-positive {
    color: #6eff6e;
    text-shadow: 0 0 10px rgba(110, 255, 110, 0.7);
}

.score-negative {
    color: #ff6e6e;
    text-shadow: 0 0 10px rgba(255, 110, 110, 0.7);
}

.score-bonus {
    color: #ffcc00;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    text-shadow: 0 0 15px rgba(255, 204, 0, 0.8);
}

.mode-details-container {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 400px;
    width: 100%;
    gap: 20px;
    padding: 15px 0;
    margin: 20px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(110, 160, 255, 0.5) rgba(10, 10, 30, 0.3);
}

.mode-details-container::-webkit-scrollbar {
    width: 8px;
}

.mode-details-container::-webkit-scrollbar-track {
    background: rgba(10, 10, 30, 0.3);
    border-radius: 4px;
}

.mode-details-container::-webkit-scrollbar-thumb {
    background: rgba(110, 160, 255, 0.5);
    border-radius: 4px;
}

.mode-details {
    text-align: left;
    padding: 15px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-title {
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    color: #6ea0ff;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(110, 160, 255, 0.5);
}

.mode-rules {
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    line-height: 1.6;
    color: #ddd;
}

.rule-item {
    margin: 8px 0;
    display: flex;
    align-items: flex-start;
}

.rule-icon {
    margin: 0 10px 0 0;
    min-width: 24px;
    text-align: center;
}

.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: float 15s infinite linear;
    box-shadow: 0 0 10px rgba(110, 160, 255, 0.5);
}

@keyframes float {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-1000%) rotate(720deg);
        opacity: 0;
    }
}

.neon-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(110, 160, 255, 0.5);
    box-shadow: 0 0 10px rgba(110, 160, 255, 0.7);
    z-index: 1;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

.pulse {
    animation: pulse 2s infinite ease-in-out;
}

.game-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 500px;
    padding: 0 10px;
    margin-top: 10px;
    gap: 20px;
}

.stat-box {
    background: rgba(10, 10, 30, 0.7);
    border-radius: 15px;
    padding: 10px 15px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(110, 160, 255, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    text-align: center;
    min-width: 100px;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-label {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: #a0a0d0;
    margin-bottom: 5px;
}

.stat-value {
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    font-weight: bold;
    background: linear-gradient(to bottom, #fff, #a0d0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

@keyframes gameOverFade {
    0% { opacity: 0; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

.game-over-anim {
    animation: gameOverFade 0.5s ease-out forwards;
}

.pause-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(10, 10, 30, 0.7);
    border: 1px solid rgba(110, 160, 255, 0.3);
    color: white;
    border-radius: 50%;
    width: clamp(35px, 8vw, 40px);
    height: clamp(35px, 8vw, 40px);
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    cursor: pointer;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.audio-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(10, 10, 30, 0.7);
    border: 1px solid rgba(110, 160, 255, 0.3);
    color: white;
    border-radius: 50%;
    width: clamp(35px, 8vw, 40px);
    height: clamp(35px, 8vw, 40px);
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    cursor: pointer;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.color-blind-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(10, 10, 30, 0.7);
    border: 1px solid rgba(110, 160, 255, 0.3);
    color: white;
    border-radius: 50%;
    width: clamp(35px, 8vw, 40px);
    height: clamp(35px, 8vw, 40px);
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    cursor: pointer;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* 进度条样式 */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 500px;
}

.loading-text {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 30px;
    color: #6ea0ff;
    text-shadow: 0 0 15px rgba(110, 160, 255, 0.8);
}

.progress-bar {
    width: 100%;
    height: clamp(20px, 5vw, 25px);
    background: rgba(10, 10, 30, 0.7);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(110, 160, 255, 0.3);
    border: 1px solid rgba(110, 160, 255, 0.3);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, #6ea0ff, #4cffdf);
    border-radius: 15px;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(110, 160, 255, 0.5);
}

/* 色盲模式说明样式 */
.color-blind-info {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(110, 160, 255, 0.3);
    text-align: left;
}

.color-blind-info h3 {
    color: #6ea0ff;
    margin-bottom: 10px;
    font-size: clamp(1.4rem, 3vw, 1.6rem);
}

.color-blind-info p {
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    line-height: 1.5;
    color: #ddd;
}

/* 小度设备适配 */
/* 7英寸小度屏适配 */
@media (device-width: 1024px) and (device-height: 600px) {
    .game-container { padding: 16px !important; }
    .game-btn { font-size: 14px !important; }
    .game-title { font-size: 24px !important; }
}

/* 10英寸小度屏适配 */
@media (device-width: 1280px) and (device-height: 800px) {
    .game-container { padding: 24px !important; }
    .game-btn { font-size: 16px !important; }
    .game-title { font-size: 28px !important; }
}

/* 触控区域适配 */
.game-btn, .function-entry {
    min-width: 48px !important;
    min-height: 48px !important;
    padding: 12px !important;
}

/* 焦点样式（高对比度，符合无障碍规范） */
.game-btn:focus, .function-entry:focus {
    outline: 2px solid #d4af37;
    outline-offset: 2px;
}

/* 遥控器设备禁用hover（避免冗余交互） */
@media (pointer: coarse) {
    .game-btn:hover, .function-entry:hover {
        background-color: inherit !important;
    }
}

/* 优化动画（使用transform，提前告知浏览器优化） */
.game-animation {
    animation: 动画名 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    will-change: transform;
}

@keyframes 动画名 {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 低性能设备禁用非必要动画 */
@media (max-performance: low) {
    .game-animation { animation: none !important; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    #game-container {
        box-shadow: none;
        border-radius: 0;
        max-width: 100%;
        max-height: 100%;
    }
    
    .menu-panel {
        padding: 20px;
        width: 95%;
        border-radius: 15px;
        max-height: 95vh;
    }
    
    .game-stats {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        margin-top: 5px;
    }
    
    .stat-box {
        padding: 8px 12px;
        min-width: 80px;
    }
    
    .pause-btn, .audio-toggle, .color-blind-toggle {
        top: 10px;
        right: 10px;
    }
    
    .audio-toggle {
        left: 10px;
    }
    
    .score-notification {
        top: 80px;
        right: 20px;
    }
    
    .game-ui {
        top: 5px;
        padding: 0 5px;
    }
}

@media (max-width: 480px) {
    .game-stats {
        gap: 5px;
    }
    
    .stat-box {
        min-width: 70px;
        padding: 6px 8px;
    }
}