* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:root {
  --bg: #0c0a11;
  --panel: #16131d;
  --panel-2: #1e1a28;
  --line: #2b2536;
  --text: #ece7f5;
  --dim: #9a92ab;
  --live: #e5484d;
  --blank: #6ea8fe;
  --gold: #e8b13a;
  --ok: #46c98b;
}
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh; min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
}
.screen { max-width: 520px; margin: 0 auto; padding: 14px 14px 28px; }
h1 { font-size: 26px; margin: 6px 0 4px; letter-spacing: 1px; }
.sub { color: var(--dim); font-size: 13px; margin: 0 0 18px; line-height: 1.6; }
.logo { font-size: 44px; text-align: center; margin-top: 24px; }

/* ---- 通用控件 ---- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #8b1f28, #5d1219); border-color: #a3303c; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; margin-bottom: 14px; }
.btn:disabled { opacity: .38; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; }
input {
  width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 13px 14px; font-size: 16px; font-family: inherit; outline: none;
}
input:focus { border-color: #4b3f63; }
.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }
.msg { color: var(--dim); font-size: 13px; min-height: 18px; line-height: 1.6; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
.ghost { background: transparent; }
.rejoin { width: 100%; margin-bottom: 10px; color: var(--gold); border-color: #6a5320; }
.topbar { display: flex; align-items: center; justify-content: space-between; color: var(--dim); font-size: 12px; padding: 2px 6px 8px; }
.topbar b { color: var(--gold); letter-spacing: 3px; font-size: 15px; }
.linkbtn { background: none; border: none; color: var(--dim); font-size: 12px; font-family: inherit; text-decoration: underline; cursor: pointer; padding: 4px; }
@keyframes pulse { 0%,100% { opacity: .45 } 50% { opacity: 1 } }

/* ---- 房间码 ---- */
.code-big { font-size: 44px; font-weight: 800; letter-spacing: 10px; text-align: center; color: var(--gold); margin: 10px 0; padding-left: 10px; }
.share { display: flex; gap: 8px; margin-bottom: 10px; }
.share input { font-size: 12px; color: var(--dim); }

/* ---- 规则 ---- */
.rules { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.rules summary { color: var(--dim); font-size: 13px; cursor: pointer; }
.rules-body { color: var(--dim); font-size: 13px; line-height: 1.8; }
.rules-body b { color: var(--text); }

/* ---- 面板 ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.panel h2 { font-size: 15px; margin: 0 0 10px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.who { font-size: 16px; font-weight: 700; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.tag.warn { color: #ffb4b8; border-color: #6d2a30; background: #2a1216; }
.tag.gold { color: var(--gold); border-color: #6a5320; background: #2a2210; }
.tag.ok { color: var(--ok); border-color: #245742; background: #10241c; }

/* ---- 生命 ---- */
.hp { display: flex; gap: 4px; }
.hp i { width: 16px; height: 16px; border-radius: 50%; background: linear-gradient(180deg, #4bd18f, #1f9e6a); box-shadow: 0 0 6px #1f9e6a66; display: inline-block; }
.hp i.off { background: #2a2536; box-shadow: none; }
.hp i.cut { background: linear-gradient(180deg, #ff7a7a, #b3262c); box-shadow: 0 0 6px #b3262c66; }

/* ---- 道具 ---- */
.items { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.item {
  width: 52px; height: 60px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: inherit; color: var(--text); cursor: pointer; padding: 2px;
}
.item .ico { font-size: 20px; }
.item .nm { font-size: 9px; color: var(--dim); }
.item:disabled { opacity: .4; }
.item.static { cursor: default; }
.empty { color: var(--dim); font-size: 12px; margin-top: 10px; }

/* ---- 枪 ---- */
.gun .shells { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.shell { width: 14px; height: 26px; border-radius: 3px; background: #2a2536; border: 1px solid #3a3348; }
.shell.live { background: linear-gradient(180deg, #ff5a60, #b3262c); border-color: #ff8a8f; }
.shell.blank { background: linear-gradient(180deg, #7fb4ff, #3b6fd4); border-color: #a8ccff; }
.shell.spent { opacity: .22; }
.gun .meta { font-size: 12px; color: var(--dim); line-height: 1.7; }
.intel { margin-top: 10px; font-size: 13px; padding: 9px 12px; border-radius: 10px; background: #12211c; border: 1px solid #245742; color: #a9f0cd; }
.intel.hot { background: #2a1216; border-color: #6d2a30; color: #ffc2c5; }
.turnbar { text-align: center; font-size: 14px; font-weight: 700; padding: 8px; border-radius: 10px; margin-bottom: 10px; }
.turnbar.mine { background: #14301f; color: #8ef0b8; border: 1px solid #245742; }
.turnbar.theirs { background: #1a1722; color: var(--dim); border: 1px solid var(--line); }

/* ---- 操作 ---- */
.actions { display: flex; gap: 10px; background: none; border: none; padding: 0; }
.actions .btn { flex: 1; padding: 18px 8px; font-size: 16px; }
.actions .btn.shoot-opp { background: linear-gradient(180deg, #8b1f28, #5d1219); border-color: #a3303c; }
.actions .btn.shoot-self { background: linear-gradient(180deg, #2b3350, #1a2036); border-color: #3c496e; }

/* ---- 日志 ---- */
.logwrap summary { color: var(--dim); font-size: 13px; cursor: pointer; }
.log { margin-top: 10px; max-height: 190px; overflow-y: auto; font-size: 12.5px; line-height: 1.9; color: var(--dim); }
.log div { border-bottom: 1px dashed #241f31; padding: 2px 0; }
.log .live { color: #ff9ba0; }
.log .blank { color: #a8ccff; }
.log .item { color: #d9c9ff; }
.log .warning { color: #ffcf7a; }
.log .end { color: var(--gold); font-weight: 700; }
.log .load { color: #8ef0b8; }
.log .chat { color: #ffd479; }

/* ---- 提示 ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #2a1216; border: 1px solid #6d2a30; color: #ffc2c5;
  padding: 10px 16px; border-radius: 12px; font-size: 13px; z-index: 60; max-width: 90vw;
}
.banner {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%);
  background: #14301f; border: 1px solid #245742; color: #8ef0b8;
  padding: 9px 16px; border-radius: 999px; font-size: 13px; z-index: 55;
}
.overlay {
  position: fixed; inset: 0; background: #000000cc; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; max-width: 420px; width: 100%; text-align: center; }
.card h2 { margin: 0 0 6px; font-size: 21px; }
.card p { color: var(--dim); font-size: 14px; line-height: 1.7; }
.card .btn { width: 100%; margin-top: 12px; }
.pick-list { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

/* ================= 对战角色（SVG + 动画） ================= */
.fighter { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.fighter .avatar { width: 104px; height: 120px; flex: 0 0 104px; position: relative; }
.fighter .avatar svg { width: 100%; height: 100%; display: block; overflow: visible; animation: breathe 3.4s ease-in-out infinite; transform-origin: 50% 92%; }
.avatar .body { transform-box: fill-box; transform-origin: 50% 50%; }
.avatar.mirror .body { transform: scaleX(-1); }
.avatar .collar { fill: #3a3153; }
.fighter .pinfo { flex: 1; min-width: 0; }
@keyframes breathe { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-3px) } }

.avatar .cloak { fill: #221d30; }
.avatar .hood { fill: #2d2740; }
.avatar .face { fill: #0b0910; }
.avatar .horn { fill: #3b3357; }
.avatar .eye { fill: #ff5d4a; animation: eyePulse 2.6s ease-in-out infinite; }
.avatar .sleeve { stroke: #221d30; stroke-width: 10; stroke-linecap: round; fill: none; }
.avatar .gun rect, .avatar .gun circle, .avatar .gun path { fill: #5b5570; }
.avatar .mouth { stroke: #4a4266; stroke-width: 2; fill: none; }
@keyframes eyePulse { 0%, 100% { opacity: .68 } 50% { opacity: 1 } }

.avatar.p2 .eye { fill: #6db4ff; }
.avatar.p2 .horn { fill: #33415f; }
.avatar.p2 .cloak { fill: #1d2436; }
.avatar.p2 .hood { fill: #263049; }
.avatar.p2 .sleeve { stroke: #1d2436; }

.avatar.dead { opacity: .3; filter: grayscale(.7); }
.avatar.dead svg { animation: none; }
.avatar.cut .eye { fill: #ff2b2b; animation-duration: .7s; }
.avatar.cut::after {
  content: '⚡'; position: absolute; right: 4px; top: 2px; font-size: 18px;
  animation: eyePulse .8s ease-in-out infinite;
}
.avatar.cuffed::after {
  content: '⛓️'; position: absolute; left: 2px; bottom: 6px; font-size: 20px;
  transition: transform .2s;
}
.avatar .flash { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, #ff4d4dcc, transparent 68%); opacity: 0; pointer-events: none; }
.hit { animation: hitShake .42s cubic-bezier(.36,.07,.19,.97); }
.avatar.laughing .eye { animation: eyeSquint .34s ease-in-out 3; }
@keyframes eyeSquint { 0%,100% { transform: scaleY(1) } 50% { transform: scaleY(.25) } }
.avatar.laughing .mouth { stroke: #ff8a8f; stroke-width: 3; }
@keyframes hitShake {
  0%, 100% { transform: translateX(0) }
  15% { transform: translateX(-7px) rotate(-3deg) }
  35% { transform: translateX(6px) rotate(3deg) }
  55% { transform: translateX(-4px) }
  75% { transform: translateX(3px) }
}

/* ================= 左轮 + 枪口火光 ================= */
.gunrow { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; }
.gunwrap { position: relative; flex: 0 0 132px; }
.revolver { width: 132px; height: 64px; display: block; }
.revolver .barrel { fill: #4a4459; }
.revolver .cylinder { fill: #3a3448; }
.revolver .cyln { fill: #211d2c; }
.revolver .grip { fill: #4a3428; }
.revolver .trigger { stroke: #3a3448; stroke-width: 4; fill: none; }
.revolver .pin { fill: #6a6280; }
.revolver.sawed .barrel { fill: #6b4a3a; }
.muzzle {
  position: absolute; left: 98px; top: 32px; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  background: radial-gradient(circle, #fff 0%, #ffd24a 22%, #ff7a1a 46%, #ff3b1a80 65%, transparent 72%);
  border-radius: 50%; opacity: 0; pointer-events: none;
}
.shake { animation: tableShake .34s cubic-bezier(.36,.07,.19,.97); }
@keyframes tableShake {
  0%, 100% { transform: translate3d(0,0,0) }
  20% { transform: translate3d(-6px, 4px, 0) }
  45% { transform: translate3d(5px, -3px, 0) }
  70% { transform: translate3d(-3px, 2px, 0) }
}

/* ================= 特效层 ================= */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 56; overflow: hidden; }
.fxitem { position: fixed; font-size: 54px; line-height: 1; transform: translate(-50%, -50%); text-shadow: 0 0 18px #000; }
.fxnum { position: fixed; font-size: 40px; font-weight: 800; transform: translate(-50%, -50%); text-shadow: 0 2px 10px #000; }
.fxnum.dmg { color: #ff5f5f; }
.fxnum.heal { color: #4be09a; }
.fxcap {
  position: fixed; left: 50%; top: 27%; transform: translate(-50%, -50%);
  background: #16131df2; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 15px; font-size: 13.5px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 6px 22px #000a;
}
.casing {
  position: fixed; width: 5px; height: 12px; border-radius: 2px;
  background: linear-gradient(180deg, #d8b25a, #8a6c22);
}

/* ================= 矮屏（iPhone SE 等）压缩排版，尽量一屏放下 ================= */
@media (max-height: 720px) {
  .screen { padding-top: 8px; padding-bottom: 16px; }
  .panel { padding: 11px; margin-bottom: 8px; border-radius: 14px; }
  .fighter .avatar { width: 78px; height: 90px; flex: 0 0 78px; }
  .item { width: 46px; height: 54px; }
  .item .ico { font-size: 18px; }
  .item .nm { font-size: 8.5px; }
  .gunrow { margin: 2px 0 6px; gap: 8px; }
  .gunwrap { flex: 0 0 108px; }
  .revolver { width: 108px; height: 52px; }
  .muzzle { left: 79px; top: 27px; }
  .actions .btn { padding: 14px 8px; font-size: 15px; }
  .turnbar { padding: 6px; font-size: 13px; margin-bottom: 6px; }
  .items { gap: 6px; margin-top: 8px; }
}

/* ================= 炸弹特效 ================= */
.fxbomb { position: fixed; font-size: 92px; line-height: 1; transform: translate(-50%, -50%); }
.fxflash { position: fixed; inset: 0; background: radial-gradient(circle, #fff6d5cc 0%, #ff8a1a66 45%, transparent 72%); }

/* ================= 漫画对话框 ================= */
.bubble {
  position: fixed; max-width: 210px; padding: 9px 13px;
  background: #fff; color: #1a1520;
  font-size: 15px; font-weight: 800; line-height: 1.35; letter-spacing: .5px;
  border: 3px solid #1a1520; border-radius: 15px;
  box-shadow: 3px 4px 0 #1a1520aa, 0 8px 22px #000a;
  word-break: break-word;
}
.bubble::after {
  content: ''; position: absolute; left: -12px; bottom: 12px;
  border: 7px solid transparent; border-right-color: #1a1520;
}
.bubble::before {
  content: ''; position: absolute; left: -7px; bottom: 13px; z-index: 1;
  border: 6px solid transparent; border-right-color: #fff;
}

/* 对话列表 */
.chat-list { display: flex; flex-direction: column; gap: 9px; margin: 14px 0 4px; }
.chat-item {
  font-family: inherit; font-size: 16px; font-weight: 700; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; cursor: pointer;
}
.chat-item:active { transform: scale(.97); }

/* 昵称违规提示 */
input.bad { border-color: #a3303c !important; background: #2a121633; }

/* ================= 大厅：房间人数选择 ================= */
.sizepick { display: flex; gap: 10px; margin-bottom: 14px; }
.sizebtn {
  flex: 1; font-family: inherit; font-size: 15px; font-weight: 700; color: var(--dim);
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 13px 8px; cursor: pointer;
}
.sizebtn.active { color: var(--gold); border-color: var(--gold); background: #2a2210; }

/* ================= 回合中的金色边框 ================= */
.panel.turn { border-color: var(--gold); box-shadow: 0 0 0 2px #e8b13a44, 0 0 18px #e8b13a2e; }
.avatar.turn svg { filter: drop-shadow(0 0 7px #e8b13a); }
.turnflag { font-size: 11px; font-weight: 800; color: #1a1520; background: var(--gold); padding: 2px 8px; border-radius: 999px; }

/* 三人局：两个对手「横向并排」（各占一半宽），卡片内部是紧凑的纵向人物卡 */
#oppArea { display: flex; gap: 8px; align-items: stretch; }
#oppArea > .panel { flex: 1 1 0; min-width: 0; }
.panel.fighter.compact { flex-direction: column; align-items: stretch; padding: 7px 7px 9px; margin-bottom: 8px; }
.panel.fighter.compact .avatar { width: 52px; height: 60px; flex: 0 0 auto; margin: 0 auto 1px; }
.panel.fighter.compact .pinfo { width: 100%; }
.panel.fighter.compact .item { width: 34px; height: 40px; }
.panel.fighter.compact .item .ico { font-size: 15px; }
.panel.fighter.compact .item .nm { font-size: 7px; }
.panel.fighter.compact .items { margin-top: 4px; gap: 5px; }
.panel.fighter.compact .who { font-size: 14px; }
.panel.fighter.compact .hp i { width: 12px; height: 12px; }
.panel.fighter.compact .tag, .panel.fighter.compact .outtag, .panel.fighter.compact .turnflag { font-size: 10px; padding: 2px 6px; }
.panel.fighter.compact .empty { font-size: 11px; }
/* 纵向卡片内部居中，视觉更像一张"人物卡" */
.panel.fighter.compact .pinfo { text-align: center; }
.panel.fighter.compact .pinfo .row { justify-content: center; gap: 8px; }
.panel.fighter.compact .items { justify-content: center; }
/* 矮屏再缩一点，保证牌桌主体不被挤出屏幕 */
@media (max-height: 720px) {
  .panel.fighter.compact { padding: 5px 6px 6px; margin-bottom: 6px; }
  .panel.fighter.compact .avatar { width: 44px; height: 50px; }
  .panel.fighter.compact .item { width: 31px; height: 35px; }
  .panel.fighter.compact .item .ico { font-size: 13px; }
  .panel.fighter.compact .hp i { width: 11px; height: 11px; }
}

/* 出局（死人）样式 */
.avatar.dead { opacity: .3; filter: grayscale(.7); }
.outtag { font-size: 11px; font-weight: 800; color: #ffb4b8; background: #2a1216; border: 1px solid #6d2a30; padding: 2px 8px; border-radius: 999px; }

/* 行动按钮换成多目标时自动换行 */
.actions { flex-wrap: wrap; }
.actions .btn { min-width: 46%; }

/* 直连 / 中转 状态标签 */
.linkchip { font-size: 10px; font-weight: 700; color: #d8c98a; background: #2a2210; border: 1px solid #6a5320; padding: 1px 6px; border-radius: 999px; margin-left: 4px; }
.linkchip.direct { color: #8ef0b8; background: #10241c; border-color: #245742; }
