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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* 适配刘海屏和底部安全区域 */
.game-container {
    width: 100%;
    min-height: 100%;
    max-height: 100%;
    padding: env(safe-area-inset-top, 10px) env(safe-area-inset-right, 10px) env(safe-area-inset-bottom, 10px) env(safe-area-inset-left, 10px);
    display: flex;
    flex-direction: column;
    max-width: none;
    box-sizing: border-box;
    /* 确保内容不被安全区域遮挡 */
    --safe-bottom: env(safe-area-inset-bottom, 20px);
    padding-bottom: calc(env(safe-area-inset-bottom, 10px) + 10px);
}

/* 顶部区域：标题和分数 */
.top-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

/* 游戏标题 */
.game-title {
    color: white;
    font-size: 1.8rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: 700;
    margin: 0;
}

/* 分数显示容器 */
.score-container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2px;
}

.score-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
}

/* 游戏区域 - 占据剩余空间 */
.game-area {
    position: relative;
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0; /* 允许flex子元素缩小到内容高度 */
    /* 确保底部有足够空间，避免被控制栏遮挡 */
    margin-bottom: env(safe-area-inset-bottom, 5px);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    max-height: 100%;
    display: block;
    border-radius: 10px;
    /* 确保Canvas内容完全可见 */
    object-fit: contain;
}

/* 控制按钮 - 隐藏，通过滑动控制方向 */
.control-buttons {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 250px;
}

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

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

/* 游戏提示 - 移到覆盖层显示，不占用主界面空间 */
.game-hint {
    display: none;
}

/* 游戏覆盖层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.overlay-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 80%;
    max-width: 350px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#overlayTitle {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 15px;
}

#overlayMessage {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 25px;
}

.btn-primary {
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* 响应式调整 */
@media (max-width: 480px) {
    .game-title {
        font-size: 2rem;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .overlay-content {
        padding: 25px;
    }
    
    #overlayTitle {
        font-size: 1.8rem;
    }
}