/* ===== 动漫猜猜看 · 界面美化 ===== */
:root {
  --bg-1: #0f0c1d;
  --bg-2: #1a1333;
  --card: rgba(24, 20, 46, 0.72);
  --card-border: rgba(167, 139, 250, 0.16);
  --card-hover: rgba(167, 139, 250, 0.28);
  --accent: #a78bfa;
  --accent-2: #f472b6;
  --accent-glow: rgba(167, 139, 250, 0.35);
  --text: #eae7f5;
  --text-dim: #9d96b8;
  --text-faint: #6b6485;
  --good: #34d399;
  --bad: #f87171;
  --radius: 6px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(167,139,250,.14), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(244,114,182,.10), transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 60%, #141026);
  color: var(--text);
  /* 旧浏览器兜底：100vh 在移动端等于 lvh（工具栏收起），比可视区高，会在答题页底部留白 */
  min-height: 100vh;
  /* 与 #view-game 的 100svh 基准保持一致，页面不再高于可视区，底部空白消失 */
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.container { max-width: 1160px; margin: 0 auto; padding: 32px 24px 64px; }

/* 顶部品牌 */
.brand { display:flex; align-items:baseline; gap:14px; margin-bottom: 6px; }
h1 { font-size: 34px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(92deg, #c4b5fd 0%, #f472b6 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.subtitle { color: var(--text-dim); font-size: 15px; margin-bottom: 36px; }
.subtitle b { color: var(--accent); font-weight: 600; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 30px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.04);
}
h3 { font-weight: 700; letter-spacing: .3px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 13px 26px;
  font-size: 15px; font-weight: 700; cursor: pointer; color: #fff;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s;
  letter-spacing: .3px;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary { background: linear-gradient(93deg, #8b5cf6, #ec4899); box-shadow: 0 8px 24px var(--accent-glow); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 32px rgba(236,72,153,.4); }
.btn-ghost {
  background: rgba(167,139,250,.08); color: var(--accent);
  border: 1px solid rgba(167,139,250,.25); box-shadow: none;
}
.btn-ghost:hover:not(:disabled) { background: rgba(167,139,250,.15); }

/* 输入 */
label { display: block; margin: 18px 0 8px; color: var(--text-dim); font-size: 13px; font-weight: 600; letter-spacing: .4px; }
input, textarea {
  width: 100%; background: rgba(10, 8, 24, .6);
  border: 1px solid rgba(167,139,250,.18); border-radius: 12px;
  padding: 13px 16px; color: var(--text); font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(167,139,250,.15); }
input::placeholder { color: var(--text-faint); }
.row { display: flex; gap: 12px; align-items: center; }
.mt { margin-top: 22px; }
.error { color: var(--bad); margin-top: 10px; font-size: 14px; min-height: 20px; }

/* ===== 大厅 ===== */
.room-code-box {
  display: flex; align-items: center; gap: 16px; padding: 18px 22px; margin: 20px 0 8px;
  background: rgba(167,139,250,.07); border: 1px dashed rgba(167,139,250,.3); border-radius: 14px;
}
.room-code-display {
  font-size: 44px; font-weight: 800; letter-spacing: 10px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  background: linear-gradient(92deg,#f472b6,#c4b5fd);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.copy-hint { color: var(--text-faint); font-size: 13px; margin-bottom: 24px; }
.players-list { display: flex; flex-wrap: wrap; gap: 12px; }
.player-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(167,139,250,.10); border: 1px solid rgba(167,139,250,.25);
  border-radius: 999px; padding: 9px 20px; font-weight: 600; font-size: 14px;
}
.player-chip.ready {
  background: rgba(52,211,153,.10);
  border-color: rgba(52,211,153,.35);
}
.player-chip.unready { opacity: .82; }
.player-chip.disconnected { opacity: .48; }
.player-chip .ready-state { font-size: 12px; color: var(--text-faint); }
.player-chip.ready .ready-state { color: var(--good); font-weight: 700; }
.player-chip .score { color: var(--accent-2); font-weight: 800; }
.share-box {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 18px; padding: 14px 16px; border-radius: 14px;
  background: rgba(52,211,153,.08); border: 1px solid rgba(52,211,153,.25);
}
.share-label { display: block; font-size: 12px; color: var(--text-faint); letter-spacing: 1px; }
.share-url {
  color: var(--good); font-weight: 800; text-decoration: none;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  word-break: break-all;
}
.share-url:hover { text-decoration: underline; }
.ready-status {
  margin: 18px 0 0; padding: 12px 16px; border-radius: 12px;
  background: rgba(167,139,250,.08); border: 1px solid rgba(167,139,250,.2);
  color: var(--text-dim); font-size: 14px; text-align: center;
}

/* ===== 游戏布局 ===== */
/* 桌面端：左侧玩家列表，右侧上方题目、下方答题记录 */
.game-layout {
  display: grid; grid-template-columns: 290px minmax(0, 1fr);
  gap: 18px; align-items: start;
}
.game-main {
  min-width: 0; display: flex; flex-direction: column; gap: 16px;
}
.game-sidebar { position: sticky; top: 24px; min-width: 0; }
.question-stage { padding: 16px; }

/* 答题记录 + 提交框 */
.answer-panel {
  margin-top: 0; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 260px;
}
.answer-log {
  flex: 1; min-height: 150px; overflow-y: auto; padding-right: 6px;
  display: flex; flex-direction: column; gap: 8px;
}
.answer-item {
  display: flex; align-items: baseline; gap: 7px;
  padding: 9px 11px; border-radius: 10px; line-height: 1.35;
  background: rgba(167,139,250,.07); border: 1px solid rgba(167,139,250,.12);
}
.answer-item .answer-name {
  flex: 0 0 auto; max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--accent); font-weight: 700; font-size: 13px;
}
.answer-item .answer-text { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--text); font-size: 13px; }
.answer-item.chat {
  background: rgba(59,130,246,.08);
  border-color: rgba(59,130,246,.2);
}
.answer-item.chat .answer-name { color: #2563eb; }
.answer-item.chat .answer-text { color: var(--text); font-weight: 500; }
.answer-item.correct {
  background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.24);
}
.answer-item.correct .answer-text,
.answer-item.correct .answer-name {
  color: var(--good); font-weight: 800;
}
.answer-item.wrong {
  background: #fdf4f4;
  border-color: #f0caca;
}
.answer-item.wrong .answer-name,
.answer-item.wrong .answer-text {
  color: var(--bad);
  font-weight: 800;
}
.answer-item.wrong.mine {
  background: #fdf1f1;
  border-color: #e9b7b7;
}
/* 记录面板的题目分隔：让「已进入下一题、上一题的答题记录已清空」这件事被玩家看见 */
.answer-log-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0 0;
  color: #8c99aa; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  white-space: nowrap;
}
.answer-log-divider::before,
.answer-log-divider::after {
  content: ''; flex: 1 1 auto; height: 1px; background: #dbe3ec;
}

/* 手机端：上方题目舞台，下方左侧玩家、右侧答题记录 */
@media (max-width: 900px) {
  .container { padding: 14px 10px 32px; }
  .game-layout {
    grid-template-columns: minmax(92px, 112px) minmax(0, 1fr);
    grid-template-rows: minmax(0, auto) minmax(0, auto);
    grid-template-areas:
      "stage stage"
      "players answers";
    gap: 10px; align-items: stretch;
  }
  .game-main { display: contents; }
  .question-stage {
    grid-area: stage; padding: 12px;
    max-height: 54svh; overflow: hidden;
  }
  .game-sidebar {
    grid-area: players; position: static;
    display: flex; flex-direction: column; min-height: 0;
  }
  .answer-panel {
    grid-area: answers; display: flex; flex-direction: column;
    padding: 12px; min-height: 0; overflow: hidden; gap: 8px;
  }
  .answer-log { flex: 1; min-height: 0; }
  .answer-input-row { margin-top: auto; }
  /* 手机端隐藏侧栏离开按钮，保持紧凑玩家栏 */

  .game-sidebar .btn { display: none; }
  .hint-line { padding: 9px 10px; gap: 8px; }
  .hint-masks { min-width: 0; font-size: clamp(18px, 5.4vw, 26px); letter-spacing: 2px; }
  .round-bar { font-size: 12px; gap: 6px; }
  .round-pill, .score-pill { padding: 4px 8px; font-size: 11px; }
}

@media (max-width: 520px) {
  .game-layout { grid-template-columns: minmax(84px, 96px) minmax(0, 1fr); gap: 8px; }
  .score-board { height: 100%; min-height: 0; overflow-y: auto; padding: 7px; border-radius: 14px; }
  .score-row { gap: 6px; padding: 7px 5px; }
  .player-avatar {
    width: 24px; height: 24px; flex: 0 0 auto;
    font-size: 11px; border-radius: 50%;
  }
  .player-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .player-name {
    font-size: 11px; line-height: 1.15;
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
.score-row .pts { font-size: 10px; line-height: 1.15; font-weight: 800; color: var(--text-dim); }
.score-row.disconnected { opacity: .48; }
  .answer-panel { padding: 10px; }
  .answer-input-row { gap: 6px; }
  .answer-input-row input { padding: 9px 10px; font-size: 13px; }
  .answer-input-row .btn { padding: 9px 10px; font-size: 12px; }
  .answer-item { padding: 7px 8px; gap: 5px; }
  .answer-item .answer-name { max-width: 32%; font-size: 11px; }
  .answer-item .answer-text { font-size: 12px; }
}

.round-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
  color: var(--text-dim); font-size: 14px;
}
.round-bar b { color: var(--text); font-weight: 700; }
.round-pill {
  padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(167,139,250,.12); border: 1px solid rgba(167,139,250,.28); color: var(--accent);
}
.score-pill {
  padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(244,114,182,.12); border: 1px solid rgba(244,114,182,.3); color: var(--accent-2);
}

.img-wrapper {
  position: relative; display: grid; place-items: center;
  aspect-ratio: var(--image-aspect, 16 / 9);
  width: 100%;
  min-height: 0; max-height: 70vh; border-radius: var(--radius); overflow: hidden;
  background: #08060f;
  border: 1px solid rgba(167,139,250,.18);
  box-shadow: 0 24px 70px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.02) inset;
}
.image-canvas { position: relative; line-height: 0; }
.img-wrapper img { width: 100%; height: 100%; object-fit: contain; display: block; }
.grid-overlay { position: absolute; inset: 0; display: grid; pointer-events: none; }
.cell { border: .5px solid rgba(8,6,15,.9); background: #08060f; transition: background .35s ease; }
.cell.revealed { background: transparent; border-color: transparent; }

.timer-bar { height: 10px; background: rgba(167,139,250,.12); border-radius: 999px; margin-top: 18px; overflow: hidden; }
.timer-fill { height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  box-shadow: 0 0 12px var(--accent-glow); transition: width .5s linear; }

/* 答题卡 */
.answer-panel label { margin-top: 0; }
.answer-input-row { gap: 10px; }
.hint-line {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: 14px;
  background: rgba(167,139,250,.09); border: 1px solid rgba(167,139,250,.2);
}
.question-hint { margin-bottom: 16px; }
.question-stage.result .img-wrapper img {
  object-fit: contain;
}
.hint-label { font-size: 13px; font-weight: 800; color: var(--text-dim); letter-spacing: 1px; }
.hint-masks {
  flex: 1; min-width: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(24px, 4vw, 36px); font-weight: 900; letter-spacing: 4px; color: var(--accent);
  white-space: pre-wrap; word-break: break-word; line-height: 1.3;
  text-shadow: 0 0 18px rgba(167,139,250,.25);
}
.hint-wrong { color: var(--bad); }
.hint-right { color: var(--good); }

/* 结果 */
.result-banner {
  margin-top: 0; padding: 20px 22px; border-radius: 14px;
  background: linear-gradient(160deg, rgba(52,211,153,.14), rgba(52,211,153,.05));
  border: 1px solid rgba(52,211,153,.35);
  animation: pop .4s cubic-bezier(.2,1.4,.4,1);
}
.result-banner.wrong {
  background: linear-gradient(160deg, rgba(248,113,113,.12), rgba(248,113,113,.04));
  border-color: rgba(248,113,113,.3);
}
.result-banner .big-line { font-size: 17px; font-weight: 700; }
.result-banner .flow { margin-top: 4px; font-size: 12px; color: var(--text-faint); letter-spacing: .5px; }
.result-banner .ans-line { margin-top: 12px; font-size: 14px; color: var(--text-dim); }
.result-banner .ans-word { font-size: 20px; font-weight: 800; color: var(--accent); margin-left: 8px; }
.result-banner .who { margin-top: 8px; font-size: 13px; color: var(--text-dim); }
@keyframes pop { 0% { transform: scale(.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* 玩家列表：头像在左，名称/分数在右 */
.score-board {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 16px; backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.score-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 12px; margin-bottom: 4px;
}
.player-avatar {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg,#8b5cf6,#ec4899); color:#fff; font-size:13px; font-weight:800;
}
.player-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.player-name {
  font-size: 14px; line-height: 1.2;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-row .pts { font-size: 12px; line-height: 1.2; color: var(--text-dim); font-weight: 800; }
.score-row.me { background: rgba(244,114,182,.1); border: 1px solid rgba(244,114,182,.22); }
.score-row.me .player-name, .score-row.me .pts { color: var(--accent-2); }

/* ===== 结算 ===== */
.final-wrap { max-width: 620px; margin: 40px auto 0; text-align: center; }
.final-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-radius: 12px; margin-bottom: 10px; font-size: 17px;
  background: rgba(167,139,250,.06); border: 1px solid rgba(167,139,250,.12);
}
.final-row.champ { background: linear-gradient(93deg, rgba(244,114,182,.16), rgba(167,139,250,.14)); border-color: rgba(244,114,182,.35); }
.final-row .pts { font-weight: 800; font-size: 22px; color: var(--accent-2); }

/* ===== 题库管理 ===== */
.divider { border: none; border-top: 1px solid rgba(167,139,250,.12); margin: 24px 0; }
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 14px; margin-top: 18px; }
.q-item {
  background: rgba(10,8,24,.5); border: 1px solid rgba(167,139,250,.14);
  border-radius: 12px; overflow: hidden; transition: transform .15s, border-color .15s;
}
.q-item:hover { transform: translateY(-3px); border-color: var(--card-hover); }
.q-item img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.q-item .answer { padding: 9px 12px 4px; font-size: 12.5px; color: var(--accent); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-item button {
  width: 100%; border: none; background: transparent; color: var(--text-faint);
  padding: 7px; cursor: pointer; font-size: 12px;
}
.q-item button:hover { color: var(--bad); }

/* 顶部导航条（游戏中） */
.topnav { display:flex; justify-content: space-between; align-items:center; margin-bottom: 18px; }
.topnav .room-tag { color: var(--text-faint); font-size: 13px; letter-spacing: 1px; }
.topnav .room-tag b { color: var(--accent); font-family: "SF Mono", monospace; letter-spacing: 3px; }

/* 手机端最终布局：强制上下分区在一屏内显示，并修复后置基础样式造成的排版覆盖 */
@media (max-width: 900px) {
  .container { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  #view-game {
    display: flex; flex-direction: column;
    min-height: calc(100svh - 20px - env(safe-area-inset-bottom));
    overflow: visible;
  }
  .topnav { flex: 0 0 auto; margin-bottom: 7px; }
  .topnav .room-tag { font-size: 11px; }
  .topnav .room-tag b { letter-spacing: 2px; }

  .game-layout {
    flex: 1; min-height: 0;
    grid-template-columns: minmax(96px, 112px) minmax(0, 1fr);
    grid-template-rows: minmax(0, auto) minmax(0, 1fr);
    grid-template-areas:
      "stage stage"
      "players answers";
    gap: 7px; align-items: stretch;
  }
  .question-stage {
    grid-area: stage;
    display: flex; flex-direction: column;
    min-height: 0; max-height: 100%;
    padding: 9px; overflow: hidden;
  }
  .question-hint { margin-bottom: 7px; }
  .hint-line {
    align-items: center; gap: 6px;
    padding: 5px 7px; border-radius: 10px;
  }
  .hint-label { flex: 0 0 auto; font-size: 10px; letter-spacing: 1px; }
  .hint-masks {
    min-width: 0; flex: 1;
    font-size: clamp(14px, 3.8vw, 19px);
    letter-spacing: 3px; line-height: 1.1;
    max-height: calc(1.1em * 3); overflow: hidden;
    text-shadow: none;
  }
  .hint-line {
    flex: 0 0 auto;
  }
  .img-wrapper {
    flex: 0 0 auto;
    aspect-ratio: var(--image-aspect, 16 / 9);
    width: 100%;
    min-height: 0;
    max-height: 60vh;
    margin: 0 auto;
  }
  .timer-bar { height: 4px; margin-top: 7px; }

  .game-sidebar {
    grid-area: players; position: static;
    min-width: 0; min-height: 0; display: flex;
  }
  .game-sidebar .btn { display: none; }
  .score-board {
    width: 100%; height: 100%; min-height: 0;
    padding: 5px; border-radius: 14px; overflow-y: auto;
  }
  .score-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 6px; row-gap: 1px;
    align-items: center; padding: 6px 4px; margin-bottom: 3px;
  }
  .player-avatar {
    grid-column: 1; grid-row: 1 / span 2;
    width: 22px; height: 22px; font-size: 10px;
  }
  .player-meta { display: contents; }
  .player-name {
    grid-column: 2; grid-row: 1;
    min-width: 0; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 11px; line-height: 1.1;
  }
  .score-row .pts {
    grid-column: 2; grid-row: 2;
    font-size: 10px; line-height: 1.1; color: var(--text-dim);
  }

  .answer-panel {
    grid-area: answers;
    height: 100%; min-height: 0;
    padding: 8px; gap: 6px; overflow: hidden;
  }
  .answer-log { flex: 1 1 auto; min-height: 0; gap: 5px; padding-right: 3px; }
  #answer-area { flex: 0 0 auto; }
  .answer-input-row { gap: 6px; align-items: stretch; margin-top: 0; }
  .answer-input-row input { min-width: 0; padding: 9px 10px; font-size: 13px; height: auto; }
  .answer-input-row .btn { padding: 9px 12px; font-size: 12px; border-radius: 10px; }
  .answer-item { padding: 6px 7px; gap: 5px; }
  .answer-item .answer-name { max-width: 31%; font-size: 11px; }
  .answer-item .answer-text { font-size: 12px; }
}

@media (max-width: 520px) {
  .game-layout { grid-template-columns: minmax(92px, 102px) minmax(0, 1fr); gap: 6px; }
}


/* 候选截图审核 */
.candidate-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; margin-top: 16px;
}
.candidate-item { padding: 0; overflow: hidden; }
.candidate-form { display: flex; flex-direction: column; gap: 7px; padding: 9px; }
.candidate-form input { padding: 8px 10px; font-size: 12px; }
.candidate-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.candidate-actions button {
  border: none; border-radius: 9px; padding: 8px; cursor: pointer;
  color: #fff; font-size: 12px; font-weight: 700;
}
.candidate-actions .approve { background: linear-gradient(93deg,#10b981,#34d399); }
.candidate-actions .reject { background: rgba(248,113,113,.16); color: var(--bad); border: 1px solid rgba(248,113,113,.28); }

/* ===== 简约清新大气 · 浅色主题覆盖 ===== */
:root {
  --bg-1: #f5f8fb;
  --bg-2: #eef3f8;
  --card: #ffffff;
  --card-border: #e4eaf2;
  --card-hover: #cfd9e7;
  --accent: #2563eb;
  --accent-2: #0f9d8f;
  --accent-glow: rgba(37, 99, 235, .12);
  --text: #17233a;
  --text-dim: #637084;
  --text-faint: #8c99aa;
  --good: #129d6e;
  --bad: #d94f4f;
  --radius: 6px;
}

html { color-scheme: light; }
body {
  background:
    radial-gradient(720px 460px at 82% 0%, rgba(59,130,246,.10), transparent 62%),
    radial-gradient(620px 430px at 0% 100%, rgba(15,157,143,.09), transparent 60%),
    linear-gradient(180deg, #f7fafc, #eef3f8);
  color: var(--text);
}

h1 {
  background: linear-gradient(92deg, #2563eb, #0f9d8f);
  -webkit-background-clip: text; background-clip: text;
}
.subtitle, .copy-hint, label, .ready-status { color: var(--text-dim); }
.subtitle b { color: var(--accent); }

.card, .score-board {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--card-border);
  box-shadow: 0 12px 34px rgba(23, 55, 94, .06);
}

.btn { color: white; }
.btn-primary {
  background: linear-gradient(93deg, #2563eb, #0ea5a4);
  box-shadow: 0 8px 20px rgba(37,99,235,.14);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 24px rgba(37,99,235,.2); }
.btn-ghost {
  background: #fff; color: #2c4a6b;
  border: 1px solid #d8e0ea;
  box-shadow: 0 2px 8px rgba(23,55,94,.04);
}
.btn-ghost:hover:not(:disabled) { background: #f5f8fb; }

input, textarea {
  background: #f8fafc;
  border: 1px solid #dbe3ec;
  color: var(--text);
}
input:focus { border-color: #93b4fb; box-shadow: 0 0 0 4px rgba(37,99,235,.08); }
input::placeholder { color: #a4b0c0; }

.room-code-box {
  background: #f3f7fd;
  border: 1px dashed #bfd0e6;
}
.room-code-display {
  background: linear-gradient(92deg, #2563eb, #0f9d8f);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.players-list .player-chip {
  background: #fff; border: 1px solid #dbe3ec; color: var(--text);
  box-shadow: 0 2px 8px rgba(23,55,94,.04);
}
.player-chip.ready {
  background: #f0fbf6;
  border-color: #a7e5c8;
  color: var(--good);
}
.player-chip .ready-state { color: var(--text-faint); }
.player-chip.ready .ready-state { color: var(--good); }
.player-chip .score { color: var(--accent-2); }

.share-box {
  background: #f0fbf6;
  border: 1px solid #bfe7d2;
}
.share-label { color: var(--text-faint); }
.share-url { color: #0d8a61; }
.ready-status {
  background: #f4f7fd;
  border: 1px solid #dce5f0;
}

.answer-item {
  background: #f7f9fc;
  border: 1px solid #e3e9f1;
}
.answer-item .answer-name { color: var(--accent); }
.answer-item .answer-text { color: #28364c; }
.answer-item.correct { background: #eefaf4; border-color: #bfe8d3; }
.answer-item.correct .answer-text,
.answer-item.correct .answer-name { color: var(--good); }
.answer-item.wrong.mine { background: #fdf4f4; border-color: #f0caca; }

.round-pill {
  background: #eef4ff;
  border: 1px solid #cfdefb;
  color: #2557b8;
}
.score-pill {
  background: #edf9f7;
  border: 1px solid #bfe7e2;
  color: #0c7f74;
}

.hint-line {
  background: #f4f7fd;
  border: 1px solid #dbe5f1;
}
.hint-label { color: #637084; }
.hint-masks {
  color: #1f4f8f;
  text-shadow: none;
}

.img-wrapper {
  background: #f2f5f8;
  border: 1px solid #e0e6ee;
  box-shadow: 0 8px 22px rgba(23,55,94,.06);
}
.grid-overlay .cell {
  background: #e7ecf3;
  border-color: rgba(255,255,255,.72);
}
.grid-overlay .cell.revealed { background: transparent; border-color: transparent; }
.timer-bar { background: #e6ecf4; }
.timer-fill {
  background: linear-gradient(90deg, #2563eb, #0ea5a4);
  box-shadow: none;
}

.score-board { box-shadow: 0 8px 24px rgba(23,55,94,.05); }
.score-row.me {
  background: #f1f7ff;
  border: 1px solid #cddff9;
}
.score-row.me .player-name,
.score-row.me .pts { color: #22518f; }
.player-avatar {
  background: linear-gradient(135deg, #2563eb, #0ea5a4);
  color: #fff;
}

.result-banner {
  background: linear-gradient(160deg, #eefaf4, #fff);
  border: 1px solid #bfe8d3;
}
.result-banner.wrong {
  background: linear-gradient(160deg, #fff6f5, #fff);
  border-color: #f2c7c5;
}
.result-banner .ans-word { color: var(--accent); }

.final-row {
  background: #f7f9fc;
  border: 1px solid #e3e9f1;
}
.final-row.champ {
  background: linear-gradient(93deg, #f0fbf6, #eef4ff);
  border-color: #bfe0f5;
}
.final-row .pts { color: var(--accent-2); }

.divider { border-top: 1px solid #e6ebf2; }
.q-item {
  background: #fff;
  border: 1px solid #e4eaf2;
  box-shadow: 0 6px 16px rgba(23,55,94,.04);
}
.q-item:hover { border-color: #bfd0e6; }
.q-item .answer { color: var(--accent); }
.q-item button { color: var(--text-faint); }
.topnav .room-tag { color: var(--text-faint); }
.topnav .room-tag b { color: var(--accent); }

/* ===== 创建房间弹窗 ===== */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(23,35,58,.28);
  backdrop-filter: blur(8px);
}
.modal-card {
  width: min(430px, 100%); background: rgba(255,255,255,.97);
  border: 1px solid var(--card-border); border-radius: 22px;
  padding: 24px; box-shadow: 0 24px 70px rgba(23,55,94,.18);
  animation: modal-pop .22s ease;
}
.modal-title { font-size: 20px; color: var(--text); }
.modal-desc { margin: 7px 0 16px; color: var(--text-dim); font-size: 13px; }
.room-size-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.room-size-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 15px 16px; cursor: pointer; text-align: left;
  background: #f8fafc; border: 1px solid #dbe3ec; border-radius: 15px;
  transition: .16s ease;
}
.room-size-option:hover { border-color: #93b4fb; background: #f2f7ff; transform: translateY(-2px); }
.room-size-option b { font-size: 16px; color: var(--text); }
.room-size-option span { font-size: 12px; color: var(--text-faint); }
.room-size-option.selected {
  background: #eef5ff;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,.10);
}
.room-size-option.selected b { color: #2358b7; }
.modal-actions {
  display: grid; grid-template-columns: 94px minmax(0, 1fr); gap: 10px;
  margin-top: 2px;
}
.modal-actions .modal-cancel { width: 100%; margin-top: 0; }
@keyframes modal-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }


/* 创建房间弹窗：2-8人布局 */
.room-size-grid { grid-template-columns: repeat(4, 1fr); }
.room-size-option { align-items: center; text-align: center; }
@media (max-width: 520px) {
  .room-size-option { padding: 8px 4px; border-radius: 11px; gap: 1px; }
  .room-size-option b { font-size: 12px; }
  .room-size-option span { font-size: 9px; }
  .modal-card { padding: 16px 14px; }
}


/* 单人模式入口 */
.solo-option {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 16px; margin-bottom: 18px; cursor: pointer; text-align: left;
  background: linear-gradient(93deg, #eef6ff, #effaf7);
  border: 1px solid #c8e2f7; border-radius: 16px;
  transition: .16s ease;
}
.solo-option:hover { transform: translateY(-2px); border-color: #93b4fb; box-shadow: 0 10px 22px rgba(37,99,235,.08); }
.solo-option b { font-size: 16px; color: var(--text); }
.solo-option span { font-size: 12px; color: var(--text-faint); }
.modal-subtitle {
  margin: 0 0 10px; color: var(--text-faint); font-size: 12px; font-weight: 700; letter-spacing: 1px;
}

.mode-selector {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 14px;
}
.mode-option {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 11px 9px; cursor: pointer; text-align: center;
  background: #f8fafc; border: 1px solid #dbe3ec; border-radius: 15px;
  transition: .16s ease;
}
.mode-option:hover { border-color: #93b4fb; background: #f2f7ff; }
.mode-option b { font-size: 14px; color: var(--text); }
.mode-option span { font-size: 11px; color: var(--text-faint); }
.mode-option.selected {
  background: #eef5ff; border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,.10);
}
.mode-option.selected b { color: #2358b7; }
#multi-room-settings { margin-bottom: 12px; }

.question-count-setting {
  margin-bottom: 16px; padding: 12px 14px;
  background: #f7fafd; border: 1px solid #dfe8f2; border-radius: 16px;
}
.question-count-setting .setting-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px; color: var(--text-dim); font-size: 13px; font-weight: 700;
}
.question-count-setting b { color: var(--accent); font-size: 15px; }
.question-count-setting input[type="range"] {
  width: 100%; height: 22px; padding: 0; margin: 0;
  border: none; background: transparent; accent-color: #2563eb; box-shadow: none;
}
.question-count-setting .range-scale {
  display: flex; justify-content: space-between; margin-top: 3px;
  color: var(--text-faint); font-size: 11px;
}


/* 当前答题阶段提示：放在图片外侧，不遮挡画面 */
.stage-timer-row {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; min-width: 0;
}
.stage-timer-row .timer-bar { flex: 1; margin-top: 0; min-width: 0; }
.stage-badge {
  flex: 0 0 auto; padding: 7px 12px; border-radius: 999px;
  background: #f4f7fd; border: 1px solid rgba(37,99,235,.18);
  color: #2358b7; font-size: 12px; font-weight: 800; letter-spacing: .5px;
  white-space: nowrap; pointer-events: none;
}
@media (max-width: 900px) {
  .stage-timer-row { gap: 6px; margin-top: 7px; }
  .stage-badge { padding: 4px 8px; font-size: 10px; }
}


/* 答题记录状态颜色 */
.answer-item.correct .answer-name,
.answer-item.correct .answer-text {
  color: var(--good);
  font-weight: 800;
}
.answer-item.wrong .answer-name,
.answer-item.wrong .answer-text {
  color: var(--bad);
  font-weight: 800;
}


/* 倒计时图标与剩余时间 */
.timer-meta {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  color: #2358b7; font-size: 12px; font-weight: 800;
  white-space: nowrap; min-width: 68px;
}
.timer-clock {
  width: 16px; height: 16px; flex: 0 0 auto;
  fill: none; stroke: #2563eb; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
@media (max-width: 900px) {
  .timer-meta { gap: 4px; min-width: 56px; font-size: 10px; }
  .timer-clock { width: 13px; height: 13px; }
}


/* 键盘弹出时锁定游戏区高度，避免视觉视口变化带动图片区域抖动 */
#view-game.keyboard-locked {
  height: var(--locked-game-height, calc(100svh - 20px - env(safe-area-inset-bottom)));
}


/* 阶段切换倒计时 Toast */
.stage-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(320px, calc(100vw - 48px));
  padding: 14px 22px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(15, 23, 42, .08);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  animation: stage-toast-in .24s ease;
}
.stage-toast.hidden { display: none; }

@keyframes stage-toast-in {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.94); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* 房间号复制与题目进度 */
.room-code-box { gap: 10px; }
.copy-room-btn {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(37, 99, 235, .18);
  border-radius: 10px; background: #fff; color: var(--text-dim);
  cursor: pointer; transition: color .16s, border-color .16s, background .16s, transform .16s;
}
.copy-room-btn:hover { color: var(--accent-2); border-color: rgba(37,99,235,.3); background: #f4f8ff; transform: translateY(-1px); }
.copy-room-btn:active { transform: translateY(0); }
.copy-room-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.copy-room-btn .icon-check { display: none; }
.copy-room-btn.copied { color: var(--good); border-color: rgba(16, 185, 129, .38); background: #f0fbf6; }
.copy-room-btn.copied .icon-copy { display: none; }
.copy-room-btn.copied .icon-check { display: block; }
.lobby .room-code-box .copy-room-btn,
#view-lobby .room-code-box .copy-room-btn { margin-left: auto; }

.room-code-tag {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 0; white-space: nowrap;
}
.room-code-tag > span:first-child { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.room-code-tag .copy-room-btn { width: 24px; height: 24px; border-radius: 8px; }
.room-code-tag .copy-room-btn svg { width: 14px; height: 14px; }
.progress-tag { flex: 0 0 auto; font-weight: 750; letter-spacing: .6px; }
.topnav { gap: 8px; }

@media (max-width: 900px) {
  .room-code-box { padding: 13px 16px; }
  .room-code-display { font-size: clamp(30px, 9vw, 38px); letter-spacing: 7px; }
  .copy-room-btn { width: 30px; height: 30px; }
  .topnav { margin-bottom: 6px; }
  .room-code-tag { gap: 4px; }
  .room-code-tag .copy-room-btn { width: 22px; height: 22px; border-radius: 7px; }
  .room-code-tag .copy-room-btn svg { width: 13px; height: 13px; }
  .progress-tag { min-width: 30px; text-align: right; }
}

@media (max-width: 520px) {
  .topnav { align-items: center; }
  .topnav .room-tag { font-size: 11px; }
  .room-code-display { font-size: clamp(27px, 8vw, 32px); letter-spacing: 5px; }
  .progress-tag { font-size: 12px; }
}


/* 答案提示内容默认居中 */
.question-hint .hint-masks {
  text-align: center;
}


/* 「答案：__」整体居中 */
.question-hint {
  justify-content: center;
}
.question-hint .hint-label {
  flex: 0 0 auto;
}
.question-hint .hint-masks {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  text-align: center;
}


/* 缩小答案下划线之间的间距 */
.question-hint .hint-masks {
  letter-spacing: 2px;
  word-spacing: normal;
}


/* 手机版玩家名称空间优化 */
@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: minmax(118px, 136px) minmax(0, 1fr);
    column-gap: 6px;
  }
  .score-board { padding: 4px; }
  .score-row {
    grid-template-columns: 26px minmax(0, 1fr);
    column-gap: 8px;
    row-gap: 1px;
    padding: 5px 4px;
    margin-bottom: 2px;
  }
  .player-avatar {
    width: 26px; height: 26px; font-size: 11px;
  }
  .player-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    white-space: normal;
    text-overflow: clip;
    font-size: 10px;
    line-height: 1.15;
  }
  .score-row.me .player-avatar {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .28);
  }
}

@media (max-width: 520px) {
  .game-layout {
    grid-template-columns: minmax(122px, 140px) minmax(0, 1fr);
    column-gap: 5px;
  }
  .score-board { padding: 3px; }
  .score-row {
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 8px;
    padding: 4px;
  }
  .player-avatar {
    width: 28px; height: 28px; font-size: 12px;
  }
  .player-name { font-size: 10px; }
}

/* 用户头像 */
.avatar-setup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}
.home-avatar,
.player-avatar {
  overflow: hidden;
}
.home-avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #2563eb, #0ea5a4);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}
.home-avatar img,
.player-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}
.avatar-upload-btn {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
}
.player-chip .player-avatar {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

@media (max-width: 520px) {
  .avatar-setup { gap: 10px; margin-top: 12px; }
  .home-avatar { width: 48px; height: 48px; font-size: 19px; }
  .avatar-upload-btn { padding: 9px 13px; font-size: 12px; }
  .player-chip .player-avatar { width: 22px; height: 22px; font-size: 10px; }
}


/* 答题记录里的头像 */
.answer-item {
  align-items: center;
}
.answer-avatar {
  width: 22px !important;
  height: 22px !important;
  flex: 0 0 auto;
  font-size: 10px !important;
}

@media (max-width: 900px) {
  .answer-avatar {
    width: 17px !important;
    height: 17px !important;
    font-size: 8px !important;
  }
  .answer-item { gap: 4px; }
  .answer-item .answer-name { flex: 0 1 auto; max-width: 38%; }
}


/* 新揭开的方格缓慢渐入 */
.grid-overlay .cell {
  transition: background-color 1.6s cubic-bezier(.22,.61,.36,1), border-color 1.6s cubic-bezier(.22,.61,.36,1);
}
.grid-overlay .cell.slow-reveal {
  animation: cellSlowReveal 1.8s cubic-bezier(.22,.61,.36,1) forwards;
}
@keyframes cellSlowReveal {
  0% {
    background-color: #e7ecf3;
    border-color: rgba(255, 255, 255, .72);
  }
  100% {
    background-color: transparent;
    border-color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grid-overlay .cell,
  .grid-overlay .cell.slow-reveal {
    transition: none;
    animation: none;
  }
}

/* 昵称为空时的行内校验提示 */
#nickname.invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .10);
}
.field-error {
  display: none;
  margin-top: 6px;
  color: #dc2626;
  font-size: 12px;
  line-height: 1.3;
}
.field-error.visible {
  display: block;
}

/* 首页标题与表单整体垂直水平居中 */
#view-home {
  min-height: calc(100svh - 96px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#view-home .brand {
  justify-content: center;
  text-align: center;
  margin: 0 0 26px;
}

#view-home .card {
  width: min(480px, 100%);
}

@media (max-width: 900px) {
  #view-home {
    min-height: calc(100svh - 20px - env(safe-area-inset-bottom));
  }

  #view-home .brand {
    margin-bottom: 20px;
  }
}

/* 答题页房间号左侧的回首页按钮 */
.home-room-btn {
  width: 24px; height: 24px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(37, 99, 235, .18); border-radius: 8px;
  background: #fff; color: var(--text-dim); cursor: pointer;
  transition: color .16s, border-color .16s, background .16s, transform .16s;
}
.home-room-btn:hover { color: #2563eb; border-color: rgba(37,99,235,.3); background: #f4f8ff; transform: translateY(-1px); }
.home-room-btn:active { transform: translateY(0); }
.home-room-btn svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

@media (max-width: 900px) {
  .home-room-btn { width: 22px; height: 22px; border-radius: 7px; }
  .home-room-btn svg { width: 13px; height: 13px; }
}

/* 回首页确认弹窗 */
.confirm-card {
  width: min(360px, 100%);
  text-align: center;
}
.confirm-card h3 { font-size: 20px; }
.confirm-card .modal-desc { margin-bottom: 22px; font-size: 14px; line-height: 1.5; }
.leave-actions { grid-template-columns: 1fr 1fr; }
.leave-actions .modal-cancel,
.leave-actions .leave-confirm { width: 100%; margin-top: 0; }
/* 确认类弹窗里主操作按钮一律撑满格子（离开确认 / 答案当聊天发送确认共用布局） */
.leave-actions > .btn:not(.modal-cancel) { width: 100%; margin-top: 0; }
.leave-confirm {
  background: #2563eb;
  color: #fff;
  box-shadow: none;
}
.leave-confirm:hover:not(:disabled) {
  background: #1d4ed8;
  box-shadow: none;
}

/* 答题页房间号右侧：只保留复制图标，不要底色和边框 */
.room-code-tag .copy-room-btn,
.room-code-tag .copy-room-btn.copied {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--text-dim);
}
.room-code-tag .copy-room-btn:hover {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #2563eb;
  transform: none;
}
.room-code-tag .copy-room-btn.copied {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--good);
}

@media (max-width: 900px) {
  .room-code-tag .copy-room-btn,
  .room-code-tag .copy-room-btn.copied {
    width: 22px;
    height: 22px;
  }
}

/* 倒计时未作答记录 */
.answer-item.timeout {
  background: #f7f9fc;
  border-color: #dbe4ef;
}
.answer-item.timeout .answer-name,
.answer-item.timeout .answer-text {
  color: #64748b;
  font-weight: 700;
}

/* 桌面端强制答题页在一屏内显示，聊天/答题区保持可见 */
@media (min-width: 901px) {
  body.viewing-game .container {
    padding: 16px 24px;
  }

  #view-game {
    display: flex;
    flex-direction: column;
    height: calc(100svh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: 0;
    overflow: hidden;
  }

  .topnav {
    flex: 0 0 auto;
    margin-bottom: 12px;
  }

  .game-layout {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
  }

  .game-sidebar {
    position: static;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .game-sidebar .score-board {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .game-sidebar .btn.mt {
    flex: 0 0 auto;
    margin-top: 10px;
  }

  .game-main {
    height: 100%;
    min-height: 0;
    gap: 14px;
  }

  .question-stage {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 14px;
  }

  .question-hint {
    flex: 0 0 auto;
  }

  .img-wrapper {
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
    max-height: 60vh;
    aspect-ratio: var(--image-aspect, 16 / 9);
  }

  .stage-timer-row {
    flex: 0 0 auto;
    margin-top: 10px;
  }
  .answer-panel {
    flex: 0 0 auto;
    height: clamp(180px, 28vh, 300px);
    min-height: 0;
    padding: 14px;
    gap: 10px;
    overflow: hidden;
  }

  .answer-log {
    flex: 1 1 auto;
    min-height: 0;
  }
}


/* 猜人物模式 */
.question-type-selector {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  margin-bottom: 18px;
}
.question-type-option {
  border: 1px solid #dbe5f1; background: #f7fafc; color: var(--text);
  border-radius: 14px; padding: 13px 14px; text-align: left; cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.question-type-option b { display: block; font-size: 15px; }
.question-type-option span { display: block; margin-top: 3px; color: #68788f; font-size: 12px; }
.question-type-option.selected {
  background: #edf5ff; border-color: #9dc1f5; color: #17458f;
  box-shadow: 0 0 0 2px rgba(37,99,235,.08);
}
.question-type-option:active { transform: scale(.99); }

.character-import .character-fields {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px;
}
.character-import #character-image-input { grid-column: 1 / -1; }
.character-import .character-fields,
.character-import input[type="file"] { color: var(--text-dim); }
.character-preview {
  margin-top: 12px; padding: 10px; border-radius: 12px;
  background: #f7fafc; border: 1px solid #dbe5f1;
}
.character-preview img {
  max-width: 180px; max-height: 220px; object-fit: contain; display: block;
  background: #fff; border-radius: 8px;
}
.character-preview div { margin-top: 8px; color: #68788f; font-size: 12px; }
.character-import .error { min-height: 18px; margin-top: 8px; }
#image-canvas.character-canvas {
  background: #fff;
  box-shadow: 0 0 0 1px #e5ebf3;
}
.result-work {
  margin: -6px 0 14px; color: #68788f; font-size: 13px; text-align: center;
}
@media (max-width: 640px) {
  .character-import .character-fields { grid-template-columns: 1fr; }
  .question-type-option b { font-size: 14px; }
  .question-type-option span { font-size: 11px; }
}


/* PC 答题稳定性：题图区和答题区共享固定可视高度，输入框始终留在底部。 */
@media (min-width: 901px) {
  .game-layout {
    height: 100%;
    min-height: 0;
    align-items: stretch;
  }
  .game-main {
    display: grid;
    grid-template-rows: minmax(0, 1fr) clamp(180px, 28vh, 300px);
    height: 100%;
    min-height: 0;
    gap: 14px;
  }
  .question-stage {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .img-wrapper {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: auto;
  }
  .answer-panel {
    height: auto;
    min-height: 0;
    margin: 0;
  }
}

/* 新题图片加载前覆盖旧图，避免上一题在下一题出现前闪过一帧。
   加载期间保持正常的浅色背景与遮挡方格，不额外显示黑屏或 Loading 文案。 */
.image-canvas #q-img {
  opacity: 1;
  transition: opacity .24s ease;
}
.image-canvas.image-loading #q-img {
  visibility: hidden;
  opacity: 0;
}


/* 管理员统计卡 */
.analytics-card { margin-bottom: 18px; }
.analytics-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.analytics-head h3 { margin: 0; color: var(--text); font-size: 16px; }
.analytics-summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.analytics-summary span { padding: 10px 8px; border-radius: 10px; background: #f4f7fb; color: #64748b; text-align: center; font-size: 12px; }
.analytics-summary b { display: block; margin-bottom: 3px; color: #2563eb; font-size: 19px; line-height: 1; }
.analytics-days { margin-top: 12px; max-height: 230px; overflow-y: auto; border-top: 1px solid #e7edf4; }
.analytics-days > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px solid #eef3f8; color: #64748b; font-size: 12px; }
.analytics-days > div span:first-child { color: #334155; font-weight: 700; }
@media (max-width: 760px) {
  .analytics-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-days > div { flex-direction: column; gap: 2px; }
}


/* 手机端：聊天按钮单独占一行，避免压缩答题输入框。 */
@media (max-width: 520px) {
  #view-game #answer-area.multiplayer-chat .answer-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(34px, 1fr) minmax(34px, 1fr);
    gap: 6px;
    min-height: 76px;
  }
  #view-game #answer-area.multiplayer-chat #answer-input {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 100%;
    min-height: 76px;
  }
  #view-game #answer-area.multiplayer-chat #btn-chat {
    grid-column: 2;
    grid-row: 1;
    min-width: 52px;
    padding: 6px 10px;
  }
  #view-game #answer-area.multiplayer-chat #btn-submit {
    grid-column: 2;
    grid-row: 2;
    min-width: 52px;
    padding: 6px 10px;
  }
  /* 单人房不带 multiplayer-chat 类：保留原输入框和提交按钮的单行高度。 */
}


.analytics-player-title { margin: 20px 0 6px; font-size: 14px; color: var(--text-dim); }
.analytics-player-note { margin: 0 0 10px; font-size: 12px; color: var(--text-faint); }
.analytics-player-table-wrap { overflow-x: auto; border: 1px solid var(--card-border); border-radius: 10px; }
.analytics-player-table { width: 100%; min-width: 780px; border-collapse: collapse; font-size: 12px; }
.analytics-player-table th,
.analytics-player-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--card-border); white-space: nowrap; }
.analytics-player-table th { color: var(--text-dim); background: rgba(167,139,250,.06); }
.analytics-player-table tr:last-child td { border-bottom: 0; }
.analytics-player-table td:first-child { display: flex; align-items: center; gap: 8px; }
.analytics-player-table small { display: block; color: var(--text-faint); margin-top: 2px; }
.analytics-player-avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 800; flex: 0 0 auto; }
.analytics-player-avatar img { width: 100%; height: 100%; object-fit: cover; }




/* 答题文本框：桌面和单人房维持单行外观，手机多人可自然换行。 */
#answer-input {
  resize: none;
  font-family: inherit;
  line-height: 1.35;
  overflow-y: auto;
}
#btn-chat[hidden] { display: none !important; }
.answer-input-row textarea {
  min-width: 0;
  padding: 9px 10px;
  font-size: 13px;
}
@media (max-width: 520px) {
  #view-game #answer-area.multiplayer-chat .answer-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(34px, 1fr) minmax(34px, 1fr);
    gap: 6px;
    min-height: 78px;
  }
  #view-game #answer-area.multiplayer-chat #answer-input {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 100%;
    min-height: 78px;
    height: 78px;
    white-space: pre-wrap;
    overflow-y: auto;
    vertical-align: top;
  }
  #view-game #answer-area.multiplayer-chat #btn-chat {
    grid-column: 2;
    grid-row: 1;
    min-width: 52px;
    padding: 6px 10px;
  }
  #view-game #answer-area.multiplayer-chat #btn-submit {
    grid-column: 2;
    grid-row: 2;
    min-width: 52px;
    padding: 6px 10px;
  }
  /* 单人房没有 multiplayer-chat 类：textarea 保持 rows=1 的原单行高度。 */
}


/* QUIZ_IMAGE_INTERACTION_GUARD：禁止题图点击、长按菜单、拖拽与文本选择。 */
#image-canvas,
#image-canvas img,
#grid-overlay {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
#image-canvas img {
  pointer-events: none;
}


/* MOBILE_CHAT_LOG_SCROLL_FIX：限制答题记录面板本身，消息多时只滚动记录区。 */
@media (max-width: 900px) {
  #view-game .answer-panel {
    height: clamp(160px, 29svh, 260px);
    max-height: 260px;
    min-height: 0;
    overflow: hidden;
  }
  #view-game .answer-log {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}


.lobby-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lobby-title-row h1 { margin: 0; }
.lobby-share-btn { flex: 0 0 auto; white-space: nowrap; }
.invite-join-panel { margin-top: 18px; padding: 14px; border-radius: 10px; background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.18); }
.invite-join-panel p { margin-bottom: 10px; color: var(--text-dim); text-align: center; }
.invite-join-panel b { color: var(--accent); letter-spacing: 2px; font-family: "SF Mono", ui-monospace, monospace; }
.question-count-setting .setting-head { justify-content: flex-start; gap: 6px; }
.question-count-setting .setting-head b { font-size: 18px; margin-left: 6px; }
#lobby-question-settings { margin-top: 14px; }
@media (max-width: 520px) {
  .lobby-title-row { align-items: flex-start; }
  .lobby-title-row h1 { font-size: 22px !important; }
  .lobby-share-btn { padding: 7px 9px; font-size: 12px; }
}

.copy-toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(30, 41, 59, .94);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 16px 38px rgba(15, 23, 42, .28);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

#home-create-row.hidden,
#home-join-label.hidden,
#home-join-row.hidden,
#invite-join-panel.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  #view-game {
    height: calc(100svh - 20px - env(safe-area-inset-bottom));
    min-height: 0;
    overflow: hidden;
  }

  #view-game.keyboard-locked {
    height: var(--locked-game-height, calc(100svh - 20px - env(safe-area-inset-bottom)));
  }

  #view-game .game-layout {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  #view-game .game-sidebar,
  #view-game .score-board,
  #view-game .answer-panel {
    min-height: 0;
  }

  #view-game .answer-panel {
    height: 100%;
    max-height: none;
    overflow: hidden;
  }

  #view-game .answer-log {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #view-game.multiplayer-game #answer-input {
    min-height: 78px;
    max-height: 78px;
    overflow-y: auto;
  }
}

#view-home { position: relative; }
.invite-home-link {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
}
.invite-home-link .btn {
  min-height: 46px;
  padding: 11px 18px;
  gap: 9px;
  font-size: 15px;
  border-radius: 13px;
}
.invite-home-link .btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 900px) {
  .invite-home-link { top: 0; left: 0; }
  .invite-home-link .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
  }
  .invite-home-link .btn svg { width: 20px; height: 20px; }
}

.analytics-head { flex-wrap: wrap; }
.analytics-controls { display: inline-flex; align-items: center; gap: 8px; }
.analytics-controls select {
  width: auto; min-width: 102px; padding: 9px 11px; border-radius: 10px;
  font-size: 13px; color: var(--text); background: #f8fafc; border: 1px solid #dbe5f1;
}
.analytics-section-title { margin: 20px 0 9px; color: var(--text-dim); font-size: 13px; letter-spacing: 1px; }
.analytics-live, .analytics-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 0; }
.analytics-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.analytics-kpi {
  min-height: 76px; padding: 12px 10px;
  border: 1px solid #e2eaf5; border-radius: 12px; background: #f8fafc;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.analytics-kpi.live { background: #f1f7ff; border-color: #d6e5fb; }
.analytics-kpi b { display: block; margin-bottom: 5px; color: #2563eb; font-size: 22px; line-height: 1; }
.analytics-kpi span { display: block; color: #64748b; font-size: 12px; line-height: 1.35; }
.analytics-table-wrap { overflow-x: auto; border: 1px solid #e2eaf5; border-radius: 12px; }
.analytics-mode-table, .analytics-day-table, .analytics-recent-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 12px; }
.analytics-mode-table th, .analytics-mode-table td,
.analytics-day-table th, .analytics-day-table td,
.analytics-recent-table th, .analytics-recent-table td { padding: 10px 11px; text-align: center; border-bottom: 1px solid #edf2f7; white-space: nowrap; }
.analytics-mode-table thead th, .analytics-day-table thead th, .analytics-recent-table thead th { color: #64748b; background: #f8fafc; font-weight: 700; }
.analytics-mode-table tbody tr:last-child th, .analytics-mode-table tbody tr:last-child td,
.analytics-day-table tbody tr:last-child td, .analytics-recent-table tbody tr:last-child td { border-bottom: 0; }
.analytics-mode-table tbody th { color: #334155; text-align: left; }
.analytics-player-table { min-width: 920px; }
.analytics-player-table td small { display: block; margin-top: 2px; color: var(--text-faint); font-size: 11px; }
@media (max-width: 760px) {
  .analytics-live, .analytics-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-kpi { min-height: 70px; }
  .analytics-kpi b { font-size: 20px; }
  .analytics-controls { width: 100%; justify-content: space-between; }
  .analytics-controls select { flex: 1; }
}
.analytics-mode-note { margin: 9px 2px 0; color: var(--text-faint); font-size: 12px; line-height: 1.45; }

.game-top-actions { display: inline-flex; align-items: center; gap: 12px; }
.game-feedback-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: #2563eb;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}
.game-feedback-link:hover { color: #0f766e; }
.result-feedback-button { margin-top: 16px; }
@media (max-width: 900px) {
  .game-top-actions { gap: 8px; }
  .game-feedback-link { font-size: 12px; }
}
.feedback-modal-card { width: min(520px, calc(100vw - 28px)); }
.feedback-modal-card textarea { margin-top: 8px; resize: vertical; min-height: 120px; }
.feedback-upload-label { margin: 14px 0 6px; }
.feedback-upload-label input { margin-top: 7px; padding: 9px; font-size: 12px; }
.feedback-preview, .feedback-images { display: flex; flex-wrap: wrap; gap: 8px; }
.feedback-preview { margin-top: 10px; }
.feedback-preview img, .feedback-images img {
  width: 72px;
  height: 72px;
  border: 1px solid #dce7f5;
  border-radius: 10px;
  object-fit: cover;
  background: #f8fafc;
}
.feedback-admin-card { margin-bottom: 18px; }
.feedback-admin-list { display: grid; gap: 10px; margin-top: 14px; }
.feedback-item { padding: 13px; border: 1px solid #dfe8f4; border-radius: 12px; background: #fbfdff; }
.feedback-item.resolved { opacity: .7; background: #f7fafc; }
.feedback-item-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.feedback-item-head b { color: #1e3a5f; }
.feedback-item-head span { color: #718096; font-size: 12px; white-space: nowrap; }
.feedback-item p { margin: 9px 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #334155; line-height: 1.55; }
.feedback-item-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.feedback-status-btn { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.feedback-empty { color: #94a3b8; font-size: 13px; padding: 12px 2px; }
.analytics-range-note { margin: -3px 0 10px; color: var(--text-faint); font-size: 12px; }
.analytics-player-table { min-width: 1040px; }
@media (max-width: 900px) {
  .feedback-item-head { flex-direction: column; gap: 3px; }
  .feedback-item-head span { white-space: normal; }
}

.feedback-preview-item { position: relative; width: 72px; height: 72px; }
.feedback-preview-item img { width: 100%; height: 100%; }
.feedback-preview-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 17px;
  line-height: 16px;
  cursor: pointer;
}
.feedback-image-thumb {
  width: 72px;
  height: 72px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: zoom-in;
}
.feedback-image-thumb img { width: 100%; height: 100%; }
.feedback-image-viewer {
  position: relative;
  width: min(900px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 52px 54px 16px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15,23,42,.32);
}
.feedback-image-toolbar { position: absolute; top: 10px; right: 10px; left: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feedback-image-toolbar span { color: #64748b; font-size: 13px; font-weight: 700; }
.feedback-image-viewer img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 118px);
  margin: 0 auto;
  border-radius: 10px;
  object-fit: contain;
}
.feedback-image-close { min-height: 32px; padding: 5px 11px; font-size: 12px; }
.feedback-image-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 36px;
  height: 46px;
  border: 0;
  border-radius: 10px;
  background: rgba(37,99,235,.12);
  color: #2563eb;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-10%);
}
.feedback-image-nav:hover:not(:disabled) { background: rgba(37,99,235,.2); }
.feedback-image-nav:disabled { opacity: .3; cursor: default; }
.feedback-image-prev { left: 10px; }
.feedback-image-next { right: 10px; }

/* ===== 答案「简称」标记与说明弹窗 ===== */
.answer-short-tag {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px 3px 4px;
  font-family: inherit; font-size: 12px; font-weight: 800; letter-spacing: .5px;
  color: #2563eb;
  background: rgba(37,99,235,.10);
  border: 1px solid rgba(37,99,235,.30);
  border-radius: 999px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.answer-short-tag:hover { background: rgba(37,99,235,.18); border-color: rgba(37,99,235,.5); transform: translateY(-1px); }
.answer-short-tag:active { transform: none; }
.answer-short-tag:focus-visible { outline: 2px solid rgba(37,99,235,.5); outline-offset: 2px; }
/* 不可点击的标记（例如把「简称」换成「梗」）：纯展示，去掉手型与悬停反馈 */
.answer-short-tag.static { cursor: default; }
.answer-short-tag.static:hover,
.answer-short-tag.static:active { background: rgba(37,99,235,.10); border-color: rgba(37,99,235,.30); transform: none; }
.answer-short-tag.static:disabled { opacity: 1; }
.answer-short-icon {
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #2563eb; color: #fff;
  font-size: 12px; font-weight: 900; line-height: 1;
}
/* 「简称（可点击）」作为一个整体，避免 flex gap 在两者之间插入间距 */
.answer-short-label { display: inline-block; }
.answer-short-clickable { font-size: 11px; font-weight: 600; letter-spacing: 0; opacity: .78; }

/* 揭晓时跟在简称后面的原番剧全名 */
.answer-original {
  flex: 0 1 auto;
  margin-left: -8px;
  font-size: clamp(13px, 2.2vw, 17px);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--text-dim);
}

.answer-short-modal-card { width: min(420px, calc(100vw - 28px)); }
.answer-short-examples { display: grid; gap: 8px; margin: 2px 0 18px; }
.answer-short-example {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 13px;
  border-radius: 12px;
  background: #f4f7fb; border: 1px solid #e4eaf2;
  font-size: 13px; color: var(--text-dim);
}
.answer-short-example span { min-width: 0; overflow-wrap: anywhere; }
.answer-short-example b { flex: 0 0 auto; color: #2563eb; font-size: 14px; }
/* 全局 reset 把标题的外边距清零了，这里显式给一段间距，否则说明块会贴着标题（显得很挤） */
#answer-short-modal .modal-title { margin: 0 0 14px; }
.answer-short-note {
  /* 与标题左对齐：块向外扩出自身横向内边距，让文字回到标题的左边界 */
  margin: 0 -14px 20px;
  padding: 12px 14px;
  font-size: 13px; line-height: 1.85;
  color: var(--text-dim); background: #f6f9fd; border: 1px solid #e3ebf5;
  border-radius: 12px;
  /* 说明可以带换行（「别名」「梗」这类题的说明是多行的） */
  white-space: pre-line;
}
.answer-short-actions { grid-template-columns: 1fr; }

@media (max-width: 520px) {
  .answer-short-tag { font-size: 11px; padding: 2px 9px 2px 3px; gap: 4px; }
  .answer-short-icon { width: 14px; height: 14px; font-size: 11px; }
  .answer-short-example { font-size: 12px; padding: 9px 11px; }
  /* 手机上卡片内边距只有 14px，把外扩量收小一点，文字仍与标题对齐 */
  .answer-short-note { margin-left: -8px; margin-right: -8px; padding-left: 8px; padding-right: 8px; }
}

/* ===== 管理后台：数据看板 / 内容管理 分区 ===== */
.admin-tabs {
  display: flex; gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--card-border);
}
.admin-tab {
  appearance: none; border: 0; background: transparent;
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--text-dim); cursor: pointer;
  padding: 9px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .16s ease, border-color .16s ease;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.admin-panel .card + .card { margin-top: 18px; }
@media (max-width: 520px) {
  .admin-tab { padding: 8px 10px; font-size: 13px; }
}

/* ===== 匿名玩家统计：搜索 + 分页 ===== */
.analytics-player-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 8px; }
.analytics-player-toolbar input {
  flex: 0 1 300px; min-width: 160px;
  padding: 7px 11px; border: 1px solid #dbe3ec; border-radius: 10px;
  font-family: inherit; font-size: 13px; color: var(--text); background: #fff;
}
.analytics-player-toolbar input:focus { outline: none; border-color: #93b4fb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.analytics-player-count { color: var(--text-dim); font-size: 12px; }
.analytics-pager { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.analytics-pager-info { color: var(--text-dim); font-size: 12px; }
.analytics-pager .btn { min-height: 32px; padding: 5px 12px; font-size: 12px; }
.analytics-pager .btn:disabled { opacity: .45; cursor: default; }

/* ===== 房间记录（聊天 + 对局事件）===== */
.room-log-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.room-log-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 8px; }
.room-log-toolbar input {
  padding: 7px 11px; border: 1px solid #dbe3ec; border-radius: 10px;
  font-family: inherit; font-size: 13px; color: var(--text); background: #fff;
}
.room-log-toolbar input[type="date"] { flex: 0 0 158px; width: 158px; }
.room-log-toolbar input[type="search"] { flex: 0 1 240px; min-width: 150px; width: auto; }
.room-log-toolbar input:focus { outline: none; border-color: #93b4fb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.room-log-switch { display: inline-flex; border: 1px solid #dbe3ec; border-radius: 10px; overflow: hidden; }
.room-log-switch-btn {
  appearance: none; border: 0; background: #fff; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 700; color: var(--text-dim);
  padding: 8px 14px; transition: background .16s ease, color .16s ease;
}
.room-log-switch-btn + .room-log-switch-btn { border-left: 1px solid #dbe3ec; }
.room-log-switch-btn.active { background: #2563eb; color: #fff; }

.room-log-list { display: grid; gap: 6px; max-height: 460px; overflow-y: auto; }
.room-log-row {
  display: grid; grid-template-columns: 116px 96px 210px minmax(0, 1fr) 92px; gap: 10px; align-items: baseline;
  padding: 9px 11px; border-radius: 10px; background: #f8fafc; border: 1px solid #eef3f8;
  font-size: 12px; cursor: pointer; transition: background .16s ease, border-color .16s ease;
}
.room-log-row:hover { background: #eef5ff; border-color: #cfe0fb; }
.room-log-when { color: var(--text-faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.room-log-key { color: #2563eb; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-log-meta { color: var(--text-dim); }
.room-log-extra { color: #334155; overflow-wrap: anywhere; }
.room-log-extra small { margin-left: 3px; color: var(--text-faint); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.room-log-open { color: #2563eb; text-align: right; white-space: nowrap; }

.room-log-detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.room-log-detail-title { color: var(--text); font-size: 13px; font-weight: 700; }
.room-log-timeline { display: grid; gap: 5px; max-height: 560px; overflow-y: auto; padding-right: 2px; }
.room-log-line {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; align-items: baseline;
  padding: 7px 11px; border-radius: 9px; font-size: 12px;
}
.room-log-line.event { background: #eefaf4; border: 1px solid #cdeee0; color: #0f6e56; font-weight: 700; }
.room-log-line.event.wrong { background: #fdf1f1; border-color: #e9b7b7; color: #b91c1c; }
.room-log-line.event.timeout { background: #fff8ec; border-color: #f0dcb8; color: #a16207; }
.room-log-flag {
  margin-left: 6px; padding: 1px 6px; border-radius: 999px; white-space: nowrap;
  background: #fff7e6; border: 1px solid #f5d9a8; color: #a16207;
  font-size: 11px; font-weight: 700;
}
.room-log-line.chat { background: #f8fafc; border: 1px solid #eef3f8; color: #334155; }
.room-log-line-time { color: var(--text-faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.room-log-line-body { overflow-wrap: anywhere; }
.room-log-line-body b { color: #2563eb; font-weight: 700; }
.room-log-line-body small { margin-left: 4px; color: var(--text-faint); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.analytics-empty { color: #94a3b8; font-size: 13px; padding: 12px 2px; margin: 0; }
@media (max-width: 900px) {
  .room-log-row { grid-template-columns: 1fr; gap: 3px; }
  .room-log-open { text-align: left; }
  .room-log-line { grid-template-columns: 60px minmax(0, 1fr); }
}
