/* ==========================================================================
   mobile.css · 移动端适配层（全站共用）
   HsscjxgtOS Version 2.1.0(37)
   规则：只做 ≤900px / ≤640px / ≤400px 的覆盖，不改桌面端表现
   ========================================================================== */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, svg, canvas, video, iframe {
    max-width: 100%;
}

@media (hover: none) {
    /* 触屏去掉悬停才出现的效果，避免第一次点按无效 */
    * { -webkit-tap-highlight-color: transparent; }
}

/* ==========================================================================
   一、通用：正文排版、列表、表格、按钮、弹层
   ========================================================================== */
@media (max-width: 900px) {
    body { overflow-wrap: break-word; }
    h1, h2, h3, h4 { word-break: break-word; }
    table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    pre, code { word-break: break-word; }
    pre { overflow-x: auto; }

    button, .back-btn, .nav-btn, .submit-btn, .hex-btn, .btn {
        min-height: 40px;
    }

    /* 通用弹层：不留 20px 空白，避免小屏挤压 */
    .modal, .dlg, .lockLayer, #chLockOverlay, #volLockOverlay {
        padding: 12px !important;
    }
    .modal-box, .dlg-box, .lock-box, .ch-lock-box {
        width: min(100%, 480px) !important;
        max-width: 100% !important;
        max-height: 86vh;
        overflow-y: auto;
        padding: 22px 18px !important;
    }
}

/* ==========================================================================
   二、桌面系统首页 index.html
   ========================================================================== */
@media (max-width: 900px) {
    /* 图标改为可拖动的绝对布局（index.html 内置样式），这里只做尺寸微调 */
    .desk-icon {
        padding: 6px 2px;
    }
    .desk-icon .cap {
        width: auto !important;
        max-width: 100%;
        font-size: 12px;
        line-height: 1.3;
        letter-spacing: 0;
        white-space: normal !important;
        word-break: break-all;
        text-align: center;
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    .desk-icon .cube { transform: scale(.86); }

    #desktopClock { display: none !important; }

    /* 任务栏：横向可滚动，任务项只留图标 */
    #taskbar {
        height: 54px;
        padding: 0 2px;
        gap: 2px;
        display: flex !important;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #taskbar::-webkit-scrollbar { display: none; }
    #trayIcons { display: none !important; }
    #tray {
        flex: 0 0 auto;
        margin-left: auto;
        gap: 0;
    }
    #trayClock {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 2px 2px;
    }
    #trayClock .tm { font-size: 11.5px !important; }
    #trayClock .td { font-size: 9.5px !important; }
    #trayPower { flex: 0 0 auto; width: 24px !important; height: 24px !important; }
    #trayPower svg { width: 12px !important; height: 12px !important; }
    #taskbar .tb-item, #taskbar .tb-app {
        flex: 0 0 auto;
        height: 40px;
        min-width: 32px;
        max-width: 120px;
        padding: 0 3px;
    }
    #taskbar .tb-item svg, #taskbar .tb-app svg { width: 18px; height: 18px; }
    #taskbar .tb-item .t-name,
    #taskbar .tb-app .t-name { display: none; }
    #startBtn { flex: 0 0 auto; }

    /* 开始菜单：全宽抽屉 */
    #startMenu {
        left: 8px !important;
        right: 8px;
        bottom: 62px !important;
        width: auto !important;
        transform: none !important;
        max-height: 68vh;
        overflow-y: auto;
        border-radius: 10px;
    }
    .sm-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 2px; }
    .sm-grid .sm-item { min-height: 62px; }
    .sm-grid .sm-item .sm-name { font-size: 11.5px; }

    /* 窗口：整屏铺满（JS 会写 inline left/top/width/height，用 !important 压住） */
    .window {
        left: 0 !important;
        top: 0 !important;
        width: 100vw !important;
        height: calc(100% - 54px) !important;
        max-width: none !important;
        max-height: none !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    .window .rz { display: none !important; }
    .window.minimized { display: none !important; }
    .window .titlebar { height: 42px !important; padding: 0 8px !important; }
    .window .titlebar .t-name { font-size: 13px !important; }
    .window .tb-btn { min-height: 32px; min-width: 32px; }
    #recoverWindow.floating, #recoverWindow.floating .frame-wrap { inset: 0 !important; }

    /* 用户设置 / 锁屏 */
    #userSetup .cfg-box, .cfg-box {
        width: min(94vw, 420px) !important;
        padding: 20px 16px !important;
    }
    #userSetup input, .cfg-box input { font-size: 16px; }
    .lock-box { width: min(92vw, 360px) !important; }
    .desk-ctx { max-width: 220px; font-size: 13px; }

    /* 开机 / 关机 / 安装 / 开机终端 */
    #powerHint {
        font-size: 12px !important;
        letter-spacing: 1.5px !important;
        max-width: 84vw;
        line-height: 1.7 !important;
        white-space: normal !important;
        text-align: center;
        padding: 0 8px;
    }
    .power-btn { width: 82px !important; height: 82px !important; }
    .setup-card {
        width: min(92vw, 420px) !important;
        padding: 22px 16px !important;
    }
    .setup-title { font-size: 20px !important; }
    .setup-brand, .setup-sub { letter-spacing: 2px !important; font-size: 11.5px !important; }
    #bootScroll { width: calc(100vw - 24px) !important; height: 62vh !important; }
    #bootLogo { font-size: 30px !important; letter-spacing: 5px !important; }
    #bootSub { font-size: 11.5px !important; letter-spacing: 2px !important; }
    #bootTip { font-size: 11px !important; letter-spacing: 1px !important; text-align: center; }
    #bootText, .be-line { font-size: 11.5px !important; line-height: 1.7 !important; letter-spacing: 0 !important; }
}

/* ==========================================================================
   三、章节正文（chapter/*.html，共用 chapter.css）
   ========================================================================== */
@media (max-width: 640px) {
    body { padding: 12px 8px !important; }
    .chapter-container {
        padding: 18px 14px !important;
        border-width: 1px !important;
        border-radius: 4px;
        background-size: 28px 28px;
    }
    .chapter-title {
        font-size: 22px !important;
        letter-spacing: 1px !important;
        line-height: 1.35 !important;
        padding-bottom: 8px;
        margin-bottom: 10px;
    }
    .chapter-date {
        font-size: 13.5px !important;
        letter-spacing: 1px !important;
        margin-bottom: 18px !important;
    }
    .chapter-content {
        font-size: 17px !important;
        line-height: 30px !important;
        margin-bottom: 7px;
        text-indent: 2em;
        text-align: justify;
    }
    .chapter-mark {
        font-size: 15px !important;
        line-height: 24px !important;
        margin: 12px 0 !important;
    }
    .chapter-note { font-size: 13px; }
    .chapter-copyright {
        margin-top: 28px;
        font-size: 13px;
        padding-top: 12px;
        line-height: 1.7;
    }

    /* 导航：三个按钮换行，不再横向挤出屏幕 */
    .chapter-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin: 20px 0 6px;
    }
    .chapter-nav .nav-btn {
        flex: 1 1 42%;
        padding: 10px 14px !important;
        font-size: 14.5px !important;
        letter-spacing: .5px !important;
        min-height: 42px;
    }
    .chapter-nav .quiz-btn { flex: 1 1 100%; margin: 0; }
    .back-btn {
        padding: 10px 20px !important;
        font-size: 15px !important;
        margin: 22px auto 4px;
        min-height: 42px;
    }

    /* 第24章的电子屏 / 各类板式块：不横向溢出 */
    .ch24-board, .chapter-board {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 12px !important;
        padding: 10px !important;
    }
    .bgm-dock { top: 8px; right: 8px; }
    .bgm-hint { display: none !important; }
}

@media (max-width: 400px) {
    .chapter-content { font-size: 16.5px !important; line-height: 29px !important; }
    .chapter-title { font-size: 20px !important; }
    .chapter-container { padding: 16px 12px !important; }
    .chapter-nav .nav-btn { flex: 1 1 100%; }
}

/* 手机横屏矮屏 */
@media (orientation: landscape) and (max-height: 520px) {
    body { padding: 10px 14px !important; }
    .chapter-container { max-width: 100% !important; padding: 14px 18px !important; }
    .chapter-content { font-size: 16.5px !important; line-height: 28px !important; }
    .chapter-nav { margin: 14px 0 4px; }
    .chapter-nav .nav-btn, .back-btn { padding: 8px 16px !important; font-size: 14px !important; min-height: 38px; }
}

/* ==========================================================================
   四、视觉小说 放映厅（App/visual novel game/）
   放映厅已内置双端响应式样式（style.css 自带断点），此处不再叠加覆盖
   ========================================================================== */

/* ==========================================================================
   五、档案 / 文件管理 / 时间线 / 资源 / 恢复 / 终端 / 答题 / 人物卡
   ========================================================================== */
@media (max-width: 900px) {
    /* 通用容器宽度收敛 */
    .wrap, .page, .container, .content, .rc-main, .rc-layout, .q-card, .quiz-wrap {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 640px) {
    /* 面包屑、工具栏：横向可滚，不换行撑破 */
    .crumb, .cfg-bar, .rc-head, .qh-row, .quiz-head, .pv-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        white-space: nowrap;
        scrollbar-width: none;
    }
    .crumb::-webkit-scrollbar, .rc-head::-webkit-scrollbar { display: none; }

    /* 文件列表：行内文字允许截断，不撑宽 */
    .filelist, .lh-row, .file {
        min-width: 0;
    }
    .f-name, .lh-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .lh-size, .f-size, .lh-date, .f-date { flex: 0 0 auto; font-size: 11px; }
    .list-head { gap: 8px !important; font-size: 11.5px !important; }
    .icon-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)) !important; gap: 8px !important; }
    .desk-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)) !important; }
    .modal-btns, .dlg-btns, .btn-group { flex-wrap: wrap; gap: 8px; }
    .modal-btns button, .dlg-btns button { flex: 1 1 40%; }

    /* 时间线：节点行纵向压实，横向留出滚动余量 */
    .tl-body { padding: 16px 10px 28px !important; }
    .timeline { padding-left: 18px !important; }
    .nrow { gap: 8px !important; padding: 10px 10px !important; flex-wrap: wrap; }
    .nm { font-size: 13.5px; }
    .seg, .arc-hd { font-size: 12.5px; }
    .legend { flex-wrap: wrap; gap: 6px; font-size: 11.5px; }
    .summary { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
    .nfields { grid-template-columns: 1fr 1fr !important; }

    /* 资源库预览 */
    .pv-frame, .preview { height: 46vh !important; }
    .pv-url { font-size: 11px; }
    .item .t { font-size: 14.5px; }
    .item .desc { font-size: 12.5px; }

    /* 恢复页：两栏变单栏 */
    .rc-layout { display: block !important; }
    .rc-side { display: none !important; }
    .rc-main { padding: 16px 14px !important; }
    .rc-title, .repair-title, .reboot-title { font-size: 22px !important; }

    /* 终端 */
    body { font-size: 13.5px; }
    .p { font-size: 13px !important; line-height: 1.75 !important; word-break: break-word; }

    /* 答题关卡 */
    .quiz-wrap { padding: 14px 12px !important; }
    .qh-kicker { letter-spacing: .8px !important; white-space: normal !important; font-size: 11px !important; word-break: break-word; }
    .qh-title { font-size: 20px !important; }
    .q-card { padding: 14px 12px !important; }
    .question-title { font-size: 15.5px !important; line-height: 1.6; }
    .opt { padding: 11px 12px !important; font-size: 14px !important; }
    .options { gap: 8px !important; }
    .submit-btn, .quiz-foot button { width: 100%; font-size: 15px; }

    /* 人物档案：版式已由 character.css 自带响应式接管，此处不再覆盖 */
    .unlock-actions button { width: 100%; }
    .secret-input { width: 100% !important; font-size: 16px; } /* 16px 防 iOS 自动缩放 */
}

@media (max-width: 400px) {
    .summary { grid-template-columns: repeat(2, 1fr) !important; }
}

/* 所有输入框：手机上 16px 起，避免聚焦时页面自动放大 */
@media (max-width: 900px) {
    input[type="text"], input[type="password"], input[type="search"], input[type="number"], textarea, select {
        font-size: 16px !important;
    }
}

/* =========================================================
   章节「阅读模式选择」小屏堆叠
   ========================================================= */
@media (max-width: 640px) {
    .ms-cards { grid-template-columns: 1fr !important; gap: 10px !important; }
    .ms-card, .ms-card.video { grid-column: auto !important; width: 100% !important; }
    .ms-panel { padding: 18px 14px !important; }
    .ms-title { font-size: 26px !important; letter-spacing: 2px !important; }
    .ms-kicker { letter-spacing: 3px !important; font-size: 10px !important; }
    .ms-card .mc-desc, .ms-card.video .mc-desc { font-size: 12px !important; line-height: 1.6 !important; }
    .ms-card .mc-name, .ms-card.video .mc-name { font-size: 15px !important; letter-spacing: 1.2px !important; }
    .ms-foot { font-size: 11px !important; }
}
/* =========================================================
   资源管理器类页面：底部状态栏小屏压缩
   ========================================================= */
@media (max-width: 640px) {
    .statusbar {
        height: auto !important;
        min-height: 26px;
        gap: 8px !important;
        padding: 3px 8px !important;
        font-size: 10.5px !important;
    }
    .statusbar > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .statusbar .sb-note { font-size: 10px !important; margin-left: auto; max-width: 42%; }
}
/* =========================================================
   时间线页：筛选按钮组换行、统计卡压缩
   ========================================================= */
@media (max-width: 640px) {
    .tl-ctl { display: flex; flex-direction: column; gap: 8px; }
    .seg { display: flex !important; flex-wrap: wrap; width: 100%; border-radius: 6px; }
    .seg button {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        font-size: 12px !important;
        letter-spacing: 0 !important;
        padding: 8px 4px !important;
    }
    .summary { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
    .sum { padding: 10px 12px !important; }
    .sum b { font-size: 19px !important; }
    .sum span { font-size: 11.5px !important; letter-spacing: 0 !important; }
}
/* =========================================================
   答题页（problems/quiz.html）头部重排
   ========================================================= */
@media (max-width: 640px) {
    .qh-row { display: block !important; }
    .qh-title { font-size: 19px !important; line-height: 1.35; }
    .qh-kicker {
        margin-top: 5px;
        font-size: 9px !important;
        letter-spacing: .5px !important;
        white-space: normal !important;
        word-break: break-word;
    }
    .qh-sub { font-size: 13px !important; line-height: 1.75 !important; word-break: break-word; white-space: normal !important; }
    .qh-meta { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px 12px !important; }
    .qh-meta span { font-size: 11.5px !important; letter-spacing: 0 !important; }
    .qh-meta b { font-size: 13px !important; }
}
/* =========================================================
   长文滚动性能：视口外段落跳过渲染
   ========================================================= */
@media (max-width: 900px) {
    body { background-attachment: scroll !important; }
    .chapter-content p,
    p.chapter-content,
    .chapter-note,
    .chapter-copyright {
        content-visibility: auto;
        contain-intrinsic-size: auto 140px;
    }
    .chapter-container { background-attachment: scroll; }
}