:root {
  --bg: #14110f;
  --bg2: #1d1814;
  --panel: #241d18;
  --panel2: #2e251e;
  --gold: #d9a441;
  --gold-soft: #f0c878;
  --red: #b5302a;
  --red-glow: #ff5a4d;
  --green: #3fae6b;
  --text: #f3e9dc;
  --muted: #b9a892;
  --line: #4a3a2c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #2a1f17 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.screen { max-width: 980px; margin: 0 auto; padding: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #2a1c08; border-color: var(--gold); font-weight: 700; }
.btn.danger { background: linear-gradient(180deg, #d8483f, var(--red)); border-color: #e0665c; color: #fff; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 8px; font-size: 12px; }

/* ---------- 大厅 ---------- */
.lobby-card {
  max-width: 360px; margin: 8vh auto; padding: 28px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(217,164,65,.08), 0 20px 60px rgba(0,0,0,.5);
}
.lobby-card h1 { text-align: center; margin: 0 0 4px; color: var(--gold-soft); letter-spacing: 2px; }
.lobby-card .sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.lobby-card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.lobby-card input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 15px; text-transform: uppercase;
}
.avatar-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-opt { width: 42px; height: 42px; font-size: 22px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; }
.avatar-opt.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217,164,65,.4); }
.lobby-actions { margin-top: 20px; }
.lobby-actions .btn { width: 100%; }
.join-row { display: flex; gap: 8px; margin-top: 14px; }
.join-row input { text-transform: uppercase; letter-spacing: 4px; }
.msg { color: var(--red-glow); font-size: 13px; min-height: 18px; text-align: center; margin-top: 10px; }

/* ---------- 准备房间 ---------- */
.room-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.room-head-actions { display: flex; gap: 10px; }
.code-box {
  font-size: 22px; font-weight: 800; color: var(--gold-soft); letter-spacing: 6px;
  background: var(--panel); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px;
  cursor: pointer; user-select: none; box-shadow: inset 0 0 14px rgba(217,164,65,.1);
}
.code-box span { font-size: 30px; }
.player-list { display: flex; flex-direction: column; gap: 8px; }
.pl-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.pl-item.host { border-color: var(--gold); }
.pl-item .av { font-size: 24px; }
.pl-item .nm { flex: 1; font-weight: 600; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; margin-left: 4px; }
.tag.host { background: rgba(217,164,65,.2); color: var(--gold-soft); border: 1px solid var(--gold); }
.tag.ai { background: rgba(180,48,42,.18); color: var(--red-glow); border: 1px solid var(--red); }
.host-panel { display: flex; gap: 10px; margin-top: 16px; }
.host-panel .btn { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin-top: 12px; }

/* ---------- 游戏：玩家卡 ---------- */
.players { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.pcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  text-align: center; position: relative; transition: border-color .2s, box-shadow .2s, opacity .2s;
}
.pcard.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217,164,65,.35), 0 0 18px rgba(217,164,65,.25); }
.pcard.dead { opacity: .45; filter: grayscale(.6); }
.pc-av { font-size: 30px; }
.pc-name { font-weight: 700; margin: 2px 0; font-size: 14px; }
.ai-dot { font-size: 10px; color: var(--red-glow); border: 1px solid var(--red); border-radius: 6px; padding: 0 4px; margin-left: 4px; }
.pc-hp { font-size: 14px; letter-spacing: 1px; min-height: 18px; }
.pc-buffs { min-height: 18px; color: var(--gold-soft); font-size: 14px; }
.pc-items { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- 竞技区 ---------- */
.arena { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cylinder-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; align-items: center; }
.cylinder { position: relative; width: 240px; height: 240px; margin: 6px auto; }
.chamber {
  position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; border: 2px solid var(--line); background: #1a1410;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.chamber.current { border-color: var(--gold); box-shadow: 0 0 14px rgba(217,164,65,.6); }
.chamber.known-bullet { border-color: var(--red); background: rgba(181,48,42,.25); }
.chamber.known-empty { border-color: var(--green); background: rgba(63,174,107,.18); }
.prob { color: var(--gold-soft); font-weight: 700; margin-top: 6px; }
.bullets { color: var(--muted); font-size: 13px; }

.log {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px;
  height: 300px; overflow-y: auto; font-size: 13px; line-height: 1.7;
}
.log-line { padding: 1px 0; border-bottom: 1px dashed rgba(74,58,44,.4); }
.log-line.normal { color: var(--text); }
.log-line.good { color: var(--green); }
.log-line.bad { color: var(--red-glow); }
.log-line.important { color: var(--gold-soft); font-weight: 700; }

/* ---------- 道具栏 ---------- */
.items { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; min-height: 90px; }
.item-card {
  width: 110px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  cursor: pointer; transition: transform .08s, box-shadow .2s, border-color .2s;
}
.item-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.item-card.selectable { border-style: dashed; }
.item-card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217,164,65,.4); }
.item-card.r-common { border-left: 3px solid #8a8a8a; }
.item-card.r-rare { border-left: 3px solid #4a8fe0; }
.item-card.r-legendary { border-left: 3px solid var(--gold); }
.ic-ic { font-size: 22px; }
.ic-name { font-weight: 700; font-size: 13px; }
.ic-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.synth-tip { width: 100%; color: var(--gold-soft); font-size: 12px; align-self: center; }

.actions { display: flex; gap: 12px; }
.actions .btn { flex: 1; }

/* ---------- 房间聊天 ---------- */
.chat {
  margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px;
  display: flex; flex-direction: column;
}
.chat-head { color: var(--gold-soft); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.chat-log { height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.chat-line { line-height: 1.5; word-break: break-word; }
.chat-line .chat-av { margin-right: 6px; }
.chat-line .chat-name { color: var(--gold-soft); font-weight: 700; margin-right: 6px; }
.chat-line .chat-time { color: var(--muted); font-size: 11px; margin-right: 6px; }
.chat-line .chat-text { color: var(--text); }
.chat-line.ai .chat-name { color: var(--red-glow); }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row input {
  flex: 1; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 14px;
}
.chat-input-row .btn { flex: 0 0 auto; }

/* ---------- 弹窗 / Toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--gold); border-radius: 16px; padding: 26px; max-width: 320px; text-align: center; box-shadow: 0 0 30px rgba(217,164,65,.25); }
.modal-card h2 { margin: 0 0 12px; color: var(--gold-soft); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--gold); color: var(--gold-soft); padding: 10px 18px; border-radius: 999px; z-index: 60; font-size: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .players { grid-template-columns: repeat(2, 1fr); }
  .arena { grid-template-columns: 1fr; }
  .cylinder { width: 200px; height: 200px; }
  .log { height: 220px; }
  .item-card { width: calc(50% - 4px); }
}
