/* ============================================================
   mobile.css —— 手机端适配层
   最后加载，只做「覆盖」，不改设计语言：像素直角、硬阴影、
   同一个调色板，全部保留。
   治的是手机上特有的四类毛病：
   ① 手指点不准（点击区小于 44px）
   ② 刘海 / 底部小横条压住内容（安全区）
   ③ iOS 点输入框整页被放大（字号 < 16px）
   ④ 从屏幕边缘滑会触发浏览器刷新 / 返回手势
   ============================================================ */

/* ---------------- 0. 触摸基建 ---------------- */

html {
  /* iOS 横屏时不许自作主张放大正文 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.yuyu-pet { position:fixed;z-index:80;width:68px;height:88px;padding:0;border:0;background:transparent;color:#2f365f;cursor:grab;touch-action:none;user-select:none;display:flex;flex-direction:column;align-items:center;justify-content:center;filter:drop-shadow(2px 3px 0 #2f365f33); }
.yuyu-pet svg { width:64px;height:64px;pointer-events:none;image-rendering:pixelated; }
.yuyu-pet.dragging { cursor:grabbing;filter:drop-shadow(4px 6px 0 #2f365f33); }
.yuyu-pet:focus-visible { outline:2px dashed #76619b;outline-offset:3px; }
.yuyu-dialog.ovl { z-index:75;background:#2f365f12;backdrop-filter:none;display:block;animation:none;padding:0; }
.yuyu-bubble { position:fixed;width:min(286px,calc(100vw - 24px));max-height:calc(100dvh - 28px);overflow:auto;box-sizing:border-box;background:#faf7ee;border:2px solid #2f365f;box-shadow:4px 4px 0 #2f365f;padding:14px;color:#2f365f;font-size:13px;line-height:1.8; }
.yuyu-bubble header,.yuyu-bubble footer { display:flex;align-items:center;justify-content:space-between;gap:8px; }
.yuyu-bubble header b { font-size:13px;color:#76619b; }
.yuyu-close { width:36px;height:36px;border:0;background:transparent;color:inherit;font-size:24px;cursor:pointer; }
.yuyu-words { margin:6px 0 14px;min-height:72px; }
.yuyu-topic { font-size:10px;color:#6b6d78; }
.yuyu-next { border:2px solid #2f365f;padding:7px 10px;background:#b8f4d2;color:#2f365f;min-height:40px;cursor:pointer;font:inherit;font-size:12px; }
.yuyu-bubble details { border-top:1px dashed #cbc6b9;margin-top:12px;padding-top:6px;font-size:10px;color:#6b6d78; }
.yuyu-bubble summary { cursor:pointer; }
.yuyu-bubble details a,.yuyu-bubble details small { display:block;color:inherit; }

/* Keep navigation and utility controls on one row without a duplicate brand bar. */
#pg-home .hall-nav { align-items: stretch; gap: 8px; }
#pg-home .hall-tab { padding: 8px 6px; min-width: 0; letter-spacing: 1px; }
#pg-home .mast-tools { gap: 6px; flex-shrink: 0; }
#pg-home .mast-tools .iconb { width: 40px; min-width: 40px; height: 44px; }

/* Readable counters against the firefly game's night background. */
#pg-game[data-game=firefly] .ff-status .chip { background: #3b435d !important; color: #fff2bc; border-color: #81899f !important; }
#pg-game[data-game=firefly] .ff-msg b { color: inherit; }

/* The illustration and its message are the reward, so keep them visible on phones. */
#bbEndScene { display: block; width: min(220px, 100%); }
#bbEndScene figcaption { font-size: 12px; line-height: 1.7; padding: 9px; }
.sheet-win .win-title { font-size: 22px; letter-spacing: 2px; line-height: 1.5; }
.sheet-win .sheet-btns { gap: 8px; }
@media (max-width: 380px) {
  .sheet-win .sheet-btns .btn { padding: 9px 10px; font-size: 13px; }
  #bbEndScene { width: min(180px, 100%); }
}

/* 手指点过的方框，是手机浏览器加的，和像素风冲突 */
* { -webkit-tap-highlight-color: transparent; }

/* 手机上没有 hover，把「抬起来」的反馈留给 :active */
@media (hover: none) {
  .gcard:hover, .bb-node:hover, .ticket:hover, .chip-tab:hover, .gcard-new:hover {
    transform: none; box-shadow: var(--sh-hard);
  }
  .bb-q-av { opacity: 1; }
}

/* 点哪儿都立刻响应：干掉双击缩放的等待窗口 */
button, [role="button"], a, input, label,
.hall-tab, .ticket, .chip-tab, .linkb, .iconb, .mini-btn, .gcard-new, .diffseg button {
  touch-action: manipulation;
}

/* 游戏里要连着快点、要拖，选中高亮和长按菜单只会碍事 */
#pg-game .gbar,
#pg-game .gmeta,
#pg-game .grules,
#pg-game .gbody,
#pg-game .gtools,
.bb-hud, .bb-map, .games-grid, .cat-chips {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* 该能选的地方还是要能选（真要抄点什么的时候） */
#gBody input, #gBody textarea, #qAll, .tip-body, .win-line, .cf-txt, .dossier-table {
  -webkit-user-select: text;
  user-select: text;
}

/* 整页在 .page 里内部滚动：滑到头不要「传染」给浏览器变成下拉刷新 */
.page { overscroll-behavior-y: contain; }

/* ---------------- 1. iOS 输入框：字号必须 >= 16px ---------------- */
/* 低于 16px 时，Safari 会在聚焦那一刻把整页放大，退出后不会还原——
   搜个游戏而已，不该付出「页面歪掉」的代价。 */
@media (max-width: 700px) {
  #qAll,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  textarea,
  select {
    font-size: 16px;
  }
  /* 放大后搜索框本身也要跟着长高，否则字挤在 24px 的框里 */
  .search-wrap { padding: 6px 12px; }
  #qAll { min-height: 30px; }
}

/* ---------------- 2. 安全区：给刘海和底部小横条让位 ---------------- */
.home-inner,
.all-inner,
.game-shell {
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
.home-inner,
.all-inner { padding-bottom: max(46px, calc(env(safe-area-inset-bottom) + 34px)); }
.game-shell { padding-bottom: max(44px, calc(env(safe-area-inset-bottom) + 32px)); }

/* 顶部：存到手机桌面后用独立窗口打开时，内容会跑到状态栏底下 */
.home-inner,
.all-inner { padding-top: max(18px, calc(env(safe-area-inset-top) + 10px)); }
.game-shell { padding-top: max(14px, calc(env(safe-area-inset-top) + 8px)); }

/* 弹层四周留出安全区，卡片才不会被圆角切掉 */
.ovl {
  padding: max(14px, env(safe-area-inset-top))
           max(14px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom))
           max(14px, env(safe-area-inset-left));
}
/* 结算卡底部那两个按钮是钉在底边的，正好落在小横条上 */
.sheet-win .sheet-btns { padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); }
.toast { bottom: max(26px, calc(env(safe-area-inset-bottom) + 14px)); }

/* ---------------- 3. 手指点击区：够不到 44px 的都补上 ----------------
   判定条件用「粗指针 或 窄视口」，不只用 hover:none——
   因为个别手机/平板笔会把 pointer 报成 fine，那时 hover:none 是假的，
   点击区补丁会一声不响地失效。窄视口这条兜底。 */
@media (pointer: coarse), (max-width: 700px) {
  /* 返回 / 暂停 / 音效 / 设置这类小图标按钮，最容易被点歪 */
  .iconb {
    min-width: 44px; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  /* 难度三选一：整局最常点的一排 */
  .diffseg button { min-height: 44px; padding: 11px 16px; font-size: 13.5px; }
  /* 规则问号不需要 44，但 22px 实在太小；顺带把整行拉高 */
  .grules { align-items: center; }
  .grules .q { width: 34px; height: 34px; font-size: 15px; flex: none; }

  /* 任务清单的分类标签：这是那一页的主导航，按 44 给 */
  .chip-tab { min-height: 44px; display: inline-flex; align-items: center; padding: 9px 15px; }
  /* 卡片右下角「换新题」：次级操作，但之前只有 51x25，抬到 36 */
  .gcard-new { min-height: 36px; padding: 8px 14px; font-size: 12px; }
  .mini-btn { min-height: 44px; padding: 10px 15px; }

  /* 页脚、暂停面板里的次级按钮 */
  .linkb { min-height: 40px; padding: 10px 10px; display: inline-flex; align-items: center; }
  .sheet-btns .btn, .gtools .btn { min-height: 44px; padding: 12px 18px; }
  .setrow { padding: 15px 2px; }
  .setrow input { width: 54px; height: 32px; }
  .setrow input::after { width: 24px; height: 24px; top: 2px; left: 2px; }
  .setrow input:checked::after { left: 26px !important; }
}

/* ---------------- 4. 窄屏排版：320–400px 的收口 ---------------- */
@media (max-width: 400px) {
  /* 「Lv.1 Yuyu鱼 · 今天也有点累」在 320px 上会拆成两行，干脆让它体面地拆 */
  .bb-hud-name { flex-wrap: wrap; gap: 4px 7px; font-size: 14px; line-height: 1.35; }
  .bb-hud-name i { flex-basis: 100%; font-size: 11.5px; }
  .bb-hud { padding: 11px 12px; }
  .bb-hud-r { min-width: 64px; }
  .bb-hud-r svg { width: 56px; height: auto; }
  .bb-bar { grid-template-columns: 50px 1fr 32px; gap: 6px; }

  /* 章节标题：副标题 <small> 挤在一起就换行 */
  .bb-h { flex-wrap: wrap; gap: 6px 9px; font-size: 14.5px; }
  .bb-h small { font-size: 11px; }

  .bb-q-name { font-size: 14.5px; }
  .ticket { padding: 13px 12px 11px; }
  .tick-main { font-size: 15px; }
  .sheet { padding: 18px 16px; }
  .win-title { font-size: 22px; letter-spacing: 4px; }
  .ws { min-width: 78px; padding: 7px 12px; }
}

/* ---------------- 5. 横屏 / 矮视口：主视觉别把内容顶下去 ---------------- */
@media (max-height: 560px) and (orientation: landscape) {
  .bb-scene-img { max-height: 30vh; }
  .bb-scene { margin: 10px 0 4px; }
  .home-inner, .all-inner { padding-top: 12px; }
  .bb-hud-name { margin-bottom: 6px; }
  .sheet { max-height: 94vh; }
  .sheet-win .bb-done-scene { max-width: 200px; }
}

/* 大屏手机横过来时，主视觉按 1:1 会超过一屏，直接裁掉不撑高 */
@media (orientation: landscape) and (max-width: 900px) {
  .bb-scene-img { aspect-ratio: 16 / 10; }
}

/* ---------------- 6. 触屏没有 hover：把小世界 / 抽屉的"展开"说清楚 ---------------- */
@media (hover: none) {
  .bb-node:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--bb-night); }
  .gcard:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--bb-night); }
}

/* 休息版：首屏开玩，保留原有像素与插画语言。 */
.rest-hero{display:grid;grid-template-columns:1.15fr 1fr;gap:28px;align-items:center;padding:24px 0}.rest-eyebrow{font-size:12px;letter-spacing:2px;color:#69755d}.rest-copy h1{font-size:36px;line-height:1.5;margin:14px 0;color:#2f365f}.rest-copy h1 em{font-style:normal;color:#76619b}.rest-copy p{line-height:1.9;color:#676775;font-size:14px}.rest-primary{display:flex;justify-content:space-between;align-items:center;width:100%;padding:18px 20px;background:#d9e995;border:2px solid #2f365f;box-shadow:4px 4px 0 #2f365f;color:#2f365f;font-weight:800;font-size:18px;cursor:pointer;margin:22px 0 14px}.rest-secondary,.rest-library{border:0;background:none;color:#63527f;min-height:44px;cursor:pointer;font:inherit}.rest-secondary{font-size:13px}.rest-library{display:block;margin:18px auto 32px;text-decoration:underline;font-size:13px}.rest-hero .bb-scene{margin:0;min-width:0}.rest-card-icon{font-size:28px;display:block;margin-bottom:12px}.rest-card-desc{font-size:13px;line-height:1.8;display:block;margin:12px 0 20px;min-height:46px;color:#666879}.gcard{min-height:210px;text-align:left}.gcard .bb-q-foot{font-size:12px;display:flex;justify-content:space-between;gap:8px}.gcard .gcard-new{display:inline-flex;align-items:center;min-height:36px}.bb-q-name{line-height:1.5}.rest-primary:focus-visible,.rest-secondary:focus-visible,.rest-library:focus-visible{outline:3px solid #9b72d6;outline-offset:5px}#pg-game[data-game=fit] .gbody{background:#fbefd8;border-radius:24px;border:3px double #bd9460;padding:12px}#pg-game[data-game=pipes] .gbody{background:#eef5df;border-radius:20px;padding:12px}#pg-game[data-game=firefly] .gbody{background:#272e49;border-radius:20px;padding:16px;color:#f2ebc9}#pg-game[data-game=firefly] .ff-msg{color:#f2ebc9}#pg-game[data-game=firefly] .ff-cell{background:#3b435d}#pg-game[data-game=firefly] .ff-cell.fire{background:#f0c24c;box-shadow:0 0 20px #f0c24c88}.bb-gains{font-size:14px}
@media(max-width:600px){.rest-hero{grid-template-columns:1fr;gap:16px;padding:12px 0}.rest-copy h1{font-size:27px;margin:10px 0}.rest-copy p{margin:8px 0}.rest-primary{margin-top:16px}.rest-hero .bb-scene{max-height:180px;overflow:hidden}.rest-hero .bb-scene img{width:100%;height:160px;object-fit:cover}.rest-hero .bb-scene figcaption{display:none}.rest-copy{text-align:left}.rest-secondary{width:100%}.gcard{min-height:190px}#pg-game[data-game=fit] .gbody,#pg-game[data-game=pipes] .gbody{padding:4px}.gbar-r{gap:4px}}

/* Yuyu鱼：一眼识别，一步开玩。 */
.gcard{position:relative;min-height:190px!important;padding:20px!important;box-shadow:3px 3px 0 #2f365f!important;border-width:2px!important;display:flex;flex-direction:column;align-items:flex-start;gap:0;cursor:pointer;width:100%;font:inherit}.gcard::after{display:none!important}.gcard .rest-card-icon{width:56px;height:56px;display:flex;align-items:center;justify-content:center;margin:0 0 14px;background:#e9ecd7;border-radius:12px;color:#2f365f}.rest-card-icon svg{width:46px;height:46px}.gcard .bb-q-name{font-size:18px!important;margin:0!important}.gcard .rest-card-desc{margin:10px 0 0;min-height:0;font-size:13px;line-height:1.65;color:#696c7d}.continue-note{font-size:11px;margin-top:12px;color:#76619b}.game-mark{display:flex;flex-shrink:0;width:36px;height:36px;color:#2f365f}.game-mark svg{width:100%;height:100%}#gTag,#bbSill,#bbCorner,#bbDesk,#bbPal,#gExtraWrap,#gTime{display:none!important}.gbar{gap:8px}.gbar-t{min-width:0}.gbar-t h1{font-size:18px!important}.gbar-r{margin-left:auto}.grules{display:flex!important;flex-wrap:nowrap!important;align-items:center;gap:8px}.grules .ru{flex:1;min-width:0;border:0!important;background:transparent!important;padding:0!important;font-size:13px!important;line-height:1.6!important}.grules .q{flex-shrink:0}.gtools{margin-top:16px}#bbEndState,#bbGains,#winLine,.win-stats .ws:last-child{display:none!important}.win-stats{grid-template-columns:repeat(2,1fr)!important}.gcard:focus-visible{outline:3px solid #9b72d6;outline-offset:4px}
@media(max-width:600px){.games-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:12px!important}.gcard{padding:14px!important;min-height:180px!important}.gcard .bb-q-name{font-size:16px!important}.gcard .rest-card-icon{width:48px;height:48px;margin-bottom:12px}.rest-card-icon svg{width:40px;height:40px}.game-mark{width:30px;height:30px}.gbar-t h1{font-size:16px!important}.gbar{gap:5px}}
