/* ═══════════ 好坏大作战 ═══════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --good: #f5b21a;
  --bad: #c0392b;
  --neutral: #6c4fb5;
  --ink: #1c1c1c;
  --paper: #f7f2e7;
  --paper2: #fffdf6;
}

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #232323;
  background-image: radial-gradient(circle at 20% 20%, #2e2e2e 0, #1d1d1d 70%);
  color: var(--ink);
  overflow: hidden;
}

.hidden { display: none !important; }

.screen { height: 100vh; width: 100vw; overflow: auto; }

/* ─────── 标题页 ─────── */
#screen-title { display: flex; align-items: center; justify-content: center; }
.title-box {
  text-align: center; background: var(--paper); padding: 56px 72px;
  border-radius: 24px; border: 5px solid var(--ink);
  box-shadow: 10px 12px 0 rgba(0,0,0,.45);
  transform: rotate(-1deg);
}
.game-title {
  font-size: 64px; letter-spacing: 10px; margin-bottom: 10px;
  text-shadow: 3px 3px 0 var(--good);
}
.game-subtitle { font-size: 17px; color: #666; margin-bottom: 18px; }
.title-factions { margin-bottom: 30px; }

.badge {
  display: inline-block; padding: 4px 14px; border-radius: 999px;
  color: #fff; font-weight: bold; font-size: 15px; margin: 0 6px;
  border: 2px solid var(--ink);
}
.badge-good { background: var(--good); }
.badge-bad { background: var(--bad); }
.badge-neutral { background: var(--neutral); }
.badge-sm { font-size: 12px; padding: 1px 8px; margin: 0; }

.big-btn {
  display: block; width: 100%; margin: 12px auto 0; padding: 14px 30px;
  font-size: 20px; font-weight: bold; font-family: inherit;
  background: var(--good); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 14px; cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0,0,0,.35);
  transition: transform .08s;
}
.big-btn:hover { transform: translate(-1px,-1px); }
.big-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.big-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-outline { background: var(--paper2); }

/* ─────── 选人页 ─────── */
#screen-setup { padding: 30px 40px; }
.setup-head { text-align: center; color: #fff; margin-bottom: 22px; }
.setup-head h2 { font-size: 32px; letter-spacing: 3px; }
.setup-head p { color: #bbb; margin-top: 6px; font-size: 16px; min-height: 22px; }

.count-row { display: flex; gap: 18px; justify-content: center; margin-top: 40px; }
.count-btn {
  width: 110px; height: 110px; font-size: 26px; font-weight: bold; font-family: inherit;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 20px;
  cursor: pointer; box-shadow: 5px 5px 0 rgba(0,0,0,.4);
}
.count-btn:hover { background: var(--good); }

.char-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; max-width: 1250px; margin: 0 auto; padding-bottom: 40px;
}
.char-card {
  background: var(--paper2); border: 3px solid var(--ink); border-radius: 14px;
  overflow: hidden; cursor: pointer; position: relative;
  transition: transform .1s; box-shadow: 4px 4px 0 rgba(0,0,0,.4);
}
.char-card:hover { transform: translateY(-4px) rotate(-.5deg); }
.char-card.taken { opacity: .35; pointer-events: none; }
.char-card img { width: 100%; height: 210px; object-fit: cover; display: block; }
.char-card .cc-body { padding: 10px 12px 12px; }
.char-card .cc-name { font-size: 18px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; }
.char-card .cc-skills { font-size: 12px; color: #555; margin-top: 6px; line-height: 1.5; }
.char-card .cc-taken-tag {
  position: absolute; top: 8px; left: 8px; background: var(--ink); color: #fff;
  padding: 3px 10px; border-radius: 999px; font-size: 13px;
}

/* ─────── 游戏页布局 ─────── */
.game-layout { display: flex; height: 100vh; gap: 12px; padding: 12px; }
.board-wrap {
  flex: 1; background: #111; border: 4px solid #000; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,.8);
}
#board-svg { width: 100%; height: 100%; }

.sidebar {
  width: 360px; min-width: 360px; display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
}
.panel {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 14px;
  padding: 12px 14px; box-shadow: 4px 4px 0 rgba(0,0,0,.4);
}

/* 当前玩家面板 */
.cur-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cur-avatar {
  width: 54px; height: 54px; border-radius: 12px; border: 3px solid var(--ink);
  object-fit: cover; background: #fff;
}
.cur-name { font-size: 19px; font-weight: bold; }
.cur-sub { font-size: 13px; color: #666; margin-top: 2px; }
.cur-stats { display: flex; gap: 12px; font-size: 14px; margin: 6px 0; flex-wrap: wrap; }
.stat-chip { background: var(--paper2); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; }
.passive-line { font-size: 12.5px; color: #555; background: #efe8d8; border-radius: 8px; padding: 6px 8px; margin: 6px 0; line-height: 1.45; }

.skill-btn {
  display: block; width: 100%; text-align: left; margin-top: 7px; padding: 8px 10px;
  font-family: inherit; font-size: 14px; background: var(--paper2);
  border: 2.5px solid var(--ink); border-radius: 10px; cursor: pointer;
}
.skill-btn:hover { background: #fff3c9; }
.skill-btn:disabled { opacity: .45; cursor: not-allowed; }
.skill-btn .sk-name { font-weight: bold; }
.skill-btn .sk-uses { float: right; color: #a06000; font-weight: bold; }
.skill-btn .sk-desc { font-size: 12px; color: #666; margin-top: 3px; line-height: 1.4; }

/* 骰子 */
.dice-panel { display: flex; align-items: center; gap: 14px; }
.dice {
  width: 74px; height: 74px; min-width: 74px; background: #fff; border: 3px solid var(--ink);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: bold; box-shadow: inset -3px -3px 0 #ddd;
}
.dice.rolling { animation: shake .1s infinite; }
@keyframes shake {
  0% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } 100% { transform: rotate(-4deg); }
}
.dice-btns { flex: 1; }
.dice-btns .big-btn { margin-top: 0; padding: 10px 10px; font-size: 17px; }
.dice-btns .big-btn + .big-btn { margin-top: 8px; }

/* 玩家列表 */
.pl-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px;
  font-size: 14px;
}
.pl-row.active { background: #ffe9a8; outline: 2px dashed var(--ink); }
.pl-token {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%; border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff;
}
.pl-info { flex: 1; line-height: 1.3; }
.pl-name { font-weight: bold; }
.pl-meta { font-size: 12px; color: #666; }
.pl-flags { font-size: 12px; }

/* 日志 */
.log-panel { flex: 1; min-height: 110px; overflow: hidden; display: flex; }
#log { flex: 1; overflow-y: auto; font-size: 13px; line-height: 1.55; }
#log p { margin-bottom: 3px; border-bottom: 1px dashed #ddd2b8; padding-bottom: 3px; }
#log p.important { color: var(--bad); font-weight: bold; }
#log p.good { color: #1a7a2e; font-weight: bold; }

/* ─────── 弹窗 ─────── */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--paper); border: 4px solid var(--ink); border-radius: 18px;
  padding: 24px 28px; max-width: 640px; width: min(92vw, 640px); max-height: 86vh; overflow-y: auto;
  box-shadow: 8px 10px 0 rgba(0,0,0,.5);
}
.modal-box h3 { font-size: 24px; margin-bottom: 6px; }
.modal-box .modal-sub { color: #666; font-size: 14px; margin-bottom: 14px; }

.choice-btn {
  display: block; width: 100%; text-align: left; margin-top: 10px; padding: 12px 14px;
  font-family: inherit; font-size: 16px; background: var(--paper2);
  border: 3px solid var(--ink); border-radius: 12px; cursor: pointer;
}
.choice-btn:hover { background: #fff3c9; transform: translateX(3px); }
.choice-btn:disabled { opacity: .45; cursor: not-allowed; }
.choice-btn .ch-sub { display: block; font-size: 13px; color: #666; margin-top: 3px; }

.modal-close-row { margin-top: 16px; text-align: center; }

.win-box { text-align: center; }
.win-box .win-emoji { font-size: 80px; }
.win-box h3 { font-size: 34px; margin: 10px 0; }

.rules-body { font-size: 15px; line-height: 1.8; }
.rules-body h4 { margin: 14px 0 4px; font-size: 17px; }
.rules-body li { margin-left: 20px; }

/* toast */
.toast {
  position: fixed; top: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 26px; border-radius: 999px;
  font-size: 17px; font-weight: bold; z-index: 99; border: 2px solid #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
  animation: toast-in .18s;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(-14px); } }

/* 棋盘元素 */
.cell-circle { fill: #fffdf6; stroke: #111; stroke-width: 4; }
.cell-icon { font-size: 22px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.cell-idx { font-size: 11px; font-weight: bold; fill: #555; text-anchor: middle; }
.token-g { transition: transform .28s ease; }
.corpse-icon { font-size: 18px; text-anchor: middle; dominant-baseline: central; }
