:root {
  --bg: #070b14;
  --panel: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.1);
  --text: #e9eefb;
  --muted: #8ea2c4;
  --gold: #ffd166;
  --red: #ef4444;
  --green: #22c55e;
  --blue: #3b82f6;
  --yellow: #f59e0b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(110% 60% at 50% -8%, #1b2a4d 0%, #0a1020 55%, #070b14 100%);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(6px + env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#hudTop,
#hudBottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}

/* ---------------- 棋盘 ---------------- */

#boardWrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

#boardViewport {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  display: grid;
  place-items: center;
}

#board {
  /* 绝对定位 + 自身 -50% 平移：放大到比视口大时也永远以视口中心为原点，
     这样 camApply 里 ±(尺寸-视口)/2 的夹取范围才是准的。
     （用 grid 的 place-items: center 不行：超尺寸的轨道会从左上角开始溢出） */
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  aspect-ratio: 1;
  transform-origin: center center;
  will-change: transform;
  filter: drop-shadow(0 14px 34px rgba(0, 0, 0, 0.55));
}

#boardSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.piece {
  position: absolute;
  width: 8.6%;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  transform: translate(-50%, -50%) scale(var(--s, 1));
  transition: left 0.1s linear, top 0.1s linear, transform 0.18s ease;
  pointer-events: auto;
  z-index: 6;
  border-radius: 50%;
  cursor: default;
}

.piece img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

.piece::before {
  content: none;
  position: absolute;
  inset: 19%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.9), transparent 46%),
    var(--c);
  border: 2px solid #ffffff;
  box-shadow:
    0 0 0 1.5px rgba(0, 0, 0, 0.42),
    0 3px 7px rgba(0, 0, 0, 0.35),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25);
}

.piece.mine {
  z-index: 7;
}

.piece.finished {
  opacity: 0.9;
}

.piece.pickable {
  cursor: pointer;
  z-index: 9;
  animation: bob 1s ease-in-out infinite;
}

.piece.pickable::before {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 0 16px rgba(255, 255, 255, 0.55);
}

.piece.targetable {
  cursor: pointer;
  z-index: 10;
}

.piece.targetable::before {
  box-shadow: 0 0 0 3px #ff5252, 0 0 18px rgba(255, 82, 82, 0.75);
  animation: blink 0.9s ease-in-out infinite;
}

.piece.reversed::after {
  content: "↩";
  position: absolute;
  top: -46%;
  right: -26%;
  font-size: 10px;
  line-height: 1;
  color: #67e8f9;
  text-shadow: 0 0 6px #000;
}

.piece.hit::before {
  animation: hit 0.6s ease;
}

/* 护盾卡：给这家的每架飞机套一个球罩（.bubble 平时 display:none） */
.piece .bubble {
  display: none;
  position: absolute;
  inset: -14%;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0.12) 26%, transparent 46%),
    radial-gradient(circle at 50% 55%, rgba(120, 200, 255, 0.22) 0%, rgba(90, 170, 255, 0.34) 62%, rgba(60, 130, 230, 0.5) 100%);
  border: 1.5px solid rgba(190, 230, 255, 0.9);
  box-shadow:
    0 0 12px rgba(120, 190, 255, 0.8),
    inset 0 0 10px rgba(210, 240, 255, 0.7);
  z-index: 2;
}
.piece.shielded .bubble {
  display: block;
  animation: shieldIn 0.45s cubic-bezier(0.2, 1.4, 0.5, 1);
}
/* 慢慢呼吸，看得出是"持续生效" */
.piece.shielded .bubble::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(140, 205, 255, 0.75);
  animation: shieldPulse 1.8s ease-in-out infinite;
}

@keyframes shieldIn {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes shieldPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@keyframes bob {
  0%, 100% { transform: translate(-50%, -50%) scale(var(--s, 1)); }
  50% { transform: translate(-50%, -62%) scale(calc(var(--s, 1) * 1.06)); }
}

@keyframes blink {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.55); }
}

@keyframes hit {
  0% { filter: brightness(3); transform: scale(1.25); }
  100% { filter: brightness(1); transform: scale(1); }
}

/* ---------------- 玩家卡片 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

.roundbadge {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.topbtns {
  display: flex;
  gap: 6px;
}

.icon-btn {
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.14);
}

.pcard {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  overflow: hidden;
}

.pcard::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c);
  opacity: 0.85;
}

.pcard.active {
  background: rgba(255, 255, 255, 0.085);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
}

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: rgba(255, 255, 255, 0.07);
}

.pmeta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pname {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pname .seat {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.prow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}

.pips {
  display: flex;
  gap: 4px;
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
}

.pip.on {
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
}

.tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.tag.six { background: rgba(245, 158, 11, 0.25); color: #fbbf24; }
.tag.breach { background: rgba(168, 85, 247, 0.25); color: #d8b4fe; }
.tag.skip { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }
.tag.rev { background: rgba(6, 182, 212, 0.25); color: #67e8f9; }
.tag.dark { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

.loglist {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 52dvh;
  overflow: auto;
}

.logrow {
  display: flex;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #cfd9ee;
}

.logrow .lr {
  flex: 0 0 auto;
  color: #7b8aa8;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 道具包 ---------------- */

.bagrow {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bag-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  padding: 0 2px;
}

.bag-label .mini {
  opacity: 0.7;
}

.bag {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.slot {
  position: relative;
  height: 54px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.025);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--muted);
  font: inherit;
  overflow: hidden;
  padding: 0;
}

.slot.filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}

.slot.filled::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c);
  opacity: 0.18;
}

.slot.filled::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--c);
  opacity: 0.9;
}

.slot.filled:disabled {
  opacity: 0.55;
}

.slot .ico,
.slot .nm {
  position: relative;
  z-index: 1;
}

.slot .ico {
  font-size: 18px;
  line-height: 1;
}

.slot .nm {
  font-size: 10px;
  opacity: 0.9;
}

/* ---------------- 操作区 ---------------- */

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dice {
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(160deg, #2a3859, #131d33);
  color: #dfe8ff;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.dice .face {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.dice .lbl {
  font-size: 10px;
  opacity: 0.75;
}

.dice.ready {
  background: linear-gradient(160deg, #ffd479, #df9a12);
  color: #33210a;
  box-shadow: 0 8px 26px rgba(223, 154, 18, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  animation: breathe 2s ease-in-out infinite;
}

.dice.ready:active {
  transform: scale(0.95);
}

.dice:disabled {
  opacity: 0.45;
}

.dice.rolling .face {
  animation: shake 0.12s linear infinite;
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 8px 26px rgba(223, 154, 18, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.55); }
  50% { box-shadow: 0 8px 34px rgba(223, 154, 18, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
}

@keyframes shake {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(1px, -1px) rotate(-6deg); }
  100% { transform: translate(-1px, 1px) rotate(6deg); }
}

.hintwrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  min-height: 36px;
  display: flex;
  align-items: center;
}

.cancel-btn {
  flex: 0 0 auto;
  font: inherit;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* ---------------- 弹层 ---------------- */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

#overlay.open {
  display: block;
}

#overlay .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.68);
  backdrop-filter: blur(3px);
}

#overlay .sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 520px;
  margin: 0 auto;
  max-height: 82dvh;
  overflow: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, #18213a, #0c1322);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.6);
  animation: sheetIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheetIn {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.stitle {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.sbody {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sbody p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #cfd9ee;
}

.detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
}

.dico {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: var(--c);
  opacity: 0.95;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.ddesc {
  text-align: center;
  font-size: 14px !important;
  color: var(--text) !important;
}

.dnote {
  font-size: 12px !important;
  color: var(--muted) !important;
  text-align: center;
}

.sheet-foot {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  flex: 1 1 0;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(160deg, #ffd479, #df9a12);
  color: #33210a;
  border-color: transparent;
}

.btn.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn.ghost {
  background: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.targets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.target {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  text-align: left;
}

.target .tico {
  font-size: 22px;
}

.target .ttxt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}

.target .ttxt b {
  font-size: 14px;
}

.target .ttxt small {
  font-size: 11px;
  color: var(--muted);
}

.target.bad {
  opacity: 0.42;
  border-style: dashed;
}

.tip {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  line-height: 1.65;
  color: #cfd9ee;
}

.rules p {
  font-size: 13px !important;
}

.rules b {
  color: var(--gold);
}

.win {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 0;
}

.wico {
  font-size: 44px;
}

.wtxt {
  font-size: 20px;
  font-weight: 800;
  color: var(--c);
}

.win small {
  color: var(--muted);
  font-size: 12px;
}

/* ---------------- 提示 ---------------- */

/* 3D 立体按钮：骰子（紫）/ 道具（蓝） */
#diceBtn {
  background: linear-gradient(180deg, #b07bff 0%, #7c3aed 55%, #5b21b6 100%);
  border: none;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  box-shadow:
    0 7px 0 #4c1d95,
    0 12px 20px rgba(0, 0, 0, 0.45),
    inset 0 2px 6px rgba(255, 255, 255, 0.35),
    inset 0 -3px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
#diceBtn:not([disabled]):active {
  transform: translateY(5px);
  box-shadow:
    0 2px 0 #4c1d95,
    0 6px 12px rgba(0, 0, 0, 0.4),
    inset 0 2px 6px rgba(255, 255, 255, 0.3);
}
#diceBtn .lbl { font-weight: 800; }
#diceBtn .face {
  color: #fff;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
#diceBtn[disabled] { filter: saturate(0.35) brightness(0.8); }

.bagrow .bag-label {
  background: linear-gradient(180deg, #6fb6ff 0%, #2f7dc4 60%, #1d5c96 100%);
  border: none;
  color: #fff;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  box-shadow:
    0 5px 0 #164a79,
    0 9px 14px rgba(0, 0, 0, 0.4),
    inset 0 2px 5px rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  padding: 8px 12px;
}

/* 骰子：屏幕正中悬浮 + 右侧投掷按钮 */
.diceCenter {
  position: fixed;
  left: 50%;
  top: calc(46% - 120px);
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 18px;
  z-index: 40;
  pointer-events: none;
}
.diceFace {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 54px;
  font-weight: 900;
  color: #1b1b1f;
  background: linear-gradient(180deg, #ffffff 0%, #e9e9ef 70%, #cfcfd8 100%);
  box-shadow:
    0 8px 0 #a9a9b8,
    0 16px 26px rgba(0, 0, 0, 0.45),
    inset 0 3px 8px rgba(255, 255, 255, 0.9),
    inset 0 -4px 10px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  user-select: none;
}
.diceFace.has { animation: dicePop 0.28s ease; }
.diceFace.rolling { animation: diceShake 0.16s linear infinite; }
@keyframes diceShake {
  0% { transform: rotate(-7deg) scale(0.98); }
  50% { transform: rotate(7deg) scale(1.03); }
  100% { transform: rotate(-7deg) scale(0.98); }
}
@keyframes dicePop {
  0% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.rollBtn {
  pointer-events: auto;
  min-width: 132px;
  padding: 16px 22px;
  border-radius: 16px;
  font-size: 22px;
}
@media (max-width: 480px) {
  .diceFace { width: 78px; height: 78px; font-size: 44px; }
  .rollBtn { min-width: 108px; padding: 13px 18px; font-size: 19px; }
}

/* 弹窗关闭按钮 */
.sheet { position: relative; }
.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sheet-close:active { transform: scale(0.92); }

/* 提示框：屏幕中间白色框 + 黑色粗体字 */
#toast {
  position: fixed;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%) scale(0.94);
  padding: 18px 26px;
  border-radius: 14px;
  background: #ffffff;
  color: #111111;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  width: max-content;
  max-width: 86vw;
  height: auto;
  min-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* 精简 HUD：上下栏透明，不占视觉 */
#hudTop, #hudBottom {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: none;
  padding: 0;
  z-index: 30;
}

/* 道具按钮：右上角蓝色立体 */
/* 选项按钮：挂在道具按钮下面 */
.menuBtn {
  position: fixed;
  right: 18px;
  top: 86px;
  z-index: 999;
  min-width: 96px;
  padding: 11px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(12, 26, 52, 0.72);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer;
}
.menuBtn:active { transform: translateY(2px); }

/* 选项弹窗（屏幕中间，蓝色） */
.optMask {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 10, 26, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.optCard {
  width: min(86vw, 340px);
  padding: 22px 20px 18px;
  border-radius: 24px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(180deg, #3d7bf7 0%, #2455c8 45%, #16318a 100%);
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(120, 180, 255, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: optPop 0.18s ease-out;
}
@keyframes optPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.optTitle {
  text-align: center;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.16em;
  margin: 2px 0 16px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.optBtn {
  width: 100%;
  margin-top: 10px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease;
}
.optBtn:hover { background: rgba(255, 255, 255, 0.24); }
.optBtn .state {
  min-width: 34px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.optBtn.danger {
  justify-content: center;
  background: linear-gradient(180deg, #ff6b6b 0%, #d92b2b 100%);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 0 #8f1414, 0 10px 18px rgba(0, 0, 0, 0.3);
}
.optBtn.danger:active { transform: translateY(3px); box-shadow: 0 3px 0 #8f1414; }
.optBtn.ghost {
  justify-content: center;
  margin-top: 14px;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  font-weight: 600;
}

/* 规则弹窗：同一张蓝卡片，但是大一号、正文可滚动 */
.rulesMask { z-index: 1300; }
.optCard.big {
  width: min(92vw, 430px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  padding: 20px 18px 16px;
}
.optClose {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.optCard { position: relative; }
.rulesBody {
  flex: 1 1 auto;
  min-height: 0; /* 不加这条，flex 子项撑不开滚动区 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 2px 0 4px;
  padding-right: 6px;
  font-size: 13.5px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.94);
}
.rulesBody p { margin: 0 0 9px; }
.rulesBody b { color: #ffffff; font-weight: 900; }
.rulesBody::-webkit-scrollbar { width: 4px; }
.rulesBody::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.35); border-radius: 4px; }

.itemBtn {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 999;
  min-width: 96px;
  padding: 14px 18px;
  border-radius: 16px;
  border: none;
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  background: linear-gradient(180deg, #6fb6ff 0%, #2f7dc4 55%, #1b5a92 100%);
  box-shadow:
    0 6px 0 #14456e,
    0 11px 18px rgba(0, 0, 0, 0.45),
    inset 0 2px 6px rgba(255, 255, 255, 0.4),
    inset 0 -3px 8px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  cursor: pointer;
}
.itemBtn:not([disabled]):active { transform: translateY(4px); box-shadow: 0 2px 0 #14456e, 0 6px 12px rgba(0,0,0,0.4); }
.itemBtn[disabled] { filter: saturate(0.3) brightness(0.75); }

/* 取消选择按钮 */
.cancel-btn {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-weight: 800;
  font-size: 16px;
  pointer-events: auto;
}

/* 道具包弹窗 */
.baggrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.bagcell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(180deg, #ffffff 0%, #e8e8f0 100%);
  color: #14141a;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 0 #b9b9c8, 0 8px 14px rgba(0, 0, 0, 0.35);
}
.bagcell:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9b9c8; }
.bagcell .bico { font-size: 22px; }

/* 回合提示条（不可关闭） */
.turnNotice {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%) translateY(-8px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 14, 24, 0.86);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
}
.turnNotice.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 30 秒倒计时 */
.cdTimer {
  position: fixed;
  left: calc(50% + 62px);
  top: calc(46% - 120px + 39px);
  transform: translateX(-50%);
  min-width: 54px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 45;
}
.cdTimer.show { opacity: 1; }
.cdTimer.urgent { color: #e23a35; animation: cdPulse 0.8s ease infinite; }
@keyframes cdPulse { 0%,100%{ transform: translateX(-50%) scale(1);} 50%{ transform: translateX(-50%) scale(1.12);} }

/* 叠机数量徽标：贴在棋子右下角的小胶囊（以前用大字+白描边，会糊成一大块白斑） */
.piece[data-stack]::after {
  content: attr(data-stack);
  position: absolute;
  right: -8%;
  bottom: 0;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.3;
  padding: 0 5px;
  border-radius: 999px;
  color: #fff;
  background: rgba(10, 18, 34, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.85);
  text-shadow: none;
  pointer-events: none;
  z-index: 3;
  white-space: nowrap;
}

/* ================= 首页 / 大厅 / 房间（带背景、有质感） ================= */
#pages { display: none; }
#pages.open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 900;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #0d1b2a;
}

/* 首页：铺满背景图 */
#pages.page-splash.open {
  background: url('./pictureModel/splash.jpg') center center / cover no-repeat;
}

/* 大厅 / 房间：同一张背景 + 柔化遮罩 */
#pages.page-lobby.open,
#pages.page-room.open {
  background:
    linear-gradient(180deg, rgba(12, 22, 36, 0.35), rgba(12, 22, 36, 0.72)),
    url('./pictureModel/splash.jpg') center center / cover no-repeat;
}

.splashWrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 0 24px calc(64px + env(safe-area-inset-bottom));
}
.splashTitle {
  position: absolute;
  top: calc(22px + env(safe-area-inset-top));
  left: 22px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(0, 0, 0, 0.4);
}

/* 通用大按钮：彩色渐变 + 3D */
.bigBtn {
  min-width: 250px;
  padding: 18px 28px;
  border-radius: 20px;
  border: none;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  background: linear-gradient(180deg, #ffb347 0%, #f5851f 55%, #d96a0b 100%);
  box-shadow:
    0 8px 0 #a94f05,
    0 14px 24px rgba(0, 0, 0, 0.45),
    inset 0 2px 8px rgba(255, 255, 255, 0.45),
    inset 0 -4px 10px rgba(0, 0, 0, 0.22);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.bigBtn:not([disabled]):active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #a94f05, 0 6px 12px rgba(0, 0, 0, 0.4);
}
.bigBtn[disabled] { opacity: 0.55; }
.bigBtn.ghost {
  background: linear-gradient(180deg, #9fb3c8 0%, #6b7f95 60%, #4d5f73 100%);
  box-shadow:
    0 8px 0 #3a4a5c,
    0 14px 24px rgba(0, 0, 0, 0.45),
    inset 0 2px 8px rgba(255, 255, 255, 0.35);
}

/* 进度条 */
.loading { display: none; width: 250px; }
.loading.show { display: block; }
.loading .bar {
  height: 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.loading .fill {
  height: 100%;
  width: 0;
  border-radius: 10px;
  background: linear-gradient(90deg, #ffd76e, #ff9f1a);
  box-shadow: 0 0 12px rgba(255, 190, 80, 0.8);
  transition: width 0.28s ease;
}
.loading .pct {
  margin-top: 8px;
  text-align: center;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* 大厅 */
.lobbyWrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 42px;
  padding: calc(28px + env(safe-area-inset-top)) 24px 40px;
}
.lobbyTitle {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.7), 0 2px 0 rgba(0, 0, 0, 0.4);
  align-self: flex-start;
  margin-bottom: 8px;
}

/* 房间 */
.roomWrap {
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100dvh;
}
.roomTitle {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
}
.seatCard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border-left: 8px solid var(--seat, #fff);
}
.seatCard.off { opacity: 0.6; }
.seatImg { width: 88px; height: 88px; object-fit: contain; flex: 0 0 auto; }
.seatInfo { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; }
.seatLine { display: flex; align-items: center; gap: 10px; }
.seatName { font-size: 21px; font-weight: 900; color: #14141a; }
.seatState { font-size: 18px; font-weight: 800; color: #5b6472; }
.seatTeam { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; color: #14141a; }
.seatTeam select {
  flex: 1;
  padding: 7px 10px;
  border: 2px solid #d5d9e0;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 800;
  background: #f7f8fa;
}
.miniBtn {
  align-self: flex-start;
  padding: 8px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #6fb6ff, #2f7dc4);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 4px 0 #1d5c96, 0 6px 12px rgba(0, 0, 0, 0.3);
}
.miniBtn.ghost {
  background: linear-gradient(180deg, #f0a4a0, #d0564f);
  box-shadow: 0 4px 0 #9c3b35, 0 6px 12px rgba(0, 0, 0, 0.3);
}
.miniBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }

.roomFoot { display: flex; gap: 12px; margin-top: 4px; }
.roomFoot .bigBtn { flex: 1; min-width: 0; font-size: 22px; padding: 16px 10px; }
.roomHint {
  text-align: center;
  color: #ffe08a;
  font-weight: 800;
  min-height: 22px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* 邀请弹窗 */
.modalMask {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(6, 12, 22, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modalCard {
  position: relative;
  width: min(340px, 92vw);
  padding: 22px 20px 18px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.modalClose {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #eef0f4;
  color: #333;
  font-size: 16px;
  font-weight: 800;
}
.modalTitle { font-size: 19px; font-weight: 900; color: #14141a; margin-bottom: 14px; }
.qrBox { display: grid; place-items: center; margin-bottom: 12px; }
.qrBox canvas { width: 210px; height: 210px; border-radius: 10px; }
.roomCode { font-size: 17px; font-weight: 800; color: #14141a; }
.roomCode b { letter-spacing: 0.12em; }
/* 邀请弹窗里的大号房间码（扫码去掉之后，就靠它报数） */
.roomCodeBig {
  margin: 4px 0 14px;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-align: center;
  color: #14141a;
  font-variant-numeric: tabular-nums;
}
.modalTip { margin-top: 10px; font-size: 13px; color: #6b7280; line-height: 1.5; }

/* 扫码页 */
.joinWrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: #0b1220;
  padding: 20px;
}
/* 加入房间页底部的说明条 */
.joinHint {
  margin-top: 4px;
  max-width: min(88vw, 420px);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(8, 16, 28, 0.5);
  color: #fff;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.joinHint span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}
#joinVideo {
  width: min(86vw, 420px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 18px;
  background: #000;
}
.scanFrame {
  width: min(62vw, 260px);
  aspect-ratio: 1;
  border: 3px solid #ffd76e;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  margin-top: -46vh;
  pointer-events: none;
}
.joinTip { color: #fff; font-weight: 700; text-align: center; }

/* 页面打开时隐藏道具按钮 */
body.pages-open #itemBtn { display: none !important; }

/* 房间内容整体下移 120px */
.roomWrap { padding-top: calc(140px + env(safe-area-inset-top)) !important; }

.joinCode { display: flex; gap: 10px; align-items: center; }
.joinCode input {
  width: 180px; padding: 12px 14px; border-radius: 12px; border: none;
  font-size: 22px; font-weight: 800; letter-spacing: .2em; text-align: center;
}

/* 加入房间页 */
.joinWrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(12, 22, 36, 0.35), rgba(12, 22, 36, 0.72)),
    url('./pictureModel/splash.jpg') center center / cover no-repeat;
}
.joinTitle {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  margin-bottom: 8px;
}
.joinCard {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 14px;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}
.joinCard input {
  width: 170px;
  padding: 14px 12px;
  border: 2px solid #d5d9e0;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-align: center;
  background: #f7f8fa;
}
.joinCard .bigBtn { min-width: 120px; font-size: 22px; padding: 14px 18px; }
.scanBtn { background: linear-gradient(180deg, #6fb6ff, #2f7dc4 55%, #1b5a92); box-shadow: 0 8px 0 #14456e, 0 14px 24px rgba(0,0,0,.45), inset 0 2px 8px rgba(255,255,255,.4); }

.scanLayer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 960;
  background: #0b1220;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
}
.scanLayer.show { display: flex; }
.scanLayer #joinVideo {
  width: min(86vw, 420px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 18px;
  background: #000;
}
.scanLayer .scanFrame {
  position: absolute;
  width: min(62vw, 260px);
  aspect-ratio: 1;
  border: 3px solid #ffd76e;
  border-radius: 16px;
}
.scanLayer .joinTip {
  position: absolute;
  bottom: 130px;
  color: #fff;
  font-weight: 700;
  text-align: center;
  padding: 0 20px;
}
.scanLayer .bigBtn { position: absolute; bottom: 60px; }

.netDebug {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 9999;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #7CFC00;
  font: 12px/1.4 monospace;
  pointer-events: none;
  max-width: 92vw;
}
