* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #1a1a1a;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    padding: 10px;
}

.container {
    text-align: center;
    width: 100%;
    max-width: 800px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    color: #ff6b6b;
    text-shadow: 3px 3px 0px #4ecdc4;
}

.game-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

#game-board {
    border: 3px solid #4ecdc4;
    background-color: #2c2c2c;
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.5);
    max-width: 100%;
    height: auto;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 200px;
    width: 100%;
    max-width: 300px;
}

.next-piece-container {
    border: 2px solid #4ecdc4;
    padding: 10px;
    background-color: #2c2c2c;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.next-piece-container h3 {
    margin-bottom: 10px;
    color: #4ecdc4;
}

#next-piece {
    background-color: #1a1a1a;
    border: 1px solid #4ecdc4;
    max-width: 100%;
    height: auto;
}

.score-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #2c2c2c;
    padding: 15px;
    border-radius: 5px;
    border: 2px solid #4ecdc4;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-item label {
    font-weight: bold;
    color: #4ecdc4;
}

.score-item div {
    font-size: 1.2rem;
    color: #ff6b6b;
    font-weight: bold;
}

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

button {
    padding: 10px 15px;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    background-color: #ff6b6b;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
}

.instructions {
    background-color: #2c2c2c;
    padding: 15px;
    border-radius: 5px;
    border: 2px solid #4ecdc4;
}

.instructions h4 {
    margin-bottom: 10px;
    color: #4ecdc4;
}

.instructions p {
    margin: 5px 0;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2c2c2c;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 3px solid #ff6b6b;
    box-shadow: 0 0 30px rgba(255, 107, 107, 0.7);
    display: none;
    z-index: 1000;
    max-width: 90%;
    width: 300px;
}

.game-over h2 {
    color: #ff6b6b;
    margin-bottom: 15px;
    font-size: clamp(1.5rem, 5vw, 2rem);
}

.game-over p {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

#final-score {
    color: #4ecdc4;
    font-weight: bold;
    font-size: 1.4rem;
}

#play-again {
    background-color: #4ecdc4;
}

#play-again:hover {
    background-color: #45b7aa;
}

/* 触摸控制按钮样式 */
.touch-controls {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    min-width: 120px;
    padding: 10px;
}

.touch-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.touch-btn {
    width: 80px;
    height: 80px;
    font-size: 1.5rem;
    border-radius: 50%;
    background-color: #4ecdc4;
    color: #fff;
    border: 3px solid #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.touch-btn:active {
    background-color: #45b7aa;
    transform: scale(0.95);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .game-info {
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 768px) {
    /* 在中等屏幕上显示触摸控制按钮在右侧 */
    .touch-controls {
        display: flex;
    }
}

@media (max-width: 480px) {
    /* 在小屏幕上隐藏键盘操作说明 */
    .instructions {
        display: none;
    }
    
    /* 调整按钮大小适应小屏幕 */
    .touch-btn {
        width: 60px;
        height: 60px;
        font-size: 1.1rem;
    }
    
    /* 确保游戏板在小屏幕上正确缩放 */
    #game-board {
        max-width: 100vw;
        height: auto;
    }
}

/* 横屏模式优化 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    body {
        padding: 5px;
    }
    
    .container {
        flex-direction: row;
        height: 100vh;
        max-height: 100vh;
    }
    
    .game-container {
        flex: 1;
        min-width: 0;
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    
    .game-info {
        flex: 0 0 auto;
        min-width: 150px;
        max-width: 200px;
        margin-right: 10px;
    }
    
    .touch-controls {
        flex: 0 0 auto;
        min-width: 100px;
        height: auto;
        justify-content: center;
        align-items: center;
    }
    
    .touch-btn {
        width: 50px;
        height: 50px;
        font-size: 0.9rem;
    }
    
    #game-board {
        max-height: 100vh;
    }
}