/* ===== 《猫鸡大战》样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh; /* 动态视口高度：地址栏收放时长机身不留白 */
  overflow: hidden;
  background: #0c1119;
  font-family: 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  color: #eef2fb;
  user-select: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; height: 100dvh; overflow: hidden; }

/* 画布 */
#game { position: absolute; inset: 0; display: block; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud.hidden, .hidden { display: none !important; }

.panel {
  position: absolute;
  z-index: 7; /* 高于致盲遮罩（6），黑魔法期间自己的血量/比分仍可见 */
  background: rgba(12, 18, 28, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 210, 120, 0.18);
  border-radius: 14px;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.8);
}

/* 左上：玩家信息 */
#hud-tl {
  left: calc(10px + env(safe-area-inset-left, 0px));
  top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 8px;
  min-width: 210px;
}
#me-objective { margin-top: 2px; font-size: 11px; font-weight: 700; color: #ffd166; white-space: nowrap; }
#me-objective .bf-count { color: #cfe0f2; font-weight: 600; }
#me-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 210, 120, 0.55);
  object-fit: contain;
  flex: 0 0 auto;
}
.me-col { display: flex; flex-direction: column; gap: 4px; }
.me-name { display: flex; align-items: baseline; gap: 8px; }
.me-name b { font-size: 15px; color: #ffe9b6; }
.me-name span { font-size: 12px; color: #a9b6cc; }
#me-hpwrap {
  position: relative; width: 168px; height: 16px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#me-hp {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #4bd07a, #8ff0a6);
  transition: width 0.12s linear;
}
#me-hptext {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #08131a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
#me-kda { font-size: 12px; color: #cbd5e1; }

/* 战况面板：默认隐藏，点小地图左侧按钮开关。半透明浮层、不吃指针事件（不挡操作）。
   z-index 高于击杀播报（12）：面板打开时播报不遮挡战绩。 */
#score-panel {
  position: absolute;
  left: 50%; top: calc(8px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  z-index: 13;
  pointer-events: none;
  width: min(92vw, 450px);
  max-height: calc(100vh - 16px);
  overflow: hidden;
  background: rgba(10, 16, 26, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 210, 120, 0.22);
  border-radius: 14px;
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.85);
  padding: 6px 10px 8px;
}
.sp-top { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.sp-cols { display: flex; gap: 8px; margin-top: 6px; }
.sp-col { flex: 1 1 0; min-width: 0; }
.sp-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
  padding: 2px 4px 4px; font-size: 12px; font-weight: 800; letter-spacing: .5px;
}
.sp-head.chicken { color: #9be7ff; }
.sp-head.cat { color: #ffd866; }
.sp-legend { font-size: 9px; font-weight: 500; color: #8b98ad; }
.sp-list { display: flex; flex-direction: column; gap: 3px; }
.sp-row {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 7px;
  min-height: 30px; padding: 3px 8px;
  border-radius: 8px; background: rgba(0, 0, 0, 0.32);
}
.sp-row-bg {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0; z-index: 0;
  transition: width 0.15s linear;
}
.sp-row > *:not(.sp-row-bg) { position: relative; z-index: 1; }
.sp-av {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  object-fit: cover; background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.sp-name {
  flex: 1 1 auto; min-width: 0; font-size: 12px; color: #e7edf7;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-stats {
  flex: 0 0 auto; font-size: 11px; font-variant-numeric: tabular-nums;
  color: #cdd7e6; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.sp-stats b { color: #fff; }
.sp-stats .a { color: #9be7ff; }
.sp-stats .d { color: #ff9a9a; }
.sp-badge {
  margin-left: 6px; padding: 0 5px; border-radius: 6px;
  font-size: 10px; color: #ffd866; background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 216, 102, 0.35); white-space: nowrap;
}
.sp-row.me { box-shadow: inset 0 0 0 1px rgba(255, 224, 102, 0.75); }
.sp-row.dead { opacity: 0.55; }
.sp-empty { font-size: 11px; color: #7c889b; padding: 4px; }
#hud-timer { font-size: 24px; font-weight: 800; color: #fff; letter-spacing: 1px; text-shadow: 0 2px 6px #000; }
#hud-scores { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 800; }
#hud-scores .sc.chicken { color: #9be7ff; }
#hud-scores .sc.cat { color: #ffd866; }
#hud-scores .sc-sep { color: #8b98ad; }
#hud-mode { font-size: 11px; color: #9fb0c8; margin-top: 1px; letter-spacing: .5px; }

/* 拆家模式：中上改为两条基地血条（代替倒计时 / 比分） */
#hud-bases { display: flex; flex-direction: column; gap: 3px; margin: 1px 0; }
#hud-bases .base-bar { display: flex; align-items: center; gap: 5px; }
#hud-bases .bb-ico { font-size: 13px; line-height: 1; }
#hud-bases .bb-track {
  position: relative; display: block; width: 168px; height: 11px;
  background: rgba(0, 0, 0, 0.55); border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
#hud-bases .bb-fill { display: block; height: 100%; width: 100%; transition: width 0.2s linear; }
#hud-bases .base-bar.chicken .bb-fill { background: linear-gradient(90deg, #4aa8ff, #9be7ff); }
#hud-bases .base-bar.cat .bb-fill { background: linear-gradient(90deg, #ffca5a, #e09a25); }

/* 右上：小地图 */
#hud-tr {
  position: absolute;
  right: calc(10px + env(safe-area-inset-right, 0px));
  top: calc(10px + env(safe-area-inset-top, 0px));
  z-index: 7;
}
#minimap {
  width: 132px; height: 132px; display: block;
  border-radius: 12px;
  border: 2px solid rgba(255, 210, 120, 0.35);
  background: #101a12;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.85);
}
/* 小地图左侧：按住显示队友面板的按钮（右手拇指可及） */
#ally-btn {
  position: absolute; right: calc(100% + 8px); top: 0;
  width: 44px; height: 44px; border-radius: 12px; padding: 0;
  font-size: 22px; line-height: 1;
  background: rgba(12, 18, 28, 0.62); color: #dfe6f3;
  border: 2px solid rgba(255, 210, 120, 0.35);
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.85);
  pointer-events: auto; cursor: pointer; touch-action: none;
}
#ally-btn:active { border-color: rgba(255, 210, 120, 0.85); }
#ally-btn.on { color: #ffe066; border-color: rgba(255, 224, 102, 0.85); background: rgba(40, 34, 20, 0.75); }
/* 小地图下方：自动施放 / 电脑托管按钮（右对齐竖排） */
#hud-tr-tools {
  position: absolute; right: 0; top: calc(100% + 8px);
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
#auto-btn, #ai-btn {
  padding: 6px 10px; border-radius: 12px; font-size: 12px; font-weight: 700;
  background: rgba(12, 18, 28, 0.62); color: #9fb0c6;
  border: 2px solid rgba(255, 210, 120, 0.28);
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.85);
  pointer-events: auto; cursor: pointer; touch-action: none; white-space: nowrap;
}
#auto-btn.on { color: #ffe066; border-color: rgba(255, 224, 102, 0.75); }
#ai-btn.on { color: #9be7ff; border-color: rgba(155, 231, 255, 0.85); background: rgba(20, 40, 60, 0.75); }

/* 致盲遮罩 */
#blind-overlay {
  position: absolute; inset: 0; z-index: 6;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
#blind-overlay span {
  color: #6b4b8f; font-size: 15px; letter-spacing: 2px;
  animation: blindPulse 2s ease-in-out infinite;
}
@keyframes blindPulse { 0%,100% { opacity: .35; } 50% { opacity: .85; } }

/* 被贪吃猫吞噬遮罩 */
#swallow-overlay {
  position: absolute; inset: 0; z-index: 6;
  background: radial-gradient(circle at 50% 45%, #3a2a12, #120c06 70%);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
#swallow-overlay span {
  color: #ffd27a; font-size: 17px; letter-spacing: 2px; font-weight: 700;
  animation: blindPulse 1.6s ease-in-out infinite;
}

/* 状态提示：排在道具栏上方 */
#status-tags {
  position: absolute; left: 50%;
  bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); z-index: 12;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  max-width: 72vw; pointer-events: none;
}
.tag {
  padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(255, 143, 208, 0.22); color: #ffb8e4;
  border: 1px solid rgba(255, 143, 208, 0.5);
}
.tag.immune { background: rgba(120, 255, 220, 0.18); color: #9ff5df; border-color: rgba(120, 255, 220, 0.5); }
.tag.invincible { background: rgba(255, 225, 120, 0.2); color: #ffe9a3; border-color: rgba(255, 225, 120, 0.55); }
.tag.invisible { background: rgba(190, 160, 255, 0.18); color: #d6c2ff; border-color: rgba(190, 160, 255, 0.5); }
.tag.excited { background: rgba(255, 170, 80, 0.2); color: #ffcf9a; border-color: rgba(255, 170, 80, 0.55); }
.tag.silenced { background: rgba(160, 120, 255, 0.2); color: #cbb6ff; border-color: rgba(160, 120, 255, 0.55); }
.tag.timestop { background: rgba(120, 200, 255, 0.2); color: #b8e2ff; border-color: rgba(120, 200, 255, 0.55); }
.tag.anchor { background: rgba(255, 210, 120, 0.2); color: #ffe1a1; border-color: rgba(255, 210, 120, 0.55); }
.tag.swallowed { background: rgba(255, 150, 90, 0.2); color: #ffc39a; border-color: rgba(255, 150, 90, 0.55); }
.tag.seasoned { background: rgba(255, 120, 160, 0.2); color: #ffb3c8; border-color: rgba(255, 120, 160, 0.55); }
.tag.radar { background: rgba(120, 230, 150, 0.18); color: #a9f0bf; border-color: rgba(120, 230, 150, 0.5); }
.tag.form { background: rgba(255, 224, 102, 0.22); color: #ffe066; border-color: rgba(255, 224, 102, 0.6); }
.tag.duck { background: rgba(255, 200, 80, 0.22); color: #ffe3a3; border-color: rgba(255, 200, 80, 0.65); }
.tag.deathshield, .tag.deathrush { background: rgba(255, 220, 100, 0.2); color: #ffeda6; border-color: rgba(255, 220, 100, 0.65); }
.tag.auto { background: rgba(120, 200, 255, 0.2); color: #b8e2ff; border-color: rgba(120, 200, 255, 0.55); }

/* 道具栏：屏幕底部中间，4 格、不堆叠，点格子使用 */
#item-bar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 12; display: flex; gap: 8px; pointer-events: auto;
}
.item-slot {
  position: relative;
  width: 62px; height: 62px; border-radius: 14px; padding: 0; cursor: pointer;
  background: rgba(12, 18, 28, 0.62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 2px solid rgba(255, 210, 120, 0.28);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.85);
}
.item-slot.empty { border-style: dashed; border-color: rgba(255, 255, 255, 0.18); cursor: default; opacity: 0.7; }
.item-slot:not(.empty):hover, .item-slot:not(.empty):active { border-color: rgba(255, 210, 120, 0.75); }
.item-slot img { width: 48px; height: 48px; object-fit: contain; pointer-events: none; }
.item-slot .nm {
  position: absolute; left: 0; right: 0; bottom: 2px;
  font-size: 9px; text-align: center; color: #eef2fb; text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* 时停提示 */
#timestop-banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 13; font-size: 22px; font-weight: 800; color: #bfe6ff;
  letter-spacing: 2px; text-shadow: 0 3px 12px #000;
}
#respawn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 12; font-size: 20px; font-weight: 800; color: #ffd866;
  text-shadow: 0 3px 10px #000;
}
#respawn b { font-size: 26px; }

/* 终局倒计时：决斗 / 夺宝最后 5 秒的大字数字（数字由 JS 写，动画全部在这里）
   - 屏幕中上部居中，字号占屏高近 1/4（矮屏稍小）；
   - 突然出现（1% ≈ 10ms 跳到不透明，没有淡入）；
   - 停留 0.5s（53% × 0.95s）；
   - 向上缩小飞出并淡出。
   填充色仍然半透明（不糊住画面），但加上描边 + 投影，浅色草地/沙地上也足够醒目；
   pointer-events: none 保证不影响操作。 */
#final-countdown {
  position: absolute;
  left: 50%; top: 26%;
  z-index: 14;
  pointer-events: none;
  font-size: clamp(76px, 24vh, 230px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  color: rgba(255, 250, 234, 0.9);
  -webkit-text-stroke: 0.05em rgba(28, 16, 0, 0.34);
  text-shadow: 0 0.04em 0.16em rgba(0, 0, 0, 0.6), 0 0 0.42em rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-50%, -50%);
}
/* 最后两秒换偏红的半透明色，气氛更紧 */
#final-countdown.urgent { color: rgba(255, 122, 108, 0.92); }
/* 只在动画期间提前升合成层，平时不占资源 */
#final-countdown.tick { animation: finalCountdown 0.95s ease-out both; will-change: transform, opacity; }
@keyframes finalCountdown {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.25); }
  1%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  53%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  /* 用 vh 而不是 % 定飞行距离：字号调大后按百分比会直接飞出屏幕外，
     vh 让"上移距离"跟屏幕高度挂钩，大字号也能完整看到它缩小飞出的过程 */
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 14vh)) scale(0.5); }
}

/* 左下：摇杆 */
.stick {
  position: absolute;
  left: calc(20px + env(safe-area-inset-left, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 2px solid rgba(255, 255, 255, 0.18);
  pointer-events: auto; z-index: 12;
}
.stick .knob {
  position: absolute; left: 50%; top: 50%;
  width: 62px; height: 62px; margin: -31px 0 0 -31px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9b6, #d9a83c);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
  transition: transform 0.03s linear;
}

/* 右下：技能按钮 */
#skills {
  position: absolute;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 14px; align-items: flex-end;
  pointer-events: auto; z-index: 12;
}

/* 贪吃猫消化目标：技能按钮上方的小卡片（头像 + 血条 + 剩余秒数） */
#digest-hud {
  position: absolute;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  z-index: 12;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px; border-radius: 14px;
  background: rgba(12, 18, 28, 0.72);
  border: 2px solid rgba(255, 150, 90, 0.55);
  pointer-events: none;
}
#digest-hud img { width: 40px; height: 40px; object-fit: contain; }
#digest-hud .dg-col { display: flex; flex-direction: column; gap: 4px; min-width: 84px; }
#digest-hud .dg-name { font-size: 11px; font-weight: 700; color: #ffd27a; white-space: nowrap; }
#digest-hud .dg-hpwrap { height: 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.6); overflow: hidden; }
#digest-hud .dg-hp { height: 100%; background: linear-gradient(90deg, #ff8f5a, #ffd27a); }
.skill-btn {
  position: relative;
  width: 82px; height: 82px; border-radius: 50%;
  padding: 0; border: 3px solid rgba(255, 210, 120, 0.6);
  background: radial-gradient(circle at 38% 32%, #2f3d52, #141c28);
  overflow: hidden;
  box-shadow: 0 8px 18px -6px rgba(0, 0, 0, 0.9);
  cursor: pointer;
  touch-action: none;
}
.skill-btn img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
/* 长按技能/道具/小图标时别弹"保存图片"菜单（iOS 的 callout + 桌面右键菜单） */
.skill-btn, .skill-btn *, .item-slot, .item-slot *,
#ally-btn, #ally-btn *, #auto-btn, #auto-btn *, #ai-btn, #ai-btn * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.skill-btn small {
  /* 技能名缩成圆内的一枚小胶囊：贴着按钮底边通栏画会把外圈的进度环挡住一截 */
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  max-width: 64px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 10px; text-align: center; color: #fff;
  background: rgba(0, 0, 0, 0.62); border-radius: 7px; padding: 1px 6px;
  pointer-events: none;
}
/* 冷却：外圈进度环 + 中心倒计时数字。
   1) .cd 是贴在按钮内沿的一圈进度环（conic-gradient），JS 每帧写 --cdp = 剩余比例，
      环从 12 点方向顺时针"退"，剩多少就亮多少；底色是浅色轨道，能看清总长度。
   2) .cdt 是中间的剩余秒数（10s 以上取整、10s 以内一位小数），不会被底部技能名挡住。
   3) 冷却中图标统一压暗 + 去饱和，不再用半透明蒙版"从上往下揭开"（旧做法会把底部
      技能名那一行挡住，长 CD 根本看不出进度）。 */
.skill-btn .cd {
  position: absolute; inset: 0; border-radius: 50%;
  display: none; pointer-events: none;
  background: conic-gradient(from -90deg,
    #ffd166 0turn,
    #ff7a4d calc(var(--cdp, 0) * 1turn),
    rgba(255, 255, 255, 0.12) calc(var(--cdp, 0) * 1turn));
  /* 只留最外圈 7px 的一环，中间露出来给图标 */
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
}
.skill-btn.cooling .cd { display: block; }
.skill-btn .cdt {
  position: absolute; left: 0; right: 0; top: 0; bottom: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: 0.5px;
  color: #ffe9b6;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}
.skill-btn .cdt:empty { display: none; }
.skill-btn.cooling img { filter: grayscale(0.6) brightness(0.5); }
.skill-btn.cooling { border-color: rgba(255, 150, 90, 0.55); }
/* 被沉默药水封禁技能：灰掉并盖一个拉链 */
.skill-btn.silenced { opacity: 0.5; border-color: rgba(160, 120, 255, 0.7); }
.skill-btn.empty { opacity: 0.45; border-style: dashed; border-color: rgba(255, 255, 255, 0.2); cursor: default; }
.skill-btn.silenced::after {
  content: "🤐"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); font-size: 26px; pointer-events: none;
}
.skill-btn:active { transform: scale(0.96); }

/* ---------- 覆盖层 / 卡片 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex;
  /* 关键：内容比屏幕高时要从顶部开始排，否则 flex 居中会把顶部顶出可视区，
     而且滚不上去（经典 flex + overflow 问题）。.card 用 margin:auto 兜住"不高时居中"。 */
  align-items: flex-start;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px))
           calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  background: radial-gradient(circle at 25% 20%, #1a2636, #080c12 75%);
  overflow: auto;
}
.card {
  width: min(460px, 100%);
  margin: auto;
  background: rgba(18, 26, 38, 0.92);
  border: 1px solid rgba(255, 210, 120, 0.22);
  border-radius: 24px;
  padding: 24px 22px;
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.9);
}
.card.wide { width: min(720px, 100%); }
.card h1 {
  font-size: 24px; text-align: center; color: #ffe9b6;
  text-shadow: 0 3px 0 #5e3a1c; margin-bottom: 6px;
}
.card h1 span { color: #7ee0ff; }
.card h3 { font-size: 15px; color: #cbd5e1; margin: 16px 0 8px; font-weight: 700; }
.sub { text-align: center; color: #a9b6cc; font-size: 13px; margin-bottom: 16px; }
.sub b { color: #ffe9b6; }
.hint { text-align: center; color: #7c8aa0; font-size: 12px; margin-top: 10px; }
.link { background: none; border: none; color: #7ee0ff; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; }

input {
  width: 100%; height: 48px; padding: 0 14px;
  background: rgba(8, 12, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px; color: #eef2fb; font-size: 16px; outline: none;
}
input:focus { border-color: rgba(126, 224, 255, 0.7); }

.row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 18px; }
/* 行内输入框要能伸缩：否则 input 的 width:100% 加上不可收缩的按钮会把整行撑爆 */
.row input { flex: 1 1 0; min-width: 0; width: auto; }

.btn {
  flex: 0 0 auto; height: 46px; padding: 0 20px;
  border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(38, 50, 68, 0.95); color: #eef2fb;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, #ffca5a, #e09a25);
  border-color: #ffd98a; color: #2a1c05;
}
/* 只有"独占一行"的主按钮才撑满宽度；行内的主按钮（开始游戏/回到房间）
   必须保持内容宽度，否则 flex 行会被撑爆、左边的按钮被挤出屏幕 */
#screen-room .row.end .btn.primary { margin-left: auto; }

/* ---------- 登录页 ---------- */
/* 全屏背景图，用户名 + 登录按钮放在背景图中下部 */
#screen-name {
  background: url("assets/login_bg.webp") center / cover no-repeat, #0c1119;
  overflow: hidden;
}
.login-panel {
  margin: auto auto 12vh; /* 水平居中、压到中下方 */
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 0 16px;
  width: min(480px, 94%);
}
.login-title {
  font-size: 34px; color: #fff; text-align: center;
  text-shadow: 0 3px 0 #5e3a1c, 0 6px 18px rgba(0, 0, 0, 0.8);
}
.login-form {
  display: flex; gap: 10px; width: 100%;
  background: rgba(10, 14, 22, 0.72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 210, 120, 0.35);
  border-radius: 16px; padding: 14px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
}
.login-form input { flex: 1 1 0; min-width: 0; width: auto; }
.login-form .btn.primary { height: 48px; }

/* ---------- 防沉迷数学关（登录前） ---------- */
/* 5 道题排成两列（最后一道占满整行），矮屏也不会超出卡片 */
#screen-quiz .quiz-card { width: min(640px, 100%); }
.quiz-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 14px 0 0;
}
.quiz-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(30, 42, 58, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
/* 5 道题两列排布时，最后一道没有搭档 → 独占整行 */
.quiz-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
.quiz-no {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #2a1c05;
  background: linear-gradient(180deg, #ffca5a, #e09a25);
}
.quiz-main { flex: 1 1 auto; min-width: 0; }
.quiz-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 18px; font-weight: 700; color: #eef2fb; line-height: 1.75;
  font-variant-numeric: tabular-nums;
}
.quiz-item .quiz-input {
  flex: 0 0 auto; width: 76px; height: 40px; padding: 0 8px;
  text-align: center; font-size: 18px; font-weight: 700;
}
.quiz-input.bad { border-color: #ff6b6b; background: rgba(255, 80, 80, 0.16); color: #ffb3b3; }
.quiz-input.good { border-color: rgba(75, 208, 122, 0.85); background: rgba(75, 208, 122, 0.12); }
.quiz-tip {
  min-height: 20px; margin-top: 12px;
  text-align: center; font-size: 13px; color: #a9b6cc;
}
.quiz-tip.bad { color: #ff9a9a; }
.quiz-tip.good { color: #8ff0a6; }
.quiz-actions { display: flex; gap: 10px; margin-top: 6px; }
.quiz-actions #quiz-submit { flex: 1 1 auto; }

/* 表单行（大厅顶部）：不换行 */
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1 1 0; min-width: 0; width: auto; }

/* 房间列表：两列网格，超高滚动 */
.room-list.two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  max-height: 320px; overflow-y: auto; padding: 2px;
}
.room-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  height: 56px; /* 固定行高：不随内容/行数变化 */
  overflow: hidden;
  padding: 0 12px; border-radius: 12px;
  background: rgba(30, 42, 58, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px;
}
.room-item b { color: #7ee0ff; font-size: 16px; }
.room-item .meta { color: #a9b6cc; font-size: 12px; white-space: nowrap; }
.room-item .ri-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.room-item .ri-main b { flex: 0 0 auto; }
.room-item .ri-main .meta { overflow: hidden; text-overflow: ellipsis; }
.room-item .ri-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.room-item:hover { border-color: rgba(255, 210, 120, 0.5); }
.room-item .btn { height: 34px; padding: 0 14px; font-size: 13px; }
.room-empty { grid-column: 1 / -1; text-align: center; color: #7c8aa0; font-size: 13px; padding: 18px; }

/* 房间页顶栏：左=房间号 / 中=提示 / 右=我的角色 */
.room-top {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 12px;
  background: rgba(12, 18, 28, 0.6);
  border: 1px solid rgba(255, 210, 120, 0.18);
}
.room-no { font-size: 15px; color: #cbd5e1; white-space: nowrap; }
.room-no b { color: #7ee0ff; font-size: 19px; letter-spacing: 1px; }
.room-hint {
  flex: 1 1 0; min-width: 0; text-align: center;
  font-size: 14px; font-weight: 700; color: #ffe9b6;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 顶栏右侧"我的角色"：点击打开选角弹层 */
.room-mychar {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  font-size: 13px; color: #cbd5e1;
  cursor: pointer; padding: 4px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.room-mychar:hover, .room-mychar:focus-visible {
  border-color: rgba(255, 210, 120, 0.45);
  background: rgba(255, 210, 120, 0.08);
  outline: none;
}
.room-mychar::after { content: "▾"; font-size: 11px; color: #9fb0c6; }
#my-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.35); /* 未选角色：空边框 */
  background: rgba(255, 255, 255, 0.06);
  object-fit: contain;
}
#my-avatar.picked { border-style: solid; border-color: rgba(255, 210, 120, 0.65); }

/* 击杀播报（HUD 顶部居中，所有人可见）。计分板已收进战况面板（默认隐藏），
   播报上移到屏幕中上方原计分板的位置；战况面板打开时层级更高、盖住播报。 */
#kill-feed {
  position: absolute; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  z-index: 12; display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
}
.kf-item {
  padding: 4px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(10, 14, 20, 0.82); border: 1px solid rgba(255, 120, 120, 0.45);
  color: #ffdada; white-space: nowrap;
  animation: kfIn 0.18s ease-out;
}
.kf-item .kf-skill { color: #ffe9b6; }
/* 播报里的名字按"敌我"上色（相对自己，不按阵营）：自己黄、同阵营蓝、敌对红、无阵营灰 */
.kf-item .kf-name { font-weight: 800; }
.kf-item .kf-me { color: #fff066; }
.kf-item .kf-ally { color: #6fc0ff; }
.kf-item .kf-enemy { color: #ff7b7b; }
.kf-item .kf-neutral { color: #cfd8e3; }
.kf-item.fade { opacity: 0; transition: opacity 0.5s; }
@keyframes kfIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 房间：选角弹层（默认不显示，点顶栏右侧"我的角色"打开） */
.popup {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px))
           calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
}
.popup-mask { position: absolute; inset: 0; background: rgba(4, 8, 14, 0.72); }
.popup-panel {
  position: relative; z-index: 1;
  width: min(560px, 100%); max-height: 100%;
  display: flex; flex-direction: column;
  background: rgba(18, 26, 38, 0.98);
  border: 1px solid rgba(255, 210, 120, 0.28);
  border-radius: 20px; padding: 18px 16px 16px;
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.9);
}
.popup-close {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30, 42, 58, 0.95); color: #eef2fb;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 15px; line-height: 1; cursor: pointer;
}
.popup-close:hover, .popup-close:active {
  background: rgba(255, 120, 120, 0.25); border-color: rgba(255, 120, 120, 0.6);
}
.popup-body { display: flex; gap: 12px; min-height: 0; flex: 1 1 auto; margin-top: 8px; }

/* 结算页"查看日志"弹层 */
.row.center { justify-content: center; }
.log-list {
  margin-top: 10px; min-height: 0; flex: 1 1 auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 6px; padding-right: 4px;
}
.log-row {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 14px; color: #dfe6f3;
  background: rgba(30, 42, 58, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px; padding: 7px 10px;
}
.log-row .lt { flex: 0 0 auto; font-size: 12px; color: #9fb0c8; font-variant-numeric: tabular-nums; }
.log-row.empty { justify-content: center; color: #8fa0b8; }

/* 房间页"场内道具"弹层（房主设置道具池） */
.pool-hint { margin: 6px 0 10px; font-size: 13px; color: #a9b6cc; }
.pool-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  min-height: 0; flex: 1 1 auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}
.pool-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border-radius: 12px; cursor: pointer; text-align: center;
  background: rgba(30, 42, 58, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.10);
}
.pool-item img, .pool-item .emoji { width: 40px; height: 40px; object-fit: contain; font-size: 26px; line-height: 40px; }
.pool-item .nm { font-size: 12px; color: #dfe6f3; }
/* 选中态：道具池是多选、模式是单选，都由 JS 直接切 .sel（不再用 <input>，
   避免全局 input{width:100%;height:48px} 把行内控件撑爆） */
.pool-item.sel {
  border-color: rgba(255, 201, 77, 0.65);
  background: rgba(80, 62, 20, 0.45);
}
/* 游戏模式弹层：每个模式占一整行，名称 + 说明 */
.mode-item {
  grid-column: 1 / -1;
  flex-direction: row; align-items: flex-start; text-align: left; gap: 10px;
}
.mode-item .emoji { width: auto; height: auto; font-size: 22px; line-height: 1.3; flex: 0 0 auto; }
.mode-item .nm { display: flex; flex-direction: column; gap: 3px; font-weight: 700; }
.mode-item .nm small { font-weight: 400; font-size: 11px; color: #9fb0c8; line-height: 1.35; }
.popup-factions { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.faction-tab {
  width: 66px; padding: 8px 4px; border-radius: 14px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(30, 42, 58, 0.9); color: #cbd5e1;
  border: 2px solid rgba(255, 255, 255, 0.1);
  font-size: 12px; font-weight: 700;
}
.faction-tab img { width: 40px; height: 40px; object-fit: contain; }
.faction-tab.chicken.sel { border-color: #9be7ff; background: rgba(40, 80, 110, 0.9); color: #d6f5ff; }
.faction-tab.cat.sel { border-color: #ffd866; background: rgba(110, 84, 30, 0.9); color: #fff2cf; }

.popup-chars { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.char-row {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 12px; cursor: pointer;
  background: rgba(26, 36, 50, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.1);
}
.char-row:hover { border-color: rgba(255, 210, 120, 0.5); }
.char-row.sel { border-color: #ffe07a; box-shadow: 0 0 0 2px rgba(255, 224, 122, 0.35) inset; }
.char-row img.av { width: 46px; height: 46px; object-fit: contain; flex: 0 0 auto; }
.char-row .info { flex: 1 1 auto; min-width: 0; }
.char-row .nm { font-size: 15px; font-weight: 800; color: #ffe9b6; }
.char-row .ti { font-size: 11px; color: #9fb0c6; }
.char-row .hp { font-size: 12px; color: #8ff0a6; font-weight: 700; }
.char-row .sk { display: flex; gap: 6px; flex: 0 0 auto; }
.char-row .sk div { display: flex; flex-direction: column; align-items: center; width: 40px; }
.char-row .sk img { width: 30px; height: 30px; object-fit: contain; }
.char-row .sk span { font-size: 10px; color: #cbd5e1; line-height: 1.15; }

/* 房间玩家列表 */
.room-players { display: flex; flex-direction: column; gap: 6px; overflow: auto; flex: auto; }
.player-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(26, 36, 50, 0.9); font-size: 14px;
}
.player-item .side { display: flex; align-items: center; gap: 8px; }
.player-item img.av { width: 26px; height: 26px; object-fit: contain; }
.player-item .tag, .rtag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700;
}
.rtag.host { background: rgba(255, 210, 120, 0.2); color: #ffd866; }
.rtag.ai { background: rgba(160, 200, 255, 0.18); color: #a9d4ff; }
.rtag.chicken { background: rgba(155, 231, 255, 0.16); color: #9be7ff; }
.rtag.cat { background: rgba(255, 216, 102, 0.16); color: #ffd866; }
.rtag.none { background: rgba(255, 120, 120, 0.16); color: #ff9d9d; }
/* 房主逐个移除电脑的叉 */
.ai-x {
  width: 24px; height: 24px; border-radius: 50%; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30, 42, 58, 0.95); color: #ffdada;
  border: 1px solid rgba(255, 120, 120, 0.5); font-size: 12px; line-height: 1;
}
.ai-x:hover, .ai-x:active { background: rgba(255, 120, 120, 0.3); }

/* 结算 */
.result-splash {
  position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 18px; border: 0; cursor: default;
  background: rgba(3, 6, 10, 0.97); color: #fff;
}
.result-splash.ready { cursor: pointer; }
.result-splash img {
  display: block; max-width: 100%; max-height: calc(100% - 54px); object-fit: contain;
  /* 边缘柔化：径向渐隐遮罩让四边淡出，融入深色背景，不再是一块生硬的直角图 */
  -webkit-mask-image: radial-gradient(ellipse 62% 62% at 50% 50%, #000 46%, rgba(0, 0, 0, 0) 100%);
  mask-image: radial-gradient(ellipse 62% 62% at 50% 50%, #000 46%, rgba(0, 0, 0, 0) 100%);
}
.result-splash span { min-height: 22px; font-size: 14px; color: #d5deec; }
/* 标题行：标题居中，查看日志按钮靠右上，把纵向空间都让给排行榜 */
.result-top { display: flex; align-items: center; gap: 12px; }
.result-top h1 { margin: 0; flex: 1; text-align: center; }
.result-top .btn { height: 34px; padding: 0 12px; font-size: 13px; }
/* 战绩：左鸡右猫两列，每列各自成组（列头 + 成员），超高滚动；MVP 在各自列内标注。
   上限 10 人 = 每阵营最多 5 行，max-height 按正好容纳 5 行调整，行高可以放宽一些。 */
.result-list.two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start;
  /*max-height: 224px;*/ overflow-y: auto; padding: 2px;
}
.result-list.two-col .col {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.result-list.two-col .col-head {
  text-align: center; font-size: 16px; font-weight: 800;
  padding: 2px 0; color: #cbd5e1;
}
.result-list.two-col .col-head.chicken { color: #9be7ff; }
.result-list.two-col .col-head.cat { color: #ffd866; }
/* 拆家模式结算：基地剩余血量下面那行小字（本阵营成员击杀数之和） */
.result-list.two-col .col-sub {
  text-align: center; font-size: 11px; font-weight: 600;
  color: #93a4bb; margin-top: -3px;
}
.result-list.two-col .col-sub b { color: #fff; }
.result-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 5px 10px; border-radius: 8px;
  background: rgba(26, 36, 50, 0.9); font-size: 13px;
}
.result-row.mvp-row { border: 1px solid rgba(255, 210, 120, 0.7); background: rgba(70, 56, 24, 0.9); }
.result-row.empty { justify-content: center; color: #7c8aa0; background: rgba(26, 36, 50, 0.5); }
.result-row .nm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.result-row .nm img.av { width: 26px; height: 26px; object-fit: contain; }
.result-row .kd { color: #cbd5e1; white-space: nowrap; }
.result-row .kd b { color: #fff; }

/* ---------- 游戏说明 ---------- */
/* 登录页入口：登录背景是亮色插画，原来的青色小字看不清，改成深底胶囊按钮 */
.login-help {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin: 12px auto 0; padding: 9px 22px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.5px;
  color: #ffe9a3;
  background: rgba(10, 14, 22, 0.78);
  border: 1px solid rgba(255, 210, 120, 0.55);
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.login-help:hover, .login-help:active {
  color: #fff; background: rgba(26, 34, 48, 0.92);
  border-color: rgba(255, 225, 150, 0.9);
}
.icon-link {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; text-decoration: none;
  background: rgba(30, 42, 58, 0.9); border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 14px; line-height: 1;
}
.icon-link:hover { border-color: rgba(255, 210, 120, 0.55); }

.help-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.help-top h1 { margin: 0; }
.help-body { text-align: left; }
.help-body h3 { color: #ffe9b6; font-size: 15px; margin: 16px 0 8px; }
.help-body ul { margin: 0 0 4px 18px; }
.help-body li { font-size: 13px; color: #cbd5e1; line-height: 1.65; margin-bottom: 3px; }
.help-body b { color: #fff2cf; }
.help-note { font-size: 12px; color: #9fb0c6; margin: 4px 0 8px; line-height: 1.6; }
.help-factions { display: flex; gap: 10px; flex-wrap: wrap; }
.help-faction {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  background: rgba(26, 36, 50, 0.9); border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700; font-size: 14px;
}
.help-faction img { width: 34px; height: 34px; object-fit: contain; }
.help-char {
  display: flex; gap: 10px; align-items: center; text-align: left;
  padding: 8px 10px; border-radius: 12px; margin-bottom: 6px;
  background: rgba(26, 36, 50, 0.9); border: 1px solid rgba(255, 255, 255, 0.08);
}
.help-char > img.av { width: 52px; height: 52px; object-fit: contain; flex: 0 0 auto; }
.help-char-main { flex: 1 1 auto; min-width: 0; }
.help-char .nm { font-size: 14px; font-weight: 800; color: #ffe9b6; }
.help-char .nm .ti { font-size: 11px; font-weight: 400; color: #9fb0c6; margin-left: 8px; }
.help-char .sk { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.help-skill { display: flex; align-items: center; gap: 6px; max-width: 320px; }
.help-skill img { width: 30px; height: 30px; object-fit: contain; flex: 0 0 auto; }
.help-skill b { display: block; font-size: 12px; color: #eef2fb; }
.help-skill i { font-style: normal; font-size: 11px; color: #9fb0c6; line-height: 1.4; }
.help-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px;
  margin-bottom: 5px; background: rgba(26, 36, 50, 0.9);
}
.help-item img { width: 34px; height: 34px; object-fit: contain; flex: 0 0 auto; }
.help-item b { display: block; font-size: 13px; color: #ffe9b6; }
.help-item i { font-style: normal; font-size: 11px; color: #9fb0c6; }

/* 横屏提示 */
#rotate-gate {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: #080c12;
}
.rotate-card { text-align: center; color: #cbd5e1; }
.rotate-icon { font-size: 54px; margin-bottom: 12px; animation: rot 2s ease-in-out infinite; }
@keyframes rot { 0%,100% { transform: rotate(0); } 50% { transform: rotate(90deg); } }
.rotate-card h2 { color: #ffe9b6; margin-bottom: 6px; }
@media (orientation: portrait) and (pointer: coarse) {
  body.playing #rotate-gate { display: flex !important; }
}

/* Toast */
#toast {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  z-index: 50; padding: 10px 20px; border-radius: 999px;
  background: rgba(10, 14, 20, 0.92); border: 1px solid rgba(255, 210, 120, 0.4);
  color: #ffe9b6; font-size: 14px; pointer-events: none;
}

/* 小屏（横屏手机）压缩 HUD */
@media (max-height: 420px) {
  #me-avatar { width: 42px; height: 42px; }
  #me-hpwrap { width: 132px; }
  #minimap { width: 108px; height: 108px; }
  .stick { width: 124px; height: 124px; }
  .stick .knob { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
  .skill-btn { width: 68px; height: 68px; }
  #hud-timer { font-size: 20px; }
  .card { padding: 18px 16px; }
  .item-slot { width: 52px; height: 52px; border-radius: 12px; }
  .item-slot img { width: 40px; height: 40px; }
  #status-tags { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .tag { font-size: 11px; padding: 3px 9px; }
  #timestop-banner { font-size: 18px; }
  #final-countdown { font-size: clamp(64px, 20vh, 140px); top: 27%; }
  #ally-btn { width: 38px; height: 38px; font-size: 18px; }
  #auto-btn, #ai-btn { font-size: 11px; padding: 5px 8px; }
  /* 战况面板：矮屏压缩行高，尽量在一屏内放下 */
  #score-panel { padding: 4px 8px 6px; max-height: calc(100vh - 10px); }
  .sp-cols { margin-top: 4px; gap: 6px; }
  .sp-row { min-height: 24px; padding: 2px 6px; gap: 5px; }
  .sp-av { width: 20px; height: 20px; }
  .sp-name { font-size: 11px; }
  .sp-stats { font-size: 10px; }
  .sp-badge { font-size: 9px; margin-left: 4px; padding: 0 4px; }
}

/* ---------- 手机横屏（矮而宽）----------
   手机横屏可视高度只有 320~420px，房间页竖着排肯定显示不全，
   所以这里把房间 / 大厅 / 结算都改成左右两栏 + 全面瘦身。 */
@media (orientation: landscape) and (max-height: 560px) {
  .overlay {
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px))
             calc(8px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  }
  .card { padding: 12px 16px; border-radius: 18px; height: 100%; display: flex; flex-direction: column; }
  .card.wide { width: min(1040px, 100%); }
  .card h1 { font-size: 18px; margin-bottom: 2px; }
  .card h3 { font-size: 12px; margin: 8px 0 5px; }
  .card .sub { font-size: 11px; margin-bottom: 6px; }
  .hint { font-size: 11px; margin-top: 4px; }
  input { height: 38px; font-size: 14px; }
  .btn { height: 38px; font-size: 13px; padding: 0 16px; }
  .room-list { max-height: 152px; }
  .result-list { /* max-height: 126px; */ }
  .room-item { height: 48px; border-radius: 10px; }
  .player-item { padding: 5px 10px; font-size: 12px; }

  /* 房间页：竖排（顶栏 → 参战玩家 → 按钮）。卡片本身已是纵向 flex，
     所以列表用 flex:auto 撑满剩余高度，不再靠固定 max-height。 */
  #screen-room .card.wide > h3 { margin: 30px 0 5px; }
  #screen-room #room-players { /* max-height: 134px; */ }
  #screen-room .row.end { margin-top: 8px; justify-content: space-between; }

  .room-list.two-col { /* max-height: 152px; */ }
  .result-list.two-col { /* max-height: 126px; */ }
  .room-top { padding: 5px 10px; gap: 8px; }
  #my-avatar { width: 34px; height: 34px; }
  .room-hint { font-size: 12px; }

  /* 选角弹层在矮屏上收紧 */
  .popup { padding: 8px; }
  .popup-panel { padding: 12px 12px 10px; border-radius: 16px; }
  .popup-close { width: 28px; height: 28px; font-size: 13px; }
  .popup-body { gap: 10px; margin-top: 6px; }
  .faction-tab { width: 52px; padding: 6px 2px; font-size: 11px; }
  .faction-tab img { width: 32px; height: 32px; }
  .char-row { padding: 6px 8px; gap: 8px; }
  .char-row img.av { width: 36px; height: 36px; }
  .char-row .nm { font-size: 13px; }
  .char-row .sk div { width: 34px; }
  .char-row .sk img { width: 24px; height: 24px; }

  /* 大厅：表单一行 + 房间列表（列表吃满卡片剩余高度） */
  #screen-lobby .room-list.two-col { /* max-height: 220px; */ flex: auto; }

  /* 登录页在矮屏上收紧 */
  #screen-name .login-title { font-size: 24px; }
  #screen-name .login-panel { margin-bottom: 8vh; }
  #screen-name .login-form { padding: 10px; }
  #screen-name .login-form .btn.primary { height: 40px; }

  /* 数学关在矮屏上收紧：5 道题 + 提示 + 按钮必须一屏放得下（横屏只有 ~300px 高） */
  #screen-quiz .quiz-card { padding: 8px 14px 10px; }
  #screen-quiz .card h1 { font-size: 17px; margin-bottom: 0; }
  #screen-quiz .card .sub { margin-bottom: 2px; }
  .quiz-list { gap: 4px; margin-top: 4px; }
  .quiz-item { padding: 4px 8px; gap: 8px; border-radius: 10px; }
  .quiz-no { width: 20px; height: 20px; font-size: 11px; }
  .quiz-line { font-size: 13px; line-height: 1.32; gap: 6px; }
  .quiz-item .quiz-input { width: 54px; height: 26px; font-size: 13px; padding: 0 4px; }
  .quiz-tip { min-height: 14px; margin-top: 4px; font-size: 11px; }
  .quiz-actions { margin-top: 2px; }
  .quiz-actions .btn { height: 32px; }

  /* 结算：两列排行榜（满员 12 人 = 每阵营 6 行，列表按 6 行固定高度，不满员留白） */
  #screen-result .result-list.two-col { /* max-height: 228px; */ flex: auto; }
  #screen-result .result-row { padding: 7px 10px; font-size: 13px; }
  #screen-result .result-row .nm img.av { width: 22px; height: 22px; }
  #screen-result .result-top .btn { height: 28px; padding: 0 10px; font-size: 12px; }
  #screen-result .row.end { margin-top: 6px; justify-content: space-between; }
  /* 游戏说明：内容在卡片内部滚动 */
  #screen-help .help-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-top: 4px; }
  #screen-help .help-body h3 { font-size: 13px; margin: 10px 0 5px; }
  #screen-help .help-body li { font-size: 11px; }
  #screen-help .help-char { padding: 5px 8px; margin-bottom: 4px; }
  #screen-help .help-char > img.av { width: 38px; height: 38px; }
  #screen-help .help-skill img, #screen-help .help-item img { width: 26px; height: 26px; }
  #screen-help .help-item { padding: 4px 8px; margin-bottom: 3px; }
}

/* 窄屏（竖屏手机）：题目单列排布，避免一行里"题干 + 输入框"挤到换行 */
@media (max-width: 520px) {
  .quiz-list { grid-template-columns: 1fr; }
  .quiz-item:last-child:nth-child(odd) { grid-column: auto; }
}
