/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* 顶部导航 */
.navbar {
    position: static;
    top: auto;
    z-index: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.nav-left .brand {
    color: #5a67d8;
    font-weight: 700;
    font-size: 1.2rem;
}

.nav-btn {
    background: #5a67d8;
    padding: 8px 14px;
    font-size: 1rem;
}

.main-layout {
    display: flex;
    min-height: 100vh;
    gap: 20px;
    padding: 20px;
    justify-content: center;
    max-width: 1400px;
    margin: 0 auto;
}

.leftbar {
    width: 220px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    height: fit-content;
    position: sticky;
    top: 20px;
    flex-shrink: 0;
    align-self: flex-start;
}

.main-content {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    height: fit-content;
    position: sticky;
    top: 20px;
    flex-shrink: 0;
}

@media (max-width: 1200px) {
    .main-layout {
        flex-direction: column;
        max-width: 100%;
        padding: 15px;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        order: -1;
    }
    
    .main-content {
        align-items: center;
    }
}

@media (max-width: 1000px) {
    .main-layout {
        padding: 10px;
        gap: 15px;
    }
    
    .sidebar {
        padding: 15px;
    }
}

@media (max-width: 800px) {
    .main-layout {
        padding: 8px;
        gap: 10px;
    }
    
    .sidebar {
        padding: 12px;
    }
    
    .container {
        padding: 15px;
    }
}

/* 针对高DPI屏幕和缩放的适配 */
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
    .main-layout {
        max-width: 1200px;
    }
    
    .sidebar {
        width: 260px;
    }
}

/* 针对150%缩放的适配 */
@media (max-width: 1600px) and (min-width: 1201px) {
    .main-layout {
        max-width: 1200px;
        padding: 15px;
    }
    
    .sidebar {
        width: 260px;
        padding: 18px;
    }
}

.container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 25px;
    max-width: 1000px;
    width: 100%;
    text-align: center;
}

h1 {
    color: #5a67d8;
    font-size: 2.2em;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.game-area {
    margin: 30px 0;
}

.target-key {
    font-size: 2.8em;
    color: #e53e3e;
    font-weight: bold;
    margin: 15px 0;
    padding: 20px 40px;
    border: 3px solid #e53e3e;
    border-radius: 15px;
    background: linear-gradient(135deg, #fff5f5, #fed7d7);
    display: inline-block;
    min-width: 120px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.target-key:hover {
    background: linear-gradient(135deg, #fed7d7, #feb2b2);
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.keyboard {
    background: #f7fafc;
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin: 8px 0;
    gap: 8px;
}

.key {
    background: #e2e8f0;
    border: none;
    border-radius: 8px;
    padding: 16px 18px;
    font-size: 1.3em;
    font-weight: bold;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 55px;
    position: relative;
}

.key:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
}

.key.active {
    background: #4299e1;
    color: white;
    transform: translateY(2px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.key.target {
    background: #ffd700;
    color: #2d3748;
    animation: targetPulse 1s infinite;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

@keyframes targetPulse {
    0% { 
        background: #ffd700;
        transform: scale(1);
    }
    50% { 
        background: #ffed4e;
        transform: scale(1.1);
    }
    100% { 
        background: #ffd700;
        transform: scale(1);
    }
}

.key.correct {
    background: #48bb78;
    color: white;
    animation: correctPop 0.5s ease;
}

@keyframes correctPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.key.wrong {
    background: #f56565;
    color: white;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.space-key {
    min-width: 300px;
    background: #a0aec0;
}

.stats {
    margin-bottom: 25px;
}

.stat-box {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-number {
    font-size: 1.8em;
    font-weight: bold;
    color: white;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    background: #5a67d8;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 60px;
}

.btn:hover {
    background: #4c51bf;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.btn:active, .btn.active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: #38a169;
}

.mode-selector {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.mode-btn {
    background: #ed8936;
    padding: 8px 16px;
    font-size: 1em;
    margin: 0;
    width: 100%;
}

.mode-btn.active {
    background: #38a169;
}

@media (max-width: 768px) {
    .navbar { padding: 10px 12px; }
    .nav-left .brand { font-size: 1rem; }
    .container {
        padding: 20px;
        margin: 10px;
    }

    h1 {
        font-size: 2em;
    }

    .key {
        padding: 12px 14px;
        font-size: 1.1em;
        min-width: 45px;
    }

    .space-key {
        min-width: 250px;
    }

    .stats {
        flex-direction: column;
    }
}

/* 模态弹窗 */
.modal { display: none; }
.modal.show { display: block; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
}
.modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(900px, 92vw);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    overflow: hidden;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    z-index: 2001;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #5a67d8;
    color: #fff;
}
.modal-title { font-weight: 700; }
.modal-close {
    background: transparent;
    color: #fff;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}
.modal-body { padding: 14px; overflow: auto; }
.tutorial-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
}
.modal-tip { margin-top: 8px; font-size: 0.9rem; color: #4a5568; }