:root {
  --bg: #f7f4ff;
  --card: #ffffff;
  --ink: #201a3d;
  --muted: #706a86;
  --line: #e9e4f6;
  --primary: #6d28d9;
  --primary-2: #8b5cf6;
  --primary-soft: #f1eafe;
  --accent: #f59e0b;
  --good: #059669;
  --good-soft: #e8f8f1;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow: 0 18px 50px rgba(76, 29, 149, .10);
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(139, 92, 246, .16), transparent 30%),
    radial-gradient(circle at 100% 18%, rgba(245, 158, 11, .10), transparent 26%),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.back-home {
  position: fixed;
  z-index: 30;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(109, 40, 217, .14);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(76, 29, 149, .08);
  backdrop-filter: blur(8px);
}
.back-home:hover { background: #fff; }
body.in-game .back-home { display: none; }

.landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  position: relative;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}
.blob-a {
  width: 260px; height: 260px;
  background: linear-gradient(135deg, #ddd0ff, #f3e8ff);
  top: -90px; left: -80px;
  transform: rotate(18deg);
}
.blob-b {
  width: 220px; height: 220px;
  background: linear-gradient(135deg, #ffe8c2, #fff3da);
  right: -80px; bottom: -70px;
  transform: rotate(-20deg);
}
.landing-card {
  position: relative;
  width: min(430px, 100%);
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 28px;
  padding: 30px 28px 24px;
  box-shadow: 0 28px 80px rgba(76, 29, 149, .16);
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}
.logo {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: 18px;
  color: #fff;
  font-size: 27px;
  font-weight: 900;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  box-shadow: 0 10px 26px rgba(109, 40, 217, .35);
  transform: rotate(-3deg);
}
.brand h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.03em;
}
.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.field span {
  font-size: 14px;
  font-weight: 700;
  color: #4c4663;
}
input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fbfaff;
  color: var(--ink);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
input:focus {
  border-color: #a78bfa;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, .12);
}
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 800;
  transition: transform .12s, box-shadow .16s, opacity .16s;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  box-shadow: 0 10px 24px rgba(109, 40, 217, .26);
}
.btn.primary:hover { box-shadow: 0 14px 30px rgba(109, 40, 217, .32); }
.btn.secondary {
  color: var(--primary);
  background: var(--primary-soft);
}
.btn.ghost, .ghost-btn {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 700;
}
.wide { width: 100%; }
.or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #9b95ae;
  font-size: 12px;
  margin: 20px 0 12px;
}
.or::before, .or::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}
.join-row {
  display: flex;
  gap: 10px;
}
.join-row input { flex: 1; min-width: 0; }
.join-row .btn { flex: none; }
.landing-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin: 18px 0 0;
}
.landing-msg {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.game {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 20px 18px 60px;
}
.roombar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px 18px;
}
.room-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.room-label { color: var(--muted); font-size: 13px; }
.room-info strong {
  font-size: 22px;
  letter-spacing: .12em;
  color: var(--primary);
}
.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 9px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}
.phase-pill {
  margin-left: auto;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}
.main-col, .side-col { display: grid; gap: 16px; }
.panel {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.phase-panel { padding: 22px 22px 18px; }
.phase-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.kicker {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #9b8fc0;
}
.phase-head h2 {
  margin: 5px 0 0;
  font-size: 25px;
  letter-spacing: -.025em;
}
.badge {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}
.phase-desc {
  margin: 10px 0 14px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}
.composer {
  display: flex;
  gap: 9px;
}
.composer input { flex: 1; min-width: 0; }
.composer .btn { flex: none; }
.my-clue {
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--primary-soft);
  color: #4c1d95;
  font-size: 14px;
  line-height: 1.6;
}
.my-clue b { font-weight: 900; }
.vote-status {
  padding: 11px 14px;
  border-radius: 13px;
  background: #fff8e8;
  color: #92500a;
  font-size: 14px;
  font-weight: 700;
}
.vote-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.vote-choice {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-weight: 800;
  transition: border-color .16s, background .16s, transform .12s;
}
.vote-choice:hover {
  border-color: #c4b5fd;
  background: #faf7ff;
}
.vote-choice:active { transform: translateY(1px); }
.vote-choice .avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 21px;
}
.vote-choice b {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.vote-choice small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}
.vote-choice.abstain {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-style: dashed;
  color: #6b7280;
  background: #fcfcfe;
}
.vote-history {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.vote-history-title {
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 8px;
}
.vote-round + .vote-round {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.vote-round-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 6px;
}
.vote-rows {
  display: grid;
  gap: 5px;
}
.vote-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  line-height: 1.5;
}
.vote-row b { font-weight: 800; }
.vote-row.me b { color: #7c3aed; }
.vote-arrow { color: #b3a9c7; font-weight: 900; }
.vote-row .target { color: #be185d; font-weight: 800; }
.vote-row .abstain { color: #6b7280; font-weight: 700; }
.vote-row .missing { color: #b45309; font-weight: 700; }
.host-controls { margin-top: 14px; }
.host-controls .btn { width: 100%; }

.players {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.players.players-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.player {
  position: relative;
  min-width: 0;
  background: rgba(255, 255, 255, .9);
  border: 1.5px solid rgba(255, 255, 255, .95);
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(76, 29, 149, .07);
  padding: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 92px;
  transition: border-color .16s, transform .16s, opacity .16s;
}
.player.me {
  border-color: #c4b5fd;
  background: linear-gradient(180deg, #fff, #faf7ff);
}
.player.out {
  opacity: .48;
  filter: grayscale(.35);
}
.player.empty {
  border: 1.5px dashed #ddd5f0;
  box-shadow: none;
  background: rgba(255, 255, 255, .42);
  align-items: center;
  justify-content: center;
  color: #aaa1c0;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.avatar {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f3e8ff, #fce7f3);
  font-size: 22px;
}
.player-main { min-width: 0; flex: 1; }
.player-name {
  font-weight: 900;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-meta {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
.tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 6px;
  background: #fff2c9;
  color: #92500a;
  font-size: 9px;
  font-weight: 900;
  vertical-align: 1px;
}
.role-tag {
  display: inline-block;
  margin-top: 5px;
  padding: 3px 7px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 900;
}
.role-tag.good { color: var(--good); background: var(--good-soft); }
.role-tag.bad { color: var(--danger); background: var(--danger-soft); }
.vote-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 0;
  border-radius: 9px;
  padding: 6px 9px;
  color: #fff;
  background: var(--primary);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 6px 14px rgba(109, 40, 217, .2);
}
.vote-mark {
  position: absolute;
  right: 10px;
  bottom: 11px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head h3, .word-head h3, .help-panel h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -.01em;
}
.leaderboard {
  display: grid;
  gap: 5px;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: #faf8ff;
  font-size: 13px;
}
.leaderboard-row.me {
  background: #f3e8ff;
  box-shadow: inset 0 0 0 1px #ddd6fe;
}
.leaderboard-rank {
  flex: none;
  width: 22px;
  color: #9b8fc0;
  font-weight: 900;
  font-size: 12px;
  text-align: center;
}
.leaderboard-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}
.leaderboard-score {
  flex: none;
  color: #7c3aed;
  font-weight: 900;
}
.leaderboard-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 2px;
}
.hint { color: #9b95ae; font-size: 11px; }
.clues-list { display: grid; gap: 8px; }
.clue {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fbfaff;
  border: 1px solid #f0ecfa;
  font-size: 14px;
  line-height: 1.55;
}
.clue-name {
  flex: none;
  color: var(--primary);
  font-weight: 900;
  font-size: 12px;
}
.clue.mine { background: var(--primary-soft); border-color: #ddd0ff; }

.chat-messages {
  height: 190px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 4px 2px 8px;
}
.chat-empty { color: #aaa1c0; font-size: 13px; text-align: center; margin: 24px 0; }
.chat-msg {
  max-width: 88%;
  font-size: 13px;
  line-height: 1.55;
  padding: 8px 10px;
  border-radius: 12px 12px 12px 4px;
  background: #f4f1fb;
  align-self: flex-start;
  word-break: break-word;
}
.chat-msg.mine {
  align-self: flex-end;
  border-radius: 12px 12px 4px 12px;
  background: var(--primary);
  color: #fff;
}
.chat-msg .who {
  display: block;
  font-size: 10px;
  font-weight: 900;
  opacity: .65;
  margin-bottom: 2px;
}
.chat-sys {
  align-self: center;
  color: #9b8fc0;
  font-size: 11px;
  text-align: center;
  padding: 2px 4px;
}
.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.chat-form input { flex: 1; min-width: 0; padding: 10px 12px; }
.chat-form .btn { padding: 9px 13px; }

.word-panel { position: sticky; top: 14px; }
.word-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.word-content { text-align: center; }
.word {
  font-size: clamp(34px, 7vw, 48px);
  font-weight: 900;
  letter-spacing: .04em;
  padding: 20px 8px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f5f0ff, #fff8ea);
  color: var(--primary);
  transition: filter .2s;
}
.word.blurred {
  filter: blur(11px);
  user-select: none;
  pointer-events: none;
}
.word-actions { margin-top: 10px; }
.word-role {
  margin-top: 10px;
  font-weight: 900;
  font-size: 14px;
}
.word-role.good { color: var(--good); }
.word-role.bad { color: var(--danger); }
.help-panel p {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.75;
  margin: 8px 0 0;
}

.result-box {
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
  background: #fbfaff;
  border: 1px solid var(--line);
}
.result-box.good { background: var(--good-soft); border-color: #b7ebd7; }
.result-box.bad { background: var(--danger-soft); border-color: #fecaca; }
.result-title { font-size: 22px; font-weight: 900; margin-bottom: 5px; }
.result-title.good { color: var(--good); }
.result-title.bad { color: var(--danger); }
.result-reason { color: #4f4965; font-size: 13px; line-height: 1.65; }
.result-words {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
}
.result-words b { color: var(--ink); }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  max-width: min(88vw, 420px);
  background: #211a42;
  color: #fff;
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .side-col { order: -1; }
  .word-panel { position: static; }
  .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .players.players-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .game { padding: 12px 10px 44px; }
  .roombar { padding: 6px 2px 12px; }
  .room-info strong { font-size: 20px; }
  .panel { border-radius: 17px; padding: 16px; }
  .phase-panel { padding: 18px 16px 15px; }
  .phase-head h2 { font-size: 22px; }
  .composer { flex-direction: column; }
  .composer .btn { width: 100%; }
  .vote-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player { padding: 12px; min-height: 84px; }
  .avatar { width: 34px; height: 34px; font-size: 19px; border-radius: 11px; }
  .player-name { font-size: 13px; }
  .vote-btn { position: static; margin-top: 8px; width: 100%; }
  .vote-mark { position: static; display: block; margin-top: 8px; }
  .chat-messages { height: 160px; }
}

.tutu-reminder {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: #000;
  pointer-events: none;
}
.tutu-reminder img {
  display: block;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  object-position: center;
}
