/* ===== 通用组件 ===== */
/* hidden 属性必须真的隐藏：组件类常带 display:grid/flex，会盖掉 UA 的 [hidden] */
[hidden] { display: none !important; }
/* 横向兜底：装饰光晕（绝对定位、超宽）不得把页面撑出横向滚动，手机端会因此整页缩小 */
html, body { overflow-x: hidden; }
.btn {
  border: 1px solid var(--border-hi);
  background: var(--surface-hi);
  color: var(--ink-0);
  padding: 10px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); background: rgba(60,70,120,.85); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(86,89,222,.35);
}
.btn--primary:hover:not(:disabled) { box-shadow: var(--sh-glow); background: linear-gradient(135deg, #7B7EF5, #6063E8); }
.btn--ghost { background: rgba(255,255,255,.04); }
.btn--sm { padding: 6px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--lg { padding: 14px 28px; font-size: var(--fs-h3); }
.btn--xl { padding: 18px 32px; font-size: 1.15rem; width: 100%; }

.icon-btn {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  cursor: pointer;
  transition: background var(--t-fast);
}
.icon-btn:hover { background: rgba(255,255,255,.12); }

.input, .select {
  background: rgba(10,14,32,.6);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  color: var(--ink-0);
}
.input::placeholder { color: var(--ink-3); }
.input--sm { padding: 6px 10px; width: 84px; }
.select { padding: 8px 10px; max-width: 190px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  backdrop-filter: blur(14px);
  padding: var(--s6);
}
.panel__head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.panel__title { font-size: var(--fs-h3); margin: 0 0 var(--s4); color: var(--ink-0); }

.brand { font-weight: 800; letter-spacing: .5px; color: var(--ink-0); font-size: 1.15rem; }
.brand span { color: var(--brand-400); }
.brand--lg { font-size: 2.2rem; letter-spacing: 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-full);
  background: var(--surface-hi); border: 1px solid var(--border-hi);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-1);
  white-space: nowrap; flex: 0 0 auto;
}
.pill--playing { color: var(--pos); border-color: rgba(67,217,163,.4); background: var(--pos-soft); }
.pill--paused { color: var(--warn); border-color: rgba(255,193,94,.4); background: var(--warn-soft); }
.pill--reveal { color: var(--brand-400); border-color: rgba(139,140,246,.4); }
.pill--round_settlement { color: var(--role-b); background: var(--role-b-soft); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 600;
}
.badge--ref { color: var(--role-ref); background: var(--role-ref-soft); }
.badge--a { color: var(--role-a); background: var(--role-a-soft); }
.badge--b { color: var(--role-b); background: var(--role-b-soft); }

.tag-me, .tag-owner {
  font-size: var(--fs-xs); padding: 1px 7px; border-radius: var(--r-full);
  background: var(--brand-500); color: white; vertical-align: middle;
}
.tag-owner { background: var(--warn); color: #3a2a00; }

.field { display: flex; align-items: center; gap: var(--s2); color: var(--ink-2); font-size: var(--fs-sm); }

.fullpage {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  gap: var(--s4); padding: var(--s6);
}
.fullpage__title { color: var(--ink-0); font-size: var(--fs-h1); margin: 0; }
.fullpage__desc { color: var(--ink-2); max-width: 480px; margin: 0; }
.fullpage__icon { font-size: 4rem; }
.fullpage--warn .fullpage__icon { filter: drop-shadow(0 8px 24px rgba(255,193,94,.3)); }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid var(--border-hi); border-top-color: var(--brand-400);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reconnect-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--warn); color: #2b1d00; text-align: center;
  padding: 8px; font-weight: 600; font-size: var(--fs-sm);
}

.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: rgba(12,16,36,.94); border: 1px solid var(--border-hi);
  color: var(--ink-0); padding: 12px 22px; border-radius: var(--r-full);
  box-shadow: var(--sh-2); z-index: 200; font-size: var(--fs-sm);
  animation: toastIn var(--t) var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ===== 首页 ===== */
.home { position: relative; max-width: 880px; margin: 0 auto; padding: 64px 24px 40px; overflow: hidden; }
.home__glow { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: -1; }
.home__glow--a { width: 340px; height: 340px; top: -120px; left: -80px; background: rgba(108,111,240,.28); }
.home__glow--b { width: 300px; height: 300px; top: 80px; right: -120px; background: rgba(167,139,250,.22); }
.home__top { text-align: center; margin-bottom: var(--s10); }
.home__tagline { color: var(--ink-2); margin: var(--s3) 0 0; }

.identity-card {
  display: flex; align-items: center; gap: var(--s5);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5) var(--s6);
  box-shadow: var(--sh-1); backdrop-filter: blur(14px);
  max-width: 560px; margin: 0 auto var(--s8);
}
.identity-card__avatar {
  width: 58px; height: 58px; flex: 0 0 58px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.7rem; font-weight: 800;
  background: linear-gradient(135deg, var(--brand-500), var(--role-b));
  color: white; box-shadow: 0 8px 20px var(--brand-glow);
}
.identity-card__main { flex: 1; min-width: 0; }
.identity-card__label { font-size: var(--fs-xs); color: var(--ink-3); margin-bottom: 4px; }
.identity-card__row { display: flex; gap: var(--s2); }
.identity-card__input {
  flex: 1; min-width: 0; background: rgba(10,14,32,.6);
  border: 1px solid var(--border-hi); border-radius: var(--r-sm);
  padding: 8px 12px; color: var(--ink-0); font-weight: 600;
}
.identity-card__meta { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 6px; }

.home__actions { max-width: 560px; margin: 0 auto var(--s10); }
.home__divider {
  display: flex; align-items: center; gap: var(--s4);
  color: var(--ink-3); font-size: var(--fs-sm); margin: var(--s6) 0 var(--s4);
}
.home__divider::before, .home__divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.join-form { display: flex; gap: var(--s3); }
.join-form__input {
  flex: 1; background: rgba(10,14,32,.6); border: 1px solid var(--border-hi);
  border-radius: var(--r-md); padding: 12px 16px; color: var(--ink-0);
  letter-spacing: 4px; font-size: 1.1rem; text-align: center;
}

.home__how-title { color: var(--ink-0); text-align: center; margin-bottom: var(--s6); }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s4); }
.how-item {
  padding: var(--s5);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
}
.how-item__head { display: flex; align-items: center; gap: var(--s3); }
.how-item__no {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800;
  background: var(--brand-500); color: white;
}
.how-item b { color: var(--ink-0); }
.how-item > div { min-width: 0; }
.how-item p { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--ink-2); }
.how-note { text-align: center; color: var(--ink-3); font-size: var(--fs-xs); margin: var(--s4) 0 0; }
.home__foot { text-align: center; color: var(--ink-3); font-size: var(--fs-xs); margin-top: var(--s10); }

/* ===== 首页：创建房间（可设密码） + 房间列表 ===== */
.create-row { display: flex; gap: var(--s3); align-items: stretch; }
.create-row .btn--xl { flex: 1; }
.create-pwd { margin-top: var(--s3); }
.create-pwd .input { width: 100%; }

.roomlist { max-width: 560px; margin: 0 auto var(--s10); }
.roomlist__tools { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.roomlist__body { display: flex; flex-direction: column; gap: var(--s2); max-height: 328px; overflow-y: auto; }

.room-row {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s4);
  background: rgba(10, 14, 32, .42); border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--t), background var(--t);
}
.room-row.is-joinable:hover { border-color: var(--border-hi); background: var(--surface-hi); }
.room-row.is-locked { opacity: .72; }
.room-row__code {
  flex: 0 0 auto; font-weight: 800; font-size: 1.05rem;
  letter-spacing: 2px; font-variant-numeric: tabular-nums; color: var(--ink-0);
}
.room-row__main { flex: 1; min-width: 0; }
.room-row__title { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.room-row__status {
  font-size: var(--fs-xs); padding: 1px 8px; border-radius: var(--r-full);
  border: 1px solid transparent; white-space: nowrap;
}
.room-row__status.is-open { color: var(--pos); background: var(--pos-soft); border-color: rgba(67, 217, 163, .3); }
.room-row__status.is-ready { color: var(--warn); background: var(--warn-soft); border-color: rgba(255, 193, 94, .3); }
.room-row__status.is-playing { color: var(--ink-2); background: rgba(150, 165, 225, .12); border-color: var(--border); }
.room-row__lock { font-size: var(--fs-sm); line-height: 1; }
.room-row__lock.is-open { opacity: .45; }
.room-row__seats { font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.room-row__meta {
  font-size: var(--fs-xs); color: var(--ink-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.room-row .btn { flex: 0 0 auto; }

.room-empty { text-align: center; color: var(--ink-3); font-size: var(--fs-sm); padding: var(--s6) var(--s4); }
.room-empty__icon { display: block; font-size: 1.6rem; margin-bottom: var(--s2); }
.room-empty p { margin: 0; }
.room-empty.is-error { color: var(--warn); }

/* 密码门（邀请链接直达加密房） */
.gate-form { display: flex; gap: var(--s2); width: min(360px, 100%); margin: var(--s4) 0 var(--s2); }
.gate-form .input { flex: 1; }

/* ===== 大厅 ===== */
.lobby { position: relative; max-width: 1100px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s10); overflow-x: clip; }
.lobby__glow { position: absolute; width: 500px; height: 300px; top: -160px; left: 20%; background: rgba(108,111,240,.16); filter: blur(80px); border-radius: 50%; z-index: -1; }
.lobby__head { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; margin-bottom: var(--s6); }
.lobby__room { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.lobby__room-label { color: var(--ink-3); font-size: var(--fs-sm); }
.lobby__room-code { font-size: 1.6rem; font-weight: 800; letter-spacing: 6px; color: var(--brand-400); font-variant-numeric: tabular-nums; }
.lobby__lock { font-size: .95rem; }
.lobby__lock.is-locked { background: var(--warn-soft); border-color: rgba(255, 193, 94, .38); }
.invite { margin-bottom: var(--s6); }
.invite__row { display: flex; gap: var(--s3); flex-wrap: wrap; }
.invite__url { flex: 1; min-width: 240px; background: rgba(10,14,32,.6); border: 1px solid var(--border-hi); border-radius: var(--r-sm); padding: 10px 14px; color: var(--ink-2); font-size: var(--fs-sm); }
.invite__row .btn { flex: 0 0 auto; white-space: nowrap; }
.invite .muted { margin-top: var(--s3); }

.seats-section__head { display: flex; align-items: baseline; gap: var(--s4); margin-bottom: var(--s4); flex-wrap: wrap; }
.seats-section__head h2 { color: var(--ink-0); margin: 0; }
.seat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.seat-card {
  position: relative; min-height: 150px; padding: var(--s5);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); cursor: pointer; overflow: hidden;
  transition: transform var(--t) var(--ease), border-color var(--t), box-shadow var(--t);
}
.seat-card:hover { transform: translateY(-4px); }
.seat-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--role); }
.seat-card--ref { --role: var(--role-ref); --role-soft: var(--role-ref-soft); }
.seat-card--a { --role: var(--role-a); --role-soft: var(--role-a-soft); }
.seat-card--b { --role: var(--role-b); --role-soft: var(--role-b-soft); }
.seat-card.is-me { border-color: var(--role); box-shadow: 0 0 0 1px var(--role), 0 12px 30px rgba(0,0,0,.3); }
.seat-card.is-empty { background: rgba(255,255,255,.025); border-style: dashed; }
.seat-card.is-offline { opacity: .62; }
.seat-card.is-offline .seat-card__avatar { filter: grayscale(1); }
.seat-card__role { color: var(--role); font-weight: 700; margin-bottom: var(--s4); display: flex; align-items: center; gap: 6px; }
.seat-card__avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; background: var(--role-soft); color: var(--role); float: left; margin-right: var(--s3); }
.seat-card__avatar--empty { background: var(--surface-hi); color: var(--ink-3); }
.seat-card__body { overflow: hidden; }
.seat-card__name { color: var(--ink-0); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-card__status { font-size: var(--fs-xs); margin-top: 3px; }
.seat-card__status.ok { color: var(--pos); }
.seat-card__status.off { color: var(--neg); }
.seat-card .tag-owner { position: absolute; top: var(--s4); right: var(--s4); }
.seat-card__swap, .seat-card__take {
  position: absolute; bottom: var(--s4); right: var(--s4);
  font-size: var(--fs-xs); padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border-hi); background: var(--surface-hi); color: var(--ink-1); cursor: pointer;
}
.seat-card__take { color: var(--role); border-color: var(--role); }
.seat-card__hint { position: absolute; bottom: var(--s4); right: var(--s4); font-size: var(--fs-xs); color: var(--ink-3); }

.lobby__foot { display: flex; align-items: center; gap: var(--s6); flex-wrap: wrap; justify-content: space-between; }
.lobby__me { display: flex; align-items: center; gap: var(--s3); flex: 1; min-width: 260px; }
.lobby__me-avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, var(--brand-500), var(--role-b)); color: white; }
.lobby__me-name { color: var(--ink-0); font-weight: 700; }
.lobby__controls { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }

.qr-modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(4,6,16,.75); backdrop-filter: blur(6px); }
.qr-modal__box { position: relative; background: var(--surface-solid); border: 1px solid var(--border-hi); border-radius: var(--r-lg); padding: var(--s8); text-align: center; box-shadow: var(--sh-2); }
.qr-modal__box h3 { color: var(--ink-0); margin: 0 0 var(--s4); }
.qr-modal__stage { min-width: 280px; min-height: 280px; display: grid; place-items: center; margin: 0 auto var(--s3); }
.qr-modal__box img { width: 280px; height: 280px; background: white; border-radius: var(--r-md); display: block; }
.qr-modal__box img[hidden] { display: none; }
.qr-modal__fallback { width: 280px; min-height: 280px; border-radius: var(--r-md); border: 1px dashed var(--border-hi); background: rgba(255,255,255,.03); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); padding: var(--s4); }
.qr-modal__fallback[hidden] { display: none; }
.qr-modal__fallback-icon { font-size: 2rem; }
.qr-modal__fallback p { margin: 0; color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.6; }
.qr-modal__fallback code { display: block; max-width: 100%; word-break: break-all; font-size: var(--fs-xs); color: var(--ink-1); background: rgba(0,0,0,.28); border-radius: var(--r-sm); padding: 8px 10px; }
.qr-modal__close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--ink-2); font-size: 1.2rem; cursor: pointer; }

/* ===== 游戏场（一屏布局：整页锁定视口高，仅词链内部滚动） ===== */
.game {
  max-width: 1280px; margin: 0 auto;
  height: 100dvh; box-sizing: border-box;
  padding: var(--s4) var(--s6) var(--s4);
  display: grid; grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: var(--s3); overflow: hidden;
}
.game__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.game__head-left, .game__head-right { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.game__room { color: var(--ink-3); font-size: var(--fs-sm); }
.game__banner { background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(255,193,94,.3); border-radius: var(--r-md); padding: 8px 16px; text-align: center; font-weight: 600; }

/* 昵称按钮：点击即改昵称 */
.nick-btn { background: none; border: none; padding: 0; cursor: pointer; }
.nick-btn:hover { filter: brightness(1.15); }

/* 计分条：一条横排，三人总分 + 奖池，尽量不占竖向空间 */
.score-wrap { padding: 0; }
.score-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: var(--s2); }
.score-chip {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.045); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 6px 10px; min-width: 0;
}
.score-chip__icon { font-size: .95rem; opacity: .9; }
.score-chip__meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.score-chip__role { font-size: var(--fs-xs); color: var(--ink-3); }
.score-chip__nick { font-size: var(--fs-sm); color: var(--ink-1); font-weight: 600; max-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-chip__value { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-0); }
/* 右侧两行：总分（大）+ 本局得分（小，局中实时变化） */
.score-chip__nums { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.1; }
.score-chip__round { font-size: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.score-chip__round.is-pos { color: var(--pos); }
.score-chip__round.is-neg { color: var(--neg); }
.score-chip__stake { position: absolute; right: 8px; bottom: 4px; font-size: 10px; color: var(--ink-3); }
.score-chip--ref { --tint: var(--role-ref); }
.score-chip--a { --tint: var(--role-a); }
.score-chip--b { --tint: var(--role-b); }
.score-chip--ref .score-chip__value { color: var(--role-ref); }
.score-chip--a .score-chip__value { color: var(--role-a); }
.score-chip--b .score-chip__value { color: var(--role-b); }
.score-chip.is-negative .score-chip__value { color: var(--neg); }
.pot-chip {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 4px 14px; border-radius: var(--r-md); min-width: 84px;
  background: linear-gradient(135deg, rgba(255,193,94,.14), rgba(255,127,176,.1));
  border: 1px solid rgba(255,193,94,.3);
}
.pot-chip__label { font-size: 10px; color: var(--ink-3); }
.pot-chip__value { font-size: 1.25rem; font-weight: 800; color: var(--warn); font-variant-numeric: tabular-nums; }
.score-float { position: absolute; right: 10px; top: 2px; font-weight: 700; font-size: var(--fs-xs); animation: floatUp .5s ease-out forwards; }
.score-float.is-pos { color: var(--pos); }
.score-float.is-neg { color: var(--neg); }
@keyframes floatUp { to { opacity: 0; transform: translateY(-22px); } }
.is-bump { animation: bump .35s var(--ease); }
@keyframes bump { 50% { transform: scale(1.07); } }
.is-redistribute { animation: redistribute .5s var(--ease); }
@keyframes redistribute { 0% { background: rgba(255,193,94,.22); } 100% { background: transparent; } }

.game__main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, .85fr); gap: var(--s4); min-height: 0; }
/* 游戏页内面板收紧内边距，为一屏布局让出空间 */
.game .panel { padding: var(--s4); }
.play-panel { min-height: 0; display: flex; flex-direction: column; }
.turn-head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s2); }
.turn-head__label { font-size: var(--fs-h3); font-weight: 700; color: var(--ink-0); }
.turn-head .muted { margin-left: auto; }
.countdown {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-full);
  background: rgba(255,255,255,.06); font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-sm);
}
.countdown__icon { font-size: .85rem; opacity: .8; }
.countdown.is-urgent { background: rgba(255,107,138,.18); color: var(--neg); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.progress { height: 5px; border-radius: var(--r-full); background: rgba(255,255,255,.08); overflow: hidden; margin-bottom: var(--s3); }
.progress__fill { height: 100%; width: 0; border-radius: var(--r-full); background: linear-gradient(90deg, var(--brand-500), var(--role-b)); transition: width var(--t) var(--ease); }

.rule-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; background: rgba(108,111,240,.1); border: 1px solid rgba(108,111,240,.22); border-radius: var(--r-md); padding: 8px 12px; font-size: var(--fs-sm); margin-bottom: var(--s3); }
.rule-bar__title { font-weight: 700; color: var(--brand-400); }
.anchor-chip { padding: 2px 10px; border-radius: var(--r-full); font-weight: 700; }
.anchor-chip--a { color: var(--role-a); background: var(--role-a-soft); }
.anchor-chip--b { color: var(--role-b); background: var(--role-b-soft); }

.cards { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s3); align-items: center; margin-bottom: var(--s3); flex: 1; min-height: 0; }
.card-slot { min-width: 0; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.card-slot > .word-card { width: 100%; height: 100%; }
.cards__vs { color: var(--ink-3); font-weight: 800; font-size: 1rem; }
.word-card { position: relative; perspective: 1000px; min-height: 150px; cursor: default; display: flex; flex-direction: column; }
.card__label { display: flex; align-items: center; gap: 6px; justify-content: center; font-weight: 700; margin-bottom: 6px; font-size: var(--fs-sm); }
.card__nick { font-weight: 500; color: var(--ink-2); font-size: var(--fs-xs); max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-card--a .card__label { color: var(--role-a); }
.word-card--b .card__label { color: var(--role-b); }
.card__inner { position: relative; width: 100%; flex: 1; min-height: 130px; transform-style: preserve-3d; transition: transform var(--d-flip, 600ms) var(--ease); }
.word-card.is-submitted .card__inner, .word-card.is-revealed .card__inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--r-lg); padding: var(--s3); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--sh-2); border: 1px solid var(--border-hi); }
.card-face--front { background: rgba(20,26,54,.9); }
.card__corner { position: absolute; top: 10px; left: 12px; font-size: var(--fs-xs); color: var(--ink-3); }
.card__placeholder { display: flex; flex-direction: column; align-items: center; gap: var(--s2); color: var(--ink-3); font-size: var(--fs-sm); }
.card__placeholder-icon { font-size: 2rem; }
.card__word { font-size: clamp(1.6rem, 3vw, 2.6rem); font-weight: 800; color: var(--ink-0); word-break: break-all; text-align: center; }
.card-face--back { transform: rotateY(180deg); background: var(--g-card-back); color: white; gap: var(--s3); }
.card__brand { letter-spacing: 4px; opacity: .85; }
.card__done { font-size: 1.2rem; font-weight: 700; }
.word-card.is-match .card-face--front { border-color: var(--pos); box-shadow: 0 0 0 3px rgba(67,217,163,.25), 0 16px 40px rgba(67,217,163,.25); }
.word-card.is-match .card__word { color: var(--pos); }
/* 我的牌 / 对手的牌：仅做轻微区分，避免抢走「揭晓/撞词」的视觉重点 */
.word-card.is-mine .card-face--front { border-color: var(--brand-400); }
.word-card.is-opponent { opacity: .96; }
.is-muted { opacity: .5; }
.card__particles { position: absolute; inset: 0; pointer-events: none; }
.card__particles .particle {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0;
}
.word-card.is-match .card__particles .particle { animation: particle-pop 900ms var(--ease) forwards; }
.word-card.is-match .card__particles .particle:nth-child(1) { left: 12%; top: 30%; animation-delay: 0ms; }
.word-card.is-match .card__particles .particle:nth-child(2) { left: 26%; top: 66%; animation-delay: 60ms; }
.word-card.is-match .card__particles .particle:nth-child(3) { left: 40%; top: 22%; animation-delay: 120ms; }
.word-card.is-match .card__particles .particle:nth-child(4) { left: 54%; top: 72%; animation-delay: 180ms; }
.word-card.is-match .card__particles .particle:nth-child(5) { left: 68%; top: 34%; animation-delay: 240ms; }
.word-card.is-match .card__particles .particle:nth-child(6) { left: 82%; top: 62%; animation-delay: 300ms; }
.word-card.is-match .card__particles .particle:nth-child(7) { left: 18%; top: 78%; animation-delay: 360ms; }
.word-card.is-match .card__particles .particle:nth-child(8) { left: 34%; top: 44%; animation-delay: 420ms; }
.word-card.is-match .card__particles .particle:nth-child(9) { left: 62%; top: 16%; animation-delay: 480ms; }
.word-card.is-match .card__particles .particle:nth-child(10) { left: 88%; top: 44%; animation-delay: 540ms; }
@keyframes particle-pop {
  0% { opacity: 0; transform: translateY(6px) scale(.6); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px) scale(1.15); }
}
.card__status { text-align: center; font-size: var(--fs-sm); margin-top: var(--s3); min-height: 20px; color: var(--ink-3); }
.card__status.is-win { color: var(--pos); font-weight: 700; }

.submit-zone__row { display: flex; gap: var(--s3); }
.input--word { flex: 1; font-size: 1.15rem; padding: 14px 18px; }
.submit-zone__hint { font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--s2); }
.submit-zone__error { color: var(--neg); font-size: var(--fs-sm); min-height: 18px; margin-top: 2px; }
.judge-hint { background: var(--role-ref-soft); color: var(--role-ref); border-radius: var(--r-md); padding: 14px; text-align: center; }

.side-panel { display: flex; flex-direction: column; gap: var(--s3); min-height: 0; overflow: hidden; }
.side-panel > .panel { min-width: 0; }
.controls-panel, .chain-panel { display: flex; flex-direction: column; min-height: 0; }
.controls-panel[hidden] { display: none; }
.chain-panel { flex: 1; min-height: 0; }
.controls__hint { margin: var(--s2) 0; }
.controls { display: flex; flex-direction: column; gap: var(--s2); }
.members { margin-top: var(--s3); border-top: 1px solid var(--border); padding-top: var(--s2); }
.member-row { display: flex; align-items: center; gap: var(--s2); padding: 4px 0; font-size: var(--fs-sm); }
.member-row .muted { margin-left: auto; }
.member-row.is-off { opacity: .5; }
.member-row__kick { background: none; border: none; color: var(--neg); cursor: pointer; font-size: var(--fs-sm); }
.chain { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
.chain__item { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); padding: 5px 9px; border-radius: var(--r-sm); background: rgba(255,255,255,.03); flex: 0 0 auto; }
.chain__item.is-match { background: var(--pos-soft); }
.chain__item.is-anchor { border-left: 2px solid var(--brand-400); }
.chain__no { color: var(--ink-3); width: 22px; }
.chain__word { font-weight: 700; }
.chain__word--a { color: var(--role-a); }
.chain__word--b { color: var(--role-b); }
.chain__word--unknown { color: var(--ink-3); }
.chain__empty { color: var(--ink-3); font-style: italic; font-weight: 400; }
.chain__sep { color: var(--ink-3); }
.chain__tag { margin-left: auto; font-size: var(--fs-xs); color: var(--ink-3); }
/* 已结束的一轮：轮末回合可点，回看结算 */
.chain__item.is-openable { cursor: pointer; border: 1px solid transparent; }
.chain__item.is-openable:hover { border-color: var(--border-hi); background: rgba(255,255,255,.06); }
.chain__item.is-openable:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 1px; }
.chain__open { font-size: var(--fs-xs); color: var(--brand-400); margin-left: var(--s2); white-space: nowrap; }
.panel__hint { font-size: var(--fs-xs); font-weight: 400; color: var(--ink-3); margin-left: var(--s2); }
.chain--compact { max-height: none; }

.result-overlay { position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; background: rgba(4,6,16,.78); backdrop-filter: blur(6px); padding: var(--s4); }
.result-card { position: relative; width: min(560px, 100%); background: var(--surface-solid); border: 1px solid var(--border-hi); border-radius: var(--r-xl); padding: var(--s6); box-shadow: var(--sh-2); }
/* 结算弹窗：左右两栏，整体不滚动（只有右栏词链内部滚动） */
.result-card--split { width: min(940px, 100%); max-height: 86vh; overflow: hidden; }
.result-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: var(--s5); max-height: calc(86vh - 2 * var(--s6)); }
.result-split__left { display: flex; flex-direction: column; min-width: 0; }
.result-split__right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.result-split__right .chain { overflow-y: auto; }
.result-card__close { position: absolute; top: var(--s3); right: var(--s3); background: none; border: none; color: var(--ink-2); cursor: pointer; font-size: 1.2rem; }
.result__hero { text-align: center; margin-bottom: var(--s3); }
.result__emoji { font-size: 2.4rem; line-height: 1.1; }
.result__title { font-size: var(--fs-h3); margin: 4px 0 0; }
.result__title.is-win { color: var(--pos); }
.result__title.is-lose { color: var(--warn); }
.result__title.is-refund { color: var(--brand-400); }
.result__section { color: var(--ink-2); font-weight: 700; margin: 0 0 var(--s2); }
.result__wait { text-align: center; color: var(--ink-3); font-size: var(--fs-sm); margin-top: auto; padding-top: var(--s3); }
.result__wait.is-past { opacity: .7; }

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); }
.table th:first-child, .table td:first-child { text-align: left; color: var(--ink-2); }
.table thead th { color: var(--ink-2); font-weight: 600; }
.table tfoot td { font-weight: 700; color: var(--ink-0); border-bottom: none; }
.delta-pos { color: var(--pos); }
.delta-neg { color: var(--neg); }

.no-anim *, .no-anim *::before, .no-anim *::after { transition: none !important; animation-duration: .01ms !important; }

/* ===== 弹窗（换座确认 / 改昵称） ===== */
.modal { position: fixed; inset: 0; z-index: 320; display: grid; place-items: center; background: rgba(4,6,16,.72); backdrop-filter: blur(4px); padding: var(--s4); }
.modal__box { width: min(420px, 100%); background: var(--surface-solid); border: 1px solid var(--border-hi); border-radius: var(--r-lg); padding: var(--s6); box-shadow: var(--sh-2); }
.modal__box h3 { margin: 0 0 var(--s3); color: var(--ink-0); font-size: var(--fs-h3); }
.modal__text { color: var(--ink-1); line-height: 1.7; margin: 0 0 var(--s4); font-size: var(--fs-sm); }
.modal__actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s4); }
.link-btn { background: none; border: none; color: var(--brand-400); cursor: pointer; font-size: var(--fs-xs); text-decoration: underline; padding: 0 0 0 6px; }

/* 结算表：紧凑 */
.st-table th, .st-table td { padding: 6px 8px; }
.st__who { white-space: nowrap; }
.st__nick { color: var(--ink-3); font-weight: 400; font-size: var(--fs-xs); margin-left: 4px; }
.st__total { font-weight: 800; }
.st__round { font-variant-numeric: tabular-nums; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .game { height: auto; min-height: 100dvh; overflow: visible; grid-template-rows: auto auto auto auto; }
  .game__main { grid-template-columns: 1fr; }
  .side-panel { flex-direction: row; flex-wrap: wrap; }
  .side-panel > .panel { flex: 1; min-width: 240px; }
  .result-split { grid-template-columns: 1fr; max-height: calc(86vh - 2 * var(--s6)); overflow-y: auto; }
}
@media (max-width: 640px) {
  .home, .lobby, .game { padding-left: var(--s4); padding-right: var(--s4); }
  .home { padding-top: var(--s10); }
  .brand--lg { font-size: 1.8rem; }
  .lobby__room-code { font-size: 1.25rem; letter-spacing: 3px; }
  .score-bar { grid-template-columns: 1fr 1fr; }
  .pot-chip { grid-column: 1 / -1; flex-direction: row; gap: 8px; }
  .score-chip__value { font-size: 1.15rem; }
  .cards { gap: var(--s2); }
  .card__word { font-size: 1.8rem; }
  .invite__row .btn { flex: 1; }

  /* 邀请区：链接独占一行，两个按钮并排；避免「复制链接」被挤成竖排单字 */
  .invite__url { flex: 1 1 100%; min-width: 0; }
  .invite__row { gap: var(--s2); }
  .lobby__me { min-width: 0; }
  .lobby__foot { gap: var(--s3); }
  .lobby__controls { width: 100%; justify-content: space-between; gap: var(--s2); }
  .seat-grid { grid-template-columns: 1fr; }

  /* 游戏页头部：左（品牌+房间号）/ 右（昵称·状态·返回·离开）各占一行，右侧不换行 */
  .game__head { gap: var(--s2); }
  .game__head-left { flex: 1 1 100%; justify-content: space-between; }
  .game__head-right { flex: 1 1 100%; justify-content: space-between; flex-wrap: nowrap; gap: var(--s2); }
  .game__room { font-size: var(--fs-xs); }
  .nick-btn { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 移动端：iOS 对 fixed 背景支持差（滚动闪烁/错位），回到 scroll */
  body { background-attachment: scroll; }
  .room-empty p { text-wrap: balance; }

  /* 创建区：竖排，避免「创建房间 + 不设密码」在窄屏挤成两行小按钮 */
  .create-row { flex-direction: column; }
  .create-row .btn--sm { width: 100%; }

  /* 怎么玩：单列 + 小一号，别让三张卡在手机上占满一屏 */
  .home__how-title { font-size: 1.05rem; margin-bottom: var(--s4); }
  .how-grid { grid-template-columns: 1fr; gap: var(--s2); }
  .how-item { padding: var(--s4); }
  .how-item__head { gap: var(--s2); }
  .how-item__no { width: 26px; height: 26px; flex-basis: 26px; font-size: var(--fs-xs); }
  .how-item b { font-size: var(--fs-sm); }
  .how-item p { font-size: var(--fs-xs); line-height: 1.55; }

  /* 房间行：收窄间距与房间码，给「加入」按钮留位置 */
  .room-row { gap: var(--s3); }
  .room-row__code { font-size: .95rem; letter-spacing: 1px; }
}
