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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
}

.game-container {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 0 30px rgba(255, 255, 0, 0.3);
    max-width: 800px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    color: #ffeb3b;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-size: 2.5em;
    margin-bottom: 15px;
}

.score-board {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1.2em;
}

.score-board span {
    color: #4caf50;
    font-weight: bold;
}

.game-area {
    background: #000;
    border: 4px solid #212121;
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 450px;
}

.game-area canvas {
    display: block;
    max-width: 100%;
    height: auto;
    touch-action: none;
}

.controls {
    text-align: center;
}

.controls p {
    margin-bottom: 15px;
    color: #aaa;
    font-size: 0.9em;
}

.controls button {
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
    color: #000;
    border: none;
    padding: 12px 30px;
    margin: 0 10px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 235, 59, 0.4);
}

.controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 235, 59, 0.6);
}

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

.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 20px;
    border: 2px solid #ffeb3b;
}

.game-over-content h2 {
    color: #ffeb3b;
    font-size: 2.5em;
    margin-bottom: 20px;
}

.game-over-content p {
    font-size: 1.5em;
    margin-bottom: 30px;
}

.image-upload {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.image-upload h3 {
    color: #ffeb3b;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.upload-group {
    margin-bottom: 10px;
}

.upload-group label {
    display: block;
    margin-bottom: 5px;
    color: #aaa;
}

.upload-group input {
    width: 100%;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 5px;
    color: #fff;
}

.upload-group input:hover {
    border-color: #ffeb3b;
}

.win-image {
    max-width: 300px;
    max-height: 200px;
    margin: 20px auto;
    display: block;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 235, 59, 0.5);
}

.win-image.shake-animation {
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    10% { transform: translateX(-5px) rotate(-3deg); }
    20% { transform: translateX(5px) rotate(3deg); }
    30% { transform: translateX(-5px) rotate(-3deg); }
    40% { transform: translateX(5px) rotate(3deg); }
    50% { transform: translateX(-5px) rotate(-3deg); }
    60% { transform: translateX(5px) rotate(3deg); }
    70% { transform: translateX(-5px) rotate(-3deg); }
    80% { transform: translateX(5px) rotate(3deg); }
    90% { transform: translateX(-5px) rotate(-3deg); }
}

.lose-image {
    max-width: 300px;
    max-height: 200px;
    margin: 20px auto;
    display: block;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.win-content {
    border-color: #ffeb3b;
}

.lose-content {
    border-color: #ff0000;
}

.lose-content h2 {
    color: #ff0000;
}

.audio-controls {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.audio-controls h3 {
    color: #ffeb3b;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.audio-controls input[type="range"] {
    width: 100%;
    margin-top: 5px;
}

.settings-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.settings-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.settings-section:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 235, 59, 0.3);
    transform: translateY(-2px);
}

.settings-section h3 {
    color: #ffeb3b;
    margin-bottom: 20px;
    font-size: 1.3em;
    border-bottom: 2px solid rgba(255, 235, 59, 0.3);
    padding-bottom: 10px;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    margin-bottom: 10px;
    color: #fff;
    font-weight: 500;
    font-size: 0.95em;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.control-group input[type="range"] {
    flex: 1;
    min-width: 150px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    appearance: none;
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #ffeb3b;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #ffeb3b;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.control-group input[type="number"] {
    width: 80px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 1em;
    text-align: center;
    transition: all 0.3s ease;
}

.control-group input[type="number"]:focus {
    border-color: #ffeb3b;
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.3);
    outline: none;
}

.control-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #ffeb3b;
    cursor: pointer;
}

.value-display {
    background: rgba(255, 235, 59, 0.2);
    color: #ffeb3b;
    padding: 5px 12px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 0.9em;
    min-width: 40px;
    text-align: center;
}

.file-input-wrapper {
    width: 100%;
    margin-bottom: 10px;
}

.file-input-wrapper:last-child {
    margin-bottom: 0;
}

.file-input-wrapper input[type="file"] {
    display: none;
}

.file-label {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: #fff;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.file-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
    background: linear-gradient(135deg, #5cb85c 0%, #4caf50 100%);
}

.file-label:active {
    transform: translateY(0);
}

.help-text {
    display: block;
    margin-top: 8px;
    color: #888;
    font-size: 0.8em;
    font-style: italic;
}

@media (max-width: 768px) {
    .settings-container {
        grid-template-columns: 1fr;
    }
    
    .game-container {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .mobile-controls {
        display: block;
    }
}

/* 控制区域 */
.control-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    flex-wrap: wrap;
}

.control-left {
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.control-tip {
    color: #aaa;
    font-size: 0.9em;
    margin: 0;
}

/* 摇杆容器 */
.joystick-container {
    display: flex;
    justify-content: center;
    padding: 10px;
}

.joystick-base {
    width: 130px;
    height: 130px;
    background: radial-gradient(circle, rgba(255, 235, 59, 0.2) 0%, rgba(255, 193, 7, 0.3) 100%);
    border-radius: 50%;
    border: 3px solid #ffeb3b;
    position: relative;
    touch-action: none;
    box-shadow: 0 4px 20px rgba(255, 235, 59, 0.3);
}

.joystick-stick {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 15px rgba(255, 235, 59, 0.5);
    cursor: pointer;
    transition: background 0.2s ease;
}

.joystick-stick:active {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
}

.joystick-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: #888;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

/* 按钮区域 */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.action-btn:hover {
    transform: translateY(-2px);
}

.action-btn:active {
    transform: scale(0.95);
}

.start-btn {
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
    color: #000;
    box-shadow: 0 4px 15px rgba(255, 235, 59, 0.4);
}

.start-btn:active {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
}

.pause-btn {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.pause-btn:active {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
}

.restart-btn {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

.restart-btn:active {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
}

.btn-icon {
    font-size: 16px;
}

.btn-text {
    font-size: 13px;
}

/* 响应式布局 */
@media (max-width: 600px) {
    .control-area {
        flex-direction: column;
        gap: 20px;
    }
    
    .joystick-base {
        width: 110px;
        height: 110px;
    }
    
    .joystick-stick {
        width: 40px;
        height: 40px;
    }
    
    .joystick-label {
        font-size: 10px;
        bottom: -20px;
    }
    
    .action-btn {
        padding: 8px 16px;
        font-size: 12px;
    }
    
    .btn-icon {
        font-size: 14px;
    }
    
    .btn-text {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .settings-container {
        grid-template-columns: 1fr;
    }
    
    .game-container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .control-tip {
        font-size: 0.8em;
    }
}

/* 旧的dpad样式已删除 */

/* 小屏幕设备显示控制按钮 */
@media (max-width: 600px) {
    .mobile-controls {
        display: block;
    }
    
    .dpad-container {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(3, 60px);
    }
    
    .dpad-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    .arrow-icon {
        font-size: 24px;
    }
    
    .pause-icon {
        font-size: 20px;
    }
}

/* 平板设备也显示控制按钮 */
@media (pointer: coarse) {
    .mobile-controls {
        display: block;
    }
}
/* 排行榜样式 */
.leaderboard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.leaderboard-content {
    background: rgba(30, 30, 50, 0.95);
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 2px solid #ffeb3b;
    box-shadow: 0 0 30px rgba(255, 235, 59, 0.3);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.leaderboard-header h2 {
    color: #ffeb3b;
    font-size: 2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 0, 0, 0.3);
    transform: scale(1.1);
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-btn:hover {
    background: rgba(255, 235, 59, 0.2);
    border-color: #ffeb3b;
}

.tab-btn.active {
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
    color: #000;
    border-color: #ffeb3b;
    font-weight: bold;
}

.leaderboard-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.leaderboard-table th {
    background: rgba(255, 235, 59, 0.2);
    color: #ffeb3b;
    padding: 12px 8px;
    text-align: center;
    border-bottom: 2px solid #ffeb3b;
}

.leaderboard-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table tbody tr:hover {
    background: rgba(255, 235, 59, 0.1);
}

.leaderboard-table tbody tr:nth-child(1) td:first-child {
    color: #ffd700;
    font-size: 1.2em;
}

.leaderboard-table tbody tr:nth-child(2) td:first-child {
    color: #c0c0c0;
    font-size: 1.1em;
}

.leaderboard-table tbody tr:nth-child(3) td:first-child {
    color: #cd7f32;
    font-size: 1.1em;
}

.status-win {
    color: #4caf50;
    font-weight: bold;
}

.status-lose {
    color: #f44336;
}

.leaderboard-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.export-btn {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

.import-btn {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.clear-btn {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
}

/* 排行榜按钮样式 */
.leaderboard-btn {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.4);
}

.leaderboard-btn:active {
    background: linear-gradient(135deg, #7b1fa2 0%, #6a1b9a 100%);
}

/* 昵称输入模态框 */
.name-input-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.name-input-content {
    background: rgba(30, 30, 50, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    border: 2px solid #ffeb3b;
    box-shadow: 0 0 30px rgba(255, 235, 59, 0.3);
    max-width: 400px;
    width: 90%;
}

.name-input-content h3 {
    color: #ffeb3b;
    font-size: 1.5em;
    margin-bottom: 15px;
}

.name-input-content p {
    color: #fff;
    margin-bottom: 20px;
    font-size: 1.2em;
}

.name-input-content input {
    width: 100%;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #ffeb3b;
    border-radius: 10px;
    color: #fff;
    font-size: 1.1em;
    text-align: center;
    margin-bottom: 20px;
    outline: none;
}

.name-input-content input:focus {
    border-color: #ffc107;
    box-shadow: 0 0 15px rgba(255, 235, 59, 0.3);
}

.name-input-content input::placeholder {
    color: #888;
}

.name-input-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.name-input-buttons button {
    padding: 12px 30px;
    border-radius: 25px;
    border: none;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.name-submit-btn {
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
    color: #000;
}

.name-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 235, 59, 0.4);
}

.name-skip-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    border: 1px solid #888;
}

.name-skip-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* 空排行榜提示 */
.empty-message {
    text-align: center;
    color: #888;
    padding: 30px;
    font-size: 1em;
}

/* 响应式排行榜 */
@media (max-width: 600px) {
    .leaderboard-content {
        padding: 20px;
        max-height: 85vh;
    }
    
    .leaderboard-header h2 {
        font-size: 1.5em;
    }
    
    .leaderboard-table {
        font-size: 0.85em;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 5px;
    }
    
    .tab-btn {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    
    .name-input-content {
        padding: 30px;
    }
    
    .name-input-content h3 {
        font-size: 1.3em;
    }
    
    .name-input-content input {
        font-size: 1em;
    }
}

/* 游戏结束按钮组 */
.game-over-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.game-over-buttons button {
    padding: 12px 24px;
    border-radius: 25px;
    border: none;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-over-buttons button:first-child {
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
    color: #000;
}

.game-over-buttons button:first-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 235, 59, 0.4);
}

/* 排行榜切换和API配置 */
.leaderboard-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.leaderboard-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #fff;
    font-size: 0.9em;
}

.leaderboard-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #ffeb3b;
}

.leaderboard-api-config {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.leaderboard-api-config label {
    color: #ffeb3b;
    font-size: 0.85em;
}

.leaderboard-api-config input:focus {
    border-color: #ffeb3b;
    outline: none;
}

/* 加载提示 */
.loading-message {
    text-align: center;
    color: #ffeb3b;
    padding: 30px;
    font-size: 1em;
}

.loading-message::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* API状态提示 */
.api-status {
    text-align: center;
    font-size: 0.85em;
    margin-bottom: 10px;
    padding: 5px 10px;
    border-radius: 10px;
}

.api-status.connected {
    color: #4caf50;
    background: rgba(76, 175, 80, 0.2);
}

.api-status.disconnected {
    color: #f44336;
    background: rgba(244, 67, 54, 0.2);
}

.api-status.local {
    color: #888;
    background: rgba(255, 255, 255, 0.1);
}

/* 排行榜模式选择 */
.leaderboard-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.leaderboard-toggle label {
    color: #fff;
    font-size: 0.9em;
}

.leaderboard-toggle select {
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #ffeb3b;
    border-radius: 10px;
    color: #fff;
    font-size: 0.9em;
    cursor: pointer;
}

.leaderboard-toggle select:focus {
    outline: none;
    border-color: #ffc107;
}

.leaderboard-api-config h4 {
    color: #ffeb3b;
    margin-bottom: 15px;
    font-size: 1em;
}

.config-item {
    margin-bottom: 15px;
}

.config-item label {
    display: block;
    color: #fff;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.config-item input:focus {
    border-color: #ffeb3b;
    outline: none;
}

.config-item small {
    display: block;
    margin-top: 5px;
    font-size: 0.75em;
}

/* ============ 移动端适配（窄屏 ≤480px） ============ */
@media (max-width: 480px) {
    body {
        align-items: flex-start;
    }

    .game-container {
        padding: 12px;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
    }

    .header {
        margin-bottom: 12px;
    }

    .header h1 {
        font-size: clamp(1.4rem, 6vw, 2rem);
        margin-bottom: 10px;
    }

    .score-board {
        font-size: 0.95em;
        gap: 12px;
        flex-wrap: wrap;
        padding: 8px 12px;
    }

    .game-area {
        margin: 10px 0;
        min-height: 0;
        border-width: 2px;
    }

    .control-area {
        padding: 10px;
        gap: 12px;
    }

    .joystick-container {
        padding: 6px;
    }

    .joystick-base {
        width: 96px;
        height: 96px;
    }

    .joystick-stick {
        width: 38px;
        height: 38px;
    }

    .joystick-label {
        white-space: normal;
        font-size: 10px;
        bottom: -18px;
        width: 120px;
        text-align: center;
        line-height: 1.2;
    }

    .control-tip {
        font-size: 0.8em;
    }

    .action-buttons {
        gap: 6px;
    }

    .action-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .action-btn .btn-text {
        font-size: 11px;
    }

    .settings-container {
        padding: 10px;
        gap: 10px;
    }

    .settings-section {
        padding: 12px;
    }

    /* 模态框：占满屏并支持滚动 */
    .leaderboard-content,
    .name-input-content {
        width: calc(100vw - 16px);
        max-width: none;
        max-height: calc(100vh - 32px);
        padding: 16px;
        overflow-y: auto;
    }

    .leaderboard-header h2 {
        font-size: 1.3em;
    }

    .leaderboard-table {
        font-size: 0.78em;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 6px 4px;
    }

    /* iOS Safari 聚焦时不放大页面（需 ≥16px） */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px;
    }

    /* 触屏按下反馈（:hover 在移动端不可靠） */
    .controls button:active,
    .tab-btn:active,
    .close-btn:active,
    .file-label:active,
    .name-submit-btn:active,
    .name-skip-btn:active {
        transform: translateY(0) scale(0.97);
        filter: brightness(1.1);
    }
}
