/* ========== 角色选择弹窗 ========== */
.role-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 20px;
}
.role-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, background .15s;
}
.role-picker-item:hover {
  background: var(--bg3);
  border-color: var(--accent);
}
.role-picker-item img {
  height: 52px;
  object-fit: contain;
}
.role-picker-item span {
  font-size: 11px;
  color: var(--text2);
}

/* ========== 弹窗通用 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 300;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 17px; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text2);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .2s, color .2s;
}
.modal-close:hover { background: var(--accent); color: #fff; transform: none; filter: none; }
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ========== 游戏规则弹窗 ========== */
#rulesModal .modal-box { width: min(720px, 100%); }
.rules-section { margin-bottom: 22px; }
.rules-section h3 {
  font-size: 15px;
  color: var(--accent2);
  margin-bottom: 10px;
  padding-bottom: 6px;
}
.rules-section p, .rules-section li {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text2);
}
.rules-section ul, .rules-section ol { padding-left: 18px; }
.rules-section ul { list-style: disc; }
.rules-section ol { list-style: decimal; }
.rules-section li { margin-bottom: 4px; }
.role-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.role-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.role-card .rc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.role-card .rc-name { font-size: 14px; font-weight: 700; }
.role-card .rc-camp {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  margin-top: 2px;
  font-weight: 600;
}
.rc-camp.wolf { background: rgba(199,64,109,0.2); color: var(--wolf); }
.rc-camp.good { background: rgba(92,186,138,0.15); color: var(--green); }
.role-card .rc-desc { font-size: 12px; color: var(--text2); line-height: 1.6; }

/* ========== 玩家管理弹窗 ========== */
#playersModal .modal-box { width: min(1100px, 96vw); }
.mgr-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: var(--bg3);
}
.mgr-toolbar-left { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mgr-toolbar-right { display: flex; gap: 16px; align-items: center; margin-left: auto; }
.mgr-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}
.mgr-checkbox-label:hover { color: var(--text); }

.mgr-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(88vh - 180px);
}
.mgr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.mgr-table th {
  padding: 6px 6px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg3);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.mgr-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(61,34,26,0.5);
  vertical-align: middle;
}
.mgr-table tr:hover td { background: rgba(255,255,255,0.025); }
.mgr-table input[type="text"],
.mgr-table input[type="password"],
.mgr-table input[type="url"] {
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 5px;
  transition: border-color .15s;
}
.mgr-table input:focus {
  border-color: var(--accent);
  background: var(--bg2);
}
.mgr-table select {
  padding: 5px 8px;
  font-size: 12px;
  width: 100%;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 5px;
}
.mgr-table select:focus { border-color: var(--accent); }
.mgr-table .td-order { width: 36px; text-align: center; }
.mgr-table .td-check { width: 40px; text-align: center; }
.mgr-table .td-name { min-width: 70px; }
.mgr-table .td-brand { width: 100px; }
.mgr-table .td-model { min-width: 130px; }
.mgr-table .td-model input[type="text"],
.mgr-table .td-model select { width: calc(100% - 22px); vertical-align: middle; }
.mgr-table .td-model-icon { width: 16px; height: 16px; object-fit: contain; vertical-align: middle; margin-right: 6px; }
.mgr-table .td-url { min-width: 180px; }
.mgr-table .td-key { min-width: 140px; }
.mgr-table .td-ops { width: 95px; white-space: nowrap; }
.mgr-table .td-takeover { width: 42px; text-align: center; }
.row-ops {
  display: flex;
  gap: 4px;
  align-items: center;
}
.order-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.mgr-add-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  background: var(--bg3);
  flex-shrink: 0;
}

/* ========== API 链接卡片 ========== */
.api-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.api-link-card:hover {
  background: var(--bg2);
  border-color: var(--accent);
}
.api-link-icon {
  width: 24px; height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}
.api-link-text { font-size: 15px; font-weight: 600; flex: 1; }
.api-link-text small { font-size: 12px; font-weight: 400; opacity: 0.6; margin-left: 4px; }
.api-link-arrow { color: var(--text-dim); font-size: 18px; }

/* ========== Toast 通知 ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  z-index: 9999;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--accent); color: var(--accent); }

/* ========== 游戏结束 Overlay ========== */
.game-over {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.game-over.show { display: flex; }
.game-over-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  position: relative;
}
.game-over-card .go-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text2);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.game-over-card .go-close:hover { background: var(--accent); color: #fff; transform: none; filter: none; }
.game-over-card h2 { font-size: 28px; margin-bottom: 8px; }
.game-over-card .result-text {
  font-size: 16px;
  color: var(--text2);
  margin-bottom: 20px;
}
.game-over-card .role-reveal { text-align: left; margin-bottom: 20px; }
.role-reveal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
}
.status-alive { color: var(--green); }
.status-dead  { color: var(--accent); }
.game-over-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}
