/* =========================================================
 * 同词相遇 · 视觉系统
 *
 * 设计语言：Apple iOS（以 iOS 17/18 的浅色分组界面为基准）
 *
 * 三条贯穿全文件的硬规矩：
 *
 * ① **毛玻璃只用在两处**：常驻的导航栏 + toast（toast 是短时的，飘上去两秒就消）。
 *    `backdrop-filter` 不是免费的：每一个
 *    带它的元素都会成为浏览器的一个 backdrop root —— 浏览器必须回读它下面
 *    那一整片像素再做模糊。把它撒在卡片上会让长列表里每张卡片各开一个
 *    backdrop root，滚动时整屏重算。所以卡片一律用**不透明填充 + 分层阴影**
 *    做出层次，质感来自高光与暗边，不来自大面积模糊。
 *
 * ② **卡片是分组列表（inset grouped）的几何**：白底、圆角 20px、行与行之间
 *    是**从文字左缘开始**的分隔线（inset divider），不是全宽细线。这是 iOS
 *    表格最容易被做错的一处：分隔线要内缩到跟正文左边对齐。
 *
 * ③ **动效用 iOS 的弹簧曲线** `cubic-bezier(0.32, 0.72, 0, 1)`，按压反馈用
 *    `scale(0.97)` 而不是变色 —— iOS 的按钮回弹手感来自缩放与回弹，不是
 *    明暗。动画时长控制在 0.25–0.45s，超过就"卡"了。
 * ========================================================= */

/* ------------------------------------------------------------ 设计令牌 */
:root {
  /* 浅色：systemGroupedBackground / secondarySystemGroupedBackground */
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #ffffff;

  --label: #000000;
  /* ⚠ 这两个是**半透明**的：最终颜色 = 与底色混合后的结果，
     所以对比度必须按「最坏真实底色」算，不能按纯白算。
       --label-2 (0.74)：最坏底色 #f2f2f7 上 4.76:1  ✓ AA
       --label-3 (0.55)：#f2f2f7 上 2.94:1 / #fff 上 3.12:1
         → 只给**纯装饰**用（分隔符、"×"）；凡是承载信息的文本
           一律改用 --label-2（见下方 .hint / .brand / placeholder 等）。 */
  --label-2: rgba(60, 60, 67, 0.74);
  --label-3: rgba(60, 60, 67, 0.55);
  --separator: rgba(60, 60, 67, 0.29);
  --separator-opaque: #c6c6c8;

  /* 系统色 */
  --blue: #0a6cff; /* 白字在它上面 4.56:1（#007aff 只有 4.02:1，不达 AA） */
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --teal: #5ac8fa;
  --purple: #af52de;
  --indigo: #5856d6;
  --pink: #ff2d55;

  /* 填充色（iOS systemFill） */
  --fill-1: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.16);
  --fill-3: rgba(118, 118, 128, 0.12);
  --fill-4: rgba(116, 116, 128, 0.08);

  /* 语义别名 */
  --accent: var(--blue);
  --win: var(--green);

  /* 圆角 */
  --r-card: 20px;
  --r-field: 12px;
  --r-btn: 14px;
  --r-chip: 16px;

  /* 阴影：分层而不是一团 */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.06);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.12);

  /* iOS 弹簧曲线 */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* 安全区 */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, "Segoe UI", Roboto, sans-serif;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --bg-elev-2: #2c2c2e;

    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.74);
    --label-3: rgba(235, 235, 245, 0.55);
    --separator: rgba(84, 84, 88, 0.65);
    --separator-opaque: #38383a;

    --blue: #0a70e0; /* 白字 4.77:1（#0a84ff 只有 3.65:1） */
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --teal: #64d2ff;
    --purple: #bf5af2;
    --indigo: #5e5ce6;
    --pink: #ff375f;

    --fill-1: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.32);
    --fill-3: rgba(118, 118, 128, 0.24);
    --fill-4: rgba(116, 116, 128, 0.18);

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.55);
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  text-rendering: optimizeLegibility;
}

/* 背景：两团极淡的柔光，给白色卡片一点"有东西在下面"的层次。
   只此一层用大面积渐变，卡片以下不再叠渐变。 */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
}

.blob-a {
  width: 60vw;
  height: 60vw;
  max-width: 420px;
  max-height: 420px;
  top: -18vw;
  left: -14vw;
  background: radial-gradient(circle, rgba(0, 122, 255, 0.34), rgba(0, 122, 255, 0) 70%);
}

.blob-b {
  width: 55vw;
  height: 55vw;
  max-width: 380px;
  max-height: 380px;
  bottom: -20vw;
  right: -16vw;
  background: radial-gradient(circle, rgba(52, 199, 89, 0.3), rgba(52, 199, 89, 0) 70%);
}

@media (prefers-color-scheme: dark) {
  .blob {
    opacity: 0.34;
  }
  .blob-a {
    background: radial-gradient(circle, rgba(10, 132, 255, 0.5), rgba(10, 132, 255, 0) 70%);
  }
  .blob-b {
    background: radial-gradient(circle, rgba(48, 209, 88, 0.4), rgba(48, 209, 88, 0) 70%);
  }
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------ 导航栏 */
/* 全站唯一常驻的 backdrop-filter 容器 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 16px) 8px calc(var(--sal) + 16px);
  background: rgba(242, 242, 247, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  transition: opacity 0.25s var(--ease);
}

@media (prefers-color-scheme: dark) {
  .navbar {
    background: rgba(22, 22, 24, 0.72);
  }
}

.navbar:empty {
  display: none;
}

/* 导航内容与 .screen 的 560px 正文栏对齐（560 − 左右各 16px 内边距）。
   桌面宽屏上不加这层，标题和状态片会被拽到通栏两端，离正文太远。 */
.nav-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 528px;
  margin: 0 auto;
}

.nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-spacer {
  flex: 1;
}

.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  /* 44px 高：这是**可点**元素的命中区下限（iOS HIG）。
     视觉上做成"扁"的靠减少内边距与字号，而不是把命中区缩小。 */
  height: 44px;
  padding: 0 10px;
  border-radius: 22px;
  background: transparent;
  color: var(--label-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.nav-chip.room {
  font-family: var(--mono);
  letter-spacing: 1.5px;
  color: var(--label);
  background: var(--fill-3);
  cursor: pointer;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  padding: 0 14px;
}

.nav-chip.room:active {
  transform: scale(0.96);
}

.nav-chip.warn {
  color: var(--orange);
  background: rgba(255, 149, 0, 0.16);
}

.nav-chip.bad {
  color: var(--red);
  background: rgba(255, 59, 48, 0.14);
}

/* 导航栏「离开」：button 元素需要显式继承字体并去掉原生外观 */
.nav-chip.danger {
  color: var(--red);
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  flex: none;
}

.nav-chip.danger:active {
  transform: scale(0.94);
}

/* ------------------------------------------------------------ 屏幕容器 */
.screen {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px calc(var(--sar) + 16px) calc(var(--sab) + 40px) calc(var(--sal) + 16px);
}

/* ------------------------------------------------------------ 排版 */
.brand {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--label-2);
  margin: 4px 0 10px;
}

.large-title {
  font-size: 34px;
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin: 0 0 10px;
}

.title2 {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.35px;
  margin: 0 0 6px;
}

.title3 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.25px;
  margin: 0 0 4px;
}

.sub {
  font-size: 15px;
  color: var(--label-2);
  margin: 0 0 18px;
  line-height: 1.45;
}

.hint {
  font-size: 13px;
  color: var(--label-2);
  margin: 12px 0 0;
  line-height: 1.45;
}

.center {
  text-align: center;
}

/* ------------------------------------------------------------ 卡片 */
.card {
  background: var(--bg-elev);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 14px;
}

.card.flush {
  padding: 0;
  overflow: hidden;
}

/* 分组列表：行之间用内缩分隔线（与正文左缘对齐），不是全宽 */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  position: relative;
  min-height: 48px;
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

.row-label {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 17px;
  font-weight: 400;
  margin: 0;
}

.row-sub {
  font-size: 13px;
  color: var(--label-2);
  margin: 2px 0 0;
}

/* ------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 50px;
  padding: 0 20px;
  border-radius: var(--r-btn);
  border: none;
  font-family: inherit;
  font-size: 17px;
  font-weight:  600;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: transform 0.18s var(--spring), opacity 0.18s var(--ease),
    background-color 0.18s var(--ease);
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
  width: 100%;
}

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

.btn:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.45);
  outline-offset: 2px;
}

.btn[disabled] {
  opacity: 0.38;
  pointer-events: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-green {
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-tinted {
  background: rgba(0, 122, 255, 0.13);
  color: var(--blue);
}

.btn-tinted-green {
  background: rgba(52, 199, 89, 0.14);
  color: var(--green);
}

.btn-plain {
  background: transparent;
  color: var(--blue);
  font-weight: 400;
}

.btn-plain.danger {
  color: var(--red);
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-row .btn {
  flex: 1;
}

/* ------------------------------------------------------------ 输入 */
.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--label-2);
  margin: 0 0 6px 2px;
  text-transform: none;
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 17px;
  color: var(--label);
  background: var(--fill-1);
  border: 1px solid transparent;
  border-radius: var(--r-field);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.input::placeholder {
  color: var(--label-2);
}

.input:focus {
  border-color: var(--blue);
  background: var(--bg-elev);
}

.input:focus-visible {
  outline: none;
}

.input-room {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 5px;
  text-align: center;
  text-transform: uppercase;
}

.input-word {
  min-height: 58px;
  font-size: 22px;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.5px;
  border-radius: var(--r-btn);
}

/* ------------------------------------------------------------ 分段控件 */
.segmented {
  display: flex;
  background: var(--fill-3);
  border-radius: 11px;
  padding: 2px;
  gap: 2px;
  position: relative;
}

.segmented button {
  flex: 1;
  /* 44px：分段控件的每一档都是可点的，命中区必须够。
     常见做法是画成 32px 的矮条（UIKit 就是这样），但在触屏网页上
     两档挨着，32px 容易点错。 */
  min-height: 44px;
  padding: 0 10px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--label);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease),
    color 0.2s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.segmented button.on {
  background: var(--bg-elev);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

.segmented button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* ------------------------------------------------------------ 房间码 */
.room-code {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: 10px;
  text-indent: 10px;
  color: var(--label);
  padding: 6px 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.room-code:active {
  transform: scale(0.98);
}

.room-code:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.45);
  outline-offset: 4px;
  border-radius: 12px;
}

.room-hint {
  font-size: 13px;
  color: var(--label-2);
  text-align: center;
  margin: 2px 0 0;
}

/* ------------------------------------------------------------ 玩家 */
.players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--fill-4);
  font-size: 15px;
}

.player.empty {
  color: var(--label-2);
  justify-content: center;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--label-3);
  flex: none;
}

.player.on .dot {
  background: var(--green);
}

.player.off .dot {
  background: var(--orange);
}

.player .tag {
  margin-left: auto;
  font-size: 12px;
  color: var(--label-2);
  background: var(--fill-2);
  padding: 2px 8px;
  border-radius: 9px;
}

/* ------------------------------------------------------------ 词面 */
.board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 2px;
}

.chip {
  flex: 1;
  min-width: 0;
  min-height: 54px;
  padding: 10px 12px;
  border-radius: var(--r-chip);
  background: var(--fill-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
  text-align: center;
  word-break: break-word;
  animation: chipIn 0.42s var(--spring) both;
}

.chip .who {
  font-size: 11px;
  font-weight: 500;
  color: var(--label-2);
  letter-spacing: 0.2px;
}

.chip .text {
  max-width: 100%;
}

.chip-empty {
  color: var(--label-3);
  font-weight: 400;
  font-size: 16px;
}

.chip-me {
  background: rgba(0, 122, 255, 0.13);
  color: var(--blue);
}

.chip-opp {
  background: rgba(52, 199, 89, 0.14);
  color: var(--green);
}

.chip-hit {
  background: rgba(52, 199, 89, 0.2);
  color: var(--green);
}

.chip-miss {
  background: var(--fill-4);
  color: var(--label);
}

.board .mult {
  font-size: 20px;
  font-weight: 300;
  color: var(--label-3);
  flex: none;
}

/* 三人局：三块词面挤一行，字号与间距相应收一点。
   窄屏（≤380px）下面还有一档微调，见文件末尾。 */
.board.board3 {
  gap: 6px;
}

.board.board3 .chip {
  font-size: 17px;
  padding: 9px 8px;
}

.board.board3 .mult {
  font-size: 16px;
}

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

/* 揭晓时两词并排撞在一起的效果 */
.board.reveal .chip {
  animation: chipIn 0.5s var(--spring) both;
}

.board.reveal .chip:nth-child(1) {
  animation-delay: 0.05s;
}

.board.reveal .chip:nth-child(3) {
  animation-delay: 0.05s;
}

.board.reveal .chip:nth-child(5) {
  animation-delay: 0.1s;
}

/* ------------------------------------------------------------ 倒计时 */
.countdown {
  font-size: 96px;
  font-weight: 700;
  letter-spacing: -3px;
  line-height: 1;
  text-align: center;
  color: var(--label);
  padding: 30px 0;
  animation: pop 0.5s var(--spring) both;
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  60% {
    opacity: 1;
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

/* ------------------------------------------------------------ 计时条 */
.timerbar {
  height: 6px;
  border-radius: 3px;
  background: var(--fill-2);
  overflow: hidden;
  margin: 10px 0 0;
}

.timerbar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
  transition: width 0.18s linear, background-color 0.3s var(--ease);
}

.timerbar.warn i {
  background: var(--orange);
}

.timerbar.crit i {
  background: var(--red);
}

.timer-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 2px;
}

.timer-meta .round {
  font-size: 13px;
  font-weight: 600;
  color: var(--label-2);
}

.timer-meta .left {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label-2);
}

.timer-meta .left.warn {
  color: var(--orange);
}

.timer-meta .left.crit {
  color: var(--red);
}

/* ------------------------------------------------------------ 提示条 */
.notice {
  margin: 12px 0 0;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(255, 149, 0, 0.14);
  color: var(--orange);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.notice.bad {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}

.prompt {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 16px 0 12px;
  line-height: 1.35;
}

.prompt .from {
  color: var(--label-2);
  font-weight: 400;
}

.prompt em {
  font-style: normal;
  color: var(--accent);
}

/* ------------------------------------------------------------ 判定 */
.verdict {
  text-align: center;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin: 18px 0 4px;
  animation: pop 0.55s var(--spring) both;
}

.verdict.hit {
  color: var(--green);
}

.verdict.miss {
  color: var(--label-2);
}

.verdict-note {
  text-align: center;
  font-size: 14px;
  color: var(--label-2);
  margin: 0 0 4px;
}

/* ------------------------------------------------------------ 回合历史 */
.history {
  margin-top: 18px;
  background: var(--bg-elev);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.history h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--label-2);
  margin: 0;
  padding: 12px 16px 8px;
  text-transform: none;
}

.hrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 15px;
  position: relative;
}

.hrow + .hrow::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

.hrow .n {
  font-size: 12px;
  color: var(--label-2);
  width: 34px;
  flex: none;
}

.hrow .words {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.hrow .w {
  padding: 2px 9px;
  border-radius: 8px;
  background: var(--fill-4);
  font-size: 14px;
  font-weight: 500;
}

.hrow.hit .w {
  background: rgba(52, 199, 89, 0.18);
  color: var(--green);
}

.hrow .x {
  color: var(--label-3);
  font-size: 12px;
}

/* ------------------------------------------------------------ Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + 28px);
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: min(88vw, 420px);
  padding: 11px 18px;
  border-radius: 22px;
  background: rgba(28, 28, 30, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--spring);
}

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

@media (prefers-color-scheme: dark) {
  .toast {
    background: rgba(58, 58, 60, 0.92);
  }
}

/* ------------------------------------------------------------ 撒花 */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

/* ------------------------------------------------------------ 杂项 */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--fill-2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}

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

.pulse {
  animation: pulse 1.6s var(--ease) infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* 等待动画的三个点。标记里是 <span class="dots"><i></i><i></i><i></i></span>
   —— 选择器必须对准 i：写成 .dots span 的话三个点是零尺寸空元素，
   等待屏的"…"动效整个不可见（曾经就是这样，还没人发现）。 */
.dots i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: var(--label-3);
  animation: bounce 1.2s infinite ease-in-out;
}

.dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.linklike {
  background: none;
  border: none;
  padding: 8px 4px;
  color: var(--blue);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.linklike:active {
  opacity: 0.6;
}

.stat-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.stat {
  flex: 1;
  background: var(--fill-4);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.stat .k {
  font-size: 11px;
  color: var(--label-2);
  display: block;
}

.stat .v {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  word-break: break-word; /* 胜利画面里"撞上的词"可能是 24 字长词 */
}

/* 无障碍：仅屏幕阅读器可见 */
.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;
}

@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: 380px) {
  .room-code {
    font-size: 36px;
    letter-spacing: 7px;
    text-indent: 7px;
  }
  .chip {
    font-size: 18px;
    min-height: 48px;
  }
  .large-title {
    font-size: 30px;
  }
}
