/* ============================================================
   css/h5.css —— 手机 / Pad（H5）自适应补丁
   说明：本文件在所有页面原有样式之后加载，
        只在小屏媒体查询内覆盖，PC 端样式保持原样。
   ============================================================ */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button, a, .stone-circle, .level-card, .option-btn { touch-action: manipulation; }

/* 地图页：横向滑动由脚本接管翻页，避免浏览器原生惯性滚动抢手势 */
.map-viewport, .map-viewport .level-card { touch-action: pan-y; }

/* ============================================================
   ① 首页 index.html
   ============================================================ */
@media (max-width: 900px) {
  .page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(68px + env(safe-area-inset-top)) 14px calc(26px + env(safe-area-inset-bottom));
    justify-content: flex-start;
  }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 560px; }
  .card { padding: 18px 10px 16px; border-radius: 18px; }
  .card-icon { width: 56px; height: 56px; margin-bottom: 10px; }
  .card-name { font-size: 18px; }
  .card-desc { font-size: 11.5px; margin-bottom: 10px; }
  .card-tag { font-size: 10.5px; padding: 3px 9px; }
  .top-actions {
    top: calc(8px + env(safe-area-inset-top));
    right: 8px;
    gap: 6px;
  }
  .action-btn { padding: 6px 10px; font-size: 12px; gap: 4px; }
  .action-btn .ab-text { display: none; }
  .action-btn .ab-icon { font-size: 17px; }
  .ab-badge { min-width: 20px; font-size: 11px; padding: 1px 6px; }
}

@media (max-width: 420px) {
  .grid { gap: 9px; }
  .card { padding: 14px 8px 13px; }
  .card-icon { width: 46px; height: 46px; }
  .card-icon .card-emoji { font-size: 22px; }
  .card-name { font-size: 16px; letter-spacing: 1px; }
  .card-desc { font-size: 10.5px; }
}

/* 平板（竖向）时首页保持三列，更饱满 */
@media (min-width: 700px) and (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; max-width: 100%; }
}

/* ============================================================
   ② 地图页 map0 ~ map5
   ============================================================ */
@media (max-width: 900px) {
  .header { padding: calc(8px + env(safe-area-inset-top)) 10px 8px; align-items: flex-start; }
  .header-left { gap: 6px; min-width: 0; }
  .header-left h1 {
    font-size: 15px; letter-spacing: 1px;
    max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .header-right { gap: 6px; font-size: 12px; }
  .header-right span { padding: 3px 9px; background: rgba(0, 0, 0, .35); border-radius: 999px; }
  .home-btn { padding: 6px 10px; font-size: 12px; }

  .nav-btn {
    width: 58px; height: 58px; font-size: 36px;
    border-width: 2.5px;
    border-radius: 50%;
  }
  .nav-btn.left { left: 6px; }
  .nav-btn.right { right: 6px; }

  .level-card {
    max-width: 60vw;
    padding: 7px 14px;
    border-radius: 12px;
  }
  .level-card .lv-name { font-size: clamp(14px, 4.4vw, 21px); letter-spacing: 1.5px; }
  .level-card::after { display: none; }

  .wukong-indicator {
    bottom: calc(74px + env(safe-area-inset-bottom));
    font-size: 13px;
    padding: 4px 12px;
  }
  .wukong-indicator .monkey { font-size: 19px; }

  /* 游客提示条不要挡住大王/翻页按钮 */
  .xy-auth-bar {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    justify-content: space-between;
    font-size: 11px;
    padding: 6px 10px;
  }
  .xy-auth-bar > span {
    max-width: 54vw;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .xy-auth-bar a { padding: 4px 10px; font-size: 11px; }
}

@media (max-width: 420px) {
  .header-left h1 { display: none; }
  .level-card .lv-name { font-size: 13.5px; letter-spacing: 1px; }
}

/* ============================================================
   ③ 学习页 learn.html
   ============================================================ */
@media (max-width: 900px) {
  /* 学习页铺满视口：抵掉 ⑤ 中给登录/积分等页面设置的 body 内边距 */
  body:has(.stone-path-container) { padding: 0; }

  .stone-path-container {
    height: 100vh;
    height: 100dvh;
    padding: calc(8px + env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
  }

  /* 游客登录提示条固定在底部，有它时给容器留出高度，避免压住翻页按钮 */
  body.has-auth-bar .stone-path-container {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .stone-top-bar {
    padding: 6px 10px;
    gap: 6px;
    border-radius: 14px;
    margin-bottom: 8px;
  }
  .stone-top-bar .bar-left { width: 100%; gap: 6px; }
  .stone-top-bar .level-title {
    font-size: clamp(15px, 4.4vw, 20px);
    white-space: normal;
  }
  .stone-top-bar .back-btn { font-size: 12px; padding: 5px 12px; }
  .stone-top-bar .bar-right {
    width: 100%;
    gap: 6px;
    justify-content: space-between;
  }
  .stat-badge { font-size: 12px; padding: 3px 10px; }
  .star-score { padding: 3px 10px; font-size: 13px; gap: 4px; }
  .star-score .star-icon { font-size: 15px; }
  .star-score .star-title { display: none; }
  .title-badge { font-size: 12.5px; padding: 3px 11px; }
  .challenge-btn { font-size: 12px; padding: 5px 12px; }

  /* 手机上去掉两侧人物，给石阶让位 */
  .character-wukong, .character-yeye { display: none; }

  .stone-path-area {
    transform: none;
    /* 用 flex-start + 石阶 margin-top:auto 让内容贴底，内容超高时仍可从顶部滚动 */
    justify-content: flex-start;
    padding-bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .stone-path {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 6px;
    padding: 8px 2px 12px;
    justify-items: center;
    align-content: end;
    border-radius: 0;
    margin-top: auto;
  }
  .stone-wrapper { transform: none !important; }
  .stone-circle { width: clamp(58px, 17vw, 92px); height: clamp(58px, 17vw, 92px); }
  .stone-circle .char { font-size: clamp(23px, 7vw, 36px); }
  .stone-circle .check-mark { font-size: clamp(13px, 3.6vw, 20px); }
  .hand-indicator { font-size: 18px; margin-bottom: -3px; }

  .path-controls {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 14px;
    margin-top: 8px;
    flex-shrink: 0;
  }
  .page-btn { flex: 1; font-size: 13px; padding: 10px 6px; }
}

/* 平板：6 个石阶一排，更像原版石阶路 */
@media (min-width: 600px) and (max-width: 900px) {
  .stone-path { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 8px; }
  .stone-circle { width: clamp(64px, 11vw, 96px); height: clamp(64px, 11vw, 96px); }
}

/* 手机横屏高度很矮时再压缩一点 */
@media (max-width: 900px) and (max-height: 460px) {
  .stone-top-bar .bar-right { justify-content: flex-start; }
  .stone-circle { width: clamp(42px, 9vh, 62px); height: clamp(42px, 9vh, 62px); }
  .stone-circle .char { font-size: clamp(18px, 4.6vh, 26px); }
  .stone-path { gap: 8px 6px; }
  .page-btn { padding: 6px; font-size: 12px; }
}

/* 字词详情：手机上做成底部抽屉 */
@media (max-width: 768px) {
  .detail-overlay { padding: 0; align-items: flex-end; }
  .detail-card {
    max-width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 26px 26px 0 0;
    padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .detail-close { top: 8px; right: 12px; font-size: 30px; }
  .detail-char-display { gap: 12px; margin-bottom: 10px; }
  .detail-char-big { font-size: 58px; min-width: 50px; }
  .detail-meta { padding: 10px 14px; border-radius: 18px; min-width: 0; }
  .detail-meta .pinyin { font-size: clamp(20px, 5.6vw, 28px); }
  .detail-meta .sub { font-size: 12px; }
  .detail-groups { gap: 6px; }
  .detail-groups .tag { font-size: 14px; padding: 5px 12px; }
  .detail-sentence { font-size: 16px; padding: 10px 12px; }
  .detail-content-text { max-height: 44vh; max-height: 44dvh; font-size: 15px; line-height: 1.9; padding: 12px 14px; }
  .trace-section { padding: 12px; border-radius: 16px; }
  .trace-canvas-wrap { padding: 8px; min-height: 170px; }
  .trace-canvas-wrap #trace-target { width: 165px; height: 165px; }
  .trace-canvas-wrap #trace-target svg { width: 165px !important; height: 165px !important; }
  .trace-btns { gap: 8px; }
  .trace-btns .trace-btn { flex: 1 1 auto; padding: 9px 10px; font-size: 13px; }
  .speaker-btn { width: 40px; height: 40px; font-size: 20px; }

  .celebration-card {
    width: 88%;
    padding: 26px 18px 30px;
    border-radius: 30px;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
  }
  .celebration-title { font-size: 30px; }
  .celebration-sub { font-size: 17px; }
  .upgrade-card {
    max-width: 96%;
    padding: 22px 16px 26px;
    max-height: 92vh;
    max-height: 92dvh;
  }
  .upgrade-title { font-size: 22px; }
}

/* ---- 全屏故事（手机 / Pad）----
   注意：learn.html 内的故事样式在本文件之后以内联方式加载，
   因此统一用双 ID（#storyFullScreen + 元素 ID）提高优先级来覆盖 */
@media (max-width: 900px) {
  #storyFullScreen { cursor: default; }

  #storyFullScreen #storyWordCard {
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
    padding: 10px 14px;
    border-radius: 16px;
    min-width: 84px;
    border-width: 1.5px;
  }
  #storyFullScreen #storyWordCard .char { font-size: clamp(30px, 10vw, 44px); }
  #storyFullScreen #storyWordCard .pinyin { font-size: clamp(14px, 4.4vw, 19px); }
  #storyFullScreen #storyWordCard .sub { font-size: 11px; }

  /* 故事字幕：手机上缩小字号、放宽行距，避免一屏只装几行 */
  #storyFullScreen #storySubtitle {
    bottom: calc(94px + env(safe-area-inset-bottom));
    width: 92%;
    padding: 0 6px;
    font-size: clamp(15px, 4.6vw, 20px);
    line-height: 1.8;
    text-shadow: 0 0 8px rgba(0,0,0,.9), 0 2px 3px #000, 0 -2px 3px #000, 2px 0 3px #000, -2px 0 3px #000;
  }

  #storyFullScreen #storyControls {
    left: 10px;
    right: 10px;
    bottom: calc(6px + env(safe-area-inset-bottom));
    flex-direction: row;
    gap: 8px;
    padding: 8px;
    border-radius: 16px;
  }
  #storyFullScreen #storyControls .fs-btn { flex: 1; width: auto; padding: 11px 8px; font-size: 14px; }

  #storyFullScreen #storyQuiz {
    width: calc(100% - 28px);
    max-width: 440px;
    padding: 20px 14px 22px;
    border-radius: 22px;
    border-width: 2px;
  }
  #storyFullScreen #storyQuiz .quiz-char { font-size: clamp(38px, 11vw, 52px); margin-bottom: 6px; }
  #storyFullScreen #storyQuiz .quiz-title { font-size: 13.5px; margin-bottom: 12px; line-height: 1.6; }
  #storyFullScreen #storyQuiz .quiz-option {
    font-size: clamp(15px, 4.4vw, 19px);
    padding: 8px 14px;
    margin: 3px;
    min-width: 56px;
  }
  #storyFullScreen #storyQuiz .feedback { font-size: 17px; margin-top: 8px; min-height: 26px; }
}

/* ============================================================
   ④ 闯关挑战 challenge.html
   ============================================================ */
@media (max-width: 900px) {
  .top-bar { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 8px; }
  .back-btn { padding: 6px 12px; font-size: 13px; border-radius: 16px; }
  .game-title { font-size: 16px; }
  .stat-pill { padding: 4px 10px; font-size: 12.5px; }
  .lives { font-size: 18px; gap: 3px; }
  .level-info { padding: 10px 12px; font-size: 13px; }
  .game-area { margin: 12px auto 34px; padding: 0 12px; }

  .start-screen { padding: 22px 4px; }
  .start-screen h1 { font-size: clamp(24px, 7vw, 34px); margin-bottom: 12px; }
  .start-screen p { font-size: 13px; line-height: 1.7; margin-bottom: 22px; }
  .mode-select { gap: 12px; }
  .mode-card { width: 100%; max-width: 340px; padding: 16px; border-radius: 16px; }
  .mode-card .mode-icon { font-size: 34px; margin-bottom: 8px; }
  .mode-card .mode-name { font-size: 18px; }
  .mode-card .mode-desc { font-size: 12.5px; }

  .progress-section { gap: 8px; margin-bottom: 14px; }
  .progress-text { font-size: 14px; min-width: 46px; }
  .question-card { padding: 20px 14px; border-radius: 18px; margin-bottom: 18px; }
  .question-type { font-size: 12.5px; padding: 3px 12px; margin-bottom: 10px; }
  .question-char { font-size: 44px; margin: 12px 0; }
  .question-prompt { font-size: 16px; line-height: 1.9; }
  .question-sub { font-size: 13px; margin: 6px 0 12px; }
  .options-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
  .option-btn { font-size: 18px; padding: 14px; border-radius: 12px; min-height: 52px; }

  .fill-area { padding: 14px 10px; margin: 14px 0; border-radius: 12px; }
  .fill-line { font-size: 17px; line-height: 2.3; }
  .fill-line .blank-input { font-size: 17px; min-width: 56px; padding: 3px 8px; }
  .fill-btn { flex: 1 1 auto; padding: 11px 14px; font-size: 15px; }
  .fill-feedback { padding: 12px 14px; }
  .fill-feedback .fb-content { font-size: 16px; line-height: 1.8; }

  .essay-area textarea { font-size: 16px; padding: 10px 12px; min-height: 130px; }
  .essay-feedback { padding: 14px; }
  .essay-feedback .content { font-size: 16px; }
  .essay-feedback .tips { font-size: 13px; }
  .essay-btn { padding: 11px 20px; font-size: 16px; }

  .result-box { padding: 26px 18px; width: calc(100% - 32px); max-height: 92vh; max-height: 92dvh; overflow-y: auto; }
  .result-emoji { font-size: 54px; margin-bottom: 8px; }
  .result-box h2 { font-size: 26px; }
  .result-score { font-size: 34px; margin: 10px 0; }
  .result-stars { font-size: 30px; margin: 10px 0; }
  .result-btns { gap: 10px; margin-top: 18px; }
  .game-btn { flex: 1 1 100%; padding: 12px 16px; font-size: 16px; }
  .combo-text { font-size: 36px; }
}

/* ============================================================
   ⑤ 登录 / 积分 / 夺宝 / 个人主页
   ============================================================ */
@media (max-width: 600px) {
  body { padding: 16px 12px calc(24px + env(safe-area-inset-bottom)); }
  .brand-icon { font-size: 42px; }
  .brand h1 { font-size: 26px; }
  .card { padding: 20px 16px; }
  .tabs { gap: 6px; }
  .tab { font-size: 13px; padding: 9px 6px; }
  label.field input { font-size: 16px; padding: 11px 12px; }
  label.field span { font-size: 12.5px; }
  .code-btn { padding: 0 10px; font-size: 12px; }
  .submit { padding: 13px; font-size: 16px; }

  .points-card, .section, .machine, .container, .header { max-width: 100%; }
  .points-num { font-size: 42px; }
  .points-card { padding: 20px 16px; }
  .section { padding: 16px 14px; border-radius: 14px; }
  .machine { padding: 22px 14px; border-width: 3px; }
  .machine h1 { font-size: 24px; }
  .machine p { font-size: 13px; margin-bottom: 20px; }
  .prize-pool { gap: 8px; margin-bottom: 22px; }
  .prize-item { font-size: 12px; padding: 12px 4px; }
  .prize-item .icon { font-size: 20px; }
  .draw-btn { padding: 14px; font-size: 16px; }
  .result-box { width: 82%; padding: 26px 18px; }

  .user-card { padding: 18px 14px; gap: 14px; }
  .avatar { width: 58px; height: 58px; font-size: 30px; }
  .user-info h2 { font-size: 19px; }
  .stats-grid { gap: 8px; }
  .stat-item { padding: 14px 6px; }
  .stat-val { font-size: 21px; }
  .stat-label { font-size: 12px; }
  .ad-banner { height: 96px; }
  .section-title { padding: 14px; font-size: 15px; }
  .list-item { padding: 14px; }
  .li-label { font-size: 14px; }
  .li-value { font-size: 13px; }
}

/* ============================================================
   ⑥ 登录后出现的“游客提示条”通用兜底
   ============================================================ */
@media (max-width: 600px) {
  .xy-auth-mask { padding: 14px; }
  .xy-auth-card { padding: 22px 18px; }
}

/* ============================================================
   ⑦ 手机 / Pad 横屏适配（横屏时宽度常 >900，上面按宽度的移动端规则失效，
      这里按「横屏 + 视口高度矮」统一收口，保证石阶、字号、弹框在横屏也舒适）
   ============================================================ */
@media (orientation: landscape) and (max-height: 540px) and (max-width: 1180px) {

  /* ---- 学习页 · 顶栏 ---- */
  .stone-path-container {
    padding: calc(4px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right))
             calc(4px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  }
  /* 底部有游客登录提示条时，给翻组按钮留出空间，避免被压住 */
  body.has-auth-bar .stone-path-container {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
  .stone-top-bar {
    padding: 4px 10px;
    margin-bottom: 4px;
    border-radius: 12px;
    gap: 4px 8px;
  }
  .stone-top-bar .bar-left { width: auto; gap: 8px; }
  .stone-top-bar .bar-right { width: auto; gap: 6px; justify-content: flex-end; }
  .stone-top-bar .level-title { font-size: clamp(14px, 3.4vh, 19px); white-space: nowrap; }
  .stone-top-bar .back-btn { font-size: clamp(11px, 2.4vh, 14px); padding: 3px 10px; }
  .stat-badge,
  .title-badge,
  .challenge-btn,
  .star-score { font-size: clamp(11px, 2.4vh, 14px); padding: 3px 9px; }
  .star-score .star-icon { font-size: clamp(12px, 2.6vh, 16px); }

  /* ---- 学习页 · 石阶：单行 6 列居中，取消错落与上移，避免与翻组按钮重叠 ---- */
  .stone-path-area {
    transform: none;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0;
  }
  .stone-path {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px 8px;
    padding: 0 4px;
    justify-items: center;
    align-content: center;
    border-radius: 0;
    margin: auto 0;
  }
  .stone-wrapper { transform: none !important; }
  .stone-circle {
    width: clamp(50px, 15vh, 72px);
    height: clamp(50px, 15vh, 72px);
    box-shadow: 0 4px 0 #b0a69a, 0 8px 16px rgba(0,0,0,0.35);
  }
  .stone-circle .char { font-size: clamp(22px, 6.4vh, 32px); }
  .stone-circle .check-mark { font-size: clamp(11px, 3vh, 16px); top: -1px; right: -1px; }
  .hand-indicator { font-size: clamp(12px, 3.4vh, 18px); margin-bottom: -2px; }
  .character-wukong, .character-yeye { display: none; }

  .path-controls {
    margin-top: 4px;
    padding: 3px 12px;
    gap: 10px;
    justify-content: center;
    width: fit-content;
    max-width: 92%;
    margin-left: auto;
    margin-right: auto;
    border-radius: 60px;
    background: rgba(20, 12, 40, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-top: none;
  }
  .page-btn {
    flex: 0 0 auto;
    font-size: clamp(12px, 2.8vh, 15px);
    padding: 4px 18px;
    color: #f6c445;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(246, 196, 69, 0.45);
  }

  /* ---- 全屏故事 · 卡片 / 字幕 / 控件 ---- */
  #storyFullScreen #storyWordCard {
    top: 8px;
    left: 10px;
    padding: 6px 12px;
    border-radius: 14px;
    min-width: 0;
    border-width: 1.5px;
  }
  #storyFullScreen #storyWordCard .char { font-size: clamp(28px, 9vh, 42px); }
  #storyFullScreen #storyWordCard .pinyin { font-size: clamp(13px, 4.2vh, 19px); margin-bottom: 0; }
  #storyFullScreen #storyWordCard .sub { display: none; }

  #storyFullScreen #storySubtitle {
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: calc(100% - 24px);
    max-width: 860px;
    padding: 0 4px;
    font-size: clamp(16px, 4.6vh, 26px);
    line-height: 1.45;
  }

  /* 控件移到右上角，给底部字幕腾出整行空间 */
  #storyFullScreen #storyControls {
    top: calc(8px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    flex-direction: row;
    gap: 6px;
    padding: 5px 6px;
    border-radius: 14px;
  }
  #storyFullScreen #storyControls .fs-btn {
    flex: none;
    width: auto;
    padding: 6px 12px;
    font-size: clamp(12px, 2.6vh, 14px);
  }

  #storyFullScreen #storyQuiz {
    width: auto;
    max-width: min(560px, 90vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 14px 18px 16px;
    border-radius: 20px;
  }
  #storyFullScreen #storyQuiz .quiz-char { font-size: clamp(30px, 9vh, 46px); margin-bottom: 4px; }
  #storyFullScreen #storyQuiz .quiz-title { font-size: clamp(12px, 2.8vh, 15px); margin-bottom: 8px; }
  #storyFullScreen #storyQuiz .quiz-option {
    font-size: clamp(14px, 3.4vh, 18px);
    padding: 6px 12px;
    min-width: 52px;
  }

  /* ---- 字词详情（弹框）与描红：横屏改为「左画布右按钮」的紧凑布局 ---- */
  .detail-overlay { padding: 0; align-items: flex-end; }
  /* 底部有游客登录提示条时，把抽屉整体抬起，避免按钮被压住 */
  body.has-auth-bar .detail-overlay {
    padding-bottom: calc(50px + env(safe-area-inset-bottom));
  }
  .detail-card {
    max-width: min(94vw, 920px);
    max-height: 96vh;
    max-height: 96dvh;
    margin: 0 auto;
    padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
  .detail-close { top: 4px; right: 10px; font-size: 26px; }
  .detail-char-display { gap: 10px; margin-bottom: 6px; }
  .detail-char-big { font-size: clamp(38px, 12vh, 58px); min-width: 0; }
  .detail-meta { padding: 6px 12px; border-radius: 14px; }
  .detail-meta .pinyin { font-size: clamp(16px, 4.6vh, 22px); }
  .detail-meta .sub { font-size: 12px; gap: 6px; }
  .detail-groups { gap: 6px; margin: 6px 0; }
  .detail-groups .tag { font-size: 12px; padding: 3px 10px; }
  .detail-sentence { font-size: 13px; padding: 6px 10px; border-radius: 0 14px 14px 0; margin: 6px 0 8px; }

  /* 横屏：左侧 1/3 放字 / 读音 / 组词 / 句子，右侧放描红与操作按钮 */
  .detail-word-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 12px;
    align-items: stretch;
  }
  .detail-info-col,
  .detail-trace-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .detail-info-col .detail-char-display { margin-bottom: 6px; }
  .detail-info-col .detail-sentence { margin: 0; }
  .detail-content-text {
    max-height: 22vh;
    font-size: 13px;
    line-height: 1.65;
    padding: 8px 10px;
  }
  .trace-section {
    margin: 0;
    padding: 6px;
    border-radius: 14px;
    text-align: center;
  }
  .trace-section .trace-title { display: none; }
  /* 描红：白板放大居中，完成/笔顺/描红/重置 四个按钮在右侧竖排 */
  .detail-trace-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 1.6vw, 16px);
  }
  .trace-canvas-wrap {
    flex: 0 0 auto;
    padding: 4px;
    border-radius: 10px;
    min-height: 0;
  }
  .trace-canvas-wrap #trace-target {
    width: min(58vh, 250px);
    height: min(58vh, 250px);
  }
  .trace-canvas-wrap #trace-target svg { width: 100% !important; height: 100% !important; }
  .detail-trace-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: clamp(112px, 32%, 142px);
  }
  .detail-trace-actions .trace-btns {
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
    gap: 6px;
    margin-top: 0;
  }
  .detail-trace-actions .trace-btn {
    width: 100%;
    padding: 6px 8px;
    font-size: clamp(11px, 2.6vh, 13px);
    white-space: nowrap;
  }
  .detail-trace-actions .detail-actions {
    order: -1;
    margin-top: 0 !important;
  }
  .detail-trace-actions .detail-actions .action-btn {
    width: 100% !important;
    padding: 7px 8px !important;
    font-size: clamp(11px, 2.4vh, 13px) !important;
    line-height: 1.25;
    white-space: normal;
  }
  .detail-actions { margin-top: 8px !important; }
  .detail-actions .action-btn { font-size: 13px; padding: 8px 14px; }

  /* ---- 庆祝 / 升级弹框 ---- */
  .celebration-card {
    width: min(560px, 88vw);
    max-height: 96vh;
    max-height: 96dvh;
    overflow-y: auto;
    padding: 14px 20px 16px;
    border-radius: 24px;
  }
  .celebration-emoji-big { font-size: clamp(30px, 9vh, 44px); }
  .celebration-title { font-size: clamp(22px, 6vh, 30px); margin: 2px 0; }
  .celebration-sub { font-size: clamp(13px, 3.2vh, 16px); margin: 2px 0 6px; }
  .celebration-stars-display { font-size: clamp(18px, 5vh, 26px); margin: 2px 0 6px; }
  .celebration-score-text { font-size: 14px; padding: 4px 12px; margin: 4px 0 8px; }
  .celebration-btn { font-size: clamp(14px, 3.4vh, 17px); padding: 8px 28px; }
  .upgrade-card {
    max-width: min(760px, 94vw);
    max-height: 96vh;
    max-height: 96dvh;
    padding: 14px 18px 18px;
    border-radius: 24px;
  }
  .upgrade-title { font-size: 20px; margin-bottom: 10px; }
  .upgrade-stats-summary { padding: 6px 12px; margin-bottom: 8px; font-size: 13px; }
  .level-list { gap: 4px; margin: 6px 0 10px; }
  .level-item { padding: 5px 10px; font-size: 13px; }
  .level-item .left .emoji { font-size: 18px; }
}

/* 竖屏手机：详情弹框底部预留游客提示条高度，避免操作按钮被压住 */
@media (max-width: 900px) {
  body.has-auth-bar .detail-overlay {
    padding-bottom: calc(54px + env(safe-area-inset-bottom));
  }
  body.has-auth-bar .detail-card {
    max-height: calc(96dvh - 54px);
  }
}
