/* ============================================================
 * v4-scene.css —— v4 实景界面（20260909 拍板稿落地）
 * ============================================================
 * 依据：design/v4-style/screens-v4.html（老板逐屏拍板通过）
 *   1. 竖版原生场景全幅铺底（7 张 AI 重绘原创图，refs/v4v → assets/scenes/v4）
 *   2. 牌匾系统：万象学宫（登录）/ 青云宗（宗门）/ 灵药铺·街市 / 铁匠铺·器殿 / 云溪客栈·宗门
 *   3. 主城减负：只留 HUD + 三店匾 + 木牌热区（心魔塔/石桥·论剑台/布告栏·仙榜）
 *   4. 九秘境：左右交错疏排胶囊（防误触，行距拉开）
 *   5. 动态：仙鹤扇翅 / 浮云漂移 / 金尘（prefers-reduced-motion 时自动关闭）
 * ============================================================ */

/* ============ 全幅竖版场景底 ============ */
.v4bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.v4bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7,13,24,.62) 0%, rgba(7,13,24,.10) 22%, rgba(7,13,24,0) 45%, rgba(7,13,24,.10) 68%, rgba(7,13,24,.80) 100%);
}

/* ============ 牌匾系统 ============ */
.v4-plaque {
  position: absolute;
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 14px;
  background: linear-gradient(180deg, #3a2410, #241505);
  border: 1.5px solid #d4a24c;
  border-radius: 8px;
  box-shadow: 0 3px 14px rgba(0,0,0,.6), 0 0 18px rgba(212,162,76,.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.v4-plaque::before,
.v4-plaque::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translateY(-50%);
  background: radial-gradient(circle at 35% 30%, #ffe9b0, #b8862e);
  border-radius: 50%;
}
.v4-plaque::before { left: 3px; }
.v4-plaque::after { right: 3px; }
.v4-plaque .p-main {
  font-family: 'Ma Shan Zheng', 'ZCOOL XiaoWei', serif;
  font-size: 15px;
  letter-spacing: 4px;
  text-indent: 4px;
  line-height: 1;
  color: #ecc472;
  text-shadow: 0 2px 4px #000;
  white-space: nowrap;
}
.v4-plaque .p-sub {
  font-family: 'Noto Serif SC', serif;
  font-size: 9px;
  letter-spacing: 2px;
  line-height: 1;
  color: #d9b26a;
  opacity: .92;
  white-space: nowrap;
}
.v4-plaque:active { transform: translateX(-50%) scale(.96); }

/* ============ 木牌热区标签（心魔塔/石桥/布告栏） ============ */
.v4-tag {
  position: absolute;
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: rgba(8,14,22,.78);
  border: 1px solid rgba(212,162,76,.45);
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.v4-tag .t-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent, #3fb6c8);
  box-shadow: 0 0 8px rgba(63,182,200,.8);
  animation: v4dot 2.2s ease-in-out infinite;
}
.v4-tag .t-txt {
  font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
  font-size: 11px;
  letter-spacing: 1px;
  color: #e8d9b0;
  white-space: nowrap;
}
.v4-tag:active { transform: translateX(-50%) scale(.95); }
@keyframes v4dot {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

/* ============ 仙鹤（SVG 内联，翅膀扇动） ============ */
.v4-crane {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  animation: v4soar 7s ease-in-out infinite;
}
.v4-crane .wing {
  transform-origin: 112px 88px;
  animation: v4flap 1.55s ease-in-out infinite;
}
.v4-crane .wing.back { animation-delay: -.12s; }
.v4-crane.flip { transform: scaleX(-1); }
@keyframes v4flap {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-34deg); }
}
@keyframes v4soar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

/* ============ 浮云 ============ */
.v4-cloud {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.16), rgba(255,255,255,0) 70%);
  filter: blur(2px);
  animation: v4drift 46s linear infinite;
}
.v4-cloud.b { animation-duration: 64s; animation-delay: -22s; }
@keyframes v4drift {
  from { transform: translateX(-16vw); }
  to { transform: translateX(116vw); }
}

/* ============ 主城：竖版市井 ============ */
.v4hub-stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
}
.v4hub-hud {
  position: relative;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px;
}
.v4hub-hud .ava {
  width: 44px; height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Ma Shan Zheng', serif;
  font-size: 20px;
  color: #f5e8c8;
  background: radial-gradient(circle at 34% 28%, #3d5a72, #15263a);
  border: 1.5px solid rgba(212,162,76,.6);
  box-shadow: 0 0 14px rgba(212,162,76,.3);
}
.v4hub-hud .who { min-width: 0; flex: 1; }
.v4hub-hud .who .nm {
  font-family: 'ZCOOL XiaoWei', serif;
  font-size: 15px;
  color: #f0e6cf;
  text-shadow: 0 1px 6px rgba(0,0,0,.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.v4hub-hud .who .rl {
  font-size: 10px;
  letter-spacing: 1px;
  color: #b8c4cc;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.v4hub-hud .res {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.v4hub-hud .chip {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px;
  color: #f5e0a8;
  padding: 2px 9px;
  border-radius: 11px;
  background: rgba(8,14,22,.72);
  border: 1px solid rgba(212,162,76,.4);
}
.v4hub-hud .chip .ic {
  font-size: 10px;
  color: #0d1a2c;
  background: #d4a24c;
  border-radius: 50%;
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ============ 九秘境：左右交错疏排胶囊 ============ */
.v4rail {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 6px 110px;
}
.v4rail-line {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  opacity: .55;
}
.v4-rn {
  position: relative;
  z-index: 1;
  width: min(72%, 300px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(7,13,24,.62);
  border: 1px solid rgba(63,182,200,.35);
  backdrop-filter: blur(3px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease, border-color .15s ease;
}
.v4-rn:nth-child(odd)  { align-self: flex-start; }
.v4-rn:nth-child(even) { align-self: flex-end; }
.v4-rn:active { transform: scale(.97); }
.v4-rn .rb {
  width: 40px; height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'ZCOOL XiaoWei', serif;
  font-size: 17px;
  color: #9cc9d4;
  background: radial-gradient(circle at 34% 28%, #33495f, #15263a);
  border: 1px solid rgba(63,182,200,.55);
  box-shadow: 0 0 10px rgba(63,182,200,.22);
  position: relative;
}
.v4-rn.done .rb { border-color: rgba(212,162,76,.75); color: #ecc472; }
.v4-rn.done .rb::after {
  content: '✓';
  position: absolute;
  right: -3px; top: -3px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #d4a24c;
  color: #0d1a2c;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
}
.v4-rn.cur .rb {
  border: 2px solid #ecc472;
  color: #f5e0a8;
  box-shadow: 0 0 18px rgba(212,162,76,.55);
}
.v4-rn.locked { opacity: .55; }
.v4-rn .rt { min-width: 0; flex: 1; }
.v4-rn .rt b {
  display: block;
  font-family: 'ZCOOL XiaoWei', serif;
  font-size: 14px;
  font-weight: 400;
  color: #eef3f6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.v4-rn .rt i {
  display: block;
  font-style: normal;
  font-size: 10px;
  color: #8fa5b0;
  margin-top: 2px;
}
.v4-rn .go {
  flex-shrink: 0;
  font-size: 11px;
  letter-spacing: 2px;
  color: #0d1a2c;
  background: linear-gradient(180deg, #f0d08a, #c9973f);
  border-radius: 12px;
  padding: 5px 12px;
  box-shadow: 0 0 12px rgba(212,162,76,.5);
}
/* 九秘境页其余卡片在竖版底图上加一层可读底 */
.page-realms .card, .page-realms .realms2-banner, .page-realms .realms2-guide,
.page-realms .realms2-pouch, .page-realms .realms2-trial {
  background: rgba(10,18,28,.82);
  backdrop-filter: blur(4px);
}

/* ============ 我的页：徽章行（后台可配·首版 5 枚） ============ */
.v4-badges {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.v4-badge {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 10px 2px 8px;
  border-radius: 12px;
  background: rgba(10,18,28,.72);
  border: 1px solid rgba(212,162,76,.45);
}
.v4-badge .b-ic { font-size: 22px; line-height: 1; }
.v4-badge .b-nm {
  margin-top: 5px;
  font-size: 10px;
  color: #eedcb0;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.v4-badge[data-locked="1"] {
  border: 1px dashed rgba(138,147,160,.5);
  filter: grayscale(1);
  opacity: .6;
}
.v4-badge[data-locked="1"] .b-nm { color: #93a0ab; }

/* ============ 心魔塔：塔顶全服排名 ============ */
.v4-rankchip {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 auto 14px;
  padding: 6px 16px;
  border-radius: 16px;
  background: rgba(8,14,22,.78);
  border: 1px solid rgba(212,162,76,.55);
  box-shadow: 0 0 16px rgba(212,162,76,.25);
  font-size: 12px;
  letter-spacing: 1px;
  color: #f5e0a8;
}
.v4-rankchip b { color: #ffd9a8; font-size: 14px; }

/* ============ 宗门/登录匾额挂点 ============ */
.v4-sect-plaque {
  position: relative;
  z-index: 2;
  width: max-content;
  margin: 6px auto 2px;
  transform: none;
  cursor: default;
  pointer-events: none;
}
/* 登录闸门竖版山门底：卡片改玻璃质感，主匾悬于卡片上方 */
#auth-gate .v4-gate-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 38%;
  background-repeat: no-repeat;
  z-index: 0;
}
#auth-gate .v4-gate-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(7,13,24,.30), rgba(7,13,24,.52) 70%, rgba(7,13,24,.78));
}
#auth-gate .auth-card {
  background: rgba(10,18,28,.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(212,162,76,.38);
  box-shadow: 0 12px 40px rgba(0,0,0,.55), 0 0 24px rgba(212,162,76,.12);
}
/* v4：veil 纯色遮罩退场，场景底图自带渐变遮罩 */
#auth-gate .auth-veil { opacity: 0; }
#auth-gate .v4-gate-plaque {
  position: absolute;
  z-index: 3;
  top: calc(env(safe-area-inset-top, 0px) + 20px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: none;
  text-shadow: 0 2px 14px rgba(0,0,0,.75);
}
#auth-gate .v4-gate-plaque .g-title {
  font-family: 'Ma Shan Zheng', 'ZCOOL XiaoWei', serif;
  font-size: 30px;
  letter-spacing: 8px;
  text-indent: 8px;
  color: #f5e8c8;
  text-shadow: 0 2px 14px rgba(0,0,0,.8), 0 0 28px rgba(212,162,76,.4);
  white-space: nowrap;
}
#auth-gate .v4-gate-plaque .g-seal {
  width: 22px; height: 22px;
  background: #a32c2c;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Ma Shan Zheng', serif;
  font-size: 13px;
  color: #f5e8c8;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}

/* ============ 动效降级 ============ */
@media (prefers-reduced-motion: reduce) {
  .v4-crane, .v4-crane .wing, .v4-cloud, .v4-tag .t-dot { animation: none !important; }
}

/* ============================================================
 * 宽屏信箱式适配（20260909b）
 * ------------------------------------------------------------
 * v4 界面为手机竖版专属设计（老板拍板）。平板/桌面宽窗口下
 * 把整个游戏收进一块居中的竖版舞台：
 *   - #app 限宽居中 → 各页热区（牌匾/木牌）坐标与画面重合
 *   - .v4bg 同宽居中 → 竖版场景不再被裁成横条
 *   - 底部导航回归并居中；隐藏旧桌面侧栏/右面板/浮动图标列
 *   - #auth-gate（body 直属）同步限宽 → 登录闸门对齐舞台
 *   - 登录卡下移，山门画 + 主匾在顶部露出（对齐拍板稿屏01）
 * 手机端（≤768px）完全不受影响。
 * ============================================================ */
/* 舞台水平位移 --v4side：桌面端为侧栏宽度（侧栏保留，舞台在其右侧区域居中）。
   注意 calc 必须写在各使用处：--v4left 若在 :root 声明，var(--v4side) 会在
   :root 上就代换成 0，body 上再改 --v4side 也不生效。 */
:root { --v4w: min(480px, calc(100vh * 0.5625)); --v4side: 0px; }
body[data-platform="desktop"] { --v4side: var(--sidebar-w, 220px); }

@media (min-width: 769px) {
  /* ---- 主内容列（20260909d）：答题页(view-level)不压缩，其余页收进舞台 ---- */
  body:not(.view-level) #app {
    max-width: var(--v4w) !important;
    margin-left: calc((100% + var(--v4side) - var(--v4w)) / 2) !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-bottom: calc(var(--nav-h, 64px) + 20px) !important;
  }

  /* ---- 桌面外壳：右面板/浮动图标列退场；左侧栏保留（desktop 原生导航）；
          平板无侧栏，用底部导航 ---- */
  .game-right-panel,
  .game-side-left,
  .game-side-right { display: none !important; }
  body[data-platform="tablet"] .game-nav-sidebar { display: none !important; }

  /* ---- 底部导航：桌面端此前被 responsive.css 的 display:none 压住 ---- */
  body[data-platform="desktop"] .game-nav-bottom {
    display: flex;
    left: calc((100% + var(--v4side) - var(--v4w)) / 2);
    right: auto;
    width: var(--v4w);
    max-width: none;
    transform: none;
  }
  body[data-platform="desktop"] .game-nav-bottom.hide { transform: translateY(100%); }
  body.view-level .game-nav-bottom { display: none; }

  /* ---- 竖版场景底：与主列同宽、同水平位置 ---- */
  .v4bg {
    left: calc((100% + var(--v4side) - var(--v4w)) / 2);
    right: auto;
    width: var(--v4w);
    transform: none;
  }

  /* ---- 登录闸门（body 直属）同步限宽 ---- */
  #auth-gate {
    left: 50%;
    right: auto;
    width: var(--v4w);
    transform: translateX(-50%);
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: calc(env(safe-area-inset-top, 0px) + 78px);
  }
  #auth-gate .auth-card { margin: 0 auto; }

  /* ---- 浮云漂移改用舞台宽度单位（vw 会漂出竖版舞台到幕布上） ---- */
  @keyframes v4drift {
    from { transform: translateX(-100px); }
    to   { transform: translateX(calc(var(--v4w) + 100px)); }
  }
}

/* ============ 全局横向溢出防护（20260909c） ============
 * 浮云/仙鹤等装饰层按舞台百分比定位，手机窄屏上会探出视口右缘
 * 产生横向滚动。游戏无横向滚动设计，body 统一裁掉。 */
body { overflow-x: hidden; }

/* ============ 装饰裁剪层（20260909c） ============
 * 浮云/仙鹤统一挂进这层，在舞台边缘裁掉，防止超出视口把
 * 移动端布局视口撑宽（此前 innerWidth 被撑到 493px+，
 * 底部导航 6 项随视口拉伸、右侧导航项跑出屏幕）。 */
.v4-decor {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}
.vhome { position: relative; }
