:root {
  color-scheme: light;
  --bg: #fff8f0;
  --card: #ffffff;
  --ink: #2d2a32;
  --muted: #93867f;
  --coral: #ff6b6b;
  --coral-deep: #f04e4e;
  --teal: #2ec4b6;
  --teal-deep: #17a99c;
  --yellow: #ffd166;
  --line: #f1e3d6;
  --soft: #fff1e6;
  --shadow: 0 10px 30px rgba(126, 83, 60, 0.12);
  --shadow-sm: 0 4px 14px rgba(126, 83, 60, 0.1);
  --radius: 24px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

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

html,
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
}

button,
input {
  font-family: inherit;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

button {
  cursor: pointer;
  border: 0;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.show {
  display: flex;
}

/* ----------------------------- 通用组件 ----------------------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: var(--soft);
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #ff7a6e 0%, #ff5b5b 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(255, 91, 91, 0.28);
}

.btn-secondary {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(46, 196, 182, 0.22);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
}

.btn-big {
  width: 100%;
  min-height: 60px;
  flex-direction: column;
  gap: 3px;
  font-size: 18px;
  border-radius: 20px;
}

.btn-big small {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.82;
}

.text-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 2px solid transparent;
  border-radius: 15px;
  outline: none;
  background: #fff8f1;
  color: var(--ink);
  font-size: 16px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.text-input::placeholder {
  color: #c1b4ab;
}

.text-input:focus {
  border-color: var(--coral);
  background: #fff;
}

.field-label {
  display: block;
  margin: 0 0 8px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--coral-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9bdb4;
  flex: none;
}

.dot.online {
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.15);
}

/* ----------------------------- 首页 ----------------------------- */

.home {
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
}

.home-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.home-bg::before,
.home-bg::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(4px);
  opacity: 0.5;
}

.home-bg::before {
  width: 280px;
  height: 280px;
  left: -120px;
  top: 40px;
  background: radial-gradient(circle, #ffe0cf 0%, rgba(255, 224, 207, 0) 70%);
}

.home-bg::after {
  width: 320px;
  height: 320px;
  right: -140px;
  bottom: 40px;
  background: radial-gradient(circle, #d8f4f0 0%, rgba(216, 244, 240, 0) 70%);
}

.float {
  position: absolute;
  font-size: 26px;
  opacity: 0.55;
  animation: floaty 7s ease-in-out infinite;
}

.f1 { left: 8%; top: 14%; animation-delay: -1s; }
.f2 { right: 10%; top: 20%; font-size: 20px; animation-delay: -3s; }
.f3 { left: 12%; bottom: 18%; font-size: 30px; animation-delay: -5s; }
.f4 { right: 14%; bottom: 24%; font-size: 22px; animation-delay: -2s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

.home-inner {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand {
  text-align: center;
  margin-bottom: 20px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin: 0 auto 12px;
  border-radius: 30px;
  background: linear-gradient(145deg, #fff 0%, #ffe8d8 100%);
  box-shadow: 0 14px 34px rgba(255, 107, 107, 0.2), inset 0 -4px 0 rgba(255, 107, 107, 0.08);
  font-size: 46px;
  transform: rotate(-5deg);
  animation: logoBob 4s ease-in-out infinite;
}

@keyframes logoBob {
  0%, 100% { transform: rotate(-5deg) translateY(0); }
  50% { transform: rotate(3deg) translateY(-5px); }
}

.brand h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.brand-sub {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.card {
  background: var(--card);
  border: 1px solid rgba(241, 227, 214, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.home-card {
  width: 100%;
  padding: 20px;
  animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.avatar-label {
  margin-top: 16px;
}

.avatar-list {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 18px;
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  min-width: 0;
  padding: 0;
  border-radius: 13px;
  background: #fff8f1;
  font-size: 21px;
  line-height: 1;
  border: 2px solid transparent;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.avatar-option:active {
  transform: scale(0.9);
}

.avatar-option.selected {
  border-color: var(--coral);
  background: #fff0ea;
  transform: translateY(-2px);
}

.or-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: #b8a99e;
  font-size: 11px;
  white-space: nowrap;
}

.or-line::before,
.or-line::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.join-row {
  display: flex;
  gap: 9px;
}

.code-input {
  flex: 1;
  min-width: 0;
  letter-spacing: 0.35em;
  font-size: 21px;
  font-weight: 800;
  text-align: center;
}

.join-row .btn {
  flex: 0 0 88px;
}

.server-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin-top: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.server-link span:last-child {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-foot {
  margin: 10px 0 0;
  color: #c0b2a8;
  font-size: 10px;
  letter-spacing: 0.04em;
}

/* ----------------------------- 房间等待 ----------------------------- */

.lobby {
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.lobby-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
}

.icon-btn.small {
  font-size: 16px;
}

.room-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 44px;
  padding: 0 8px 0 14px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.room-chip-label {
  color: var(--muted);
  font-size: 11px;
}

.room-chip strong {
  font-size: 22px;
  letter-spacing: 0.18em;
  color: var(--coral-deep);
}

.copy-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 9px;
  background: #fff0ea;
  color: var(--coral-deep);
  font-size: 11px;
  font-weight: 700;
}

.lobby-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.lobby-title {
  text-align: center;
  margin: 6px 0 18px;
}

.lobby-title h2 {
  margin: 0;
  font-size: 22px;
}

.lobby-title p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.lobby-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.player-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 108px;
  padding: 10px;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.player-slot.empty {
  border: 2px dashed #ead9ca;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: none;
  color: #c3b4a9;
}

.player-slot .slot-avatar {
  font-size: 34px;
  line-height: 1;
}

.player-slot .slot-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.player-slot .slot-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 16px;
}

.mini-tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: #fff0ea;
  color: var(--coral-deep);
  font-size: 9px;
  font-weight: 700;
}

.mini-tag.teal {
  background: #e3f8f5;
  color: var(--teal-deep);
}

.player-slot.is-me {
  outline: 2px solid rgba(255, 107, 107, 0.35);
  outline-offset: -2px;
}

.player-slot .empty-plus {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px dashed #dcc9ba;
  font-size: 22px;
}

.player-slot .empty-text {
  font-size: 11px;
}

.lobby-action {
  margin-bottom: 20px;
  text-align: center;
}

.host-wait {
  margin: 10px 0 0;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
}

.rule {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.rule-num {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  flex: none;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--coral-deep);
  font-size: 10px;
  font-weight: 800;
}

.rule p {
  margin: 0;
  color: #746a64;
  font-size: 11.5px;
  line-height: 1.55;
}

/* ----------------------------- 游戏 ----------------------------- */

.game {
  position: relative;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  background:
    radial-gradient(circle at 0% 0%, #ffeade 0%, rgba(255, 234, 222, 0) 42%),
    radial-gradient(circle at 100% 100%, #ddf5f1 0%, rgba(221, 245, 241, 0) 45%),
    var(--bg);
}

.game-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px 10px 0;
}

.round-pill {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 11px;
  box-shadow: var(--shadow-sm);
}

.round-pill b {
  margin: 0 1px;
  color: var(--ink);
  font-size: 13px;
}

.timer {
  display: flex;
  align-items: baseline;
  gap: 1px;
  margin-left: auto;
  padding: 2px 12px 3px;
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease, background 0.2s ease;
}

.timer span {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.timer small {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

.timer.urgent {
  background: #ffe1de;
  color: #e53935;
  animation: timerPulse 1s ease-in-out infinite;
}

.timer.urgent small {
  color: #e53935;
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.score-strip {
  display: flex;
  gap: 6px;
  padding: 5px 10px 3px;
}

.score-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 42px;
  padding: 0 7px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.score-chip .chip-avatar {
  font-size: 19px;
  line-height: 1;
  flex: none;
}

.score-chip .chip-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.1;
}

.score-chip .chip-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  color: var(--muted);
}

.score-chip .chip-score {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.score-chip.is-drawer {
  border-color: var(--coral);
  background: #fff4ef;
}

.score-chip.is-me {
  box-shadow: inset 0 0 0 2px rgba(46, 196, 182, 0.25);
}

.score-chip.is-offline {
  opacity: 0.45;
}

.score-chip .pen {
  position: absolute;
}

.word-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 5px 10px 2px;
  padding: 7px 12px;
  min-height: 48px;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.word-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.word-label {
  flex: none;
  padding: 4px 7px;
  border-radius: 7px;
  background: var(--soft);
  color: var(--coral-deep);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.word-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  letter-spacing: 0.1em;
}

.word-value.mask {
  letter-spacing: 0.16em;
  color: var(--ink);
}

.category-chip {
  flex: none;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e8f8f5;
  color: var(--teal-deep);
  font-size: 10px;
  font-weight: 700;
}

.canvas-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
}

#board {
  display: block;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(126, 83, 60, 0.12);
  touch-action: none;
  cursor: crosshair;
}

.canvas-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 70%;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 248, 240, 0.9);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  pointer-events: none;
}

.feed {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  pointer-events: none;
  max-height: 74px;
  overflow: hidden;
}

.feed-item {
  max-width: 94%;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(45, 42, 50, 0.68);
  color: #fff;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: feedIn 0.2s ease;
}

.feed-item.correct {
  background: rgba(23, 169, 156, 0.92);
  font-weight: 700;
}

.feed-item.system {
  background: rgba(255, 209, 102, 0.92);
  color: #6b4b00;
}

@keyframes feedIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.draw-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 10px 2px;
  padding: 5px 7px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.colors {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.colors::-webkit-scrollbar {
  display: none;
}

.color-swatch {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(45, 42, 50, 0.12);
  transition: transform 0.12s ease;
}

.color-swatch:active {
  transform: scale(0.86);
}

.color-swatch.selected {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--ink);
}

.color-swatch.eraser {
  background:
    linear-gradient(135deg, #fff 45%, #ffd8d3 46%, #ffd8d3 54%, #fff 55%);
  box-shadow: 0 0 0 1px rgba(45, 42, 50, 0.18);
}

.tools {
  display: flex;
  gap: 4px;
  flex: none;
}

.tool-btn {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  padding: 0;
  border-radius: 9px;
  background: #fff7ef;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.12s ease, background 0.12s ease;
}

.tool-btn:active {
  transform: scale(0.9);
  background: #ffe9dc;
}

.width-dot {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
}

.bottom-bar {
  flex: none;
  padding: 4px 10px calc(8px + env(safe-area-inset-bottom));
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guess-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-send {
  flex: 0 0 74px;
  min-height: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 6px 16px rgba(46, 196, 182, 0.24);
}

.drawer-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ----------------------------- 浮层 ----------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(45, 42, 50, 0.48);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.choose-card,
.result-card,
.final-card,
.modal-card {
  width: 100%;
  max-width: 390px;
  padding: 24px 20px;
  border-radius: 28px;
  background: #fffdfb;
  box-shadow: 0 24px 70px rgba(40, 24, 16, 0.3);
  animation: sheetIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  text-align: center;
}

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.choose-card h2,
.final-card h2 {
  margin: 0 0 16px;
  font-size: 25px;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 14px;
}

.choice-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 0 16px;
  border-radius: 16px;
  background: var(--soft);
  border: 2px solid transparent;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.choice-btn:active {
  transform: scale(0.98);
  border-color: var(--coral);
}

.choice-btn .choice-word {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.choice-btn .choice-cat {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
}

.choice-btn.picked {
  background: #ffe7df;
  border-color: var(--coral);
}

.choose-countdown {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.choose-wait {
  padding: 16px 0 20px;
}

.bouncing {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 12px;
}

.bouncing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral);
  animation: bounceDot 1s ease-in-out infinite;
}

.bouncing span:nth-child(2) { animation-delay: 0.15s; background: var(--yellow); }
.bouncing span:nth-child(3) { animation-delay: 0.3s; background: var(--teal); }

@keyframes bounceDot {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-7px); opacity: 1; }
}

.choose-wait p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.answer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-bottom: 12px;
}

.answer-label {
  color: var(--muted);
  font-size: 11px;
}

.answer {
  font-size: 34px;
  letter-spacing: 0.12em;
  color: var(--coral-deep);
}

.round-winner {
  min-height: 20px;
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.mini-scores {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.mini-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  background: #fff7ef;
  font-size: 12px;
}

.mini-score-row .ms-avatar {
  font-size: 16px;
}

.mini-score-row .ms-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-score-row .ms-score {
  margin-left: auto;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mini-score-row.winner {
  background: #e3f8f5;
  color: var(--teal-deep);
}

.next-hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.trophy {
  font-size: 54px;
  line-height: 1;
  margin-bottom: 6px;
  animation: trophyPop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes trophyPop {
  from { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.ranking {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0 18px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 12px;
  border-radius: 13px;
  background: #fff7ef;
  text-align: left;
}

.rank-row.first {
  background: linear-gradient(135deg, #fff4d6 0%, #ffe8ad 100%);
}

.rank-row .rank-medal {
  width: 24px;
  flex: none;
  font-size: 17px;
  text-align: center;
}

.rank-row .rank-avatar {
  font-size: 22px;
}

.rank-row .rank-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.rank-row .rank-me {
  flex: none;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fff;
  color: var(--coral-deep);
  font-size: 9px;
}

.rank-row .rank-score {
  margin-left: auto;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.final-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.final-actions .btn {
  width: 100%;
}

/* ----------------------------- 其他 ----------------------------- */

.net-banner {
  pointer-events: none;
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  padding: 8px 14px;
  border-radius: 999px;
  background: #4a3f38;
  color: #fff;
  font-size: 11px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.spinner {
  width: 11px;
  height: 11px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 95;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(45, 42, 50, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(45, 42, 50, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  text-align: left;
}

.modal-card h3 {
  margin: 0 0 8px;
  font-size: 19px;
}

.modal-card .muted {
  margin: 0 0 14px;
}

.modal-card code {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 5px;
  background: #fff4ea;
  color: var(--coral-deep);
  font-size: 11px;
  word-break: break-all;
}

.modal-card .text-input {
  background: #fff8f1;
  border: 2px solid var(--line);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 14px;
}

.modal-actions .btn {
  min-height: 42px;
  padding: 0 14px;
  font-size: 13px;
}

.test-status {
  min-height: 17px;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 11px;
  word-break: break-all;
}

.test-status.ok {
  color: var(--teal-deep);
}

.test-status.bad {
  color: #e05252;
}

/* 小屏适配 */
@media (max-height: 700px) {
  .brand-icon { width: 70px; height: 70px; font-size: 38px; margin-bottom: 8px; }
  .brand h1 { font-size: 29px; }
  .brand { margin-bottom: 12px; }
  .home-card { padding: 16px; }
  .avatar-option { font-size: 19px; }
  .lobby-title { margin: 2px 0 12px; }
  .player-slot { min-height: 94px; }
  .rules { padding: 11px; }
  .score-chip { height: 38px; }
  .word-bar { min-height: 44px; padding: 5px 10px; }
  .word-value { font-size: 19px; }
  .feed { max-height: 48px; }
}

@media (max-width: 340px) {
  .avatar-option { font-size: 17px; }
  .color-swatch { flex-basis: 21px; width: 21px; height: 21px; }
  .tool-btn { width: 29px; height: 29px; }
}

/* 横屏时游戏尽量别挤爆 */
@media (orientation: landscape) and (max-height: 520px) {
  .game-head { min-height: 38px; }
  .score-chip { height: 34px; }
  .word-bar { min-height: 38px; margin-top: 2px; }
  .word-value { font-size: 17px; }
  .draw-tools { padding: 3px 6px; }
  .bottom-bar { padding-bottom: 4px; }
  .guess-input, .btn-send, .drawer-note { height: 38px; min-height: 38px; }
  .feed { display: none; }
}

/* ----------------------------- 游戏大厅 ----------------------------- */

.game-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 14px;
}

.game-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 74px;
  padding: 10px 11px;
  border: 2px solid transparent;
  border-radius: 17px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.game-card:active {
  transform: scale(0.98);
}

.game-card.selected {
  border-color: var(--coral);
  background: #fff4ef;
}

.game-emoji {
  font-size: 25px;
  line-height: 1;
  flex: none;
}

.game-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.game-copy b {
  font-size: 13px;
  white-space: nowrap;
}

.game-copy small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.game-check {
  position: absolute;
  right: 7px;
  top: 7px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  font-size: 9px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.game-card.selected .game-check {
  opacity: 1;
  transform: scale(1);
}

/* ----------------------------- 石头剪刀布 ----------------------------- */

.rps {
  position: relative;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  background:
    radial-gradient(circle at 100% 0%, #ffe5d6 0%, rgba(255, 229, 214, 0) 40%),
    radial-gradient(circle at 0% 100%, #dff6f2 0%, rgba(223, 246, 242, 0) 45%),
    var(--bg);
}

.rps-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 12px calc(10px + env(safe-area-inset-bottom));
}

.rps-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 5px;
}

.rps-topline .muted {
  font-size: 10px;
}

.rps-arena {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
}

.rps-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 0;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.rps-card.me {
  box-shadow: inset 0 0 0 2px rgba(46, 196, 182, 0.3), var(--shadow-sm);
}

.rps-card.winner {
  background: #e3f8f5;
  border-color: var(--teal);
}

.rps-card.loser {
  background: #fff0ee;
  border-color: #ffc2ba;
}

.rps-card.inactive {
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
}

.rps-avatar {
  font-size: 28px;
  line-height: 1;
}

.rps-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.rps-hand {
  font-size: 36px;
  line-height: 1.1;
}

.rps-state {
  min-height: 14px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
}

.rps-rank {
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff0d1;
  color: #9b6b00;
  font-size: 10px;
  font-weight: 800;
}

.rps-check {
  position: absolute;
  right: 9px;
  top: 9px;
  color: var(--teal-deep);
  font-size: 14px;
  font-weight: 800;
}

.rps-result {
  flex: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  margin: 7px 0;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.rps-result.draw {
  background: #fff3d6;
  color: #8a6200;
}

.rps-result.win {
  background: #e3f8f5;
  color: var(--teal-deep);
}

.hand-picker {
  flex: none;
  display: flex;
  gap: 9px;
}

.hand-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 84px;
  border: 2px solid transparent;
  border-radius: 19px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.hand-btn span {
  font-size: 32px;
  line-height: 1;
}

.hand-btn small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.hand-btn:active {
  transform: scale(0.95);
}

.hand-btn.selected {
  border-color: var(--coral);
  background: #fff0ea;
}

.hand-btn.selected small {
  color: var(--coral-deep);
}

.hand-btn:disabled {
  opacity: 0.55;
}

.rps-wait {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 84px;
  padding: 0 14px;
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.rps-status .score-chip {
  height: 36px;
}

.rps-status .chip-score {
  font-size: 11px;
}

@media (max-height: 700px) {
  .game-card { min-height: 64px; padding: 8px; }
  .game-emoji { font-size: 21px; }
  .game-copy b { font-size: 12px; }
  .rps-arena { gap: 6px; }
  .rps-avatar { font-size: 24px; }
  .rps-hand { font-size: 30px; }
  .hand-btn { height: 70px; }
  .hand-btn span { font-size: 27px; }
  .rps-result { min-height: 38px; margin: 5px 0; font-size: 11px; }
}

/* ----------------------------- 飞行棋 ----------------------------- */

.flight,
.memory {
  position: relative;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  background:
    radial-gradient(circle at 0% 0%, #e6f7ff 0%, rgba(230, 247, 255, 0) 42%),
    radial-gradient(circle at 100% 100%, #fff0dc 0%, rgba(255, 240, 220, 0) 45%),
    var(--bg);
}

.flight-main,
.memory-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 12px calc(10px + env(safe-area-inset-bottom));
}

.flight-topline,
.memory-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 5px;
}

.flight-topline .muted,
.memory-topline .muted {
  font-size: 10px;
}

.flight-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 6px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow-sm);
}

.flight-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  border: 2px solid transparent;
  border-radius: 11px;
  background: #fff;
  color: var(--muted);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.flight-cell.start {
  background: #e3f8f5;
}

.flight-cell.finish {
  background: #fff0d1;
}

.flight-cell.current {
  border-color: var(--coral);
  box-shadow: inset 0 0 0 2px rgba(255, 107, 107, 0.12);
}

.flight-cell .cell-num {
  position: absolute;
  top: 2px;
  left: 4px;
  color: #c3b4a9;
  font-size: 8px;
  line-height: 1;
}

.flight-tokens {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1px;
  max-width: 100%;
}

.flight-token {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  background: #fff;
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(45, 42, 50, 0.12);
}

.flight-token.me {
  border-color: var(--coral);
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.18);
}

.flight-log,
.memory-log {
  flex: none;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 7px 0;
  padding: 5px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.flight-controls {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 76px;
}

.flight-dice {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 17px;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 34px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.flight-dice.rolling {
  animation: dicePop 0.35s ease;
}

@keyframes dicePop {
  0% { transform: scale(0.8) rotate(-12deg); }
  60% { transform: scale(1.12) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.flight-controls .btn {
  min-width: 130px;
  height: 52px;
  font-size: 16px;
}

.flight-wait {
  min-width: 130px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ----------------------------- 记忆消消乐 ----------------------------- */

.memory-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 6px;
}

.memory-card {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 15px;
  background:
    repeating-linear-gradient(135deg, #ffd8cf 0 7px, #ffe7df 7px 14px);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(126, 83, 60, 0.1);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.memory-card::after {
  content: "?";
  color: rgba(255, 255, 255, 0.85);
  font-size: 25px;
  font-weight: 800;
}

.memory-card.faceup,
.memory-card.matched {
  background: #fff;
  border-color: #ffe0d6;
}

.memory-card.faceup::after,
.memory-card.matched::after {
  content: "";
}

.memory-card .memory-emoji {
  font-size: 31px;
  line-height: 1;
}

.memory-card.matched {
  background: #e3f8f5;
  border-color: var(--teal);
}

.memory-card.matched .memory-emoji {
  opacity: 0.9;
}

.memory-card:active {
  transform: scale(0.95);
}

.memory-card:disabled {
  opacity: 1;
}

.memory-card.other-turn {
  opacity: 0.92;
}

.memory-card .memory-owner {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 10px;
}

.memory-main .memory-board {
  min-height: 0;
}

.memory-log {
  margin-top: 8px;
}

@media (max-height: 700px) {
  .flight-board { gap: 4px; padding: 4px; }
  .flight-token { width: 18px; height: 18px; font-size: 10px; }
  .flight-dice { width: 54px; height: 54px; font-size: 29px; }
  .flight-controls { min-height: 62px; }
  .memory-board { gap: 5px; }
  .memory-card { font-size: 25px; }
  .memory-card .memory-emoji { font-size: 26px; }
}

.update-card {
  text-align: center;
}

.update-icon {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 6px;
}

.update-notes {
  margin: 4px 0 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff7ef;
  text-align: left;
}

.update-notes p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.update-notes p::before {
  content: "· ";
  color: var(--coral);
  font-weight: 800;
}

.update-card .modal-actions {
  justify-content: center;
}
