/* 
 * style.css - 重构版
 * 职责：定义游戏界面、广告位、Canvas 容器及响应式布局的样式。
 * 
 * 改造要点：
 * 1. 游戏占满首屏，一打开就是游戏
 * 2. SEO 放到游戏下方，滑动才能看到
 * 3. 广告改为横条（顶部/底部），不占游戏空间
 * 4. 移动端游戏全屏占比更大
 */

:root {
    --primary: #00b4db;
    --danger: #ff6b6b;
    --success: #4cd137;
    --text-shadow: 0 2px 4px rgba(0,0,0,0.9);
    --ad-bg: #1e293b;
    --ad-border: #334155;
}

/* --- 全局样式 --- */
body {
    margin: 0;
    padding: 0;
    background-color: #0a0a1a;
    font-family: 'Segoe UI', sans-serif;
    /* 移除 overflow: hidden，允许页面滚动 */
    overflow-x: hidden;
    overflow-y: auto;
    color: white;
    user-select: none;
    -webkit-user-select: none;
}

/* --- 顶部广告条 --- */
.ad-top-bar {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 8px 0;
    background: #0f172a;
    flex-shrink: 0;
}

/* --- 游戏主区域 - 占满首屏 --- */
#game-area {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 确保首屏就是游戏 */
    position: relative;
}

/* --- 游戏容器 --- */
#game-container {
    position: relative;
    width: 100%;
    max-width: 520px;
    /* 游戏区域高度：桌面端最多 90vh，移动端占满视口 */
    flex: 1 1 auto;
    min-height: 60vh;
    max-height: 90vh;
    background: #1a1a2e;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
}

/* --- 游戏内顶部广告 --- */
.ad-inner-top {
    width: 100%;
    padding: 6px 10px;
    background: rgba(15, 23, 42, 0.95);
    flex-shrink: 0;
}

/* --- 底部广告条 --- */
.ad-bottom-bar {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 8px 0;
    background: #0f172a;
    flex-shrink: 0;
}

/* --- 广告位通用样式 --- */
.ad-slot {
    background: var(--ad-bg);
    border: 1px dashed var(--ad-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0.75rem;
    text-align: center;
    transition: background 0.2s;
    padding: 4px;
}

.ad-slot:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--primary);
    color: var(--primary);
}

/* 横条广告 */
.ad-slot-horizontal {
    width: 320px;
    max-width: 95%;
    height: 50px;
}

/* 游戏内广告 */
.ad-slot-inner {
    width: 100%;
    height: 40px;
}

/* --- Canvas 画布 --- */
#canvas-wrapper {
    width: 100%;
    flex: 1 1 auto;
    position: relative;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- 覆盖层（开始/结束/暂停界面） --- */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    text-align: center;
    backdrop-filter: blur(5px);
    padding: 20px;
    box-sizing: border-box;
}

.hidden { display: none !important; }

h1 { 
    font-size: 2.2rem; 
    margin-bottom: 15px; 
    color: #e0f7fa; 
    text-shadow: 0 0 10px rgba(224, 247, 250, 0.5); 
}

p { 
    font-size: 1.1rem; 
    margin-bottom: 20px; 
    color: #b0bec5; 
    line-height: 1.5; 
}

button {
    padding: 12px 30px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--primary), #0083b0);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 180, 219, 0.3);
    transition: transform 0.1s;
    font-weight: bold;
    margin: 5px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

button:active { transform: scale(0.95); }

button.secondary { 
    background: linear-gradient(135deg, #546e7a, #37474f); 
}

/* --- HUD --- */
#hud-time-center {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
}

#hud {
    position: absolute;
    top: 10px; left: 10px; right: 10px;
    display: flex; justify-content: space-between;
    pointer-events: none;
    z-index: 5;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: var(--text-shadow);
}

#sound-toggle {
    position: absolute; top: 10px; right: 10px;
    z-index: 15;
    background: rgba(0,0,0,0.5);
    border-radius: 50%; width: 36px; height: 36px;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.2rem;
}

/* --- 移动端控制按钮 --- */
#mobile-controls {
    width: 100%;
    height: 100px;
    background: rgba(30, 30, 30, 0.8);
    display: flex; justify-content: space-between;
    padding: 10px 20px;
    box-sizing: border-box;
    z-index: 15;
    flex-shrink: 0;
}

.control-btn {
    width: 70px; height: 70px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.8rem;
    border: 1px solid rgba(255,255,255,0.1);
}

.control-btn:active { background: rgba(255,255,255,0.3); }

#btn-pause { 
    width: 50px; height: 50px; 
    font-size: 1.2rem; 
}


/* --- 触摸控制区域（游戏画面左右半屏） --- */
#touch-zones {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 8;
    display: none;
    pointer-events: auto;
}

#touch-zones.active {
    display: flex;
}

.touch-zone {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.touch-zone:active {
    opacity: 0.08;
    background: #fff;
}

.touch-zone-icon {
    font-size: 2.5rem;
    color: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* --- 成就弹窗 --- */
#achievement-popup {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(255, 215, 0, 0.95);
    color: #333; padding: 10px 20px; border-radius: 8px;
    z-index: 20; opacity: 0; transition: opacity 0.3s;
    font-weight: bold; text-align: center; width: 80%;
}

#achievement-popup.show { opacity: 1; }

/* --- Toast 通知 --- */
.toast {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 212, 255, 0.9);
    color: #000; padding: 12px 28px;
    border-radius: 10px; font-size: 1rem; font-weight: 600;
    z-index: 50; pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.toast.hidden { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
.toast:not(.hidden) { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* --- SEO 内容区域 --- */
.seo-section {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px 60px;
    background: #0f172a;
}

.seo-card {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.seo-card h2 {
    font-size: 1.6rem;
    color: var(--primary);
    margin-bottom: 15px;
    border-bottom: 2px solid rgba(0, 180, 219, 0.3);
    padding-bottom: 10px;
}

.seo-card h3 {
    font-size: 1.3rem;
    color: #e0f7fa;
    margin-top: 25px;
    margin-bottom: 10px;
}

.seo-card p {
    font-size: 1rem;
    color: #b0bec5;
    line-height: 1.7;
    margin-bottom: 12px;
}

.seo-card ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.seo-card li {
    font-size: 1rem;
    color: #b0bec5;
    line-height: 1.7;
    margin-bottom: 6px;
}

.seo-card strong {
    color: #e0f7fa;
}

/* ========================================
   响应式布局
   ======================================== */

/* --- 桌面端（宽屏） --- */
@media (min-width: 1200px) {
    #game-container {
        max-width: 520px;
        max-height: 85vh;
        border-radius: 16px;
        border: 2px solid #333;
    }
    
    .seo-section {
        padding: 50px 30px 80px;
    }
}

/* --- 平板端 --- */
@media (max-width: 1199px) and (min-width: 768px) {
    #game-container {
        max-width: 480px;
        max-height: 85vh;
        border-radius: 12px;
        border: 1px solid #333;
    }
    
    .ad-slot-horizontal {
        width: 300px;
        height: 60px;
    }
}

/* --- 手机端 --- */
@media (max-width: 767px) {
    /* 游戏占满整个屏幕高度 */
    #game-area {
        min-height: 100vh;
        min-height: 100dvh; /* 动态视口高度，适配移动端浏览器地址栏 */
    }
    
    #game-container {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        border: none;
        flex: 0 0 auto;
    }
    
    /* 顶部/底部广告条缩小 */
    .ad-top-bar,
    .ad-bottom-bar {
        padding: 4px 0;
    }
    
    .ad-slot-horizontal {
        width: 100%;
        max-width: 100%;
        height: 40px;
    }
    
    /* 移动端控制按钮增大 */
    #mobile-controls {
        height: 90px;
        padding: 10px 15px;
    }
    
    .control-btn {
        width: 65px;
        height: 65px;
        font-size: 1.6rem;
    }

    /* 触摸区域显示 */
    #touch-zones {
        display: flex;
    }

    
    #btn-pause {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    /* SEO 区域手机端更紧凑 */
    .seo-section {
        padding: 30px 15px 40px;
    }
    
    .seo-card {
        padding: 20px 15px;
        border-radius: 8px;
    }
    
    .seo-card h2 {
        font-size: 1.3rem;
    }
    
    .seo-card h3 {
        font-size: 1.15rem;
    }
    
    .seo-card p,
    .seo-card li {
        font-size: 0.95rem;
    }
    
    /* 游戏内覆盖层文字调整 */
    h1 { font-size: 1.8rem; }
    p { font-size: 1rem; }
    button { padding: 10px 24px; font-size: 1rem; }
}

/* --- 小屏手机（如 iPhone SE） --- */
@media (max-width: 375px) {
    #game-container {
        width: 100%;
        height: 100dvh;
    }
    
    .control-btn {
        width: 58px;
        height: 58px;
        font-size: 1.4rem;
    }
    
    #mobile-controls {
        height: 80px;
        padding: 8px 10px;
    }
}

/* --- 横屏适配 --- */
@media (max-height: 500px) and (orientation: landscape) {
    #game-area {
        min-height: 100vh;
    }
    
    #game-container {
        max-height: 100vh;
        height: 100vh;
    }
    
    #mobile-controls {
        display: none; /* 横屏时隐藏虚拟按钮，用键盘/触摸画布 */
    }
    
    #touch-zones {
        display: flex;
    }
    
    .ad-top-bar,
    .ad-bottom-bar {
        display: none;
    }
}

/* --- 大屏桌面端 --- */
@media (min-width: 1600px) {
    #game-container {
        max-width: 560px;
        max-height: 80vh;
    }
}
