* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden; /* 防止横向滚动 */
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #e74c3c;
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 1.2rem;
    flex-wrap: wrap; /* 允许在小屏幕上换行 */
    gap: 10px;
}

.timer {
    background-color: #e74c3c;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
}

.level {
    background-color: #3498db;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
}

.game-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    min-height: 400px;
    position: relative;
    gap: 20px;
    /* 始终保持水平布局 */
    flex-direction: row;
    flex-wrap: nowrap;
}

.column {
    width: 45%;
    background-color: #fff;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.idiom-part {
    background-color: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    /* 确保触摸屏上有足够的点击区域 */
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.idiom-part:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
}

.idiom-part.selected {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
}

.idiom-part.correct {
    background-color: #2ecc71;
    color: white;
    border-color: #27ae60;
    animation: fadeOut 1s forwards;
    pointer-events: none;
}

.idiom-part.incorrect {
    background-color: #e74c3c;
    color: white;
    border-color: #c0392b;
    animation: shake 0.5s;
}

@keyframes fadeOut {
    to {
        opacity: 0.3;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

/* 庆祝动画相关样式 */
.celebration {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

/* 烟花粒子 */
.firework-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transform-origin: center center;
}

/* 烟花发射体 */
.firework-rocket {
    position: absolute;
    width: 4px;
    height: 15px;
    background: linear-gradient(to top, #ff9500, #ffcc00);
    border-radius: 50% 50% 0 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    animation: rocketUp 0.6s ease-out forwards;
}

/* 烟花尾迹 */
.firework-trail {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background-color: rgba(255, 200, 0, 0.8);
    animation: fadeTrail 0.5s ease-out forwards;
}

/* 烟花发射动画 */
@keyframes rocketUp {
    0% {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(-150px) scale(0.8);
        opacity: 0;
    }
}

/* 烟花爆炸动画 */
@keyframes explode {
    0% {
        transform: translate(0, 0) scale(0.2);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--x), var(--y)) scale(0.8);
        opacity: 0;
    }
}

/* 烟花尾迹消失动画 */
@keyframes fadeTrail {
    0% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
    }
}

/* 闪烁效果 */
@keyframes twinkle {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes celebrate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.message {
    text-align: center;
    font-size: 1.2rem;
    min-height: 30px;
    margin-bottom: 20px;
    color: #e74c3c;
    font-weight: bold;
    padding: 0 10px;
    word-wrap: break-word;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap; /* 允许在小屏幕上换行 */
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
    /* 确保触摸屏上有足够的点击区域 */
    min-height: 44px;
    min-width: 100px;
}

button:hover {
    background-color: #2980b9;
}

#restart-btn {
    background-color: #e74c3c;
}

#restart-btn:hover {
    background-color: #c0392b;
}

#next-level-btn {
    background-color: #2ecc71;
}

#next-level-btn:hover {
    background-color: #27ae60;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    margin: 0 20px;
}

.modal h2 {
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.modal p {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

#play-again-btn {
    background-color: #2ecc71;
    font-size: 1.1rem;
    padding: 12px 25px;
}

#play-again-btn:hover {
    background-color: #27ae60;
}

/* 响应式设计 - 媒体查询 */
@media screen and (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .game-info {
        font-size: 1rem;
    }
    
    /* 保持左右两列布局 */
    .column {
        width: 48%;
    }
    
    .game-container {
        flex-direction: row;
        min-height: auto;
        gap: 10px;
    }
    
    .idiom-part {
        font-size: 1.1rem;
        padding: 10px;
    }
    
    .message {
        font-size: 1.1rem;
    }
    
    .modal h2 {
        font-size: 1.5rem;
    }
    
    .modal p {
        font-size: 1rem;
    }
}

@media screen and (max-width: 480px) {
    h1 {
        font-size: 1.6rem;
    }
    
    .container {
        padding: 10px 5px;
    }
    
    .game-info {
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }
    
    .timer, .level {
        padding: 5px 10px;
        font-size: 0.9rem;
    }
    
    /* 保持左右两列布局，但减小间距和内边距 */
    .column {
        padding: 10px;
    }
    
    .game-container {
        gap: 8px;
    }
    
    .idiom-part {
        font-size: 0.9rem;
        padding: 6px;
        min-height: 40px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-width: 80px;
    }
    
    .modal-content {
        padding: 15px 10px;
    }
}

/* 确保在横屏模式下的良好显示 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .game-container {
        min-height: 200px;
    }
    
    .idiom-part {
        padding: 5px;
        min-height: 36px;
        font-size: 0.9rem;
    }
    
    h1 {
        margin-bottom: 5px;
        font-size: 1.8rem;
    }
    
    .game-info {
        margin-bottom: 5px;
    }
    
    .message {
        margin-bottom: 5px;
        min-height: 20px;
    }
}