/* ============================================================================
   无尽之塔 —— 全局样式（暗色主题 / 移动优先 / 最大宽度 600px 居中）
   同时覆盖游戏端与管理员后台。
   ============================================================================ */

:root {
  --bg: #0d0f14;
  --bg-soft: #151823;
  --card: #1a1e2c;
  --card-2: #212637;
  --line: #2c3247;
  --text: #e8eaf2;
  --text-dim: #9aa1b5;
  --accent: #7c5cff;
  --accent-2: #4cc2ff;
  --danger: #ff5d5d;
  --success: #4cd97b;
  --warn: #ffb84c;
  --hp-grad: linear-gradient(90deg, #ff6b6b, #d92626);
  --rage-grad: linear-gradient(90deg, #ffc46b, #ff7a00);
  --shield-grad: linear-gradient(90deg, #7fd4ff, #2b7fff);
  --xp-grad: linear-gradient(90deg, #9d7bff, #5c2bff);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* hidden 属性必须始终生效：作者样式里的 display:flex/grid 会覆盖浏览器默认的
   [hidden]{display:none}，导致"隐藏"的区块（登录/注册表单、顶栏、护盾条等）
   仍然显示在页面上。用 !important 保证 JS 的 .hidden = true 真正隐藏元素。 */
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1000px 500px at 50% -10%, rgba(124, 92, 255, .12), transparent 60%),
    radial-gradient(800px 400px at 110% 110%, rgba(76, 194, 255, .07), transparent 60%),
    var(--bg);
}

/* ---------------- 布局骨架：桌面居中 600px，手机全宽 ---------------- */
.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 14px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.view { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.view[hidden] { display: none; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}
.topbar .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .floor-chip {
  font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #7c5cff, #4cc2ff);
  padding: 2px 10px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}

/* ---------------- 通用组件 ---------------- */
.game-title {
  text-align: center; font-size: 30px; font-weight: 800; letter-spacing: 2px;
  margin: 28px 0 4px;
  text-shadow: 0 0 24px rgba(124, 92, 255, .55);
}
.game-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text);
  min-height: 44px;               /* 触屏友好：按钮至少 44px 高 */
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, box-shadow .2s ease;
  user-select: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, #7c5cff, #5a3df0);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .35);
}
.btn.danger { background: linear-gradient(135deg, #ff5d5d, #d92626); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { font-size: 17px; min-height: 54px; width: 100%; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 13px; border-radius: 9px; }

input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  min-height: 44px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(124, 92, 255, .5); outline-offset: -1px; }
label.field { display: block; font-size: 13px; color: var(--text-dim); margin: 10px 0 4px; }

/* ---------------- 登录 / 注册 ---------------- */
.auth-tabs { display: flex; gap: 8px; }
.auth-tabs .btn { flex: 1; }
.auth-tabs .btn.on { background: linear-gradient(135deg, #7c5cff, #5a3df0); border-color: transparent; color: #fff; }
form.auth-form { display: flex; flex-direction: column; gap: 2px; }
.hint { color: var(--text-dim); font-size: 12.5px; text-align: center; }
.link-btn { background: none; border: none; color: var(--accent-2); cursor: pointer; font-size: 13px; padding: 6px; }

/* ---------------- 状态条（HP / 怒气 / 护盾 / 经验） ---------------- */
.bar {
  position: relative;
  height: 18px;
  background: #0a0c12;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 5px 0;
}
.bar .fill {
  height: 100%;
  border-radius: 999px;
  transition: width .45s cubic-bezier(.2, .8, .3, 1);
}
.bar.hp .fill { background: var(--hp-grad); box-shadow: 0 0 10px rgba(255, 80, 80, .4); }
.bar.rage .fill { background: var(--rage-grad); box-shadow: 0 0 10px rgba(255, 140, 0, .4); }
.bar.shield .fill { background: var(--shield-grad); }
/* 敌方充能条（攒满后下一击变重击） */
.bar.charge { height: 12px; }
.bar.charge .fill { background: linear-gradient(90deg, #ff9d9d, #c0392b); }
.bar.charge .bar-text { font-size: 10.5px; }
.bar.xp { height: 10px; }
.bar.xp .fill { background: var(--xp-grad); }
.bar .bar-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}
.bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); }

/* ---------------- 职业卡片（创建角色 / 转职） ---------------- */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.class-card {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 8px; text-align: center; cursor: pointer;
  transition: border-color .15s ease, transform .1s ease;
}
.class-card:active { transform: scale(.97); }
.class-card .ce { font-size: 44px; line-height: 1.2; }
.class-card .cn { font-weight: 700; margin-top: 2px; }
.class-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .25), 0 8px 24px rgba(124, 92, 255, .25); }
.class-card.locked { opacity: .45; cursor: not-allowed; }
.class-card .lock { font-size: 11.5px; color: var(--warn); }
.class-card.current-mark { border-color: var(--success); }

.stat-line { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--text-dim); }
.stat-line b { color: var(--text); }

.skill-brief { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.skill-brief:last-child { border-bottom: none; }
.skill-brief .sn { font-weight: 700; }

/* ---------------- 主界面 ---------------- */
.floor-banner {
  text-align: center; font-size: 24px; font-weight: 800;
  padding: 16px 0 4px; letter-spacing: 1px;
}
.floor-banner .sub { font-size: 13px; color: var(--text-dim); font-weight: 400; margin-top: 2px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin-top: 8px; }
.stat-grid .sg { background: var(--bg-soft); border-radius: 10px; padding: 6px 2px; }
.stat-grid .sg b { display: block; font-size: 15px; }
.stat-grid .sg span { font-size: 11.5px; color: var(--text-dim); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------------- 战斗界面 ---------------- */
.arena {
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(33, 38, 55, .55), rgba(13, 15, 20, .2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.fighter { text-align: center; position: relative; }
.fighter .emoji { font-size: 64px; line-height: 1.15; display: inline-block; }
.fighter .emoji.xl { font-size: 84px; }
.fighter .fname { font-weight: 700; font-size: 15px; }
.fighter .fsub { font-size: 12px; color: var(--text-dim); }
.boss-badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: linear-gradient(135deg, #ff9d2e, #ff4d4d); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: 1px;
  animation: bossPulse 1.6s infinite;
}
@keyframes bossPulse { 0%,100% { box-shadow: 0 0 6px rgba(255, 77, 77, .5); } 50% { box-shadow: 0 0 18px rgba(255, 77, 77, .95); } }

.status-icons { min-height: 22px; font-size: 15px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.status-icons .st {
  background: rgba(0, 0, 0, .45); border: 1px solid var(--line);
  border-radius: 6px; padding: 0 5px; font-size: 12px; line-height: 20px;
}

.vs-divider { text-align: center; color: var(--text-dim); font-size: 12px; letter-spacing: 4px; opacity: .6; }

/* 战斗日志 */
.battle-log {
  height: 150px; overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  display: flex; flex-direction: column; gap: 2px;
  scroll-behavior: smooth;
}
.battle-log .log-line { color: var(--text-dim); animation: logIn .25s ease; }
.battle-log .log-line.damage { color: #ff9b9b; }
.battle-log .log-line.heal { color: #8fe6a8; }
.battle-log .log-line.dot { color: #ffb26b; }
.battle-log .log-line.skill { color: #b9a7ff; font-weight: 600; }
.battle-log .log-line.ultimate { color: #ffd166; font-weight: 700; }
.battle-log .log-line.victory { color: var(--success); font-weight: 700; }
.battle-log .log-line.defeat { color: var(--danger); font-weight: 700; }
.battle-log .log-line.encounter { color: #fff; font-weight: 700; }
@keyframes logIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* 战斗操作按钮 */
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actions .btn { padding: 6px 4px; font-size: 14px; line-height: 1.3; }
.actions .btn .sub { display: block; font-size: 11px; font-weight: 400; color: var(--text-dim); }
.actions .btn.skill-btn { min-height: 56px; width: 100%; }
.actions .btn.ult-btn {
  background: linear-gradient(135deg, #ff9d2e, #ff4d4d);
  border-color: transparent; color: #fff; min-height: 54px; font-size: 16px; width: 100%;
}

/* 技能格子：按钮 + 右上角 ⓘ 详情按钮（移动端可点，不依赖鼠标悬停） */
.skill-cell { position: relative; grid-column: span 1; }
.skill-cell.ult-cell { grid-column: 1 / -1; }
.info-dot {
  position: absolute; top: -7px; right: -7px; z-index: 2;
  width: 26px; height: 26px; min-height: 26px; padding: 0;
  border-radius: 50%; font-size: 14px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-2); border: 1px solid var(--accent-2);
  color: var(--accent-2); cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.info-dot:active { transform: scale(.9); }
.actions .btn.ult-btn.ready { animation: ultGlow 1.1s infinite; }
@keyframes ultGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 157, 46, .55); }
  50% { box-shadow: 0 0 26px rgba(255, 157, 46, 1); transform: scale(1.015); }
}
.cd-chip {
  display: inline-block; min-width: 20px; padding: 0 5px; margin-left: 3px;
  background: rgba(0, 0, 0, .55); border-radius: 999px; font-size: 11px;
}
/* 怒气消耗标记（🔥N）与"怒气不足"状态 */
.cd-chip.rage-chip { background: rgba(255, 122, 0, .28); color: #ffc46b; }
.skill-btn.lack-rage { opacity: .5; }
.skill-btn.lack-rage .sub { color: var(--warn); }
/* 怒气说明文字 */
.rage-hint { text-align: left; font-size: 11.5px; line-height: 1.5; margin-top: 2px; }

/* ---------------- 战斗动画 ---------------- */
@keyframes lungeRight { 0% { transform: translateX(0); } 40% { transform: translateX(52px) scale(1.06); } 100% { transform: translateX(0); } }
@keyframes lungeLeft  { 0% { transform: translateX(0); } 40% { transform: translateX(-52px) scale(1.06); } 100% { transform: translateX(0); } }
.anim-attack-right { animation: lungeRight .42s ease; }
.anim-attack-left  { animation: lungeLeft .42s ease; }

@keyframes hitFlash {
  0%, 100% { filter: none; }
  20%, 60% { filter: brightness(2.2) saturate(3) hue-rotate(-40deg) drop-shadow(0 0 12px #ff4d4d); }
}
.anim-hit { animation: hitFlash .5s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.anim-shake { animation: shake .4s ease; }

/* 飘字层 */
.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 5; }
.float-num {
  position: absolute; left: 50%;
  font-weight: 800; font-size: 22px;
  color: #ff6b6b; text-shadow: 0 2px 8px rgba(0, 0, 0, .9);
  animation: floatUp 1s ease-out forwards;
  white-space: nowrap;
}
.float-num.heal-num { color: #4cd97b; }
.float-num.crit-num { color: #ffd166; font-size: 28px; }
.float-num .crit-tag {
  display: block; text-align: center; font-size: 14px; color: #ffd166;
  letter-spacing: 2px;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -74px) scale(1); }
}

/* ---------------- GM 控制台（滑块面板） ---------------- */
.gm-panel { text-align: left; }
.gm-hint {
  font-size: 12.5px; color: var(--text-dim);
  background: var(--bg-soft); border-radius: 8px; padding: 8px 10px;
}
.gm-budget {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 700; color: var(--accent-2);
  background: rgba(76, 194, 255, .1);
  border: 1px solid rgba(76, 194, 255, .35);
  border-radius: 8px; padding: 7px 10px;
}
.gm-row { display: flex; flex-direction: column; gap: 3px; margin-top: 10px; }
.gm-row .gm-top { display: flex; justify-content: space-between; font-size: 13px; }
.gm-row .gm-top .gm-val { font-weight: 700; color: var(--accent-2); }
.gm-row .gm-top .gm-val.neg { color: var(--danger); }
.gm-row .gm-top .gm-val.zero { color: var(--text-dim); }
.gm-row .gm-cur { font-size: 11.5px; color: var(--text-dim); }
/* 可返还点数的滑块标记 + 账目行 */
.gm-refund-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 999px; margin-left: 4px;
  background: rgba(76, 217, 123, .18); color: #8fe6a8;
}
.gm-ledger {
  font-size: 11.5px; color: var(--text-dim);
  background: var(--bg-soft); border-radius: 8px; padding: 6px 10px;
  margin-top: 6px; line-height: 1.6;
}
.gm-ledger.warn { color: var(--warn); background: rgba(255, 184, 76, .12); }
/* 滑块本体：加大拇指，方便触屏拖动 */
input[type=range] {
  width: 100%; height: 34px; margin: 0;
  background: transparent; -webkit-appearance: none; appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,93,93,.55) 0%, var(--line) 50%, rgba(76,217,123,.55) 100%);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; margin-top: -9px;
  border-radius: 50%; border: 2px solid #fff;
  background: linear-gradient(135deg, #7c5cff, #4cc2ff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}
input[type=range]::-moz-range-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,93,93,.55) 0%, var(--line) 50%, rgba(76,217,123,.55) 100%);
}
input[type=range]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; background: linear-gradient(135deg, #7c5cff, #4cc2ff);
}

/* 技能详情弹窗（长按技能按钮弹出） */
.skill-detail { text-align: left; }
.skill-detail .sd-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.skill-detail .sd-chip {
  font-size: 12px; padding: 3px 8px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text-dim);
}
.skill-detail .sd-chip.rage { background: rgba(255, 122, 0, .18); color: #ffc46b; border-color: rgba(255, 122, 0, .4); }
.skill-detail .sd-desc {
  font-size: 14.5px; line-height: 1.75; color: var(--text);
  background: var(--bg-soft); border-radius: 10px; padding: 12px;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------------- 弹窗 / 提示 ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 6, 10, .78);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; gap: 12px;
  animation: popIn .22s cubic-bezier(.2, 1.4, .4, 1);
  max-height: 86vh; overflow-y: auto;
}
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }
.modal h3 { font-size: 18px; text-align: center; }
.modal .modal-body { color: var(--text-dim); font-size: 14px; text-align: center; }
.modal .modal-body .big-emoji { font-size: 52px; display: block; margin-bottom: 6px; }
.modal .reward-lines { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.modal .reward-lines div { background: var(--bg-soft); border-radius: 8px; padding: 6px 12px; }

#toast-root {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  background: rgba(26, 30, 44, .96);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: toastIn .25s ease;
  max-width: 100%;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }

/* ---------------- 商人 ---------------- */
.merchant-head { text-align: center; }
.merchant-head .me-emoji { font-size: 64px; }
.offer-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.offer-card .oi { font-size: 34px; }
.offer-card .om { flex: 1; min-width: 0; }
.offer-card .om b { display: block; }
.offer-card .om span { font-size: 12.5px; color: var(--text-dim); }

/* ============================================================================
   管理员后台
   ============================================================================ */
.admin-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.admin-nav .btn { white-space: nowrap; min-height: 40px; font-size: 14px; }
.admin-nav .btn.on { background: linear-gradient(135deg, #7c5cff, #5a3df0); border-color: transparent; color: #fff; }
.admin-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.admin-head h2 { font-size: 18px; flex: 1; }

.admin-table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
table.admin-table th, table.admin-table td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.admin-table th { color: var(--text-dim); font-weight: 600; white-space: nowrap; }
table.admin-table tr:hover td { background: rgba(124, 92, 255, .05); }

.effect-row {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.effect-row .er-head { display: flex; gap: 6px; align-items: center; }
.effect-row .er-head select { flex: 1; }
.effect-params { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.effect-params label { font-size: 12px; color: var(--text-dim); display: block; margin: 0 0 2px; }

.preview-box {
  background: rgba(124, 92, 255, .08);
  border: 1px dashed rgba(124, 92, 255, .5);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.preview-box .pv-label { font-size: 12px; color: var(--text-dim); margin-bottom: 3px; }

.emoji-quick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* 职业筛选栏 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-bar .btn { min-height: 36px; font-size: 13.5px; }
.filter-bar .cnt { opacity: .65; font-size: 11.5px; }

/* ---------------- 逻辑门句式编辑器 ----------------
   把条件渲染成中文句子：如果 [属性][比较符][数值] 并且 … 就 [效果] 否则 [效果] */
.gate-box {
  border: 1px solid rgba(124, 92, 255, .55);
  background: rgba(124, 92, 255, .07);
  border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.gate-box.nested { background: rgba(76, 194, 255, .07); border-color: rgba(76, 194, 255, .55); }
.gate-box .gate-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gate-box .gate-sel { flex: 1; min-width: 150px; }

/* 中文关键词（如果 / 就 / 否则 / 并且 / 或者 / 不满足） */
.kw {
  flex: 0 0 auto;
  font-size: 13px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(124, 92, 255, .22);
  color: #cbbcff;
  white-space: nowrap;
}
.kw-then { background: rgba(76, 217, 123, .2); color: #8fe6a8; }
.kw-else { background: rgba(255, 184, 76, .2); color: #ffcf8a; }

/* 条件行：关键词 + 左值 + 比较符 + 右值 */
.cond-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cond-row { display: flex; gap: 6px; align-items: center; flex: 1; flex-wrap: wrap; min-width: 0; }
.cond-row select, .cond-row input { flex: 1; min-width: 84px; min-height: 38px; }
.cond-row .cond-lhs { min-width: 130px; }

/* 分支容器：就 / 否则 */
.branch-box {
  border-left: 3px solid rgba(76, 217, 123, .5);
  padding-left: 8px; display: flex; flex-direction: column; gap: 6px;
}
.branch-box.else { border-left-color: rgba(255, 184, 76, .55); }
.branch-head { display: flex; align-items: center; gap: 6px; }

.add-effect { display: flex; gap: 6px; }

/* 作用对象下拉（对自身 / 对怪物）：紧挨着效果类型下拉，窄一些以免挤掉类型 */
.whom-sel {
  flex: 0 0 auto; width: auto; min-width: 96px;
  background: rgba(76, 194, 255, .14);
  border-color: rgba(76, 194, 255, .45);
  font-size: 13.5px;
}
.emoji-quick button {
  font-size: 20px; width: 36px; height: 36px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
}
.emoji-quick button:hover { border-color: var(--accent); }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.check-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font-size: 13px; cursor: pointer;
}
.check-item input { width: auto; min-height: 0; }
.check-item.on { border-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.form-grid label.field { margin-top: 0; }

.admin-login-wrap { max-width: 380px; margin: 60px auto 0; }

/* ---------------- 战斗界面：单屏适配 ----------------
   目标：手机竖屏（约 360×640 起）不滚动就能同时看到怪物血条 + 全部技能按钮。
   做法：
   1) .fighters-row 让敌我并排（原来是上下堆叠，占了双倍高度）
   2) emoji、血条、日志在窄屏全面缩号
   3) 操作按钮改为 4 列紧凑格（图标+小字），必杀技占满一行
   4) 日志从 150px 固定高度改为 flex 自适应（min 64 / max 120）
   5) 用 100dvh（移动端浏览器地址栏收起后的真实视口），旧设备回退 100vh */
.view-battle { gap: 8px; }

.fighters-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 4px; align-items: start; }
.fighters-row .fighter { min-width: 0; }
.fighters-row .vs-divider { writing-mode: vertical-rl; letter-spacing: 2px; font-size: 11px; padding-top: 26px; opacity: .5; }
.fighters-row .bar { height: 14px; }
.fighters-row .bar .bar-text { font-size: 10px; }
.fighters-row .bar-label { font-size: 10.5px; }
.fighters-row .fname { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fighters-row .fsub { font-size: 10.5px; color: var(--text-dim); }

/* 操作按钮：紧凑网格（图标 + 小字标签），节省纵向空间 */
.actions .btn .ab-label { display: block; font-size: 11px; font-weight: 600; line-height: 1.2; }

/* 单屏视口：战斗界面塞满整个可视高度（dvh 处理手机地址栏）
   关键：整个战斗区必须是"固定高度 + 内部弹性"的容器，否则内容一多就会把按钮顶出屏幕。
   所以给 .view-battle 一个 height（不是 min-height），日志用 flex:1 吃掉剩余空间，
   操作区 flex-shrink:0 永远贴在底部可见。 */
@media (max-width: 620px) {
  /* 收紧全局留白，给内容让出纵向空间 */
  .wrap { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .view { gap: 6px; }

  /* 只在"战斗界面可见"时才锁定页面高度：
     其他界面（主界面、转职大厅、商人、事件）内容可能很长，必须能正常滚动，
     否则超出的部分会被 overflow:hidden 切掉且滚不动（转职大厅的"确认转职"
     按钮就曾在 320×568 下被切到屏幕外，玩家会卡死在那一页）。
     :has() 在现代浏览器都支持；不支持时退化为普通可滚动页面，不会切内容。 */
  body:has(#view-battle:not([hidden])) .wrap {
    height: 100dvh; height: 100vh;
    overflow: hidden;
  }

  /* 战斗视图：占满剩余高度，三段式（战场 / 日志 / 操作） */
  .view-battle {
    height: 100%;
    min-height: 0;
    justify-content: flex-start;
    padding-bottom: 0;
    gap: 6px;
  }
  /* 战场保持自然高度（约 220px），不吸走全部余量。
     多余的空间给战斗日志（日志本来就有用，多显示几行比留白强）。 */
  .view-battle .arena { flex: 0 0 auto; }
  /* 日志吃满剩余空间（带滚动条，服务器已保证最多 30 行）。
     这样屏幕任何剩余高度都变成"能看更多战报"，不会出现空白死区。 */
  .view-battle .battle-log { flex: 1 1 auto; min-height: 44px; max-height: none; }
  /* 操作区固定高度，永远贴在底部可见 */
  .view-battle .actions { flex: 0 0 auto; }

  .fighter .emoji { font-size: 40px; line-height: 1.05; }
  .fighter .emoji.xl { font-size: 46px; }
  .fighter .fname { font-size: 12px; }
  .arena { padding: 6px 6px; border-radius: 12px; }
  .status-icons { min-height: 16px; font-size: 12px; }
  .status-icons .st { font-size: 10.5px; line-height: 16px; padding: 0 4px; }
  .battle-log {
    height: auto; min-height: 40px;
    font-size: 11px; line-height: 1.45; padding: 5px 8px; border-radius: 10px;
  }

  /* 操作区：4 列紧凑方格。技能名 + 描述两行会撑高按钮（实测 67~78px），
     手机上只留"图标 + 技能名"，描述移到 ⓘ 详情弹窗里看。
     用 grid 让图标与名字各占一行，避免挤成"🧬交换空间"这种连写。 */
  .actions { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .actions .btn {
    min-height: 50px; height: 50px;
    padding: 3px 2px 4px; font-size: 17px; line-height: 1;
    display: grid; grid-template-rows: auto auto;
    align-content: center; justify-items: center; row-gap: 2px;
    overflow: hidden;
  }
  .actions .btn .ab-label {
    font-size: 10.5px; font-weight: 600; line-height: 1.15;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  /* 技能按钮里的描述、怒气提示副标题一律收起（避免撑高） */
  .actions .btn.skill-btn { min-height: 50px; height: 50px; }
  .actions .btn.skill-btn .sub { display: none; }
  .actions .btn.ult-btn {
    min-height: 50px; height: 50px; font-size: 14px;
    grid-template-rows: auto; grid-auto-flow: column; gap: 6px; align-items: center;
  }
  .actions .btn.ult-btn .sub {
    display: inline; font-size: 10px; font-weight: 500;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  /* 冷却 / 怒气角标：钉在按钮右下角（名字居中偏上，不会被压到）。
     ⓘ 详情按钮占右上角外侧，所以角标只走右下，两不相扰。 */
  .actions .skill-btn .cd-chip {
    position: absolute; bottom: 2px; right: 3px;
    min-width: 0; padding: 0 4px; margin-left: 0;
    font-size: 9.5px; line-height: 13px; border-radius: 7px;
  }
  .skill-cell { position: relative; }
  .skill-cell.ult-cell { grid-column: 1 / -1; }
  /* ⓘ 详情点：缩小并紧贴按钮右上角，不额外占位 */
  .info-dot { width: 18px; height: 18px; min-height: 18px; font-size: 11px; top: -4px; right: -4px; opacity: .85; }
  /* 顶栏在手机上收窄（RAM/金币/名字挤一行） */
  .topbar { padding: 5px 8px; font-size: 12px; }
  .topbar .floor-chip { font-size: 11px; padding: 1px 7px; }
}

/* 极窄屏幕（≤360px）：emoji 与字号再收一档 */
@media (max-width: 360px) {
  .fighter .emoji { font-size: 38px; }
  .fighter .emoji.xl { font-size: 42px; }
  .actions { gap: 4px; }
  .actions .btn .sub { display: none; }   /* 概要说明在极窄屏隐藏，只留技能名 */
  /* ⓘ 收到按钮内部右上角：负偏移会溢到隔壁按钮上，320px 宽时尤其明显 */
  .info-dot {
    width: 16px; height: 16px; min-height: 16px;
    font-size: 10px; top: 0; right: 0;
    opacity: .9;
  }
  .actions .btn .ab-label { font-size: 10px; }
  .actions .skill-btn .cd-chip { font-size: 9px; line-height: 12px; padding: 0 3px; }
}
