/**
 * play.html 运行时样式层（叠加在 ui.css 基座之上；ui.css 与线框稿同源生成，勿直接改）
 *
 * 职责：全屏化（去手机边框/页边距/connbar）、HUD 徽标簇、手牌横滑、
 * 点选态（tapable/picked/focused）、focusbar/sheet 运行时覆写、大厅/日志/toast。
 */

/* ---------- 全屏化：吃满手机竖屏，桌面端居中限宽 ---------- */
/* 设计令牌（体验测试一般1）：--font 基座 ui.css 未定义，这里补齐全局字体栈 */
:root { --font: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
html, body { margin: 0; padding: 0; background: var(--bg); font-family: var(--font); }
body { padding: 0; } /* 覆盖 ui.css 的 22px 12px 70px */
#stage { display: flex; justify-content: center; align-items: stretch; padding: 0; min-height: 100dvh; }
#stage .phone {
  position: relative; margin: 0; width: 100%; max-width: 480px;
  border: 0; border-radius: 0; box-shadow: none;
}
#stage .screen { height: 100dvh; max-height: 100dvh; } /* 覆盖 clamp(664px,…,844px) 小屏下限 */
/* 顶部为 HUD 让位；zone 收紧（原 padding-top:12px 是给调试标签留的） */
#stage .screen > .zone:first-child { padding-top: 20px; }
#stage .zone { padding-top: 2px; padding-bottom: 2px; }
#stage .zone--grow { padding-top: 4px; }
#stage .sidecol--prize { padding-top: 6px; padding-bottom: 6px; }

/* ---------- HUD 徽标簇（原 connbar 整合进棋盘右上角） ----------
   体验测试 L4：按钮过小（35×18px）且 ghost 对比度 4.2:1 低于 AA —— 加大触控目标、提升对比 */
.hud {
  position: absolute; top: max(3px, env(safe-area-inset-top)); right: 6px; z-index: 70;
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 9px 3px 7px; font-size: 10.5px; color: var(--sub);
  max-width: 72%; white-space: nowrap; overflow: hidden;
}
.hud b { color: var(--ink); font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.hud .dot { width: 7px; height: 7px; border-radius: 50%; background: #c8cdd6; flex: none; }
.hud .dot--on { background: #3f9e5a; } .hud .dot--wait { background: #d9973f; } .hud .dot--off { background: #c0563f; }
.hud .room { font-family: ui-monospace, Menlo, monospace; font-size: 10px; cursor: pointer; }
.hud .hbtn {
  flex: none; cursor: pointer; border: 1.5px solid var(--tap); color: var(--tapink); background: #fff;
  border-radius: 999px; padding: 4px 10px; font-size: 11px; line-height: 1.15; font-weight: 700;
  min-height: 40px; display: inline-flex; align-items: center; /* 体验测试严重8：触控目标 ≥40px（宽度不变增高） */
}
.hud .hbtn:active { background: var(--tapbg); transform: scale(.95); }
.hud .hbtn--ghost { border-color: #7d8492; color: #4d525c; background: #f2f3f6; } /* ≥6.5:1 */
.hud .hbtn[hidden] { display: none; }

/* ---------- 手牌横滑（覆盖 ui.css 的 overflow:hidden） ---------- */
.handrow {
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y;
  scroll-behavior: smooth; padding-top: 8px; /* 给选中卡上浮/角标留空间 */
}
.handrow::-webkit-scrollbar { display: none; }

/* ---------- 点选态：静态高亮替代 box-shadow 脉冲（合成器友好） ---------- */
[data-inst].tapable { cursor: pointer; position: relative; }
[data-inst].tapable::after {
  content: ''; position: absolute; inset: -2px; border: 2px solid #4a86d6; border-radius: 10px;
  pointer-events: none; box-shadow: 0 0 0 3px rgba(74, 134, 214, .18);
}
/* 可打出/可选常亮；不可交互的卡降饱和 + 灰罩（体验测试严重4：不可用状态必须一眼可辨） */
.handrow .hcard:not(.tapable) {
  filter: grayscale(.7) brightness(.92); position: relative;
}
.handrow .hcard:not(.tapable)::after {
  content: ''; position: absolute; inset: 0; border-radius: 10px;
  background: rgba(226, 229, 235, .45); pointer-events: none;
}
/* 选中态（体验测试严重5）：[data-inst].picked 与搜索浮层 .pcard.picked 统一命中
   （.pcard 无 data-inst，旧选择器永不命中）；绿描边 + ✓ 角标 + 抬升 */
[data-inst].picked, .pcard.picked { outline: 4px solid #3f9e5a; outline-offset: 1px; border-radius: 10px; }
[data-inst].picked, .pcard.picked { position: relative; transform: translateY(-4px); }
[data-inst].picked::before, .pcard.picked::before {
  content: '✓'; position: absolute; top: -9px; right: -7px; z-index: 5; width: 20px; height: 20px;
  border-radius: 50%; background: #3f9e5a; color: #fff; font-size: 13px; line-height: 20px; text-align: center;
  box-shadow: 0 1px 4px rgba(23, 25, 33, .3);
}
/* focus 态：选中卡突出变大（两段式点选第一拍）。
   层级表（自下而上）：普通卡 auto < focused 8 < dimlayer 10 < sheet 20 < focusbar 40
   < dimlayer--detail 50 < sheet.detail 60 < HUD 70 < logbackdrop 75 < logpanel 80 < toast 90。
   严重7：focused 曾为 30 盖住 sheet(20)，现降到 8（仍高于相邻普通卡，抬升遮挡保留） */
[data-inst].focused { z-index: 8; }
[data-inst].focused .hcard, [data-inst].focused .mon-card {
  transform: translateY(-6px) scale(1.06); box-shadow: 0 8px 18px rgba(23, 25, 33, .28);
  border-color: var(--tapink);
}

/* target-pick / 撤退候选：目标宝可梦绿色光圈（比 tapable 描边更醒目） */
[data-inst].targetglow { cursor: pointer; position: relative; }
[data-inst].targetglow .mon-card {
  border-color: #3f9e5a; box-shadow: 0 0 0 4px rgba(63, 158, 90, .3);
}
[data-inst].targetglow::before {
  content: '▾'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  z-index: 6; color: #3f9e5a; font-size: 13px; font-weight: 700;
}

/* 手牌堆叠：×N 角标（core handRowOf 输出）与多选已选计数 */
.hcard .stackn {
  position: absolute; bottom: 3px; right: 4px; z-index: 4; background: #2b2f38; color: #fff;
  font-size: 9px; font-weight: 700; border-radius: 6px; padding: 0 4px; line-height: 13px;
}
.hcard .seln {
  position: absolute; bottom: 3px; left: 4px; z-index: 4; background: #3f9e5a; color: #fff;
  font-size: 9px; font-weight: 700; border-radius: 6px; padding: 0 4px; line-height: 13px;
}

/* 手牌区上缘 mini 确认条（弃牌/起手放怪内联作答） */
.inlinebar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 3px 4px; background: #fff; border-bottom: 1px dashed var(--line);
}
.inlinebar .ib-title { font-size: 10px; color: var(--sub); flex: 1 1 auto; }
.inlinebar .ib-acts { display: flex; gap: 6px; align-items: center; }
.inlinebar .ib-acts .btn { cursor: pointer; }

/* 全量动作面板的返回出口（showAll 死胡同修复） */
.backrow { padding: 4px 2px 0; }
.backrow .btn { cursor: pointer; }

/* ---------- 技能常驻区（P-06 重构：招式槽替代攻击▸/撤退按钮） ---------- */
.quick { max-width: 104px; gap: 3px; }
/* 非回合阶段占位（core quickOf 输出空壳）：保持列宽防布局跳动，隐藏内容防误导 */
.quick--idle { visibility: hidden; min-width: 104px; }
.quick .qside { display: flex; flex-direction: column; gap: 3px; }
.quick .qside .btn { padding: 6px 4px; font-size: 10px; min-height: 40px; } /* 严重8：宽度不变增高 */
.moveslot {
  position: relative; border: 1.5px solid var(--tap); border-radius: 7px; background: #fff;
  padding: 5px 4px 4px; cursor: pointer; min-width: 78px; min-height: 44px; /* 严重8：招式槽主操作入口 */
}
.moveslot:not(.moveslot--dis):hover { background: var(--tapbg); }
.moveslot--dis { border-color: var(--line); cursor: default; opacity: .55; }
.moveslot .mv-name {
  display: block; font-size: 9px; font-weight: 700; color: var(--ink); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 72px;
}
.moveslot .mv-cost { display: flex; gap: 1px; margin-top: 1px; }
.moveslot .mv-cost .nrg { width: 10px; height: 10px; font-size: 6.5px; border-width: 1px; }
.moveslot .mv-dmg {
  position: absolute; top: 1px; right: 3px; font-size: 9.5px; font-weight: 800; color: #c0563f;
}

/* ---------- 搜索浮层（牌库/弃牌区选择：合并同类项 + 牌库 tab） ---------- */
.picker { display: flex; flex-direction: column; max-height: 74dvh; }
.picker .pickerbody {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 2px; max-height: 44dvh;
  align-content: flex-start;
}
.picker .pickerbody .hcard { width: 74px; height: 94px; cursor: pointer; }
.picker .pickerbody .hcard.picked { outline-offset: 2px; }
.pcard--ro { cursor: default; }
.pickertabs { display: flex; gap: 6px; padding: 4px 2px 0; }
.pickertab {
  cursor: pointer; font-size: 10.5px; color: var(--sub); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px; background: #fff; min-height: 36px; /* 严重8：仅标签非主入口，36 即可 */
  display: inline-flex; align-items: center;
}
.pickertab--on { color: #fff; background: var(--tap); border-color: var(--tap); font-weight: 700; }

/* ---------- 主阶提示条（占 bottom sheet 位；Phase 3 后多为提示语） ---------- */
/* 一般7：定高 + 目标按钮横滚——首拍只局部高亮，不再推挤手牌行（原 0→~108px 抖动） */
.focusbar {
  position: sticky; bottom: 0; z-index: 40; margin: 6px -6px -6px; padding: 8px 12px; background: #fff;
  border-top: 2px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -4px 14px rgba(0, 0, 0, .08);
  min-height: 76px; box-sizing: border-box;
}
.focusbar .fb-title { font-size: 11px; color: var(--sub); margin-bottom: 6px; }
.focusbar .fb-acts { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.focusbar .fb-acts::-webkit-scrollbar { display: none; }
.focusbar .fb-acts .btn { cursor: pointer; min-height: 40px; flex: none; display: inline-flex; align-items: center; }

/* ---------- sheet 运行时覆写 ---------- */
.sheet .btn--ghost { display: none; } /* 隐藏静态演示钮（悔一步/分支） */
.sheet .optrow > * { cursor: pointer; }
.sheet .btn--dis { cursor: default; }

/* ---------- 大厅：卡组选择 ---------- */
.lobby { padding: 18px 16px; }
.lobby h2 { font-size: 16px; margin: 0 0 4px; }
.lobby p { font-size: 12px; color: var(--sub); margin: 0 0 14px; }
.deckbtn {
  display: block; width: 100%; text-align: left; margin-bottom: 10px; padding: 14px 16px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink);
  font-family: inherit;
}
.deckbtn small { display: block; font-weight: 400; font-size: 11px; color: var(--sub); margin-top: 3px; }
.deckbtn:hover { border-color: #4a86d6; background: #f5f8fd; }

/* ---------- 侧边资源条可点项（弃牌/丢失区查看，data-zone 由 core 输出） ---------- */
.reschip--btn { cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; } /* 严重8 */
.reschip--btn:active { transform: scale(.94); }

/* ---------- 大厅/终局通用占位态 ---------- */
.placeholder { padding: 40px 20px; text-align: center; color: var(--sub); font-size: 13px; line-height: 2; }
.placeholder .btn { cursor: pointer; margin: 8px 6px 0; padding: 9px 16px; font-size: 12.5px; }

/* ---------- 首页入口（v1 好友双人对战：创建/加入房间；大厅大字房间码） ---------- */
.home { padding: 34px 20px 18px; max-width: 400px; margin: 0 auto; }
.home h2 { font-size: 18px; margin: 0 0 6px; text-align: center; }
.home .note { font-size: 12.5px; color: var(--sub); margin: 0 0 18px; line-height: 1.8; text-align: center; }
.homerow { display: flex; gap: 10px; margin-bottom: 10px; }
.homerow--col { flex-direction: column; }
.btn--big { flex: 1; text-align: center; padding: 16px 12px; font-size: 15px; font-weight: 600; cursor: pointer; }
.roominput {
  display: block; width: 100%; box-sizing: border-box; margin: 2px 0 14px; padding: 14px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
  font-size: 24px; font-weight: 600; letter-spacing: 10px; text-indent: 10px; text-align: center;
  font-family: inherit; transition: border-color .15s;
}
.roominput:focus { outline: none; border-color: var(--tap); }
.roomcode {
  font-size: 34px; font-weight: 700; letter-spacing: 10px; text-align: center; cursor: pointer;
  margin: 6px 0 10px; color: var(--ink); user-select: all; border-radius: 10px; padding: 4px 0 4px 10px;
}
.roomcode:hover { background: var(--tapbg); }

/* ---------- 日志抽屉（严重6：模态化——backdrop 阻断背后点击；关闭钮 44px 热区） ---------- */
#logbackdrop {
  position: fixed; inset: 0; z-index: 75; background: rgba(23, 25, 33, .35);
  display: none;
}
#logbackdrop.open { display: block; }
#logpanel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 86vw); z-index: 80; background: #fff;
  border-left: 1px solid var(--line); box-shadow: -6px 0 18px rgba(0, 0, 0, .08); display: none; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
#logpanel.open { display: flex; }
#logpanel header { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; }
#logpanel header .grow { flex: 1; }
#logpanel header button {
  border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--sub);
  width: 44px; height: 44px; margin: -6px -8px -6px 0; /* 严重8：44px 热区，视觉不变 */
}
#loglines {
  flex: 1; overflow-y: auto; padding: 10px 14px; font-size: 11.5px; line-height: 1.8; color: #3c414b;
  font-family: ui-monospace, Menlo, monospace; word-break: break-all;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
#loglines .ln { border-bottom: 1px dashed #eef0f4; padding: 2px 0; }
#loglines .ln--ev { color: #8a7340; }

/* ---------- 卡牌详情浮窗（长按/右键看卡面；查看旁路，压过 focus 卡与 focusbar） ---------- */
/* 长按期间禁系统选择/呼出菜单（iOS 长按放大镜、安卓图文菜单）——仅棋盘内，浮层文本仍可选 */
#stage .screen { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.dimlayer--detail { z-index: 50; }
.sheet.detail { z-index: 60; }
.sheet.detail .dbody {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  max-height: 66dvh; padding: 2px 2px 4px;
}
/* 卡图：成功加载时盖在自绘卡面上（onerror 移除后露出卡面，双保险） */
.dimg {
  position: relative; width: min(62vw, 252px); aspect-ratio: 63 / 88;
  margin: 6px auto 2px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(160deg, #f6f1e6, #eae2d2); border: 1px solid var(--line);
}
.dimg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dface { padding: 10px 10px 8px; min-height: 100%; box-sizing: border-box; }
.df-name { font-size: 14px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.dftag {
  font-style: normal; font-size: 9px; font-weight: 700; color: #fff; background: #c0563f;
  border-radius: 4px; padding: 0 4px; line-height: 14px;
}
.df-line { font-size: 11px; color: #4d525c; margin-top: 4px; }
.df-line--sub { color: var(--sub); }
.df-ability {
  margin-top: 5px; font-size: 11px; line-height: 1.55; color: #3c414b;
  background: #f4f6fa; border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px;
}
.df-ability b { display: block; color: var(--tapink); font-size: 11px; margin-bottom: 1px; }
.df-move { margin-top: 6px; font-size: 11.5px; color: var(--ink); }
.df-move b { margin: 0 4px 0 0; }
.df-move small { display: block; color: #4d525c; line-height: 1.5; margin-top: 1px; }
.df-mv-cost { display: inline-flex; gap: 1px; vertical-align: -1px; margin-right: 2px; }
.df-mv-cost .nrg { width: 12px; height: 12px; font-size: 7.5px; }
.df-dmg { font-style: normal; font-weight: 800; color: #c0563f; margin-left: 4px; }
/* 官方卡文全文 */
.dtext {
  margin: 6px 2px 0; font-size: 10.5px; line-height: 1.65; color: var(--sub);
  white-space: pre-line; border-top: 1px dashed var(--line); padding-top: 5px;
}
/* 场上整摞导航：进化链（底→顶）+ 工具 + 能量（同名合并）*/
.dstack {
  display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none;
  padding: 4px 0 6px; -webkit-overflow-scrolling: touch;
}
.dstack::-webkit-scrollbar { display: none; }
.dstack-item {
  flex: none; cursor: pointer; font-size: 10.5px; color: #4d525c; background: #fff;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 10px; line-height: 1.3;
  min-height: 30px; display: inline-flex; align-items: center;
}
.dstack-item.on { color: #fff; background: var(--tap); border-color: var(--tap); font-weight: 700; }
.dstack--top:not(.on) { border-color: #c9a86a; color: #8a6d3b; font-weight: 700; } /* 当前形态（顶卡）金边 */
.dstack--nrg:not(.on) { border-color: #79b98a; color: #2f7a4a; } /* 能量绿边 */
/* 场上运行时面 */
.drt { margin: 7px 2px 2px; }
.drt-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.dchip {
  font-size: 10px; font-weight: 700; color: #4d525c; background: #f2f3f6;
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; line-height: 1.4;
}
.drt-nrg { font-size: 10.5px; color: #2f7a4a; margin-top: 5px; line-height: 1.6; }
/* 竞技场卡可长按：给可点观感 */
.fieldcard[data-inst] { cursor: pointer; }

/* ---------- 运行时异常/重连提示 toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px); z-index: 90;
  background: #2b2f38; color: #fff; font-size: 12px; padding: 8px 14px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 严重3：短屏/横屏断点（基座 ui.css 零 @media，全靠本层兜底） ---------- */
/* 375×667 一档：奖赏侧栏窄化 + 场上卡整体缩小，消除奖赏列与备战区重叠 */
@media (max-height: 700px) {
  #stage .sidecol--prize { width: 52px; }
  #stage .flank .flanklabel { font-size: 8px; }
  .mon--active .mon-card { width: 92px; height: 128px; }
  .mon--bench .mon-card { width: 48px; height: 66px; }
  .handrow .hcard { width: 56px; height: 76px; }
  #stage .fieldcard { width: 54px; height: 76px; }
  #stage .screen > .zone:first-child { padding-top: 24px; }
}
/* 320×568 一档：继续压缩 + 放开纵向滚动（基座 overflow:hidden 的兜底出口；sticky focusbar 仍吸附） */
@media (max-height: 600px) {
  #stage .screen { height: 100dvh; max-height: 100dvh; overflow-y: auto; }
  .mon--active .mon-card { width: 84px; height: 116px; }
  .mon--bench .mon-card { width: 44px; height: 60px; }
  .handrow .hcard { width: 50px; height: 68px; }
  .hud { max-width: 86%; }
}
/* 横屏矮视口（844×390 等）：棋盘完全不可用，直接引导竖屏（纯 CSS，不动 JS 主路径） */
@media (orientation: landscape) and (max-height: 500px) {
  body::after {
    content: '请竖屏使用本应用';
    position: fixed; inset: 0; z-index: 100; background: rgba(243, 245, 248, .97);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; color: var(--ink, #1d2027); letter-spacing: .1em;
  }
  #logpanel, #logbackdrop { z-index: 110; } /* 日志抽屉仍可从横屏查看 */
}
