* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1410;
  --panel: #2a211a;
  --panel-light: #3a2e24;
  --border: #5a4632;
  --gold: #d4a017;
  --text: #e8dcc8;
  --red: #e74c3c;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: radial-gradient(ellipse at center, #2b2118 0%, var(--bg) 100%);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { display: none; height: 100vh; }
.screen.active { display: flex; align-items: center; justify-content: center; }
#screen-game.active { display: block; }

.k-wei { color: #7aa5e0; }
.k-shu { color: #e88; }
.k-wu { color: #7ed6a5; }
.k-qun { color: #c0c0c8; }

/* ---------- 按钮 ---------- */
.btn, .count-btn, .skill-btn {
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover:not(:disabled), .count-btn:hover, .skill-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}
.btn:disabled, .skill-btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: #6d4f1f; border-color: var(--gold); }
.btn.primary:hover:not(:disabled) { background: #8a651f; color: #fff; }
.btn.end { border-color: #a33; }
.btn.big { font-size: 20px; padding: 12px 48px; }
.count-btn.selected { background: #6d4f1f; border-color: var(--gold); color: var(--gold); }

/* ---------- 开局设置 ---------- */
.setup-box { text-align: center; max-width: 640px; padding: 40px; }
.game-title {
  font-size: 72px;
  letter-spacing: 16px;
  color: var(--gold);
  text-shadow: 0 4px 24px rgba(212,160,23,.4);
  margin-bottom: 8px;
}
.subtitle { color: #a08c6c; margin-bottom: 32px; letter-spacing: 4px; }
.setup-row { margin-bottom: 28px; }
.setup-row label { display: block; margin-bottom: 12px; color: #a08c6c; }
#player-count-options { display: flex; gap: 10px; justify-content: center; }
.count-btn { padding: 10px 22px; font-size: 16px; }
.setup-tips { margin-top: 36px; font-size: 13px; color: #8a7a62; line-height: 1.8; text-align: left; }

/* ---------- 选将 ---------- */
.pick-box { text-align: center; max-width: 1100px; padding: 24px; }
#pick-role { margin-bottom: 8px; font-size: 24px; }
#pick-generals { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.general-card {
  width: 200px;
  background: var(--panel);
  border: 2px solid;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  text-align: left;
}
.general-card:hover { transform: translateY(-6px); box-shadow: 0 8px 24px rgba(212,160,23,.35); }
.gc-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; color: #fff; }
.gc-kingdom { font-size: 12px; border: 1px solid rgba(255,255,255,.6); border-radius: 4px; padding: 1px 5px; }
.gc-name { font-size: 18px; font-weight: bold; }
.gc-hp { margin-left: auto; font-size: 12px; color: #ffd7d7; }
.gc-body { padding: 10px; font-size: 12px; line-height: 1.5; min-height: 120px; }
.gc-skill { margin-bottom: 8px; color: #cbbba0; }
.gc-skill b { color: var(--gold); }
.lord-skill b { color: #e67e22; }

/* ---------- 游戏布局 ---------- */
#game-layout { display: grid; grid-template-columns: 1fr 300px; height: 100vh; }
#table-area { display: flex; flex-direction: column; padding: 10px; min-width: 0; }

#opponents {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 6px;
}

#center-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 90px;
}
#pile-info { color: #8a7a62; font-size: 14px; }
#discard-view { display: flex; gap: 6px; }

/* ---------- 角色面板 ---------- */
.player-panel {
  position: relative;
  width: 170px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.player-panel.current { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,160,23,.45); }
.player-panel.targetable { border-color: #4fc3f7; box-shadow: 0 0 14px rgba(79,195,247,.55); }
.player-panel.target-selected { border-color: var(--red); box-shadow: 0 0 16px rgba(231,76,60,.7); }
.player-panel.dead { opacity: .55; cursor: default; }
.player-panel.flash-damage { animation: flashRed .5s; }
@keyframes flashRed {
  0% { background: #6d1f1f; } 100% { background: var(--panel); }
}

.pp-top { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.role-badge { color: #fff; font-size: 11px; border-radius: 4px; padding: 1px 5px; }
.pp-kingdom { color: #fff; font-size: 11px; border-radius: 4px; padding: 1px 5px; }
.pp-name { font-weight: bold; font-size: 15px; }
.turn-flag { margin-left: auto; }
.pp-hp { font-size: 13px; letter-spacing: 1px; margin-bottom: 3px; }
.hp.full { color: #e74c3c; }
.hp.empty { color: #666; }
.pp-row { display: flex; gap: 5px; align-items: center; margin-bottom: 3px; }
.hand-chip { background: var(--panel-light); border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.judge-chip { background: #4a2a5a; border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.pp-equips { display: flex; flex-direction: column; gap: 2px; min-height: 16px; }
.equip-chip { background: #24313d; border-radius: 4px; padding: 1px 6px; font-size: 11px; color: #9fc3e0; }
.pp-skills { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.pp-skills span { font-size: 10px; color: #a08c6c; border: 1px solid #4a3c2c; border-radius: 3px; padding: 0 4px; }
.dead-mask {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #d55; font-weight: bold;
  letter-spacing: 6px;
}

/* ---------- 自己区域 ---------- */
#self-area { display: flex; gap: 12px; align-items: stretch; padding-top: 8px; }
#self-panel { width: 190px; flex-shrink: 0; }
#self-right { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#prompt-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 44px;
  margin-bottom: 8px;
}
#prompt-msg { flex: 1; font-size: 14px; color: #f0d9a8; }
#prompt-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

#hand {
  display: flex; gap: 6px;
  overflow-x: auto;
  padding: 6px 2px;
  min-height: 118px;
}

#self-bottom { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
#self-role { font-size: 13px; color: #a08c6c; }
#skill-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.skill-btn { font-size: 13px; padding: 4px 12px; border-color: #7d5a9e; color: #c9a6e8; }
.skill-btn:hover:not(:disabled) { border-color: #b07fe0; color: #e0c6f8; }

/* ---------- 卡牌 ---------- */
.card {
  position: relative;
  width: 76px; height: 106px;
  flex-shrink: 0;
  background: #f5eeda;
  color: #222;
  border: 1px solid #b8a888;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  user-select: none;
}
.card:hover { transform: translateY(-8px); box-shadow: 0 6px 16px rgba(0,0,0,.5); }
.card.selected { transform: translateY(-14px); box-shadow: 0 0 0 2px var(--gold), 0 8px 18px rgba(0,0,0,.5); }
.card.disabled { opacity: .45; cursor: default; }
.card.disabled:hover { transform: none; box-shadow: none; }
.card.red .card-corner { color: #c0392b; }
.card-corner {
  position: absolute; top: 4px; left: 6px;
  font-size: 13px; line-height: 1.1; font-weight: bold;
  color: #222;
}
.card-name {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  writing-mode: vertical-rl;
  font-size: 17px; font-weight: bold;
  letter-spacing: 2px;
  white-space: nowrap;
}
.card-type {
  position: absolute; bottom: 4px; right: 6px;
  font-size: 10px; color: #999;
}
.card.back { background: linear-gradient(135deg, #3a2020, #241414); border-color: #5a3030; }
.card-back-logo {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px; color: #7a4040; font-weight: bold;
}

.mini-card {
  position: relative;
  width: 52px; height: 72px;
  background: #f5eeda;
  color: #222;
  border: 1px solid #b8a888;
  border-radius: 6px;
  font-size: 11px;
}
.mini-card.red .mc-corner { color: #c0392b; }
.mc-corner { position: absolute; top: 2px; left: 4px; font-weight: bold; }
.mc-name {
  position: absolute; top: 55%; left: 50%;
  transform: translate(-50%, -50%);
  writing-mode: vertical-rl;
  font-size: 12px; font-weight: bold;
  white-space: nowrap;
}

/* ---------- 战报 ---------- */
#log-panel {
  background: #171310;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh;
}
#log-title { padding: 10px 14px; color: var(--gold); border-bottom: 1px solid var(--border); font-size: 15px; }
#log-scroll { flex: 1; overflow-y: auto; padding: 8px 12px; }
#log-list { list-style: none; font-size: 12.5px; line-height: 1.7; }
#log-list li { margin-bottom: 2px; color: #b3a488; }
#log-list li.phase { color: var(--gold); margin-top: 6px; }
#log-list li.skill { color: #c9a6e8; }
#log-list li.damage { color: #e08080; }
#log-list li.heal { color: #7ed6a5; }
#log-list li.death { color: #ff5b5b; font-weight: bold; }
#log-list li.victory { color: var(--gold); font-size: 14px; margin-top: 8px; }

/* ---------- 模态框 ---------- */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 100;
  align-items: center; justify-content: center;
}
.overlay.show, .overlay.active { display: flex; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
}
#modal-title { font-size: 17px; color: var(--gold); margin-bottom: 14px; }
.modal-section-title { font-size: 13px; color: #a08c6c; margin: 10px 0 6px; }
.card-row { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-card:hover { transform: translateY(-4px); }
#modal-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- 结算 ---------- */
.result-box { text-align: center; min-width: 420px; }
#result-title { font-size: 40px; margin-bottom: 10px; }
#result-title.win { color: var(--gold); }
#result-title.lose { color: #e74c3c; }
#result-reason { color: #cbbba0; margin-bottom: 18px; }
#result-roles { list-style: none; text-align: left; margin-bottom: 22px; line-height: 2; }
#result-roles li.dead { opacity: .55; }
