:root {
  --paper: #f6efe2;
  --surface: #fffaf0;
  --ink: #231c15;
  --muted: #76695a;
  --line: #231c15;
  --red: #e5482d;
  --red-soft: #fbd9cd;
  --teal: #0f7f78;
  --teal-soft: #cdeae4;
  --on-accent: #fffaf0;
  --shadow: 3px 3px 0 var(--line);
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1813;
    --surface: #2a231c;
    --ink: #f4eadb;
    --muted: #ab9d8b;
    --line: #000;
    --red: #ef5a3e;
    --red-soft: #4d2219;
    --teal: #24a198;
    --teal-soft: #12403c;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
}

#app { height: var(--app-h, 100dvh); }

h1, h2, p { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* 控件 */

.btn {
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font: 700 16px var(--sans);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn.primary { background: var(--red); color: var(--on-accent); }
.btn.ghost {
  min-height: 40px;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn.ghost:active { transform: none; opacity: .6; }
.btn.small { flex: none; min-height: 42px; padding: 0 14px; box-shadow: 2px 2px 0 var(--line); white-space: nowrap; }
.word-form .btn, .join-row .btn { flex: none; white-space: nowrap; }

.field {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font: 16px var(--sans);
}
.field::placeholder { color: var(--muted); }
.field:focus { outline: 3px solid var(--teal); outline-offset: 1px; }
button:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* 首页 */

.home {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(100%, 420px);
  height: 100%;
  margin: 0 auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
/* 内容超出一屏时不能整体居中，否则顶部会被裁掉、滑不回去 */
.home > :first-child, .home > .home-account + *, .home > .page-back + * { margin-top: auto; }
.home > :last-child { margin-bottom: auto; }
.logo { display: flex; justify-content: center; margin-bottom: 4px; }
.logo-card {
  display: grid;
  place-items: center;
  width: 92px;
  height: 118px;
  border: 3px solid var(--line);
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--line);
  color: var(--on-accent);
  font: 900 60px var(--serif);
}
.tilt-l { background: var(--red); transform: rotate(-6deg) translateX(9px); }
.tilt-m { z-index: 1; background: #d99a12; transform: translateY(-6px); }
.tilt-r { background: var(--teal); transform: rotate(5deg) translate(-9px, 8px); }
.tagline { margin: 12px 0 12px; text-align: center; font: 700 20px/1.5 var(--serif); }
.site-pulse { margin: 0 0 8px; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.or { color: var(--muted); font-size: 14px; text-align: center; }
.join-row { display: flex; gap: 10px; }
.code-field { letter-spacing: .14em; text-transform: uppercase; }
.invite { text-align: center; }
.full-title { text-align: center; font: 900 42px var(--serif); }

.admin-stats h2 { text-align: center; font: 800 17px var(--serif); }
.admin-stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0; }
.admin-stats-grid div { display: flex; flex-direction: column; align-items: center; padding: 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.admin-stats-grid strong { font: 900 26px var(--serif); }
.admin-stats-grid span { color: var(--muted); font-size: 12px; }
.admin-stats .hint { text-align: center; }
.admin-stats > .btn { display: block; margin: 8px auto; }
.admin-stats-grid > :last-child { grid-column: 1 / -1; }
@media (min-width: 600px) {
  .admin-stats-grid { grid-template-columns: repeat(5, 1fr); }
  .admin-stats-grid > :last-child { grid-column: auto; }
}

.records { margin-top: 12px; }
.friends { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.friends h2 { text-align: center; font: 800 17px var(--serif); }
.friends .hint { text-align: center; }
.friend { padding: 4px 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.friend small { flex: none; color: var(--muted); font-size: 12px; }
.friend-join { margin-left: auto; min-height: 36px; }
.friend-remove {
  flex: none;
  width: 32px;
  min-height: 32px;
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.friend-join + .friend-remove { margin-left: 0; }
.my-code { color: var(--muted); font-size: 13px; text-align: center; }
.my-code b { color: var(--ink); font: 800 15px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; }
.friend-tag { flex: none; margin-left: auto; color: var(--teal); }
.add-friend { border-color: var(--teal); color: var(--teal); }
.add-friend + .kick-btn, .friend-tag + .kick-btn { margin-left: 0; }
/* 账号入口和账号页 */
.home { position: relative; }
.home > .home-account { margin-top: 0; }
.home-account { display: grid; flex: none; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.home-account .info-btn { justify-self: start; }
.home-account .account-chip { min-width: 0; max-width: 100%; justify-self: end; padding: 6px 9px; }
.home-author-actions { display: flex; justify-content: center; align-items: center; gap: 10px; }
.home-author-link { min-height: 36px; padding: 4px 0; border: 0; background: none; color: var(--teal); font: 700 12px/1.4 var(--sans); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; cursor: pointer; }
.home-author-link:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 3px; }
.info-btn {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 2px 2px 0 var(--line);
  color: var(--ink);
  font: 900 italic 18px var(--serif);
  text-decoration: none;
}
.info-btn.unseen::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--red);
}
.changelog-entry { padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.changelog-entry h2 { display: flex; align-items: baseline; gap: 8px; font: 800 18px var(--serif); }
.changelog-entry small { color: var(--muted); font: 12px var(--sans); }
.changelog-entry em { padding: 1px 7px; border-radius: 6px; background: var(--red); color: var(--on-accent); font: 700 11px var(--sans); }
.changelog-entry ul { margin: 6px 0 0; padding-left: 20px; }
.changelog-entry li { padding: 2px 0; font-size: 14px; line-height: 1.5; }
.changelog-page { overflow-anchor: none; }
.changelog-page > * { flex: none; }
.changelog-entries { display: flex; flex-direction: column; gap: 16px; }
.changelog-more { align-self: center; }
.changelog-more:disabled { cursor: default; color: var(--muted); text-decoration: none; }
.account-chip {
  max-width: 60%;
  padding: 6px 12px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 2px 2px 0 var(--line);
  color: var(--ink);
  font: 700 14px var(--sans);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip:active, .info-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.page-back { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 8px; }
.page-title { text-align: center; font: 900 34px var(--serif); }
.perks { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 12px 14px; border: 2px dashed var(--muted); border-radius: 12px; list-style: none; }
.perks li { display: flex; gap: 10px; font-size: 15px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.tab { min-height: 40px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: 700 16px var(--sans); cursor: pointer; }
.tab.on { background: var(--red); color: var(--on-accent); }
.account-note { text-align: center; }
.account-note.error { color: var(--red); font-weight: 700; }
.account-name { text-align: center; font: 800 22px var(--serif); }
.account-page .hint { text-align: center; }
.members-title { margin: 8px 0 2px; color: var(--muted); font: 700 13px var(--sans); text-align: left; }
.invite-friends { text-align: left; }
.invite-btn:disabled { opacity: .55; cursor: default; }
.invite-banner {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: 0;
  left: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(calc(100% - 24px), 520px);
  margin: 0 auto;
  padding: 8px 6px 8px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
.invite-banner span { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.legacy-notice {
  position: static;
  z-index: auto;
  flex: none;
  max-height: 20vh;
  overflow-y: auto;
  margin: 8px auto;
  background: var(--red-soft);
}
/* 表情吐槽 */
.rx { width: 100%; text-align: left; }
.rank .rx { grid-column: 1 / -1; }
.rx.empty { display: inline-block; width: auto; margin-left: 6px; vertical-align: middle; }
.rx.empty .rx-row { margin-top: 0; }
.rx.empty .rx-add { min-height: 24px; padding: 0 7px; }
.rank .rx.empty { grid-column: auto; margin-left: 0; }
.rx-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.rx-chip, .rx-add, .rx-pick {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--muted);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 14px var(--sans);
  cursor: pointer;
  touch-action: manipulation;
}
.rx-chip small { font-size: 12px; font-weight: 700; }
.rx-chip.mine, .rx-pick.mine { border-color: var(--teal); background: var(--teal-soft); }
.rx-add { color: var(--muted); font-size: 13px; border-style: dashed; }
.rx-comment { margin-top: 3px; padding: 3px 8px; border-radius: 8px; background: var(--red-soft); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.rx-comment b { font-weight: 700; }
.rx-picker { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding: 8px; border: 1px dashed var(--muted); border-radius: 10px; }
.rx-emojis { display: flex; flex-wrap: wrap; gap: 6px; }
.rx-pick { min-height: 36px; padding: 0 10px; font-size: 18px; }
.rx-form { display: flex; gap: 6px; }
.rx-input { min-height: 38px; font-size: 15px; }
.rx-item { display: inline-flex; flex-wrap: wrap; align-items: center; max-width: 100%; }
.story-line .rx, .num-vals .rx { font-weight: 400; }
.records-empty { text-align: center; }
.records h2 { margin-bottom: 8px; text-align: center; font: 800 17px var(--serif); }
.record { margin-bottom: 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.record summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 12px; cursor: pointer; }
.record summary b { font: 800 16px var(--serif); }
.record summary small { color: var(--muted); font-size: 12px; }
.record summary span { width: 100%; font-size: 14px; overflow-wrap: anywhere; }
.record-players { padding: 0 12px; color: var(--muted); font-size: 13px; }
.record-section { padding: 6px 12px 10px; }
.record-section h3 { margin: 4px 0; font: 700 14px var(--sans); }
.record-section p { padding: 3px 0; border-bottom: 1px dashed var(--muted); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }

/* 房间骨架 */

.room { display: flex; flex-direction: column; height: 100%; max-width: 560px; margin: 0 auto; }

.topbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 2px solid var(--line);
}
.icon-btn { width: 40px; height: 40px; border: 0; background: none; color: var(--ink); font-size: 22px; cursor: pointer; }
.room-code {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.room-code b { font: 800 16px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; }
.room-code span { color: var(--teal); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.status {
  overflow: hidden;
  min-height: 40px;
  margin-left: auto;
  padding: 0 4px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status[data-tone="ok"]::before { background: #2fb36d; }
.status[data-tone="warn"]::before { background: #e3a21a; }

.board { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }

/* 游戏区 */

.stage { display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.stage h2 { font: 800 22px/1.3 var(--serif); }
.round-tag { color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--muted); font-size: 14px; }
.big-code { font: 900 44px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .1em; }
.hint { color: var(--muted); font-size: 14px; }
.hint.ready { color: var(--teal); font-weight: 700; }

.word-form { display: flex; gap: 10px; }
.word-input { font: 700 20px var(--serif); text-align: center; }

.last-pair {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 800 18px var(--serif);
}
.last-pair span { padding: 3px 10px; border-radius: 8px; background: var(--red-soft); overflow-wrap: anywhere; }
.last-pair span:last-child { background: var(--teal-soft); }
.last-pair i { color: var(--muted); font-style: normal; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; perspective: 700px; }
.card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 112px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: var(--surface);
}
.card small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card strong { font: 900 30px/1.2 var(--serif); overflow-wrap: anywhere; }
.card strong.long { font-size: 20px; }
.card.mine { background: var(--red-soft); }
.card.theirs { background: var(--teal-soft); }
.card.back { align-items: center; background: var(--teal); color: var(--on-accent); }
.dots { font: 900 44px var(--serif); animation: bob 1.1s ease-in-out infinite; }
.card.flip { animation: flip .55s cubic-bezier(.2, .8, .3, 1.2) both; }
.card.flip.theirs { animation-delay: .12s; }

.verdict { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 2px; }

.win-title { color: var(--red); font: 900 52px/1.1 var(--serif); animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }

@keyframes flip { from { transform: rotateY(90deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 50% { transform: translateY(-5px) rotate(8deg); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.switch-btn {
  flex: none;
  min-height: 32px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--teal);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.game-list { display: flex; flex-direction: column; gap: 14px; }
.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.game-card:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.game-card:disabled { opacity: .55; cursor: default; }
.game-item { position: relative; }
.game-item .game-card { padding-right: 52px; }
/* 竖直居中在卡片右侧，和左边的大图标对称 */
.rules-btn {
  position: absolute;
  top: 50%;
  right: 12px;
  margin-top: -18px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.rules-btn:active { transform: translate(2px, 2px); }
.rules-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 64px);
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: var(--surface);
  color: var(--ink);
}
.rules-dialog::backdrop { background: rgb(0 0 0 / .45); }
.rules-dialog h2 { font: 900 22px var(--serif); }
.rules-dialog h3 { margin-top: 12px; font: 800 16px var(--serif); }
.rules-dialog ul { margin: 4px 0 0; padding-left: 20px; }
.rules-dialog li { padding: 2px 0; font-size: 14px; line-height: 1.55; }
.rules-dialog .btn { width: 100%; margin-top: 16px; }
.game-card.red { background: var(--red-soft); }
.game-card.teal { background: var(--teal-soft); }
.game-icon { font-size: 38px; line-height: 1; }
.game-text { display: flex; flex-direction: column; gap: 4px; }
.game-text b { font: 900 22px var(--serif); }
.game-text small { color: var(--muted); font-size: 13px; line-height: 1.4; }

.scoreboard { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; }
.score-chip { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; max-width: 84px; }
.score-chip small { overflow: hidden; max-width: 100%; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.pips { display: flex; gap: 3px; }
.pips i { width: 11px; height: 11px; border: 2px solid var(--line); border-radius: 50%; background: var(--surface); }
.pips i.on { background: var(--red); }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip { padding: 3px 10px; border: 1px solid var(--muted); border-radius: 999px; color: var(--muted); font-size: 13px; }
.chip.done { border-color: var(--teal); background: var(--teal-soft); color: var(--ink); font-weight: 700; }
.chip.away { border-style: dashed; opacity: .7; }
.my-answer { font: 800 20px var(--serif); overflow-wrap: anywhere; }
.wait-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.skip-btn { min-height: 42px; font-size: 14px; }
.skip-btn:disabled { opacity: .6; box-shadow: none; cursor: default; }
.progress-block, .skip-action { display: flex; flex-direction: column; align-items: stretch; gap: 7px; min-width: 0; }
.skip-action { align-items: center; }
.wait-actions .skip-action { flex: 1 1 100%; }
.decision-status { color: var(--teal); font-size: 13px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.decision-status[hidden] { display: none; }
.skip-action .decision-status { color: var(--muted); font-size: 12px; font-weight: 500; }
.word-decision { padding: 8px 12px; border: 1px dashed var(--teal); border-radius: 10px; background: var(--teal-soft); }

/* One quiet entry stays outside the game scroll. Details share one dialog. */
.room-actions-bar { flex: none; height: 38px; border-top: 2px solid var(--line); background: var(--surface); }
.room-actions-bar[hidden] { display: none; }
.room-actions-bar[data-mode="proposal"] { background: var(--red-soft); }
.room-actions-bar[data-mode="ready"] { background: var(--teal-soft); }
.room-actions-entry { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; height: 100%; padding: 0 12px; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.room-actions-summary { overflow: hidden; min-width: 0; font: 700 12px var(--sans); text-overflow: ellipsis; white-space: nowrap; }
.room-actions-badge { flex: none; padding: 2px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font: 800 11px var(--sans); white-space: nowrap; }
.room-actions-dialog { position: fixed; inset: 0; width: calc(100% - 24px); max-width: 520px; max-height: min(85dvh, calc(var(--app-h, 100dvh) - 24px)); margin: auto; padding: 0; overflow: hidden; border: 2px solid var(--line); border-radius: 16px; box-shadow: 5px 5px 0 var(--line); background: var(--paper); color: var(--ink); }
.room-actions-dialog[open] { display: flex; flex-direction: column; }
.room-actions-dialog:not([open]) { display: none; }
.room-actions-dialog::backdrop { background: rgb(35 28 21 / .5); }
.room-actions-dialog-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 2px solid var(--line); background: var(--surface); }
.room-actions-dialog-head h2 { font: 900 23px/1.2 var(--serif); }
.room-actions-dialog-head .icon-btn { flex: none; }
.room-actions-dialog-content { flex: 1 1 auto; min-height: 0; max-height: calc(85dvh - 64px); overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.room-actions-dialog .btn.primary { background: #cc3e25; color: var(--on-accent); }
.room-actions-dialog .btn:disabled { opacity: .65; box-shadow: none; cursor: default; }
.room-actions-overview, .room-actions-picker, .action-proposal, .action-ready, .room-actions-options { display: flex; flex-direction: column; gap: 12px; }
.room-actions-picker > .switch-btn { align-self: flex-start; }
.room-actions-picker .game-list { padding-bottom: 4px; }
.room-actions-picker .game-card[aria-current="true"] { outline: 2px solid var(--teal); outline-offset: 2px; }
.action-game-title { font: 900 25px/1.3 var(--serif); overflow-wrap: anywhere; }
.action-vote-count { font-size: 15px; }
.action-vote-count strong { color: var(--teal); font: 900 25px var(--serif); }
.action-proposal { padding: 14px; border: 2px solid var(--line); border-left: 6px solid var(--red); border-radius: 12px; background: var(--red-soft); }
.action-proposal .decision-status { color: var(--ink); }
.action-proposal .hint { color: var(--ink); }
.action-ready { padding: 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--teal-soft); }
.action-ready .decision-status { color: var(--ink); }
.action-footnote { font-size: 12px; line-height: 1.5; }
.account-notice-dialog { max-width: 430px; }
.account-notice-dialog .room-actions-dialog-head h2 { font-size: 22px; }
.account-notice-content { display: flex; flex-direction: column; gap: 16px; }
.account-notice-message { font: 700 17px/1.7 var(--sans); }
.account-notice-content .hint { line-height: 1.6; }
.author-dialog { max-width: 430px; }
.author-dialog .room-actions-dialog-head h2 { font-size: 22px; }
.author-content { display: flex; flex-direction: column; gap: 16px; text-align: center; line-height: 1.6; }
.author-email { color: var(--teal); font-weight: 700; overflow-wrap: anywhere; }
.author-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.author-actions .btn, .author-support > .btn { display: inline-flex; justify-content: center; align-items: center; text-decoration: none; }
.author-payment-image { display: block; width: min(100%, 300px); height: auto; margin: 0 auto; border-radius: 12px; background: #fff; }
.author-support > .btn { align-self: center; }
@media (max-width: 600px) {
  .room-actions-dialog { margin: auto auto calc(12px + env(safe-area-inset-bottom)); }
  .room-actions-dialog-content { padding: 12px; }
}

.ranks { display: flex; flex-direction: column; gap: 6px; }
.rank {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
}
.rank.won { background: var(--teal-soft); outline: 2px solid #d99a12; }
.rank-name { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.rank b { font: 900 18px var(--serif); overflow-wrap: anywhere; }
.rank small { color: var(--muted); font-size: 12px; white-space: nowrap; }

.members {
  flex: none;
  max-height: 38dvh;
  overflow-y: auto;
  padding: 6px 12px;
  border-bottom: 2px solid var(--line);
  background: var(--surface);
}
.members[hidden] { display: none; }
.host-notice { flex: none; margin: 0; padding: 6px 12px; border-bottom: 2px solid var(--line); background: #f5d77a; color: #231c15; font-size: 14px; font-weight: 700; text-align: center; }
.host-notice[hidden] { display: none; }
.member { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.member-name { overflow: hidden; min-width: 0; text-overflow: ellipsis; white-space: nowrap; }
.member small { color: var(--muted); font-size: 12px; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: #2fb36d; }
.host-tag { flex: none; padding: 1px 7px; border-radius: 6px; background: #d99a12; color: #231c15; font: 700 12px var(--sans); }
.kick-btn {
  flex: none;
  min-height: 34px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: none;
  color: var(--red);
  font-size: 13px;
  cursor: pointer;
}

.word-row { display: flex; gap: 8px; padding: 7px 4px; border-bottom: 1px dashed var(--muted); }
.word-row em { flex: none; width: 20px; color: var(--muted); font: 700 12px/1.8 var(--sans); }
.word-row.hit { border-bottom: 0; border-radius: 8px; background: var(--red-soft); font-weight: 800; }
.word-row-items { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 0; text-align: left; overflow-wrap: anywhere; }
.word-row-items small { margin-right: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
.bubble-name { display: block; color: var(--muted); font-size: 11px; }

.question { padding: 12px; border-block: 2px dashed var(--muted); font: 800 19px/1.45 var(--serif); }
.guess-preview { min-height: 18px; margin-top: -6px; color: var(--teal); }
.answer { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 6px; }
.answer small { width: 100%; color: var(--muted); font-size: 12px; }
.answer strong { color: var(--red); font: 900 38px/1.1 var(--serif); overflow-wrap: anywhere; }
.card.won { outline: 3px solid #d99a12; outline-offset: 1px; }
.round-verdict { font-weight: 800; }
.trivia { font-size: 15px; line-height: 1.5; }
.source { color: var(--muted); font-size: 12px; }

.num-row { padding: 9px 0; border-bottom: 1px dashed var(--muted); text-align: left; }
.num-row p { font-size: 14px; line-height: 1.4; }
.num-vals { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 5px; color: var(--muted); font-size: 13px; }
.num-vals b { color: var(--ink); }
.num-vals .hit { color: var(--red); font-weight: 800; }

/* 派对游戏 */

.btn:disabled { opacity: .5; box-shadow: none; cursor: default; }
.score-num { font: 900 20px var(--serif); }

.option-list, .pick-list { display: flex; gap: 8px; }
.option-list { flex-direction: column; }
.pick-list { flex-wrap: wrap; justify-content: center; }
.option, .pick {
  min-height: 46px;
  padding: 8px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: 700 16px var(--sans);
  overflow-wrap: anywhere;
  cursor: pointer;
  touch-action: manipulation;
}
.pick.num { width: 46px; padding: 0; }
.option small { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 400; }
.option:disabled { cursor: default; opacity: .65; }
.option.picked, .pick.picked { background: var(--teal); color: var(--on-accent); opacity: 1; }

.reveal-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
}
.reveal-option b { font: 800 17px var(--serif); overflow-wrap: anywhere; }
.reveal-option small { color: var(--muted); font-size: 12px; }
.reveal-option.truth { background: var(--teal-soft); outline: 2px solid #d99a12; }

.spectrum { display: flex; justify-content: space-between; gap: 12px; font: 800 15px var(--serif); }
.wave-slider { width: 100%; height: 44px; margin: 0; accent-color: var(--red); touch-action: pan-y; }
.wave-track {
  position: relative;
  height: 54px;
  margin: 0 14px;
  border-bottom: 10px solid var(--line);
  border-radius: 0 0 6px 6px;
}
.wave-mark { position: absolute; bottom: -10px; width: 2px; height: 30px; background: var(--teal); }
.wave-mark span {
  position: absolute;
  bottom: 28px;
  left: 50%;
  max-width: 64px;
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  white-space: nowrap;
}
.wave-mark.edge-left span { left: 0; transform: none; }
.wave-mark.edge-right span { right: 0; left: auto; transform: none; }
.wave-mark.target { width: 4px; background: var(--red); }
.wave-mark.target span { color: var(--red); font-weight: 800; }

/* 神回复对决、排队感应、疯狂填词 */
.quip-option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.quip-option small { margin-left: 0; }
.ito-theme { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-block: 2px dashed var(--muted); }
.ito-theme b { font: 800 20px var(--serif); }
.ito-theme span { color: var(--muted); font-size: 14px; }
.ito-number { display: flex; flex-direction: column; align-items: center; }
.ito-number small { color: var(--muted); font-size: 12px; }
.ito-number strong { color: var(--red); font: 900 48px/1.1 var(--serif); }
.ito-card { display: flex; align-items: baseline; gap: 8px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; }
.ito-card.played { background: var(--teal-soft); }
.ito-card em { color: var(--teal); font: 900 16px var(--serif); font-style: normal; }
.ito-card span { flex: none; color: var(--muted); font-size: 13px; }
.ito-card b { font: 800 17px var(--serif); overflow-wrap: anywhere; }
.rank.miss { background: var(--red-soft); }
.libs-field { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.libs-field small { color: var(--teal); font-size: 13px; font-weight: 700; }
.libs-story { font: 17px/1.8 var(--serif); text-align: left; overflow-wrap: anywhere; }
.libs-story mark { padding: 0 3px; border-radius: 4px; background: #f5d77a; color: #231c15; font-weight: 800; }
.libs-story sup { margin-left: 2px; color: var(--muted); font: 10px var(--sans); }
.emoji-big { font-size: 40px; line-height: 1.3; letter-spacing: 2px; overflow-wrap: anywhere; }
.emoji-input { font-size: 24px; }
.emoji-panel { border: 2px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.emoji-tabs { display: flex; gap: 4px; padding: 6px; overflow-x: auto; border-bottom: 1px solid var(--muted); scrollbar-width: none; }
.emoji-tab { flex: none; min-height: 32px; padding: 0 10px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: 700 13px var(--sans); cursor: pointer; }
.emoji-tab.on { background: var(--teal); color: var(--on-accent); }
.word-form .emoji-back { flex: none; padding: 0 12px; color: var(--red); font-size: 18px; }
.emoji-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); max-height: 210px; padding: 6px; overflow-y: auto; overscroll-behavior: contain; }
.emoji-key { min-height: 40px; padding: 0; border: 0; border-radius: 8px; background: none; font-size: 24px; cursor: pointer; touch-action: manipulation; }
.emoji-key:active { background: var(--teal-soft); transform: scale(.9); }
.emoji-category { align-self: center; padding: 2px 12px; border-radius: 999px; background: var(--teal-soft); font-size: 14px; font-weight: 700; }
.emoji-step { padding: 6px 0; border-bottom: 1px dashed var(--muted); }
.emoji-step.origin .emoji-text { color: var(--red); }
.emoji-step:last-child { border-bottom: 0; }
.emoji-step small { color: var(--muted); font-size: 12px; }
.emoji-step .emoji-big { font-size: 32px; }
.emoji-text { font: 800 17px/1.5 var(--serif); overflow-wrap: anywhere; }
.story-form { display: flex; flex-direction: column; gap: 8px; }
.story-input {
  min-height: 84px;
  max-height: 40dvh;
  padding: 10px 12px;
  font: 17px/1.5 var(--serif);
  resize: none;
  overflow-y: auto;
}
.story-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.char-count { color: var(--muted); font-size: 12px; }
.story-line, .stage[data-phase="input"] .question { white-space: pre-wrap; }
.story-theme { color: var(--teal); font-size: 14px; font-weight: 700; }
.must-word { padding: 6px 10px; border-radius: 8px; background: var(--red-soft); font-size: 15px; }
.must-word b { color: var(--red); font: 900 18px var(--serif); }
.story-title { font-size: 34px; }
.story { padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; }
.story h3 { margin: 0 0 6px; font: 800 16px var(--serif); }
.story-line { padding: 3px 0; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.story-line small { margin-left: 6px; color: var(--muted); font-size: 11px; }
.story-line.starter { color: var(--muted); }

/* 历史 */

.history { margin-top: 18px; font-size: 15px; }
.history:empty { display: none; }
.history-title { margin: 0 0 10px; text-align: center; font: 800 17px var(--serif); }

/* 聊天 */

.chat {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--line);
  background: var(--surface);
}
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: var(--chat-h, clamp(56px, 11dvh, 110px));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-handle {
  flex: none;
  height: 24px;
  margin: -8px 0 -6px;
  border: 0;
  background: none;
  cursor: ns-resize;
  touch-action: none;
}
.chat-handle::before {
  content: "";
  display: block;
  width: 44px;
  height: 5px;
  margin: 0 auto;
  border-radius: 3px;
  background: var(--muted);
}
.chat-empty { margin: auto; color: var(--muted); font-size: 13px; }
.chat-fx { align-self: center; color: var(--muted); font-size: 12px; }
.bubble {
  align-self: flex-start;
  max-width: 82%;
  padding: 5px 11px;
  border-radius: 12px 12px 12px 3px;
  background: var(--teal-soft);
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.bubble.mine { align-self: flex-end; border-radius: 12px 12px 3px 12px; background: var(--red-soft); }

.fx-bar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.fx-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 48px;
  padding: 3px 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}
.fx-btn:active { background: var(--red-soft); transform: scale(.92); }
.fx-icon { font-size: 22px; line-height: 1.2; }
.fx-btn small { font-size: 11px; }

.chat-form { display: flex; gap: 8px; }
.chat-input { min-height: 42px; }

/* 键盘弹起时给输入区让位 */
@media (max-height: 500px) {
  .fx-bar, .chat-handle { display: none; }
  .chat-log { height: 48px; }
  .board { padding: 8px 16px; }
  .history { display: none; }
}

/* 特效层 */

#fx { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
.fx-sprite, .fx-paper { position: absolute; top: 0; left: 0; line-height: 1; will-change: transform; user-select: none; }
.fx-bang { color: var(--red); font-family: var(--serif); font-weight: 900; -webkit-text-stroke: 2px var(--line); }
.fx-paper { border-radius: 2px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 30%;
  z-index: 60;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity .2s;
}
#toast.show { opacity: 1; }
.btn.back-room { background: var(--teal); color: var(--on-accent); }
.old-tag { flex: none; padding: 1px 6px; border-radius: 6px; background: var(--red-soft); color: var(--red); font-size: 11px; font-weight: 700; }
/* 表情连发冷却 */
.fx-bar { position: relative; }
.fx-bar.cooling .fx-btn { opacity: .35; }
.fx-bar.cooling::after {
  content: attr(data-rest);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}
/* 键盘弹起（屏幕高度不够）时，在游戏里打字就收起聊天区 */
@media (max-height: 600px) {
  body.stage-typing .chat { display: none; }
}
.rename-btn { flex: none; min-height: 30px; padding: 0 10px; border: 1px solid var(--teal); border-radius: 8px; background: none; color: var(--teal); font-size: 12px; cursor: pointer; }

/* 聊天：每人一个气泡颜色（按座位分），深色模式用深一档的同色系 */
:root {
  --b0: #fbd9cd; --b1: #cdeae4; --b2: #f5e3a8; --b3: #dcdcf7;
  --b4: #f6d4e8; --b5: #d6ecc6; --b6: #f9dfc0; --b7: #d3e6f7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --b0: #4d2219; --b1: #12403c; --b2: #4a3d14; --b3: #2e3058;
    --b4: #4b2340; --b5: #26401c; --b6: #4c3216; --b7: #1b3550;
  }
}
.bubble.c0 { background: var(--b0); } .bubble.c1 { background: var(--b1); }
.bubble.c2 { background: var(--b2); } .bubble.c3 { background: var(--b3); }
.bubble.c4 { background: var(--b4); } .bubble.c5 { background: var(--b5); }
.bubble.c6 { background: var(--b6); } .bubble.c7 { background: var(--b7); }
.bubble { -webkit-touch-callout: none; cursor: context-menu; }
.bubble-quote {
  display: block;
  margin: 2px 0 4px;
  padding: 2px 8px;
  border-left: 3px solid var(--muted);
  border-radius: 4px;
  background: rgba(0, 0, 0, .06);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
/* 聊天里的表情只显示别人贴的，不显示“＋”（用长按菜单贴） */
.bubble .rx.empty, .bubble .rx-add, .bubble .rx-comment { display: none; }
.bubble .rx-row { margin-top: 3px; }
.bubble .rx-chip { min-height: 22px; padding: 0 6px; font-size: 12px; }

.reply-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 10px;
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  background: var(--teal-soft);
  font-size: 13px;
}
.reply-bar[hidden] { display: none; }
.reply-bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .icon-btn { width: 30px; height: 30px; font-size: 18px; }

.msg-menu {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.msg-menu-emojis { display: flex; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--muted); }
.msg-menu-emojis .rx-pick { flex: 1; justify-content: center; padding: 0; }
.msg-menu-item { min-height: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: 15px var(--sans); text-align: left; cursor: pointer; }
.msg-menu-item:active { background: var(--teal-soft); }

.chat-emoji[hidden] { display: none; }
.chat-emoji .emoji-palette { max-height: 150px; }
.chat-emoji-btn { padding: 0 10px; font-size: 18px; }
.typing-bar { min-height: 16px; margin: -4px 0 -2px; color: var(--muted); font-size: 12px; }
.typing-bar:empty { min-height: 0; margin: 0; }
.read-mark { align-self: flex-end; margin: -4px 4px 0 0; color: var(--muted); font-size: 11px; }
.read-mark .unread { color: var(--red); }
