  :root {
    --ink: #33241F;
    --ink-2: #6B5346;
    --ink-3: #A08A7A;
    --line: #F0D9C0;
    --line-soft: #F7E8D8;
    --surface: #FFF8EC;
    --surface-2: #FFEFD8;
    --white: #FFFFFF;
    --space: #1B1630;
    --space-2: #2A2150;
    --accent: #FF8A3D;
    --accent-2: #FFD84D;
    --accent-deep: #C9622E;
    --radius: 22px;
    --shadow-1: 0 4px 12px rgba(201,98,46,.14);
    --shadow-2: 0 8px 20px rgba(255,122,46,.32);
    --font-dialog: "QSheepStory", "PingFang SC", -apple-system, "Helvetica Neue", sans-serif;
    --weight-dialog: 900;
    --dialog-font-size: clamp(20px, 6.4vw, 28px);
    --dialog-line-height: 1.42;
    --dialog-ink: #C3270F;
    --dialog-outline: #FFF7E6;
    --dialog-outline-shadow:
      -1.2px 0 0 var(--dialog-outline), 1.2px 0 0 var(--dialog-outline),
      0 -1.2px 0 var(--dialog-outline), 0 1.2px 0 var(--dialog-outline),
      -1.2px -1.2px 0 var(--dialog-outline), 1.2px -1.2px 0 var(--dialog-outline),
      -1.2px 1.2px 0 var(--dialog-outline), 1.2px 1.2px 0 var(--dialog-outline);
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; height: 100%; }
  body {
    background: #F3E2CA;
    color: var(--ink);
    font: 14px/1.5 "PingFang SC", -apple-system, "Helvetica Neue", sans-serif;
    display: flex; align-items: center; justify-content: center;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  #app {
    position: relative;
    width: min(100vw, 430px);
    height: min(100vh, 860px);       /* 旧浏览器兜底 */
    height: min(100dvh, 860px);      /* 移动端地址栏收缩时不抖动 */
    background: var(--surface);
    overflow: hidden;
  }
  .screen { position: absolute; inset: 0; display: none; flex-direction: column; }
  .screen.active { display: flex; }

  .dialog-frame {
    position: relative;
    padding: 0;
    border-radius: 0;                               /* 圆角与描边都在素材里 */
    /* 新框（20261111 补充素材）整张拉伸铺满：素材边缘的星星是不规则散布的，
     * 九宫格切片会从星星中间切断；整张 100%×100% 拉伸不产生接缝，星星保持完整 */
    /* 素材奶油内区实测内缩：左 8.13% / 右 8.40% / 上 19.95% / 下 14.21%（750×366 产物）。
     * 正文再各留一档呼吸位，取左 10.8% / 右 10.8% / 上 23% / 下 17%，
     * 与旧框的正文可用区（390 档约 280×127）基本一致，3 行容量不缩水 */
    --dlg-safe-x: 10.8%;
    --dlg-safe-t: 23%;
    --dlg-safe-b: 17%;
    background: url("./assets/game/ui/dialog-box-v2.webp") center / 100% 100% no-repeat;
  }
  .dialog-frame-inner {
    position: relative;
    z-index: 2;
    width: 100%; height: 100%;
    overflow: hidden;
  }
  /* 正文安全区：所有对话框共用同一套内边距，保证文字不压到素材边框与星星上 */
  .dialog-body {
    position: absolute;
    left: var(--dlg-safe-x); right: var(--dlg-safe-x);
    top: var(--dlg-safe-t); bottom: var(--dlg-safe-b);
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  .dialog-text {
    white-space: pre-line;
    font-family: var(--font-dialog);
    font-size: var(--dialog-font-size);
    font-weight: var(--weight-dialog);
    line-height: var(--dialog-line-height);
    color: var(--dialog-ink);
    text-shadow: var(--dialog-outline-shadow);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .dialog-avatar {
    position: absolute;
    /* 新框不再有 CSS 边框（旧写法要减 --dlg-b 才是外缘），头像按外框左上角直接定位 */
    left: 6px;
    top: -32px;
    width: clamp(56px, 16.4vw, 64px);
    height: clamp(56px, 16.4vw, 64px);
    z-index: 7;
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(40, 15, 5, .28));
  }
  .da-ufo { display: block; width: 100%; height: 100%; object-fit: contain; }
  .da-name {
    /* 「丘丘」正好压在 UFO 图标中间：以图标矩形（.da-ufo 铺满 .dialog-avatar）的
     * 中心点定位，不再挂在图标右下方当外挂标签。字号 / 描边 / 底衬保持不变 */
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    padding: 0 6px;
    border-radius: 8px;
    border: 2px solid #FFF9EC;
    background: #FFE27A;
    box-shadow: 0 0 0 2px #F0902E;
    color: #D9531E;
    font-family: var(--font-dialog);
    font-weight: var(--weight-dialog);
    font-size: 12px; line-height: 1.4;
    white-space: nowrap;
  }

  .boot {
    position: absolute; inset: 0;
    z-index: 50;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px;
    background: var(--space);
    color: #FFE9D6;
    font-size: 13px;
    letter-spacing: .04em;
    transition: opacity .28s ease, visibility .28s;
  }
  .boot.done { opacity: 0; visibility: hidden; pointer-events: none; }
  .boot-spin {
    width: 26px; height: 26px;
    border: 2px solid rgba(255,255,255,.18);
    border-top-color: #f0d089;
    border-radius: 50%;
    animation: bootSpin .9s linear infinite;
  }
  @keyframes bootSpin { to { transform: rotate(360deg); } }
  .boot .btn {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.28);
    color: #f2f2f2;
  }

  .nav-rail {
    position: absolute; left: 0; right: 0;
    top: calc(10px + env(safe-area-inset-top));
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
    z-index: 30;
    pointer-events: none;
  }
  .nav-group { display: flex; align-items: center; gap: 8px; }
  .nav-btn, .nav-pill { pointer-events: auto; }

  #screen-planet.active .nav-rail,
  #screen-home.active .nav-rail {
    animation: navSoftIn .14s ease-out;
  }
  /* 前后两页都有顶栏时（见 app.js 的 nav-continuous）位置不变，
     不再淡入，否则返回键会先消失一帧再淡回来，看起来像抖两下 */
  #app.nav-continuous .nav-rail { animation: none; }
  @keyframes navSoftIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  @media (prefers-reduced-motion: reduce) {
    #screen-planet.active .nav-rail,
    #screen-home.active .nav-rail { animation: none; }
  }

  .nav-btn {
    position: relative;
    width: 44px; height: 44px;              /* 触摸目标 ≥ 44px */
    padding: 0; border: 0;
    border-radius: 50%;
    display: inline-grid; place-items: center;
    background: rgba(74, 42, 24, .62);
    color: #FFF2DC;
    box-shadow: 0 4px 14px rgba(60, 34, 20, .2);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: transform .12s ease, background .16s ease;
  }
  .nav-btn:active { transform: scale(.92); background: rgba(74, 42, 24, .82); }
  .nav-btn:disabled { opacity: .45; cursor: default; }

  /* 右上角图鉴入口：用 MENU 贴纸素材（376:245）当按钮底图，去掉圆形底，
     按钮仍保持 ≥44px 触摸目标（72×47） */
  .nav-btn.nav-dex {
    width: 72px; height: 47px;
    border-radius: 12px;
    background: none;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .nav-btn.nav-dex:active { background: none; }
  .nav-btn.nav-dex .nav-dex-art { width: 100%; height: 100%; object-fit: contain; }

  .nav-pill {
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(74, 42, 24, .62);
    color: #FFF2DC;
    font-size: 12px; font-weight: 600;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  #screen-home .nav-btn, #screen-pen .nav-btn {
    background: rgba(255, 246, 226, .92);
    color: #5A3524;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  }
  #screen-home .nav-btn:active, #screen-pen .nav-btn:active {
    background: #FFEFD5;
  }
  #screen-home .nav-pill, #screen-pen .nav-pill {
    background: rgba(255, 246, 226, .92);
    color: #5A3524;
  }

  .btn {
    border: 0;
    background: rgba(255, 246, 226, .92);
    color: var(--ink);
    border-radius: 999px;
    padding: 10px 14px;
    min-height: 44px;                 /* 触摸目标 ≥ 44px */
    display: inline-flex; align-items: center;
    font-size: 13px;
    box-shadow: var(--shadow-1);
    cursor: pointer;
  }
  .btn:active { background: var(--surface-2); box-shadow: none; }
  .btn:disabled { opacity: .45; box-shadow: none; cursor: default; }

