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

body {
  background: radial-gradient(ellipse at top, #2a2018 0%, #17110b 70%);
  color: #e8dcc4;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  min-height: 100vh;
}

#app { max-width: 920px; margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }

h1 {
  text-align: center;
  color: #d8b96a;
  letter-spacing: 12px;
  margin: 20px 0 28px;
  font-size: 34px;
  text-shadow: 0 0 14px rgba(216, 185, 106, 0.45);
}

/* ---------- 选角界面（规则面板 + 角色随机分配，卡池仅展示） ---------- */
.rules-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  background: rgba(36, 27, 16, 0.85);
  border: 1px solid #6b5636;
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 22px;
}
.rules-group h3 {
  color: #c9a86a;
  font-size: 15px;
  margin-bottom: 8px;
  border-bottom: 1px solid #5a4a2e;
  padding-bottom: 4px;
}
.rules-group ul { list-style: none; }
.rules-group li {
  color: #a89a80;
  font-size: 13px;
  line-height: 1.8;
  padding-left: 14px;
  position: relative;
}
.rules-group li::before {
  content: '◆';
  color: #7a6238;
  font-size: 9px;
  position: absolute;
  left: 0;
  top: 6px;
}
.card-list.pool {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  max-width: 780px;
  margin: 0 auto;
}

/* 卡池点选提示与模式分组标签 */
.select-hint {
  text-align: center;
  color: #c9a86a;
  font-size: 14px;
  margin: 6px 0 12px;
  min-height: 20px;
}
.mode-label {
  color: #a89a80;
  font-size: 13px;
  letter-spacing: 2px;
  margin: 18px 0 4px;
}

.card {
  background: linear-gradient(160deg, #2e2417, #241b10);
  border: 2px solid #6b5636;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: #c9a86a; transform: translateY(-2px); }
.card.selected { border-color: #ffd97a; box-shadow: 0 0 14px rgba(255, 217, 122, 0.35); }
.card-name { font-size: 22px; color: #ffd97a; font-weight: bold; }
.card-stats { color: #a89878; font-size: 13px; margin: 4px 0 8px; }
.card-passive { color: #8fb0d8; font-size: 13px; margin-bottom: 6px; }
.card-skill { color: #e8dcc4; font-size: 14px; margin-top: 6px; }
.card-skill-desc { color: #9c8f74; font-size: 12px; }

/* ---------- 通用大按钮 ---------- */
.big-btn {
  display: block;
  margin: 22px auto 6px;
  padding: 12px 48px;
  font-size: 18px;
  background: linear-gradient(180deg, #7a5f30, #5a4520);
  color: #ffe9b0;
  border: 1px solid #d8b96a;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 4px;
}
.big-btn:hover:not(:disabled) { filter: brightness(1.2); }
.big-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 模式选择（人机 / 联机房间） ---------- */
.mode-panel { text-align: center; }
.mode-btn { display: inline-block; margin: 10px 6px 4px; padding: 12px 36px; }
.net-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.join-group { display: flex; align-items: center; gap: 8px; }
#room-code-input {
  width: 110px;
  padding: 12px 10px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
  background: #241b10;
  color: #ffe9b0;
  border: 1px solid #a8854a;
  border-radius: 8px;
  outline: none;
}
#room-code-input:focus { border-color: #ffd97a; }
#net-status {
  margin: 14px auto 0;
  max-width: 420px;
  padding: 10px 16px;
  background: rgba(36, 27, 16, 0.9);
  border: 1px solid #6b5636;
  border-radius: 8px;
  color: #e0c890;
  font-size: 14px;
  line-height: 1.7;
}
#net-status b {
  color: #ffd97a;
  font-size: 26px;
  letter-spacing: 8px;
  padding: 0 4px;
}

/* ---------- 扫码进入 ---------- */
.qr-box {
  margin: 26px auto 10px;
  text-align: center;
}
#qr-code {
  display: inline-block;
  background: #fff; /* 二维码必须白底，暗色页面上黑码不可扫 */
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #6b5636;
  line-height: 0;
}
.qr-hint {
  margin-top: 8px;
  color: #a89a80;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- 手机 / Pad 响应式（按屏幕宽度自动套用，横竖屏切换即时重排） ---------- */
@media (max-width: 768px) {
  #app { padding: 10px; }
  h1 { font-size: 24px; letter-spacing: 6px; margin: 12px 0 18px; }

  .rules-panel { grid-template-columns: 1fr; padding: 12px 14px; gap: 10px; }
  .rules-group li { font-size: 12px; line-height: 1.7; }

  .card-list.pool { grid-template-columns: 1fr; }
  .card-name { font-size: 19px; }

  .net-row { flex-direction: column; gap: 8px; }
  .big-btn, .mode-btn { padding: 14px 24px; font-size: 16px; min-height: 48px; }
  .qr-box { margin-top: 18px; }

  .fighter-name { font-size: 17px; }
  .fighter-p { font-size: 14px; }
  #log-area { height: 30vh; font-size: 13px; line-height: 1.6; padding: 8px 10px; }

  .action-btn { flex: 1 1 100%; min-height: 48px; padding: 10px 14px; }
  .ab-name { font-size: 14px; }

  .winner-text { font-size: 22px; letter-spacing: 3px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  #app { padding: 14px; }
  #log-area { height: 34vh; }
  .action-btn { min-height: 48px; }
}

/* ---------- 对战界面 ---------- */
.fighter-panel {
  background: rgba(36, 27, 16, 0.92);
  border: 1px solid #6b5636;
  border-radius: 10px;
  padding: 10px 14px;
}
.fighter-head { display: flex; justify-content: space-between; align-items: baseline; }
.fighter-name { font-size: 20px; color: #ffd97a; font-weight: bold; }
.fighter-p { color: #7fd4ff; font-size: 16px; font-weight: bold; }

.hp-bar {
  position: relative;
  height: 20px;
  background: #3a1414;
  border: 1px solid #6b3636;
  border-radius: 6px;
  margin: 6px 0;
  overflow: hidden;
}
.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #3fae5a, #7ad34f);
  transition: width 0.3s;
}
.hp-text {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 12px;
  line-height: 20px;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.status-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; margin-top: 6px; }
.chip {
  background: #33271a;
  border: 1px solid #7a6238;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  color: #e0c890;
}

#log-area {
  height: 260px;
  overflow-y: auto;
  scroll-behavior: smooth;
  background: rgba(10, 8, 5, 0.85);
  border: 1px solid #4a3a22;
  border-radius: 8px;
  margin: 12px 0;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.7;
}
.log-line { white-space: pre-wrap; color: #a89a80; }
.log-line.basic { color: #f2ede0; }    /* 普攻：亮白 */
.log-line.skill { color: #ffb35c; }    /* 主动技能：橙 */
.log-line.response { color: #c79bff; } /* 响应/被动发动：紫 */
.turn-header { color: #ffd97a; font-weight: bold; margin-top: 8px; }
.dice { color: #8fb0d8; }
.death { color: #ff7a6b; font-weight: bold; }

#action-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }
.action-btn {
  flex: 1 1 180px;
  background: linear-gradient(180deg, #3a2d1c, #2c2113);
  border: 1px solid #a8854a;
  border-radius: 8px;
  color: #e8dcc4;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
}
.action-btn:hover:not(:disabled) {
  border-color: #ffd97a;
  box-shadow: 0 0 8px rgba(255, 217, 122, 0.25);
}
.action-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ab-name { font-size: 15px; color: #ffd97a; font-weight: bold; }
.action-btn:disabled .ab-name { color: #b0a080; }
.ab-info { font-size: 12px; color: #9c8f74; margin-top: 3px; }
.ab-reason { font-size: 12px; color: #d98a7a; margin-top: 3px; }

/* ---------- 响应面板（并入操作区，不弹窗：零遮挡、无超屏风险） ---------- */
#action-area {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px;
  transition: border-color 0.3s;
}
#action-area.awaiting-response {
  border-color: #d8b96a;
  animation: resp-pulse 1.2s ease-in-out infinite;
}
@keyframes resp-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(216, 185, 106, 0); }
  50% { box-shadow: 0 0 18px rgba(216, 185, 106, 0.45); }
}
.response-banner {
  flex: 1 1 100%;
  text-align: center;
  color: #ffd97a;
  font-size: 15px;
  padding: 4px 10px 10px;
  border-bottom: 1px solid #5a4a2e;
  margin-bottom: 4px;
  letter-spacing: 1px;
}
.action-btn.pass { text-align: center; }
.action-btn.pass .ab-name { color: #b0a080; }

/* ---------- 掷骰定先手仪式（全屏overlay：骰子→自己点数→左右比对→宣告先手） ---------- */
#roll-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(12, 9, 5, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}
#roll-overlay.fade-out { opacity: 0; pointer-events: none; }
.roll-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 20px;
}

#roll-dice {
  width: 112px;
  height: 112px;
  background: linear-gradient(160deg, #3a2d1b, #241b10);
  border: 3px solid #d8b96a;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 34px rgba(216, 185, 106, 0.35);
}
#roll-dice-face { font-size: 58px; color: #ffd97a; font-weight: bold; }
#roll-dice.shaking { animation: dice-shake 0.1s linear infinite; }
@keyframes dice-shake {
  0%   { transform: rotate(-9deg) translateY(0); }
  25%  { transform: rotate(7deg) translateY(-7px); }
  50%  { transform: rotate(-6deg) translateY(2px); }
  75%  { transform: rotate(8deg) translateY(-5px); }
  100% { transform: rotate(-9deg) translateY(0); }
}

#roll-compare { display: flex; align-items: center; gap: 36px; min-height: 120px; }
.roll-num {
  font-size: 88px;
  font-weight: bold;
  color: #ffd97a;
  transition: transform 0.5s ease, opacity 0.45s ease, color 0.4s, text-shadow 0.4s;
}
/* 比对前：我方数字独占中央（盖住VS与对方位），对方数字缩隐 */
#roll-compare:not(.show-both) #roll-num-self { transform: translateX(76px); }
#roll-compare:not(.show-both) #roll-num-foe,
#roll-compare:not(.show-both) .roll-vs { opacity: 0; transform: scale(0.3); }
.roll-vs { font-size: 30px; color: #a89878; transition: opacity 0.4s, transform 0.4s; }
.roll-num.win { text-shadow: 0 0 26px rgba(255, 217, 122, 0.95); transform: scale(1.18); }
.roll-num.lose { color: #7a6c50; }

#roll-msg { font-size: 20px; color: #c9b98f; letter-spacing: 6px; }
#roll-msg.roll-declare { animation: declare-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); font-size: 32px; font-weight: bold; letter-spacing: 8px; }
#roll-msg.roll-declare.good { color: #ffd97a; text-shadow: 0 0 22px rgba(255, 217, 122, 0.65); }
#roll-msg.roll-declare.bad { color: #b0a080; }
@keyframes declare-pop {
  0% { transform: scale(0.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#btn-roll { min-width: 220px; }
#roll-wait { color: #9c8f74; font-size: 14px; letter-spacing: 2px; }

@media (max-width: 768px) {
  #roll-dice { width: 92px; height: 92px; }
  #roll-dice-face { font-size: 46px; }
  .roll-num { font-size: 64px; }
  #roll-compare { gap: 26px; min-height: 96px; }
  #roll-compare:not(.show-both) #roll-num-self { transform: translateX(58px); }
  #roll-msg.roll-declare { font-size: 26px; }
}

/* ---------- 胜负横幅 ---------- */
#winner-banner {
  text-align: center;
  margin-top: 14px;
  padding: 18px;
  border: 2px solid #d8b96a;
  border-radius: 12px;
  background: rgba(60, 45, 20, 0.6);
}
.winner-text { font-size: 28px; color: #ffd97a; letter-spacing: 6px; }
