* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

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

.game-container {
    position: relative;
    padding: 20px;
    z-index: 1;
}

.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 10px;
}

.control-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 100;
    pointer-events: auto;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

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

.btn-home {
    background: linear-gradient(135deg, #4ade80, #22c55e);
}

.score-display,
.high-score-display {
    color: #ffffff;
    font-size: 18px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
}

#gameCanvas {
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    z-index: 10;
}

/* 确保控制按钮始终在最上层 */
.control-buttons {
    z-index: 100;
    position: relative;
}

#startBox {
    display: flex;
}

#gameOverBox,
#rankingBox {
    display: none;
}

.overlay-content {
    text-align: center;
    color: #ffffff;
}

.overlay-content h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #4ade80;
}

.overlay-content h2 {
    font-size: 32px;
    margin-bottom: 20px;
}

.overlay-content p {
    font-size: 16px;
    margin-bottom: 10px;
    opacity: 0.8;
}

.btn {
    display: inline-block;
    padding: 12px 32px;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #1a1a2e;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(74, 222, 128, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: #ffffff;
}

.btn-secondary:hover {
    box-shadow: 0 5px 20px rgba(107, 114, 128, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#playerNameInput {
    display: block;
    width: 250px;
    padding: 12px;
    margin: 20px auto;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 16px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

#playerNameInput:focus {
    border-color: #4ade80;
}

#playerNameInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.ranking-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(74, 222, 128, 0.2);
    margin-bottom: 5px;
    border-radius: 5px;
    font-weight: bold;
    color: #4ade80;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 5px;
    border-radius: 5px;
}

.ranking-item .rank {
    font-weight: bold;
    color: #fbbf24;
    width: 50px;
    text-align: center;
}

.ranking-item .name {
    flex: 1;
    text-align: left;
    padding: 0 10px;
}

.ranking-item .score {
    font-weight: bold;
    color: #4ade80;
    width: 60px;
    text-align: right;
}

.ranking-item .time {
    width: 120px;
    text-align: right;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.ranking-list::-webkit-scrollbar {
    width: 6px;
}

.ranking-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.ranking-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

@media (max-width: 550px) {
    .game-container {
        padding: 10px;
        width: 95vw;
        max-width: 500px;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
    
    .info-bar {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .score-display,
    .high-score-display {
        font-size: 14px;
        padding: 6px 12px;
    }
    
    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .overlay-content h1 {
        font-size: 32px;
    }
    
    .overlay-content h2 {
        font-size: 24px;
    }
    
    .btn {
        padding: 10px 24px;
        font-size: 16px;
    }
    
    #playerNameInput {
        width: 200px;
    }
}

@media (max-width: 400px) {
    .game-container {
        width: 98vw;
        padding: 5px;
    }
    
    .score-display,
    .high-score-display {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}