/* 同词相逢 — 视觉：纸张、墨绿、两枚相逢的圆 */

:root {
  --paper: #f7f2e7;
  --paper-2: #efe7d6;
  --card: rgba(255, 253, 248, 0.78);
  --ink: #1f2620;
  --ink-soft: #5c665a;
  --line: rgba(31, 38, 32, 0.13);
  --green: #2f6b4f;
  --green-deep: #24523c;
  --green-soft: #dcebdf;
  --coral: #c4543c;
  --coral-soft: #f6e2db;
  --gold: #a97e2f;
  --shadow: 0 24px 60px -30px rgba(31, 38, 32, 0.42);
  --glow-a: rgba(47, 107, 79, 0.13);
  --glow-b: rgba(196, 84, 60, 0.09);
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif CN", STSong, SimSun, serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141813;
    --paper-2: #1b211a;
    --card: rgba(31, 38, 30, 0.76);
    --ink: #eee9db;
    --ink-soft: #a7b1a2;
    --line: rgba(238, 233, 219, 0.14);
    --green: #8fc7a6;
    --green-deep: #b5dcc3;
    --green-soft: rgba(143, 199, 166, 0.14);
    --coral: #e08a73;
    --coral-soft: rgba(224, 138, 115, 0.14);
    --gold: #d6b26a;
    --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.75);
    --glow-a: rgba(143, 199, 166, 0.08);
    --glow-b: rgba(224, 138, 115, 0.06);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.page-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 6%, var(--glow-a), transparent 42%),
    radial-gradient(circle at 86% 88%, var(--glow-b), transparent 46%);
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 46px) clamp(18px, 4vw, 40px) 48px;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.view { flex: 1; }
.view.is-in { animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ---------- 通用文字 ---------- */

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 1px;
  margin-right: 10px;
  vertical-align: middle;
  background: currentColor;
  opacity: 0.55;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; }
h1 { margin: 0; }
h2 { margin: 0; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.88rem; }

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-size: 1.02rem;
  letter-spacing: 0.12em;
}

.mark {
  position: relative;
  width: 42px;
  height: 28px;
  flex: none;
}

.mark i {
  position: absolute;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--green);
}

.mark i:first-child { left: 0; opacity: 0.8; }
.mark i:last-child { right: 0; background: var(--green-soft); }

.hero { margin: clamp(42px, 9vh, 96px) 0 clamp(34px, 6vh, 56px); }

.hero h1 {
  margin: 18px 0 22px;
  font-size: clamp(2.8rem, 7.2vw, 5.3rem);
  line-height: 1.14;
  letter-spacing: 0.015em;
}

.hero h1 em {
  font-style: normal;
  color: var(--green);
  background: linear-gradient(transparent 68%, var(--green-soft) 68%);
}

.lede {
  margin: 0;
  max-width: 34em;
  font-size: clamp(1rem, 1.7vw, 1.16rem);
  color: var(--ink-soft);
}

.facts {
  display: flex;
  gap: 0;
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
}

.facts li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 22px;
  border-left: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.facts li:first-child { padding-left: 0; border-left: 0; }
.facts b { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; color: var(--ink); }

.entry-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 20px;
  align-items: stretch;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(22px, 3vw, 30px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel h2 { font-size: 1.4rem; }
.panel-sub { margin: -10px 0 4px; font-size: 0.9rem; color: var(--ink-soft); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > span {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.join-fields {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) 1.3fr;
  gap: 14px;
}

input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

input::placeholder { color: var(--ink-soft); opacity: 0.55; }
input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  background: var(--paper);
}

.code-input {
  font-family: var(--mono);
  font-size: 1.18rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 0.98rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.18s, background 0.18s, border-color 0.18s, opacity 0.18s;
  white-space: nowrap;
}

.btn:focus-visible,
.text-btn:focus-visible,
.chip-btn:focus-visible,
.sound-btn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--green);
  color: var(--paper);
  box-shadow: 0 10px 24px -14px var(--green);
}

.btn-primary:not(:disabled):hover {
  background: var(--green-deep);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:not(:disabled):hover {
  border-color: var(--green);
  background: var(--green-soft);
  transform: translateY(-1px);
}

.text-btn, .chip-btn {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 6px 2px;
}

.text-btn:hover, .chip-btn:hover { color: var(--green); }

.chip-btn {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
}

.rules {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.rules summary {
  cursor: pointer;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  list-style: none;
}

.rules summary::-webkit-details-marker { display: none; }
.rules summary::after { content: " +"; color: var(--green); }
.rules[open] summary::after { content: " −"; }

.rules ol { margin: 16px 0 10px; padding-left: 1.3em; }
.rules li { margin: 6px 0; }
.rules-example {
  margin: 12px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--ink);
  font-size: 0.88rem;
}

.site-foot {
  margin-top: auto;
  padding-top: 56px;
  font-family: var(--serif);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  opacity: 0.8;
}

/* ---------- 房间大厅 ---------- */

.room-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.room-code-wrap {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.mini-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.room-code {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: 0.28em;
  line-height: 1;
  color: var(--green);
}

.lobby-main {
  width: min(680px, 100%);
  margin: clamp(40px, 9vh, 90px) auto 0;
  text-align: center;
}

.lobby-head h2 {
  margin: 12px 0 8px;
  font-size: clamp(1.9rem, 4.2vw, 2.8rem);
}

.player-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 150px;
  max-width: 220px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  animation: pop 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.player-card.is-offline { opacity: 0.5; }
.player-card .pinfo { min-width: 0; flex: 1; }
.player-card .pname {
  display: block;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-card .prole { display: block; font-size: 0.7rem; color: var(--ink-soft); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: hsl(var(--hue, 150) 42% 86%);
  color: hsl(var(--hue, 150) 44% 28%);
  font-family: var(--serif);
  font-size: 1.12rem;
}

.host-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
}

.lobby-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 34px;
}

/* ---------- 作答 ---------- */

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(860px, 100%);
  margin: 0 auto;
}

.attempt-label {
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.game-top-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.room-pill {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}
.room-pill b { font-family: var(--mono); letter-spacing: 0.2em; color: var(--ink); }

.game-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 26px;
  width: min(860px, 100%);
  margin: clamp(28px, 6vh, 56px) auto 0;
}

.stage {
  text-align: center;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

.question {
  margin: 14px 0 clamp(24px, 4vh, 38px);
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.loop-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 104px;
  height: 104px;
  margin: 0 auto clamp(24px, 4vh, 34px);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
}

.loop-badge span {
  font-family: var(--serif);
  font-size: 2.6rem;
  line-height: 1;
  color: var(--green);
}

.loop-badge small {
  margin-top: 6px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.bridge {
  width: min(520px, 100%);
  margin: 0 auto 24px;
  padding: 15px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}

.bridge-label {
  margin: 0 0 10px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

.bridge-words {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.bridge-word {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 14em;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--paper-2);
  font-family: var(--serif);
  font-size: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bridge-word i {
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.64rem;
  color: var(--ink-soft);
}

.bridge-word.mine { background: var(--green-soft); }
.bridge-x { font-size: 0.8rem; color: var(--ink-soft); }

.bridge-hint {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.answer-form {
  display: flex;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}

.answer-form input {
  height: 54px;
  min-width: 0;
  text-align: center;
  font-size: 1.06rem;
}

.answer-form .btn { height: 54px; padding: 0 30px; flex: none; }

.answer-status {
  min-height: 1.7em;
  margin: 18px 0 4px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.answer-status strong { color: var(--ink); font-weight: 600; }

/* ---------- 玩家状态 / 这一路 ---------- */

.player-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 14px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.status-chip .avatar { width: 24px; height: 24px; font-size: 0.72rem; }
.status-name {
  flex: 1;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.status-end {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.35;
}
.status-chip.done {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-deep);
}
.status-chip.done .status-dot { background: var(--green); opacity: 1; }
.status-chip.offline { opacity: 0.55; }
.status-text { min-width: 3em; text-align: right; white-space: nowrap; }

.journey {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.journey.is-empty { display: none; }

.journey-title {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
}

.journey-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  align-content: start;
  max-height: 330px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.journey-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  font-size: 0.84rem;
}

.journey-item.is-match {
  border-color: var(--green);
  background: var(--green-soft);
}

.journey-attempt {
  flex: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-soft);
}

.journey-pair {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.journey-word {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 12em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journey-word i {
  font-style: normal;
  font-size: 0.62rem;
  color: var(--ink-soft);
}

.journey-word.mine { background: var(--green-soft); }
.journey-item.is-match .journey-word { border: 1px solid var(--green); }
.journey-empty { margin: 0 0 8px; font-size: 0.85rem; color: var(--ink-soft); }

/* ---------- 揭晓 ---------- */

.reveal-top {
  text-align: center;
  width: min(860px, 100%);
  max-width: 860px;
  margin: clamp(28px, 6vh, 56px) auto clamp(28px, 5vh, 44px);
}

.reveal-top h2 { margin: 14px 0 10px; font-size: clamp(2rem, 4.6vw, 3rem); }

.personal {
  margin: 0;
  font-size: clamp(0.98rem, 1.6vw, 1.08rem);
  color: var(--ink-soft);
}
.personal b { color: var(--green); font-weight: 600; }

.reveal-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 24px;
  width: min(860px, 100%);
  margin: 0 auto;
}

.reveal-main { width: 100%; }

.guess-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.guess-card {
  padding: 24px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  animation: pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 80ms);
}

.guess-card.is-me {
  border-color: var(--green);
  background: linear-gradient(160deg, var(--green-soft), transparent 80%);
}

.guess-name { font-size: 0.8rem; color: var(--ink-soft); }

.guess-word {
  margin-top: 6px;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3.2vw, 2.3rem);
  line-height: 1.3;
  word-break: break-word;
}

.reveal-tip {
  margin: 24px 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.reveal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: clamp(30px, 5vh, 46px);
}

/* ---------- 终局 ---------- */

.final {
  /* 内容宽度与猜词页的 860 历史面板对齐；外层把 shell 的左右 padding 算进去 */
  width: min(calc(860px + 2 * clamp(20px, 4vw, 46px)), 100%);
  margin: 0 auto;
  text-align: center;
  padding-top: clamp(28px, 7vh, 64px);
}

.final h2 { margin: 12px 0 8px; font-size: clamp(2.2rem, 5vw, 3.2rem); }

.meet-word {
  width: min(380px, 100%);
  margin: 26px auto 0;
  padding: 34px 24px;
  border: 1px solid var(--green);
  border-radius: 28px;
  background: linear-gradient(160deg, var(--green-soft), transparent 85%);
  font-family: var(--serif);
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 1.2;
  color: var(--ink);
  word-break: break-word;
  animation: pop 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.meet-names {
  margin: 14px 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.journey-details {
  width: min(860px, 100%);
  max-width: 860px;
  margin: 34px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.journey-details summary {
  cursor: pointer;
  list-style: none;
  text-align: center;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink);
}

.journey-details summary::-webkit-details-marker { display: none; }
.journey-details summary::after { content: " +"; color: var(--green); }
.journey-details[open] summary::after { content: " −"; }
.journey-details .journey-list { margin-top: 12px; max-height: 300px; }

.final-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 34px;
}

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

.sound-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  backdrop-filter: blur(8px);
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.18s;
}
.sound-btn:hover { opacity: 1; }
.sound-btn.is-off { opacity: 0.4; }

.conn-banner {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translate(-50%, -12px);
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.88rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti { position: fixed; inset: 0; z-index: 35; pointer-events: none; overflow: hidden; }

.confetti i {
  position: absolute;
  top: -24px;
  left: var(--x, 50vw);
  width: 7px;
  height: 12px;
  border-radius: 2px;
  animation: fall var(--d, 1.4s) cubic-bezier(0.3, 0.6, 0.5, 1) forwards;
  animation-delay: var(--delay, 0s);
}

/* ---------- 动效 ---------- */

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

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

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

@keyframes fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 响应式 ---------- */

@media (max-width: 1200px) {
  /* 窄屏时把音效按钮移到底部，避免压住顶部的「分享链接」 */
  .sound-btn {
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  /* 首页顶部右侧没有内容，放回右上角，避免浮在表单上 */
  body.is-home .sound-btn {
    top: 16px;
    bottom: auto;
    right: 16px;
  }
}

@media (max-width: 860px) {
  .entry-grid { grid-template-columns: 1fr; }
  .question { font-size: clamp(1.7rem, 5.2vw, 2.4rem); }
}

@media (max-width: 700px) {
  .shell { padding: 16px 16px 28px; }

  /* 首页压缩 */
  .hero { margin: 26px 0 22px; }
  .hero h1 { margin: 10px 0 14px; font-size: clamp(2.1rem, 10.5vw, 2.8rem); }
  .lede { font-size: 0.94rem; }
  .facts { margin-top: 16px; }
  .facts li { padding: 0 12px; }
  .facts b { font-size: 1.25rem; }
  .entry-grid { gap: 14px; }
  .panel { gap: 14px; padding: 18px; border-radius: 18px; }
  .rules { margin-top: 18px; padding-top: 14px; }
  .site-foot { padding-top: 26px; }

  /* 大厅压缩 */
  .lobby-main { margin-top: 24px; }
  .lobby-head h2 { margin: 8px 0 6px; font-size: clamp(1.55rem, 6.4vw, 2rem); }
  .player-grid { margin-top: 20px; gap: 8px; }
  .player-card { padding: 10px 12px; border-radius: 14px; }
  .player-card .avatar { width: 36px; height: 36px; font-size: 0.98rem; }
  .lobby-actions { flex-direction: column; gap: 8px; margin-top: 22px; }

  /* 作答页：去掉装饰，把状态提到输入上方 */
  .game-top { gap: 8px; }
  .attempt-label { font-size: 0.95rem; }
  .game-grid { margin-top: 14px; gap: 14px; }
  #view-game .eyebrow { display: none; }
  .question {
    margin: 6px 0 12px;
    font-size: clamp(1.55rem, 6.6vw, 2.05rem);
    line-height: 1.3;
  }
  .question br { display: none; }
  .loop-badge { display: none; }
  .bridge { margin-bottom: 12px; padding: 10px 12px; border-radius: 14px; }
  .bridge-label { margin-bottom: 6px; font-size: 0.64rem; }
  .bridge-words { gap: 6px; }
  .bridge-word { padding: 4px 10px; font-size: 1rem; }
  .bridge-hint { margin-top: 6px; font-size: 0.76rem; }

  .player-status {
    flex-direction: row;
    gap: 8px;
    margin: 0 0 12px;
  }
  .status-chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 7px 10px;
  }
  .status-chip .avatar { width: 24px; height: 24px; font-size: 0.72rem; }
  .status-dot { display: none; }
  .status-text { min-width: 3em; }

  .answer-form { flex-direction: row; gap: 8px; max-width: none; }
  .answer-form input { height: 50px; font-size: 1rem; }
  .answer-form .btn { height: 50px; padding: 0 20px; width: auto; }
  .answer-status { margin: 10px 0 0; font-size: 0.84rem; }

  .journey-list { max-height: 220px; }

  /* 揭晓压缩 */
  .reveal-top { margin: 16px auto 18px; }
  .reveal-top h2 { margin: 8px 0 6px; font-size: clamp(1.7rem, 7vw, 2.2rem); }
  .personal { font-size: 0.92rem; }
  .reveal-grid { gap: 16px; }
  .guess-pair { gap: 10px; }
  .guess-card { padding: 14px; border-radius: 16px; }
  .guess-word { font-size: clamp(1.5rem, 6.4vw, 1.9rem); }
  .reveal-tip { margin-top: 16px; font-size: 0.84rem; }
  .reveal-actions { flex-direction: row; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

  /* 相逢页压缩 */
  .final { padding-top: 20px; }
  .final h2 { font-size: clamp(2rem, 9vw, 2.8rem); }
  .meet-word { margin-top: 16px; padding: 24px 18px; border-radius: 20px; font-size: clamp(2.2rem, 12vw, 3rem); }
  .meet-names { margin-top: 10px; font-size: 0.84rem; }
  .journey-details { margin-top: 22px; padding-top: 14px; }
  .final-actions { margin-top: 22px; }
}

@media (max-width: 560px) {
  .shell { padding-left: 14px; padding-right: 14px; }
  .hero { margin-top: 20px; }
  .hero h1 { font-size: clamp(2rem, 11vw, 2.7rem); }
  .facts li { padding: 0 12px; }
  .join-fields { grid-template-columns: 1fr; }
  .room-top { gap: 10px; }
  .room-code-wrap { order: 3; width: 100%; justify-content: space-between; padding: 10px 16px; }
  .lobby-main { margin-top: 20px; }
  .player-grid { gap: 8px; }
  .player-card { flex: 1 1 130px; max-width: none; padding: 10px; }
  .guess-pair { gap: 8px; }
  .reveal-actions { gap: 8px; }
  .game-top { flex-wrap: wrap; gap: 8px; }
  .journey-list { max-height: 200px; }
  .sound-btn { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .conn-banner { bottom: 64px; }
}
