/* 1. 全局基础（PC/手机通用） */
html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow-x: hidden;
    font-family: 'Segoe UI', Roboto, sans-serif;
}
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: -1;
}

/* 2. 主题变量（通用） */
:root {
    --primary: #3498db;
    --secondary: #2ecc71;
    --dark: #2c3e50;
    --light: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow: rgba(0, 0, 0, 0.15);
    --download: #e67e22;
}
.dark-theme:root {
    --primary: #4da6ff;
    --secondary: #57e389;
    --dark: #f0f4f8;
    --light: #1a202c;
    --card-bg: rgba(30, 41, 59, 0.95);
    --shadow: rgba(0, 0, 0, 0.3);
    --download: #f39c12;
}

/* ======================================
   PC端（≥768px）：保留原有翻页+全屏效果
====================================== */
@media (min-width: 768px) {
    .page-container {
        position: relative;
        width: 100%;
        height: 100vh; /* PC端严格全屏 */
        overflow: hidden;
    }
    .page {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh; /* 单页全屏 */
        padding: 1.5rem 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1);
    }
    /* PC端翻页动画（原样保留） */
    .page-1 { transform: translateY(0); }
    .page-2 { transform: translateY(100%); }
    .page-container.flipped .page-1 { transform: translateY(-100%); }
    .page-container.flipped .page-2 { transform: translateY(0); }

    /* PC端标题样式（原样） */
    .page-header {
        text-align: center;
        width: 100%;
        max-width: 1200px;
        margin-bottom: 1.5rem;
    }
    .page-title {
        font-size: clamp(2rem, 5vw, 3.2rem);
        margin: 1rem 0 0.8rem;
        color: var(--dark);
        text-shadow: 0 4px 12px var(--shadow);
    }
    .page-subtitle {
        font-size: clamp(1rem, 2vw, 1.3rem);
        color: var(--dark);
        opacity: 0.8;
        max-width: 800px;
    }

    .card-grid {
        display: grid;
        width: 100%;
        max-width: 1200px;
        gap: 1.5rem;
        flex-grow: 1; /* 填充全屏剩余空间 */
        align-items: center; /* 卡片垂直方向居中 */
        justify-content: center; /* 核心：卡片在网格内水平居中（解决列数固定时左对齐问题） */
        padding-bottom: 1rem;
        margin: 0 auto; /* 核心：网格容器本身在父元素中水平居中（屏幕超宽时生效） */
    }

    /* 其他PC端样式保持不变... */
    .entry-grid { grid-template-columns: repeat(2, 340px); }
    .download-grid { grid-template-columns: repeat(4, 250px); }

    /* PC端卡片样式（原样） */
    .card {
        background: var(--card-bg);
        border-radius: 16px;
        padding: 1.8rem 1.2rem;
        text-align: center;
        text-decoration: none;
        color: var(--dark);
        box-shadow: 0 8px 24px var(--shadow);
        display: flex;
        flex-direction: column;
        min-height: 300px;
        max-height: 320px;
        transition: transform 0.4s ease;
    }
    .download-card { min-height: 260px; max-height: 280px; }
    .card:hover { transform: translateY(-5px); box-shadow: 0 12px 32px var(--shadow); }

    /* PC端图标/按钮/导航（原样） */
    .icon { margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; }
    .user-icon, .admin-icon { width: 75px; height: 75px; font-size: 2.3rem; color: var(--primary); }
    .download-icon { width: 55px; height: 55px; font-size: 1.7rem; color: var(--download); }
    .card-title { font-size: 1.4rem; margin: 0 0 0.6rem; color: var(--dark); }
    .card-desc { font-size: 0.95rem; margin: 0 0 1.2rem; line-height: 1.5; opacity: 0.7; color: var(--dark); }

    .btn {
        padding: 0.8rem 1.2rem;
        border: none;
        border-radius: 30px;
        font-size: 0.9rem;
        width: 100%;
        cursor: pointer;
        transition: transform 0.3s ease;
        text-decoration: none;
        white-space: nowrap;
    }
    .user-btn { background: var(--primary); color: white; }
    .admin-btn { background: var(--secondary); color: white; }
    .download-btn { background: var(--download); color: white; }
    .tutorial-btn { background: transparent; color: var(--download); border: 2px solid var(--download); }
    .btn:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

    .btn-group { display: flex; gap: 0.6rem; justify-content: center; }
    .card-btn-wrap { margin-top: auto; width: 100%; max-width: 220px; }

    /* PC端分页导航（原样显示） */
    .page-nav {
        position: absolute;
        bottom: 1.5rem;
        left: 50%;
        transform: translateX(-50%);
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 0.8rem;
        background: var(--card-bg);
        padding: 0.8rem 1.5rem;
        border-radius: 30px;
        box-shadow: 0 4px 12px var(--shadow);
        cursor: pointer;
    }
    .nav-text { color: var(--dark); opacity: 0.9; font-size: 0.95rem; }
    .nav-icon svg { width: 24px; height: 24px; color: var(--dark); transition: transform 0.6s ease; }
    .page-container.flipped .nav-icon svg { transform: rotate(180deg); }

    /* PC端主题按钮（原样） */
    .theme-toggle {
        position: fixed;
        top: 1.5rem;
        right: 1.5rem;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: var(--card-bg);
        border: 2px solid var(--dark);
        box-shadow: 0 4px 12px var(--shadow);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 100;
    }
    .theme-icon { width: 24px; height: 24px; color: var(--dark); }
    .dark-theme .theme-icon.light { display: none; }
    .theme-icon.dark { display: none; }
    .dark-theme .theme-icon.dark { display: block; }

    /* PC端弹窗（原样） */
    .tutorial-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 1000;
        display: none;
        justify-content: center;
        align-items: center;
        padding: 1rem;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(5px);
    }
    .tutorial-modal.active { display: flex; }
    .modal-content {
        background: var(--card-bg);
        border-radius: 12px;
        width: 100%;
        max-width: 600px;
        max-height: 90vh;
        overflow-y: auto;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
        padding: 1.5rem;
    }
    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }
    .modal-title { margin: 0; font-size: 1.4rem; color: var(--dark); }
    .modal-close {
        background: transparent;
        border: none;
        color: var(--dark);
        opacity: 0.7;
        cursor: pointer;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .tutorial-steps { display: flex; flex-direction: column; gap: 1.2rem; margin-bottom: 1rem; }
    .step { display: flex; gap: 0.8rem; align-items: flex-start; }
    .step-number {
        min-width: 28px;
        height: 28px;
        border-radius: 50%;
        background: var(--download);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        flex-shrink: 0;
    }
    .step-content h4 { margin: 0 0 0.3rem; font-size: 1.1rem; color: var(--dark); }
    .step-content p { margin: 0; font-size: 0.95rem; color: var(--dark); opacity: 0.8; line-height: 1.4; }
    .modal-footer {
        display: flex;
        justify-content: center;
        padding-top: 1rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
    .close-btn { background: var(--download); color: white; width: 100%; max-width: 200px; }

    footer { display: none; }
}

/* ======================================
   手机端（<768px）：取消翻页，静态布局
====================================== */
@media (max-width: 767px) {
    .page-container {
        min-height: 100vh; /* 手机端最小全屏，允许内容滚动 */
        overflow-y: auto;
        padding-bottom: 2rem;
    }
    .page {
        position: static; /* 取消绝对定位，取消翻页 */
        height: auto; /* 高度自适应内容，不强制全屏 */
        padding: 1rem 0.8rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 2rem; /* 两个页面之间留间距 */
    }
    /* 手机端隐藏分页导航（无需翻页） */
    .page-nav { display: none; }

    /* 手机端标题：压缩尺寸 */
    .page-header {
        text-align: center;
        width: 100%;
        max-width: 320px;
        margin: 1rem 0 1rem;
    }
    .page-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
        margin: 0 0 0.5rem;
        color: var(--dark);
        text-shadow: 0 2px 8px var(--shadow);
    }
    .page-subtitle {
        font-size: clamp(0.85rem, 3vw, 1rem);
        color: var(--dark);
        opacity: 0.8;
        max-width: 90%;
        line-height: 1.4;
    }

    /* 手机端卡片：单列居中 */
    .card-grid {
        display: grid;
        width: 100%;
        max-width: 300px; /* 卡片最大宽度，不贴边 */
        gap: 1rem;
        padding-bottom: 1rem;
    }
    .entry-grid, .download-grid { grid-template-columns: 1fr; }

    /* 手机端卡片：缩小尺寸 */
    .card {
        background: var(--card-bg);
        border-radius: 16px;
        padding: 1.2rem 0.8rem;
        text-align: center;
        text-decoration: none;
        color: var(--dark);
        box-shadow: 0 4px 16px var(--shadow);
        display: flex;
        flex-direction: column;
        min-height: 220px;
        max-height: 240px;
    }
    .download-card { min-height: 190px; max-height: 210px; }

    /* 手机端图标/文字：缩小 */
    .icon { margin: 0 auto 0.8rem; display: flex; align-items: center; justify-content: center; }
    .user-icon, .admin-icon { width: 55px; height: 55px; font-size: 1.8rem; color: var(--primary); }
    .download-icon { width: 40px; height: 40px; font-size: 1.4rem; color: var(--download); }
    .card-title { font-size: 1.2rem; margin: 0 0 0.4rem; color: var(--dark); }
    .card-desc {
        font-size: 0.85rem;
        margin: 0 0 0.8rem;
        line-height: 1.4;
        opacity: 0.7;
        color: var(--dark);
        /* 文字溢出控制 */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* 手机端按钮：缩小 */
    .btn {
        padding: 0.6rem 1rem;
        border: none;
        border-radius: 30px;
        font-size: 0.85rem;
        width: 100%;
        cursor: pointer;
        text-decoration: none;
        white-space: nowrap;
    }
    .user-btn { background: var(--primary); color: white; }
    .admin-btn { background: var(--secondary); color: white; }
    .download-btn { background: var(--download); color: white; }
    .tutorial-btn { background: transparent; color: var(--download); border: 2px solid var(--download); }
    .btn-group { display: flex; gap: 0.4rem; justify-content: center; }
    .card-btn-wrap { margin-top: auto; width: 100%; max-width: 200px; }

    /* 手机端主题按钮：缩小 */
    .theme-toggle {
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--card-bg);
        border: 2px solid var(--dark);
        box-shadow: 0 2px 8px var(--shadow);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 100;
    }
    .theme-icon { width: 20px; height: 20px; color: var(--dark); }
    .dark-theme .theme-icon.light { display: none; }
    .theme-icon.dark { display: none; }
    .dark-theme .theme-icon.dark { display: block; }

    /* 手机端弹窗：适配小屏幕 */
    .tutorial-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 1000;
        display: none;
        justify-content: center;
        align-items: center;
        padding: 0.8rem;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(5px);
    }
    .tutorial-modal.active { display: flex; }
    .modal-content {
        background: var(--card-bg);
        border-radius: 12px;
        width: 100%;
        max-width: 320px;
        max-height: 85vh;
        overflow-y: auto;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
        padding: 1rem;
    }
    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        padding-bottom: 0.8rem;
        margin-bottom: 0.8rem;
    }
    .modal-title { margin: 0; font-size: 1.2rem; color: var(--dark); }
    .modal-close {
        background: transparent;
        border: none;
        color: var(--dark);
        opacity: 0.7;
        cursor: pointer;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .tutorial-steps { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 0.8rem; }
    .step { display: flex; gap: 0.6rem; align-items: flex-start; }
    .step-number {
        min-width: 26px;
        height: 26px;
        border-radius: 50%;
        background: var(--download);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        flex-shrink: 0;
        font-size: 0.85rem;
    }
    .step-content h4 { margin: 0 0 0.3rem; font-size: 1rem; color: var(--dark); }
    .step-content p { margin: 0; font-size: 0.85rem; color: var(--dark); opacity: 0.8; line-height: 1.4; }
    .modal-footer {
        display: flex;
        justify-content: center;
        padding-top: 0.8rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
    .close-btn { background: var(--download); color: white; width: 100%; max-width: 180px; }

    footer { display: none; }
}