/* 机密代号 Codenames — 间谍风暗色主题 */
:root {
  --bg: #0f1117;
  --panel: #171a25;
  --panel2: #1f2330;
  --line: #2a2f42;
  --text: #e9ecf4;
  --muted: #8b93a7;
  --accent: #e8b64c;
  --red: #e5484d;
  --red-dim: rgba(229, 72, 77, .16);
  --blue: #4285f4;
  --blue-dim: rgba(66, 133, 244, .16);
  --tan: #c9b48a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a2030 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 12px 40px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(15, 17, 23, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .back { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
.topbar .title { font-weight: 700; letter-spacing: 1px; }
.roomcode {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 18px; font-weight: 700; letter-spacing: 3px;
  color: var(--accent); background: rgba(232, 182, 76, .08);
  border: 1px dashed rgba(232, 182, 76, .45);
  padding: 2px 10px; border-radius: 8px; user-select: all;
}
.iconbtn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 9px; font-size: 14px;
}
.spacer { flex: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 52px; text-align: center; }
.timer.danger { color: #ff6b6f; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- 卡片 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 12px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }

#grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 7px; margin-top: 12px;
}
.card {
  aspect-ratio: 5 / 3.4;
  border-radius: 10px;
  border: 1px solid #333a52;
  background: linear-gradient(160deg, #232839, #1a1e2c);
  color: var(--text);
  font-size: clamp(13px, 3.4vw, 19px);
  font-weight: 600;
  letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center;
  padding: 2px; text-align: center; line-height: 1.15;
  transition: transform .06s ease;
  word-break: break-all;
}
.card.guessable:not(.revealed) { cursor: pointer; box-shadow: 0 0 0 1px rgba(232,182,76,.0); }
.card.guessable:not(.revealed):active { transform: scale(.96); }
@media (hover: hover) {
  .card.guessable:not(.revealed):hover { border-color: var(--accent); box-shadow: 0 0 10px rgba(232,182,76,.25); }
}
.card.revealed { cursor: default; }
.card.revealed.red { background: var(--red); border-color: var(--red); }
.card.revealed.blue { background: var(--blue); border-color: var(--blue); }
.card.revealed.neutral { background: var(--tan); border-color: var(--tan); color: #383021; }
.card.revealed.assassin { background: #000; border: 3px double #f2f2f2; color: #fff; }
.card.revealed.assassin::before { content: "☠"; margin-right: 4px; }
.card.spymode.red { background: var(--red-dim); border-color: rgba(229,72,77,.75); }
.card.spymode.blue { background: var(--blue-dim); border-color: rgba(66,133,244,.75); }
.card.spymode.neutral { background: rgba(201,180,138,.10); border-color: rgba(201,180,138,.5); }
.card.spymode.assassin { background: repeating-linear-gradient(45deg, #101010, #101010 6px, #1d1d1d 6px, #1d1d1d 12px); border-color: rgba(245,245,245,.7); }
.card.spymode.assassin::before { content: "☠"; opacity: .92; margin-right: 3px; }
.card.flip { animation: flipin .45s ease; }
@keyframes flipin { from { transform: rotateY(88deg); opacity: .3; } to { transform: rotateY(0); opacity: 1; } }

/* ---------- 状态条 ---------- */
.statusbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  font-size: 14px;
}
.turnchip { padding: 3px 12px; border-radius: 999px; font-weight: 700; }
.turnchip.red { background: var(--red); color: #fff; }
.turnchip.blue { background: var(--blue); color: #fff; }
.remaining { color: var(--muted); }
.remaining b.r { color: var(--red); }
.remaining b.b { color: var(--blue); }

.cluebar { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); }
.clue-display { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.clue-word { font-size: 26px; font-weight: 800; letter-spacing: 2px; color: var(--accent); }
.clue-meta { color: var(--muted); font-size: 14px; }
.clue-form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.clue-form input[type=text] {
  flex: 1; min-width: 120px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 16px;
}
.clue-form select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 15px;
}
.btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 16px; font-size: 15px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #241d07; font-weight: 700; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { background: transparent; border-color: #ff5a5f; color: #ff8085; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- 队伍 ---------- */
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.teambox { border-radius: 12px; padding: 10px; border: 1px solid var(--line); background: var(--panel); }
.teambox.red { border-top: 3px solid var(--red); }
.teambox.blue { border-top: 3px solid var(--blue); }
.teambox h4 { margin: 0 0 8px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.teambox.red h4 { color: var(--red); }
.teambox.blue h4 { color: var(--blue); }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; margin: 4px 0; font-size: 13px;
}
.chip.offline { opacity: .4; }
.chip .crown { color: var(--accent); }
.team-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- 日志 ---------- */
details.logbox { margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
details.logbox summary { cursor: pointer; color: var(--muted); font-size: 14px; }
#log { max-height: 220px; overflow-y: auto; margin-top: 8px; font-size: 13px; line-height: 1.7; }
#log .k-clue { color: var(--accent); }
#log .k-hit { color: #7dd88a; }
#log .k-miss { color: #ff9296; }
#log .k-win { color: var(--accent); font-weight: 700; }
#log .k-warn { color: #ffb454; }
#log .k-system, #log .k-turn { color: var(--muted); }
#log .t { color: #5b6274; margin-right: 6px; font-size: 11px; }

/* ---------- 结算横幅 ---------- */
.resultbar {
  margin-top: 12px; padding: 14px; border-radius: 14px; text-align: center;
  border: 1px solid var(--line); background: var(--panel);
}
.resultbar.win-red { border-color: var(--red); box-shadow: 0 0 24px rgba(229,72,77,.25); }
.resultbar.win-blue { border-color: var(--blue); box-shadow: 0 0 24px rgba(66,133,244,.25); }
.resultbar h2 { margin: 0 0 4px; font-size: 22px; }
.resultbar .reason { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

/* ---------- 覆盖层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 18, .82); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay.hidden { display: none; }
.dialog {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px;
}
.dialog h2 { margin: 0 0 4px; font-size: 20px; }
.dialog .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.dialog input[type=text] {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 16px; margin-bottom: 12px;
}
.dialog .btn { width: 100%; }

/* ---------- 大厅页 ---------- */
.hero { text-align: center; padding: 34px 0 6px; }
.hero h1 { margin: 0; font-size: 34px; letter-spacing: 6px; }
.hero p { color: var(--muted); margin: 8px 0 0; font-size: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input[type=text], .field select, .field textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 15px;
}
.field textarea { min-height: 84px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.codeinput { letter-spacing: 8px; text-align: center; font-size: 22px !important; font-family: ui-monospace, monospace; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 10px 0; }
.rules { font-size: 13px; color: var(--muted); line-height: 1.9; }
.rules b { color: var(--text); }

/* ---------- 设置区（房间内） ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-note { font-size: 12px; color: var(--muted); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast-item {
  background: rgba(30, 34, 48, .96); border: 1px solid var(--line);
  color: var(--text); padding: 9px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  animation: toastin .25s ease;
}
.toast-item.err { border-color: #ff5a5f; color: #ffb3b5; }
@keyframes toastin { from { transform: translateY(-8px); opacity: 0; } }

.footer { text-align: center; color: #565d70; font-size: 12px; margin-top: 26px; }
.footer a { color: #7a8299; }

/* ---------- 扫码 / 房间列表 ---------- */
.qrbox svg { width: 230px; height: 230px; display: block; }
.roomrow { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 14px; }
.roomrow:last-child { border-bottom: none; }
.roomrow .rc { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 2px; color: var(--accent); font-weight: 700; font-size: 16px; }
.roomrow .st { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); }
.roomrow .st.playing { color: #7dd88a; }
.roomrow .pc { color: var(--muted); font-size: 12px; }
.roomrow .arr2 { margin-left: auto; color: var(--muted); }