:root {
  --bg: #0f1420;
  --bg-soft: #172033;
  --card: #1d2740;
  --card-soft: #232f4d;
  --line: #2f3d5c;
  --text: #eef2ff;
  --muted: #9aa7c7;
  --accent: #ffb703;
  --accent-deep: #f08c00;
  --good: #2fbf71;
  --bad: #ef5350;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #22305a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  min-height: 100%;
}

button, input, select {
  font-family: inherit;
  font-size: 15px;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 18px 40px;
}

/* 顶部栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: #201703;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 20px rgba(240, 140, 0, .28);
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-text strong { font-size: 18px; letter-spacing: .5px; }
.brand-text span { color: var(--muted); font-size: 13px; }

.userbox {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px 8px 18px;
}

.who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.score { font-size: 13px; color: var(--muted); }
.score b { color: var(--accent); font-size: 16px; }

.tag {
  font-style: normal;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(47, 191, 113, .16);
  color: #7ee2a8;
  border: 1px solid rgba(47, 191, 113, .35);
}

.tag-admin {
  background: rgba(255, 183, 3, .16);
  color: var(--accent);
  border-color: rgba(255, 183, 3, .4);
}

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
}

.stage { display: flex; flex-direction: column; gap: 14px; }
.side { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 14px 34px rgba(5, 10, 22, .35);
}

.card h2 { margin: 0 0 12px; font-size: 16px; letter-spacing: .5px; }

/* 状态条 */
.statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--muted);
}

.statusbar .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(154, 167, 199, .15);
}

.statusbar .timer { margin-left: auto; font-variant-numeric: tabular-nums; }

.status-answering { color: #ffe6a8; border-color: rgba(255, 183, 3, .45); }
.status-answering .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 183, 3, .22);
  animation: pulse 1.1s infinite;
}

.status-revealed { color: #a9e8c4; border-color: rgba(47, 191, 113, .45); }
.status-revealed .dot {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(47, 191, 113, .2);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* 题目 */
.qmeta { display: flex; gap: 8px; margin-bottom: 12px; }

.chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  color: var(--muted);
  border: 1px solid var(--line);
}

.question h1 {
  margin: 0 0 16px;
  font-size: 21px;
  line-height: 1.55;
  font-weight: 600;
}

.qimage {
  font-size: 56px;
  text-align: center;
  margin: 6px 0 14px;
  line-height: 1.2;
}

.options { display: flex; flex-direction: column; gap: 10px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.option:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(255, 183, 3, .08);
  transform: translateY(-1px);
}

.option:disabled { cursor: default; opacity: .92; }

.option .key {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, .09);
  color: var(--muted);
}

.option.chosen { border-color: rgba(255, 183, 3, .7); background: rgba(255, 183, 3, .12); }
.option.chosen .key { background: var(--accent); color: #22180a; }

.option.correct { border-color: rgba(47, 191, 113, .8); background: rgba(47, 191, 113, .14); }
.option.correct .key { background: var(--good); color: #06240f; }

.option.wrong { border-color: rgba(239, 83, 80, .7); background: rgba(239, 83, 80, .12); }
.option.wrong .key { background: var(--bad); color: #2b0606; }

.fill {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  outline: none;
}

.fill:focus { border-color: var(--accent); }
.fill:disabled { opacity: .8; }

.hint { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* 揭晓 */
.reveal h2 { color: var(--accent); }
.answer-line { margin: 0 0 8px; font-size: 17px; }
.answer-line b { color: #ffe6a8; }
.winner-line { margin: 0 0 8px; color: #8fe0b3; font-size: 15px; }
.explain { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* 管理员控制台 */
.filters { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  min-width: 130px;
}

.host-actions { display: flex; gap: 10px; flex-wrap: wrap; }

button.primary, button.ghost, button.danger, .submit-fill {
  padding: 10px 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter .15s ease, transform .12s ease;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #22180a;
  font-weight: 700;
}

button.ghost {
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  border-color: var(--line);
}

button.danger {
  background: rgba(239, 83, 80, .16);
  color: #ffb3b1;
  border-color: rgba(239, 83, 80, .45);
}

button.primary:hover:not(:disabled),
button.ghost:hover:not(:disabled),
button.danger:hover:not(:disabled),
.submit-fill:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }

button:disabled { opacity: .42; cursor: not-allowed; transform: none; }

.submit-fill { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #22180a; font-weight: 700; }

/* 排行榜 */
.board-head { display: flex; align-items: baseline; justify-content: space-between; }
.muted { color: var(--muted); font-size: 12px; }

.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.board-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid transparent;
}

.board-row .rank {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, .08);
  color: var(--muted);
}

.rank-1 { background: linear-gradient(135deg, #ffd76a, #f0a500) !important; color: #2b1c00 !important; }
.rank-2 { background: linear-gradient(135deg, #dfe6f2, #b9c4d8) !important; color: #1d2433 !important; }
.rank-3 { background: linear-gradient(135deg, #f0b98a, #c98a55) !important; color: #2b1608 !important; }

.board-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .name.me { color: var(--accent); font-weight: 700; }
.board-row .pts { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.board-list .empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

/* 玩法说明 */
.tips ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.85; }

/* 提示条 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: rgba(15, 20, 32, .94);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
  z-index: 40;
}

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--card) 0%, var(--card-soft) 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 30px 28px;
  box-shadow: 0 24px 60px rgba(4, 8, 18, .55);
}

.login-card .logo { margin: 0 auto 14px; }
.login-title { text-align: center; margin: 0 0 6px; font-size: 20px; }
.login-sub { text-align: center; margin: 0 0 22px; color: var(--muted); font-size: 13px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }

.tab {
  padding: 9px 0;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: rgba(255, 183, 3, .14);
  border-color: rgba(255, 183, 3, .55);
  color: var(--accent);
  font-weight: 700;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }

.field input {
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  outline: none;
}

.field input:focus { border-color: var(--accent); }

.login-card .primary { width: 100%; padding: 12px 0; font-size: 16px; }

.alert {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 11px;
  font-size: 13px;
  background: rgba(239, 83, 80, .14);
  border: 1px solid rgba(239, 83, 80, .4);
  color: #ffb3b1;
}

.login-foot { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.7; }

/* ------------------------------------------------------------------ */
/* 大厅聊天（v1.5 新增）                                                */
/* ------------------------------------------------------------------ */
.chat { display: flex; flex-direction: column; gap: 10px; }

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 4px 2px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.chat-list::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

.chat-empty {
  margin: auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.chat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid transparent;
  animation: chat-in .18s ease;
}

@keyframes chat-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.chat-row[data-role="admin"] {
  background: rgba(255, 183, 3, .09);
  border-color: rgba(255, 183, 3, .28);
}

.chat-row.mine {
  background: rgba(47, 191, 113, .08);
  border-color: rgba(47, 191, 113, .25);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.chat-name {
  font-size: 13px;
  font-weight: 600;
  color: #dfe6f2;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-row.mine .chat-name { color: #9ee7bf; }
.chat-time { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 11px; }

.chat-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-form { display: flex; gap: 8px; align-items: stretch; }

.chat-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  outline: none;
  transition: border-color .12s ease;
}

.chat-input:focus { border-color: var(--accent); }
.chat-input.warn { border-color: rgba(255, 183, 3, .7); }

.chat-send {
  flex: none;
  min-width: 76px;
  padding: 0 14px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.chat-hint { margin: 0; font-size: 12px; }

/* 平板 / 手机 */
@media (max-width: 880px) {
  .chat-list { height: 300px; }
}

@media (max-width: 560px) {
  .page { padding: 14px 12px calc(28px + env(safe-area-inset-bottom)); }
  .card { padding: 16px 14px; border-radius: 14px; }
  .topbar { gap: 10px; margin-bottom: 12px; }
  .brand-text strong { font-size: 16px; }
  .brand-text span { font-size: 12px; }
  .userbox {
    width: 100%;
    justify-content: space-between;
    padding: 8px 10px 8px 14px;
    border-radius: 14px;
  }
  .statusbar { font-size: 13px; padding: 9px 13px; }
  .question h1 { font-size: 18px; line-height: 1.5; }
  .option { padding: 12px 13px; font-size: 14px; }
  .chat-list { height: 46vh; min-height: 220px; }
  .chat-form { gap: 6px; }
  .chat-input { font-size: 16px; padding: 11px 12px; }
  .chat-send { min-width: 64px; padding: 0 12px; }
  .chat-text { font-size: 15px; }
  .board-row { grid-template-columns: 28px minmax(0, 1fr) auto; padding: 8px 10px; }
}
