/* 霞鹜文楷按 unicode-range 切片，页面用到哪些字才下载哪几片（scripts/split-font.py 生成） */
@import url('assets/fonts/lxgw-wenkai/font.css');
/* 内嵌字体：离线也能加载，全部为 OFL 1.1 开源许可，见 assets/fonts/OFL.txt */
@font-face {
  font-family: 'Ma Shan Zheng';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/ma-shan-zheng.woff2') format('woff2');
}
/* Nunito（界面西文字母）*/
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/nunito-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/nunito-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/nunito-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('assets/fonts/nunito-800.woff2') format('woff2');
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #999;
  --accent: #c8a45c;
  --accent-dim: #faf6ef;
  --accent-glow: rgba(200, 164, 92, 0.25);
  --border: #eee;
  --radius: 24px;
  --radius-sm: 16px;
  --radius-btn: 30px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --success: #5a9e6f;
  --danger: #d4695a;

  /* Lobby v2.3 Light Tokens */
  --lb-bg: #f4f4f2;
  --lb-surface: #ffffff;
  --lb-surface-2: #ecece8;
  --lb-surface-glass: rgba(244, 244, 242, 0.86);
  --lb-text: #121316;
  --lb-text-2: #5b5e66;
  --lb-text-3: #8a8e98;
  --lb-border: rgba(18, 19, 22, 0.08);
  --lb-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 18px rgba(0, 0, 0, 0.05);
  --lb-chip-ring: inset 0 0 0 1px rgba(18, 19, 22, 0.07);
  --lb-accent: #e0632a;
  --lb-on-accent: #ffffff;
  --lb-thumb-bg: #1d1f24;
  --lb-radius-card: 14px;
  --lb-radius-hero: 18px;
  --lb-radius-chip: 999px;
  --lb-radius-ctl: 12px;
  --lb-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --lb-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --lb-dur-press: 100ms;
  --lb-dur-fast: 160ms;
  --lb-dur-base: 220ms;
  --lb-dur-panel: 300ms;
}

:root[data-theme="dark"] {
  --lb-bg: #0f1012;
  --lb-surface: #181a1f;
  --lb-surface-2: #22252c;
  --lb-surface-glass: rgba(15, 16, 18, 0.86);
  --lb-text: #f5f5f7;
  --lb-text-2: #a0a4ad;
  --lb-text-3: #6c707a;
  --lb-border: rgba(255, 255, 255, 0.07);
  --lb-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 8px 24px rgba(0, 0, 0, 0.36);
  --lb-chip-ring: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  --lb-accent: #ff7838;
  --lb-on-accent: #ffffff;
  --lb-thumb-bg: #1d1f24;
}

html[data-theme="light"] {
  color-scheme: light;
  background: var(--lb-bg);
  color: var(--lb-text);
}

html[data-theme="dark"] {
  color-scheme: dark;
  background: var(--lb-bg);
  color: var(--lb-text);
}

/* View Transition circular theme reveal (C4) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

html.theming * {
  transition: none !important;
}

/* ====== Animations ====== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

.is-active-turn {
  border: 2px solid var(--accent, #c8a45c);
  animation: pulse 1.2s ease 1;
}

@keyframes breathe {
  0%, 100% { border-color: var(--border); }
  50% { border-color: #ccc; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes goldShine {
  0% { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

html {
  font-family: 'Nunito', 'LXGW WenKai', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  height: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  padding: 28px 16px;
  /* 顶部挖孔/状态栏：viewport-fit=cover 会让内容铺到刘海下面，必须自己让位。
     横屏时挖孔跑到左侧，所以左右也要吃安全区。 */
  padding-top: max(28px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: calc(28px + var(--safe-bottom));
}

button, input { font-family: inherit; font-size: inherit; }

/* ====== Headers ====== */
.page-title {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 6px;
  text-align: center;
  margin-bottom: 4px;
  animation: fadeInUp 0.5s ease both;
}

.title-divider {
  width: 36px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 10px auto 6px;
  animation: fadeIn 0.6s ease 0.2s both;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
  font-weight: 300;
  animation: fadeInUp 0.5s ease 0.15s both;
}

/* ====== Cards ====== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s;
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-btn);
  padding: 15px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  letter-spacing: 1px;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: linear-gradient(135deg, #1a1a1a 0%, #333 100%);
  color: #fff;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-primary:hover::after { opacity: 1; animation: shimmer 1.5s ease infinite; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.2); }
.btn-primary:active { transform: scale(0.96) translateY(0); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #b8944c 100%);
  color: #fff;
  width: 100%;
  box-shadow: 0 2px 10px var(--accent-glow);
  border: none;
}
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 4px 18px var(--accent-glow); }
.btn-accent:active { transform: scale(0.96); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover, .btn-outline:active { border-color: var(--text); }

.btn-sm { padding: 10px 18px; font-size: 14px; min-height: 42px; }

.btn:disabled, .btn.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

/* ====== Inputs ====== */
.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 15px 20px;
  color: var(--text);
  font-size: 16px;
  text-align: center;
  letter-spacing: 3px;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  font-family: inherit;
}

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.input::placeholder {
  color: #ccc;
  letter-spacing: 0;
  text-transform: none;
  font-size: 14px;
}

/* ====== Lobby ====== */
#gameOptions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.game-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s, transform 0.15s;
  text-align: center;
  animation: fadeInUp 0.4s ease both;
}

.game-option:nth-child(1) { animation-delay: 0s; }
.game-option:nth-child(2) { animation-delay: 0.03s; }
.game-option:nth-child(3) { animation-delay: 0.06s; }
.game-option:nth-child(4) { animation-delay: 0.09s; }
.game-option:nth-child(5) { animation-delay: 0.12s; }
.game-option:nth-child(6) { animation-delay: 0.15s; }
.game-option:nth-child(7) { animation-delay: 0.18s; }
.game-option:nth-child(8) { animation-delay: 0.21s; }

.game-option:hover, .game-option.selected {
  border-color: var(--accent);
  box-shadow: 0 2px 16px rgba(200, 164, 92, 0.15);
  background: var(--surface);
}

.game-option:active { transform: scale(0.97); }

.game-option-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim) 0%, #f5edd8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: transform 0.25s;
}

.game-option.selected .game-option-icon { transform: scale(1.1); }

.game-option-info { text-align: center; }
.game-option-info .name { font-weight: 600; font-size: 14px; }
.game-option-info .desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.game-option-info .meta { font-size: 10px; color: var(--accent); margin-top: 2px; font-weight: 500; }

/* ====== Game Pages ====== */
.game-header {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.back-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none;
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  cursor: pointer; padding: 8px 4px;
  -webkit-tap-highlight-color: transparent;
}
/* Invisible extension so the tap target is at least 40px tall even when the padding is tightened */
.back-btn { position: relative; }
.back-btn::after { content: ''; position: absolute; left: -6px; right: -10px; top: 50%; height: 44px; transform: translateY(-50%); }

.room-id-badge {
  font-size: 12px; color: var(--text-muted);
  background: var(--bg); padding: 6px 14px;
  border-radius: 20px; font-weight: 600; letter-spacing: 1px;
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mute-btn {
  background: var(--bg); border: 0; border-radius: 20px;
  min-width: 36px; min-height: 32px; font-size: 15px; line-height: 1; cursor: pointer;
}

.player-bar {
  width: 100%;
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 14px; gap: 10px;
  /* Many players: keep full names and scroll sideways instead of squeezing */
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.player-bar::-webkit-scrollbar { height: 3px; }
.player-bar::-webkit-scrollbar-button { display: none; }
.player-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.player-tag {
  flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 8px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  background: var(--bg); transition: all 0.25s;
  border: 1px solid transparent;
  min-width: 0; /* 允许收缩，名字超长才能省略号，否则会换行竖排 */
  white-space: nowrap;
}

.player-tag-avatar {
  font-size: 16px;
  line-height: 1;
}

/* 玩家名：单行 + 超长省略，避免竖排撑破布局 */
.player-tag-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  min-width: 0;
}

.player-tag.active {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(200, 164, 92, 0.1);
  animation: pulse 1.2s ease 1;
}

.player-tag .dot {
  display: inline-block; flex-shrink: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
}

.player-tag.p1 .dot { background: var(--text); }
.player-tag.p2 .dot { background: var(--accent); }
.player-tag.p3 .dot { background: #d4695a; }
.player-tag.p4 .dot { background: #5a9e6f; }

.vs-text {
  font-size: 13px; font-weight: 700;
  color: var(--text-muted); flex-shrink: 0;
}

.game-status {
  text-align: center; font-size: 15px; font-weight: 600;
  margin-bottom: 12px; min-height: 22px; color: var(--text-muted);
  transition: color 0.3s;
}

.game-status.my-turn { color: var(--accent); animation: fadeIn 0.3s ease; }
.game-status.winner { color: var(--success); }
.game-status.draw { color: var(--text-muted); }

/* ====== Board ====== */
.board-wrap {
  width: 100%;
  display: flex; justify-content: center;
  align-items: center;
  padding-bottom: 72px;
}

/* TicTacToe */
.ttt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(340px, 80vw);
  aspect-ratio: 1;
}

.ttt-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: clamp(28px, 10vw, 52px);
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.ttt-cell:active { background: var(--bg); }
.ttt-cell.p1 { color: #1a1a1a; }
.ttt-cell.p2 { color: var(--accent); }
.ttt-cell.win-cell { background: var(--accent-dim) !important; }

/* Gomoku */
.gomoku-wrap {
  width: min(400px, 88vw);
  aspect-ratio: 1;
}

#gomokuCanvas {
  width: 100%; height: 100%;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ====== Actions ====== */
.game-actions {
  margin-top: 18px;
  display: flex; gap: 12px;
  width: 100%;
}

/* ====== Toast ====== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: var(--text); color: #fff;
  padding: 12px 24px; border-radius: 30px;
  font-size: 14px; font-weight: 600;
  z-index: 100; pointer-events: none;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
  box-shadow: var(--shadow-lg);
}

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

/* ====== Responsive ====== */
@media (max-width: 400px) {
  body { padding: 16px 10px; }
  .card, .lobby-section { padding: 18px; }
  .btn { padding: 13px 18px; font-size: 14px; }
  .player-tag { font-size: 13px; padding: 8px 6px; }
  .player-tag .dot { width: 8px; height: 8px; }
  #gameOptions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .game-option { padding: 12px 8px; }
  .game-option-icon { width: 36px; height: 36px; font-size: 17px; }
  .game-option-info .name { font-size: 13px; }
  .game-option-info .desc { font-size: 10px; }
}

/* ====== Waiting Room ====== */
.waiting-room {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.4s ease both;
}

.waiting-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

.waiting-game-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.waiting-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.waiting-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color 0.25s, background 0.25s, opacity 0.25s, box-shadow 0.25s;
  animation: fadeInUp 0.35s ease both;
}

.waiting-slot:nth-child(1) { animation-delay: 0.05s; }
.waiting-slot:nth-child(2) { animation-delay: 0.1s; }
.waiting-slot:nth-child(3) { animation-delay: 0.15s; }
.waiting-slot:nth-child(4) { animation-delay: 0.2s; }
.waiting-slot:nth-child(5) { animation-delay: 0.25s; }
.waiting-slot:nth-child(6) { animation-delay: 0.3s; }

.waiting-slot.occupied {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.waiting-slot.empty {
  opacity: 0.45;
  border-style: dashed;
  animation: fadeInUp 0.35s ease both, breathe 3s ease infinite;
}

.waiting-slot.me {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(200, 164, 92, 0.15);
}

.waiting-slot-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.waiting-slot-info {
  flex: 1;
  min-width: 0;
}

.waiting-slot-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waiting-slot-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.waiting-slot-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
  white-space: nowrap;
}

.waiting-slot-badge.ready {
  background: #e8f5ec;
  color: var(--success);
}

.waiting-slot-badge.host {
  background: linear-gradient(135deg, var(--accent), #b8944c);
  color: #fff;
}

.waiting-slot-badge.ai {
  background: #f0f0f0;
  color: #666;
}

/* 换座 / 移除 / 踢人：三个小徽标式按钮，状态徽标同尺寸，避免大圆圈占用版面 */
.waiting-slot-swap,
.waiting-slot-xbtn {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  padding: 2px 6px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
}
/* Phones keep the 32px look; the (pointer: coarse) ::after rule below supplies the 44px hit area */
@media (max-width: 768px) {
  .waiting-slot { padding: 10px 12px; }
  .waiting-slot-avatar { width: 36px; height: 36px; }
}

.waiting-slot-swap {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.waiting-slot-swap:hover, .waiting-slot-swap:active {
  background: var(--bg);
  border-color: var(--accent);
}

/* 移除AI / 踢人：统一为红色小字 X（与左侧徽标留出间距,避免和 ⇅ 换位按钮紧挨误触） */
.waiting-slot-xbtn {
  margin-left: 6px;
  border: 1px solid rgba(224,80,80,.28);
  background: rgba(224,80,80,.06);
  color: #e05050;
}
.waiting-slot-xbtn:hover, .waiting-slot-xbtn:active {
  background: rgba(224,80,80,.16);
  border-color: #e05050;
}

.waiting-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.waiting-actions .btn { min-width: auto; }

.waiting-status {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 20px;
}

#readyBtn.ready-active {
  background: #e8f5ec;
  border-color: var(--success);
  color: var(--success);
}

/* ====== Avatar Drawer (bottom sheet) ====== */
.avatar-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: avatarFade 0.2s ease;
}
@keyframes avatarFade { from { opacity: 0; } to { opacity: 1; } }

.avatar-drawer-sheet {
  background: var(--surface);
  width: 92%;
  max-width: 420px;
  max-height: 70vh;
  border-radius: 16px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  animation: avatarSlideUp 0.26s cubic-bezier(.2, .8, .2, 1);
}
/* Mobile: make the drawer nearly full-height and emoji grid compact so all
   avatars are visible without scrolling to the bottom. */
@media (max-width: 480px) {
  .avatar-drawer-sheet { max-height: 90vh; padding: 8px 10px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
  .emoji-btn { width: 32px; height: 32px; font-size: 16px; }
}
@keyframes avatarSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.avatar-drawer-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 12px;
}

.avatar-drawer-title {
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
}

/* ====== Emoji Picker ====== */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  justify-items: center;
}

.emoji-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.emoji-btn:active { transform: scale(0.9); }
.emoji-btn.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ====== QR Area ====== */
.qr-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.qr-card img {
  border-radius: 12px;
  width: 160px; height: 160px;
  box-shadow: var(--shadow-sm);
}

.qr-room-code {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--text);
  margin-top: 8px;
}

.qr-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ====== Overlay Refinements ====== */
.overlay {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.overlay .overlay-card {
  animation: scaleIn 0.3s ease both;
  box-shadow: var(--shadow-lg);
}

.overlay-card .result.win-text {
  background: linear-gradient(135deg, var(--accent), #e8c56a, var(--accent));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: goldShine 2s ease infinite;
}

/* ====== Notify Bar ====== */
#notifyBar {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ====== Game Actions ======
   位于文档流最底部，不吸附屏幕：要滑到整个页面底部才出现，
   避免常驻横条压住棋盘。（类名沿用 -fixed 是历史原因，现在并非 position:fixed） */
.game-actions-fixed {
  position: static;
  margin-top: 24px;
  padding: 14px 20px;
  padding-bottom: calc(14px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ====== Global Scrollbar ====== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

@media (max-width: 480px) {
  body {
    padding: 12px 8px;
    padding-bottom: calc(12px + var(--safe-bottom));
  }
  /* Player bar compact: scrollable avatar row, tap for name */
  .player-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 2px;
    padding-bottom: 6px;
    justify-content: flex-start;
  }
  .player-tag-name { font-size: 11px; max-width: 96px; }
  .player-tag {
    flex: 0 0 auto; min-width: 32px;
    padding: 6px 6px; gap: 3px;
  }
  .player-tag-avatar { font-size: 17px; }
  .player-tag .dot { width: 6px; height: 6px; }
  .vs-text { font-size: 9px; padding: 0 1px; flex: 0 0 auto; }
  .player-bar { gap: 2px; margin-bottom: 8px; }
}

@media (min-width: 768px) {
  body { padding: 24px 32px; }
  /* Board games: bigger boards on desktop */
  .ttt-grid { width: min(460px, 55vw); }
  .gomoku-wrap { width: min(560px, 60vw); }
  /* Canvas-based games: JS controls sizing, no CSS cap */
  #fcCanvas, #ccCanvas, #goCanvas {
    margin: 0 auto;
    display: block;
  }
  /* Player bar: follow board width */
  .player-bar {
    max-width: min(900px, 90vmin);
    margin-left: auto;
    margin-right: auto;
  }
  .player-tag { font-size: 13px; padding: 8px 12px; }
  .player-tag .dot { width: 8px; height: 8px; }
  .game-status { margin-bottom: 10px; }
}

/* ====== Flight Chess ====== */
.flightchess-wrap canvas {
  cursor: pointer;
  touch-action: manipulation;
}

#fcDice {
  user-select: none;
  transition: transform 0.15s ease;
}
#fcDice:active {
  transform: scale(0.9);
}

/* ====== Chinese Chess ====== */
#ccCanvas {
  cursor: pointer;
  touch-action: manipulation;
}

/* ====== Go 9x9 ====== */
#goCanvas {
  cursor: pointer;
  touch-action: manipulation;
}

#goPassBtn {
  transition: background 0.2s, transform 0.15s;
}
#goPassBtn:active {
  transform: scale(0.95);
}

/* ====== Stage 1 Visual Refresh ====== */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
}

.game-page-shell {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  /* Subtract body's top+bottom padding (28px each) so the shell fills the
     viewport exactly without leaving dead scroll space below the game. */
  min-height: calc(100dvh - 56px);
}

.game-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 4px;
}

.game-topbar-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.game-title-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.game-title-stack strong {
  font-size: 18px;
}

.game-title-stack span {
  font-size: 12px;
  color: var(--text-muted);
}

.room-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.waiting-room.refresh {
  max-width: none;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.waiting-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.surface-panel {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(25, 22, 17, 0.08);
}

.waiting-main-panel,
.waiting-side-panel,
.game-stage-panel {
  padding: 22px;
}

.waiting-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.waiting-headline-copy {
  display: grid;
  gap: 6px;
}

.waiting-headline-copy h2 {
  font-size: 28px;
}

.waiting-headline-copy p {
  color: #5f584f;
  line-height: 1.5;
}

.waiting-meta-row,
.room-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-pill,
.room-facts span {
  padding: 7px 12px;
  border-radius: 999px;
  background: #f3efe6;
  color: #5f564a;
  font-size: 12px;
  font-weight: 600;
}

.waiting-profile {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 14px 0 16px;
}

.waiting-side-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.rules-btn {
  width: 100%;
}

.game-stage-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.game-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.board-wrap.stage-board {
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
}

.game-actions-fixed.refresh {
  border-radius: 20px;
  background: rgba(255,255,255,0.92);
}

@media (max-width: 1100px) {
  .waiting-layout {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 820px) {
  .waiting-layout {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 560px) {
  .waiting-main-panel,
  .waiting-side-panel,
  .game-stage-panel {
    padding: 14px;
    border-radius: 18px;
  }
  .waiting-headline-copy h2 {
    font-size: 22px;
  }
}

/* ====== Page Transitions ====== */

/* Game → Lobby exit (game.html) */
.game-page-shell.exit-anim {
  animation: pageSlideUpExit 0.35s ease-in forwards;
}

@keyframes pageSlideUpExit {
  to {
    opacity: 0;
    transform: translateY(-24px);
  }
}

/* Game → Lobby entrance (index.html) */
.lobby-page.entrance-anim {
  animation: pageSlideUpEntrance 0.4s ease-out;
}

@keyframes pageSlideUpEntrance {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

/* ====== Game Elements (shared tokens + CardUI) ====== */
:root {
  --ge-ink: #1c1b19;
  --ge-ink-soft: #5d5850;
  --ge-paper: #fffdf8;
  --ge-line: rgba(28, 27, 25, 0.12);
  --ge-red: #c0392b;
  --ge-gold: #b9954f;
  --ge-felt: #2f5d4a;
  --ge-felt-dark: #1f4032;
  --ge-wood: #d9b98a;
  --ge-shadow-rest: 0 1px 2px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.06);
  --ge-shadow-lift: 0 4px 12px rgba(0,0,0,0.12), 0 16px 32px rgba(0,0,0,0.14);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;
  --ease: cubic-bezier(.2,.8,.2,1);
  --card-w: 52px;
}

.pc-card {
  --w: var(--card-w);
  position: relative;
  flex: 0 0 auto;
  width: var(--w);
  height: calc(var(--w) * 1.4);
  border-radius: calc(var(--w) * 0.11);
  background: var(--ge-paper);
  border: 1px solid var(--ge-line);
  box-shadow: var(--ge-shadow-rest);
  color: var(--ge-ink);
  font-family: 'Nunito', 'LXGW WenKai', sans-serif;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.pc-sm { --w: 38px; }
.pc-md { --w: var(--card-w); }
.pc-lg { --w: 68px; }
.pc-red { color: var(--ge-red); }

.pc-corner {
  position: absolute;
  top: calc(var(--w) * 0.07);
  left: calc(var(--w) * 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: calc(var(--w) * 0.26);
  letter-spacing: -0.5px;
}
.pc-corner .pc-suit { font-size: calc(var(--w) * 0.2); }
.pc-corner-br { top: auto; left: auto; bottom: calc(var(--w) * 0.07); right: calc(var(--w) * 0.08); transform: rotate(180deg); }
.pc-sm .pc-corner-br { display: none; }
.pc-pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--w) * 0.5);
  opacity: 0.9;
}
.pc-sm .pc-pip { font-size: calc(var(--w) * 0.34); top: 30%; }

.pc-joker .pc-joker-text {
  position: absolute;
  top: calc(var(--w) * 0.08);
  left: calc(var(--w) * 0.08);
  writing-mode: vertical-rl;
  font-size: calc(var(--w) * 0.17);
  letter-spacing: 1px;
}
.pc-wild { background: linear-gradient(145deg, #fffaf0, #f3e6c8); color: var(--ge-gold); }
.pc-ghost { background: linear-gradient(145deg, #34322e, #1c1b19); color: #fff; }
.pc-back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.07) 0 4px, transparent 4px 8px),
    linear-gradient(145deg, #2d3a4a, #1b2430);
  border-color: rgba(255,255,255,0.18);
  box-shadow: inset 0 0 0 3px var(--ge-paper), var(--ge-shadow-rest);
}

.pc-card.is-selected { transform: translateY(-14px); box-shadow: var(--ge-shadow-lift); border-color: var(--ge-gold); }
.pc-card.is-disabled { opacity: 0.45; }
.pc-card[data-id] { cursor: default; }
.pc-selectable { cursor: pointer; }
.pc-selectable:active { transform: translateY(-4px) scale(0.98); transition-duration: var(--dur-fast); }
@media (hover: hover) {
  .pc-selectable:not(.is-selected):hover { transform: translateY(-6px); box-shadow: var(--ge-shadow-lift); }
}

.pc-group { display: flex; align-items: flex-end; justify-content: center; gap: 6px; }
.pc-layout-hand {
  justify-content: flex-start; /* centred via auto margins so overflow stays scrollable */
  gap: 0;
  padding-top: 18px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pc-layout-hand::-webkit-scrollbar { display: none; }
.pc-layout-hand > .pc-card:first-child { margin-left: auto; }
.pc-layout-hand > .pc-card:last-child { margin-right: auto; }
.pc-layout-hand .pc-card + .pc-card { margin-left: calc(var(--w) * -0.42); }
@media (min-width: 900px) and (hover: hover) {
  .pc-layout-hand .pc-card + .pc-card { margin-left: calc(var(--w) * -0.34); }
}
@media (max-width: 560px) {
  :root { --card-w: 46px; }
  .pc-layout-hand { padding-left: 4px; padding-right: 4px; }
  /* Phones: show ~32px of each card so a thumb can hit it; long hands scroll (see .hs-bar) */
  .pc-layout-hand .pc-card + .pc-card { margin-left: calc(var(--w) * -0.3); }
}

@keyframes pcDeal {
  from { opacity: 0; transform: translateY(-24px) scale(0.92); }
  to { opacity: 1; transform: none; }
}
.pc-deal .pc-card { animation: pcDeal var(--dur-slow) var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms); }

@media (prefers-reduced-motion: reduce) {
  .pc-card { transition: opacity var(--dur) linear; }
  .pc-deal .pc-card { animation-name: fadeIn; }
}

/* Felt table surface (poker-style games) */
.ge-felt {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255,255,255,0.10), transparent 65%),
    linear-gradient(160deg, var(--ge-felt), var(--ge-felt-dark));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), inset 0 10px 30px rgba(0,0,0,0.25);
  color: #fff;
}
.ge-felt > div[style*="text-muted"] { color: rgba(255,255,255,0.66) !important; }
.ge-felt .pc-card:not(.pc-back) { box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.pc-back.tx-slot {
  background: transparent;
  border: 1.5px dashed rgba(255,255,255,0.28);
  box-shadow: none;
}
.pc-card.lb-theme:not(.is-selected) { box-shadow: 0 0 0 2px var(--ge-gold), var(--ge-shadow-rest); }
.pc-group { max-width: 100%; min-width: 0; }
#ddzWrap, #btWrap, #txWrap, #lbWrap { min-width: 0; }

/* Action rows in card games: compact buttons side by side, not full-width stacks */
#ddzActions, #btActions, #txActions, #lbActions { flex-wrap: wrap; gap: 8px; }
#ddzActions .btn, #btActions .btn, #txActions .btn, #lbActions .btn {
  width: auto;
  flex: 1 1 0;
  min-width: 84px;
  max-width: 160px;
  margin: 0;
}
@media (max-width: 560px) {
  #ddzActions .btn, #btActions .btn, #txActions .btn, #lbActions .btn { min-height: 46px; }
}
/* Board host must be allowed to shrink, otherwise wide content (long hands) widens the page */
#boardArea { min-width: 0; max-width: 100%; }
#ddzActions .btn, #btActions .btn, #txActions .btn, #lbActions .btn { white-space: nowrap; }

/* ====== Tic-tac-toe (refresh) ====== */
.ttt-grid { gap: 8px; padding: 8px; background: var(--ge-line); border-radius: 22px;
  /* minmax(0,…) so a placed mark never widens its column */
  grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.ttt-cell {
  position: relative;
  min-width: 0; min-height: 0; padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--ge-paper);
  box-shadow: var(--ge-shadow-rest);
  transition: background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.ttt-cell:disabled { cursor: default; }
.ttt-cell.open { cursor: pointer; }
@media (hover: hover) { .ttt-cell.open:hover { background: #fff; } }
.ttt-cell.open:active { transform: scale(0.97); }
.ttt-mark { width: 62%; height: 62%; fill: none; stroke-width: 4.5; stroke-linecap: round; }
.ttt-cell.p1 .ttt-mark { stroke: var(--ge-ink); }
.ttt-cell.p2 .ttt-mark { stroke: var(--ge-gold); }
.ttt-cell.ttt-new .ttt-mark path,
.ttt-cell.ttt-new .ttt-mark circle { stroke-dasharray: 1; stroke-dashoffset: 1; animation: tttDraw var(--dur-slow) var(--ease) forwards; }
.ttt-cell.ttt-new .ttt-mark path + path { animation-delay: 120ms; }
@keyframes tttDraw { to { stroke-dashoffset: 0; } }
.ttt-cell.win-cell { background: #f6ecd6 !important; }
.ttt-cell.win-cell .ttt-mark { animation: tttWin 600ms var(--ease) both; }
@keyframes tttWin { 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .ttt-cell.ttt-new .ttt-mark path, .ttt-cell.ttt-new .ttt-mark circle { animation: none; stroke-dashoffset: 0; }
  .ttt-cell.win-cell .ttt-mark { animation: none; }
}

/* Scroll-position bar for horizontally scrolling hands (see CardUI) */
.hs-bar { position: relative; height: 4px; margin: 6px auto 2px; width: min(160px, 50%); border-radius: 2px; background: var(--ge-line, rgba(0,0,0,.08)); cursor: pointer; }
.hs-bar::before { content: ""; position: absolute; inset: -10px 0; } /* larger tap target */
.hs-bar > i { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--ge-ink, #1c1b19); opacity: .45; transition: left 80ms linear; }
.hs-bar[hidden] { display: none; }

/* ====== UI Components (v2.4): segmented, slider-steps, sheet ====== */
#gameOptions {
  min-width: 0;
  max-width: 100%;
  margin-top: 16px;
}
.waiting-actions {
  margin-top: 16px;
}
.ui-opt-summary {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-family: inherit;
  min-width: 0;
  max-width: 100%;
}
button.ui-opt-summary {
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  button.ui-opt-summary:hover {
    border-color: var(--accent);
    background: var(--surface);
  }
}
button.ui-opt-summary:active { transform: scale(0.99); }
button.ui-opt-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ui-opt-summary-label {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.ui-opt-summary-val {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.ui-opt-summary-chev {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
}
.ui-opt-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  min-width: 0;
  max-width: 100%;
}
.ui-opt-row:last-child { margin-bottom: 0; }
.ui-opt-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.ui-seg {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.ui-seg::-webkit-scrollbar { display: none; }
.ui-seg-btn {
  flex: 1 1 0;
  min-width: max-content;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .ui-seg-btn:not(.is-selected):hover { background: var(--bg); }
}
.ui-seg-btn:active { transform: scale(0.96); }
.ui-seg-btn {
  position: relative;
  z-index: 1;
}
.ui-seg-btn.is-selected {
  color: #fff;
}
@media (hover: hover) {
  .ui-seg-btn.is-selected:hover { background: transparent; }
}
/* Sliding selection pill, moved by segmented.js (liquid stretch like the lobby category tabs). */
.ui-seg-ind {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
}
.ui-seg-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ui-switch-wrap {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.ui-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ui-switch-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.ui-switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.ui-switch-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.ui-switch {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: var(--ge-line, #d6d3cd);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.ui-switch::after {
  content: '';
  position: absolute;
  inset: -8px -4px;
}
.ui-switch[aria-checked="true"],
.ui-switch.is-on {
  background: var(--accent);
}
.ui-switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ui-switch-thumb {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform var(--dur-fast) var(--ease);
}
.ui-switch[aria-checked="true"] .ui-switch-thumb,
.ui-switch.is-on .ui-switch-thumb {
  transform: translateX(20px);
}

.ui-ss {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.ui-ss-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.ui-ss-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.ui-ss-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--ge-ink);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.ui-ss-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ui-ss-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ge-ink);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.ui-ss-btn:active:not(:disabled) { transform: scale(0.95); }
.ui-ss-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ui-ss-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-ss-range {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.ui-ss-range:disabled { opacity: 0.45; cursor: not-allowed; }
.ui-ss-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.ui-ss-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--ge-line);
}
.ui-ss-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--ge-paper);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  margin-top: -11px;
}
.ui-ss-range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--ge-line);
}
.ui-ss-range::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--ge-paper);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}
.ui-ss-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ui-ss-preset {
  flex: 1 1 0;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.ui-ss-preset:active:not(:disabled) { transform: scale(0.96); }
.ui-ss-preset.is-active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--ge-ink);
}
.ui-ss-preset:disabled { opacity: 0.4; cursor: not-allowed; }
.ui-ss-preset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ui-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.ui-sheet-backdrop[hidden] { display: none; }
.ui-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 82dvh;
  background: var(--surface);
  color: var(--text);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  touch-action: pan-y;
}
.ui-sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}
.ui-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  touch-action: none;
}
.ui-sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.ui-sheet-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ui-sheet-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
.ui-sheet-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ui-sheet-item {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.ui-sheet-item:active { transform: scale(0.98); }
.ui-sheet-item.is-danger { color: var(--danger); }
.ui-sheet-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-sheet-done-wrap {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}
.ui-sheet-done {
  min-height: 44px;
}
@media (min-width: 768px) {
  .ui-sheet-backdrop.ui-sheet-responsive {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .ui-sheet-backdrop.ui-sheet-responsive .ui-sheet {
    border-radius: 22px;
    padding: 18px 22px 20px;
    box-shadow: 0 20px 56px rgba(0, 0, 0, 0.22);
  }
  .ui-sheet-backdrop.ui-sheet-responsive .ui-sheet-handle {
    display: none;
  }
}

.mono-trade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 480px) {
  .mono-trade-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .ui-opt-summary,
  button.ui-opt-summary:active,
  .ui-seg-btn,
  .ui-seg-btn:active,
  .ui-switch,
  .ui-switch-thumb,
  .ui-ss-btn,
  .ui-ss-btn:active:not(:disabled),
  .ui-ss-preset,
  .ui-ss-preset:active:not(:disabled),
  .ui-sheet,
  .ui-sheet-item,
  .ui-sheet-item:active {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}

/* Touch: seat badges keep their compact look, but get a >=44px invisible hit area */
@media (pointer: coarse) {
  .waiting-slot-swap, .waiting-slot-xbtn { position: relative; }
  .waiting-slot-swap::after, .waiting-slot-xbtn::after {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: max(100%, 44px); height: 44px; transform: translate(-50%, -50%);
  }
  .waiting-slot-swap + .waiting-slot-xbtn, .waiting-slot-xbtn + .waiting-slot-swap { margin-left: 10px; }
  .mute-btn { min-width: 40px; min-height: 40px; }
  #gameOptions select { min-height: 36px; }
}

/* Game stage: the top bar already names the game, so drop the duplicate header and give the height to the board */
#gameStage .game-stage-header { display: none; }
#gameStage .game-status:empty { display: none !important; }
#gameStage .game-actions-fixed { margin-top: 8px; padding-top: 10px; }
@media (max-width: 560px) {
  #gameStage.game-stage-panel { padding: 8px; }
}
/* Square board games on wide screens, and on phones held sideways: players on the left,
   actions on the right, board takes the middle (stacked, a sideways phone had to scroll to see the board) */
@media (min-width: 1100px), (orientation: landscape) and (max-height: 540px) and (min-width: 640px) {
  #gameStage.stage-side {
    display: grid;
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr) minmax(200px, 260px);
    grid-template-rows: auto auto auto 1fr;
    column-gap: 24px;
    align-items: start;
  }
  #gameStage.stage-side .player-bar { grid-column: 1; grid-row: 1; flex-direction: column; align-items: stretch; margin: 0; }
  #gameStage.stage-side .player-tag { flex: none; justify-content: flex-start; padding: 12px 14px; }
  #gameStage.stage-side .vs-text { align-self: center; }
  #gameStage.stage-side .stage-info { grid-column: 1; grid-row: 2; }
  #gameStage.stage-side .game-status { grid-column: 1; grid-row: 3; }
  #gameStage.stage-side .board-wrap { grid-column: 2; grid-row: 1 / span 4; }
  #gameStage.stage-side .game-actions-fixed { grid-column: 3; grid-row: 1; margin: 0; padding: 0; border: 0; background: none; justify-content: flex-end; }
}
/* Side info (match score / captures / moves) for board games */
.stage-info { display: grid; gap: 12px; }
.si-block { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg); font-size: 13px; }
.si-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.si-score { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.si-score span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-score span:last-child { text-align: right; }
.si-score b { font-size: 20px; font-variant-numeric: tabular-nums; }
.si-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.si-row > span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.si-row b { font-size: 18px; font-variant-numeric: tabular-nums; }
.si-cap { display: flex; align-items: flex-start; gap: 8px; font-size: 20px; line-height: 1.4; word-break: break-all; }
.si-cap .si-stone { margin-top: 5px; }
.si-stone { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 -1px 2px rgba(0,0,0,.25); }
.si-stone.b { background: radial-gradient(circle at 35% 30%, #5a5a5a, #111); }
.si-stone.w { background: radial-gradient(circle at 35% 30%, #fff, #d8d4cc); border: 1px solid #bdb6aa; }
.si-stone.r { background: radial-gradient(circle at 35% 30%, #e0655a, #a8261c); }
.si-moves ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 300px; overflow: auto; font-variant-numeric: tabular-nums; }
.si-moves li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.si-moves li:first-child { background: var(--surface); font-weight: 600; }
.si-n { min-width: 22px; color: var(--text-muted); font-size: 12px; }
.si-mv { font-size: 14px; }
.si-fig { font-size: 20px; line-height: 1; margin-right: 2px; vertical-align: -2px; }
.si-note { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.si-empty { color: var(--text-muted); }
/* Narrow screens: only the match score, the board needs the height */
@media (max-width: 1099px) {
  .stage-info { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
  .stage-info .si-block:not(.si-match):not(.si-count) { display: none; }
  .stage-info .si-block { padding: 8px 12px; }
  .stage-info .si-title { margin-bottom: 2px; }
  .stage-info .si-score b, .stage-info .si-row b { font-size: 16px; }
}
/* Phones held upright: the title bar, player bar and turn line used ~185px before the board started,
   so card tables needed scrolling. Tighten them so the whole table fits on one screen. */
@media (max-width: 560px) and (orientation: portrait) {
  .game-page-shell { gap: 6px; }
  .game-topbar { padding: 0; }
  .game-title-stack span { display: none; }
  .game-title-stack strong { font-size: 16px; }
  .game-topbar .back-btn { padding-top: 4px; padding-bottom: 4px; }
  .room-stage { gap: 8px; }
  #gameStage.game-stage-panel { gap: 4px; padding-top: 6px; }
  #gameStage .player-bar { margin-bottom: 0; padding-bottom: 2px; }
  #gameStage .player-tag { padding: 4px 6px; }
  #gameStage .game-status { margin-bottom: 0; min-height: 0; font-size: 14px; line-height: 20px; }
}
/* Phones held sideways (~375px tall): same tightening as upright phones, so the board starts near the top */
@media (orientation: landscape) and (max-height: 540px) {
  body:has(.game-page-shell) { padding-top: 6px; padding-bottom: 6px; }
  .game-page-shell { gap: 6px; }
  .game-topbar { padding: 0; }
  .game-title-stack span { display: none; }
  .game-title-stack strong { font-size: 16px; }
  .room-stage { gap: 8px; }
  #gameStage.game-stage-panel { gap: 4px; padding: 6px 10px; }
  /* 90vmin (from the >=768px rule) is only ~338px here, which cut off 3-4 player name tags */
  #gameStage .player-bar { margin-bottom: 0; padding-bottom: 2px; max-width: none; }
  #gameStage .player-tag { padding: 4px 8px; }
  #gameStage .game-status { margin-bottom: 0; min-height: 0; font-size: 14px; line-height: 20px; }
  #gameStage .game-actions-fixed { margin-top: 4px; padding-top: 6px; }
}
@media (orientation: landscape) and (max-height: 540px) and (min-width: 640px) and (max-width: 1099px) {
  #gameStage.stage-side { grid-template-columns: 150px minmax(0, 1fr) 150px; column-gap: 12px; }
  #gameStage.stage-side .player-tag { padding: 6px 8px; }
  #gameStage.stage-side .game-actions-fixed { flex-direction: column; align-items: stretch; }
}

/* 跑得快结算积分表 */
.pdk-score-wrap { overflow-x: auto; margin: 4px 0 6px; max-width: 100%; text-align: left; }
.pdk-score { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.pdk-score th, .pdk-score td { padding: 6px 8px; white-space: nowrap; border-bottom: 1px solid var(--border); background: var(--surface); }
.pdk-score th { font-weight: 500; font-size: 12px; color: var(--text-muted); }
.pdk-score .pdk-num { text-align: right; }
.pdk-score .pdk-name { position: sticky; left: 0; z-index: 1; text-align: left; max-width: 7em; overflow: hidden; text-overflow: ellipsis; }
.pdk-score .pos { color: var(--accent); }
.pdk-score .neg { color: var(--ge-red); opacity: .8; }
.pdk-score .pdk-total { font-weight: 700; }
.pdk-score tr.me td { background: var(--accent-dim); font-weight: 600; }
.pdk-score tbody tr:last-child td { border-bottom: 0; }

/* 卧底结算：阵营 + 词卡 + 身份表 */
.res-camp { font-size: 20px; font-weight: 700; text-align: center; margin: 2px 0 8px; }
.res-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 8px; }
.res-card { flex: 1 1 88px; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.res-card span { font-size: 11px; color: var(--text-muted); }
.res-card b { font-size: 16px; color: var(--text); overflow-wrap: anywhere; text-align: center; }
.res-card.uc { border-color: var(--ge-red); }
.res-card.blank { border-style: dashed; }
.res-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--border); color: var(--text-muted); }
.res-tag.undercover { background: var(--ge-red); color: #fff; }
.res-tag.blank { background: #7c5cbf; color: #fff; }

/* ====== Lobby v2.3 Cover-First Redesign ====== */
body.lobby-page {
  display: block;
  align-items: stretch;
  background: var(--lb-bg);
  color: var(--lb-text);
  min-height: 100dvh;
  padding: 0 0 calc(92px + var(--safe-bottom));
}

body.lobby-page :focus-visible {
  outline: 2px solid var(--lb-accent);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* Sticky Top Header (C6 hide on scroll down on phones + C2 search expand) */
.lb-top {
  position: sticky;
  top: 0;
  z-index: 30;
  transition: transform 180ms var(--lb-ease-in-out);
  will-change: transform;
}

.lb-top.hide {
  transform: translateY(-100%);
}

.lb-top-bg {
  position: absolute;
  inset: 0;
  background: var(--lb-surface-glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--lb-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--lb-ease-out);
}

.lb-top.scrolled .lb-top-bg {
  opacity: 1;
}

.lb-top-in {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  min-height: calc(56px + env(safe-area-inset-top, 0px));
  padding:
    calc(6px + env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 16px))
    6px
    max(16px, env(safe-area-inset-left, 16px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.lb-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--lb-text);
  white-space: nowrap;
  user-select: none;
}

.lb-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  min-height: 44px;
}

.lb-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity var(--lb-dur-fast) var(--lb-ease-out);
}

.lb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--lb-surface-2);
  color: var(--lb-text);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition:
    background var(--lb-dur-fast) var(--lb-ease-out),
    box-shadow var(--lb-dur-fast) var(--lb-ease-out),
    transform var(--lb-dur-press) var(--lb-ease-out);
}

.lb-icon-btn:active {
  transform: scale(0.94);
}

.lb-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

body.lobby-page .lb-icon-btn.lang-switch {
  position: static;
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  color: var(--lb-text);
}

:root[data-theme="dark"] .lb-ico-moon {
  display: none;
}

:root:not([data-theme="dark"]) .lb-ico-sun {
  display: none;
}

/* Expanding Search Field (C2 clip-path on phones, always visible on >=800px) */
.lb-search-wrap {
  position: absolute;
  inset: 0 0 0 auto;
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 12px;
  border-radius: 999px;
  background: var(--lb-surface);
  box-shadow: var(--lb-chip-ring), var(--lb-shadow);
  clip-path: inset(0 0 0 100% round 999px);
  opacity: 0;
  pointer-events: none;
  transition:
    clip-path var(--lb-dur-panel) var(--lb-ease-in-out),
    opacity var(--lb-dur-fast) var(--lb-ease-out);
}

.lb-bar.searching .lb-search-wrap {
  clip-path: inset(0 0 0 0 round 999px);
  opacity: 1;
  pointer-events: auto;
}

.lb-bar.searching .lb-top-actions {
  opacity: 0;
  pointer-events: none;
}

.lb-search-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--lb-text-3);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--lb-text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

/* The pill is clipped by clip-path, so the generic outward focus outline shows only as two side bars.
   Draw the focus ring inside the pill instead. */
body.lobby-page .lb-search-input:focus-visible {
  outline: none;
}

.lb-search-wrap:focus-within {
  box-shadow: inset 0 0 0 2px var(--lb-accent), var(--lb-shadow);
}

.lb-search-input::placeholder {
  color: var(--lb-text-3);
}

.lb-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.lb-search-close {
  position: relative;
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--lb-text-2);
}

.lb-search-close::after {
  content: '';
  position: absolute;
  inset: -4px;
}

/* Main Shell */
.lobby-shell {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding:
    8px
    max(16px, env(safe-area-inset-right, 16px))
    0
    max(16px, env(safe-area-inset-left, 16px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}

/* Resume Room Banner */
.lb-resume-wrap {
  min-width: 0;
}

.lb-resume {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--lb-radius-card);
  background: var(--lb-surface);
  box-shadow: var(--lb-shadow);
}

.lb-resume-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--lb-thumb-bg);
}

.lb-resume-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lb-resume-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
}

.lb-resume-body {
  flex: 1;
  min-width: 0;
}

.lb-resume-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--lb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-resume-meta {
  font-size: 12px;
  color: var(--lb-text-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-resume-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--lb-accent);
  color: var(--lb-on-accent);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--lb-dur-press) var(--lb-ease-out), filter var(--lb-dur-fast);
}

.lb-resume-btn:active {
  transform: scale(0.96);
}

/* Status & Offline Banners */
body.lobby-page .mobile-only-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-radius: var(--lb-radius-card);
  background: var(--lb-surface);
  box-shadow: var(--lb-shadow);
  text-align: center;
}

body.lobby-page .mobile-only-banner strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
}

body.lobby-page .mobile-only-banner span {
  font-size: 12px;
  color: var(--lb-text-2);
}

body.lobby-page .wifi-note {
  text-align: center;
  font-size: 13px;
  color: var(--lb-text-2);
}

/* Featured New-Games Hero (16:10 cover + scrim + optional carousel dots) */
.lb-hero-section {
  min-width: 0;
}

.lb-hero-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.lb-hero-track::-webkit-scrollbar {
  display: none;
}

.lb-hero-card,
.lb-hero-track:empty::before {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 16 / 10;
}

.lb-hero-track:empty::before {
  content: '';
  display: block;
}

.lb-hero-card {
  position: relative;
  display: block;
  border: 0;
  padding: 0;
  border-radius: var(--lb-radius-hero);
  overflow: hidden;
  background: var(--lb-thumb-bg);
  box-shadow: var(--lb-shadow);
  scroll-snap-align: start;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--lb-dur-fast) var(--lb-ease-out), box-shadow var(--lb-dur-fast) var(--lb-ease-out);
}

.lb-hero-card.selected {
  box-shadow: var(--lb-shadow);
}

/* The track scrolls sideways, so it clips anything drawn outside the card:
   draw the selection ring inside, on top of the cover. */
.lb-hero-card.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--lb-accent);
  pointer-events: none;
  z-index: 3;
}

.lb-hero-card:active {
  transform: scale(0.99);
}

.lb-hero-media {
  position: absolute;
  inset: 0;
  background: var(--lb-thumb-bg);
}

/* Progressive blur-up / fade+scale image reveal (loading.md section 2) */
.lb-hero-img,
.lb-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 400ms ease-out, transform 600ms var(--lb-ease-out);
}

.lb-hero-img.is-loaded,
.lb-card-img.is-loaded {
  opacity: 1;
  transform: scale(1);
}

.lb-hero-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  color: #fff;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.14), transparent 55%),
    var(--lb-thumb-bg);
}

.lb-hero-cap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  padding: 18px;
  background: linear-gradient(
    180deg,
    rgba(15, 16, 18, 0) 32%,
    rgba(15, 16, 18, 0.48) 65%,
    rgba(15, 16, 18, 0.88) 100%
  );
  color: #fff;
}

.lb-hero-tag {
  width: fit-content;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--lb-accent);
  color: var(--lb-on-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}

.lb-hero-name {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.lb-hero-meta {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.84);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-hero-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 6px;
  margin-top: 10px;
}

.lb-hero-dot {
  position: relative;
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--lb-text-3);
  opacity: 0.45;
  cursor: pointer;
  transition: width var(--lb-dur-base) var(--lb-ease-out), opacity var(--lb-dur-fast), background var(--lb-dur-fast);
}

.lb-hero-dot::after {
  content: '';
  position: absolute;
  inset: -16px -12px;
}

.lb-hero-dot.active {
  width: 18px;
  background: var(--lb-accent);
  opacity: 1;
}

/* Join Room Row & LAN Rooms */
.lb-join-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.lb-join-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.lb-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--lb-radius-ctl);
  background: var(--lb-surface);
  box-shadow: var(--lb-chip-ring);
  color: var(--lb-text);
  font-size: 15px;
  font-family: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
  -webkit-appearance: none;
  transition: box-shadow var(--lb-dur-fast) var(--lb-ease-out);
}

.lb-input::placeholder {
  color: var(--lb-text-3);
  letter-spacing: 0;
  text-transform: none;
  font-size: 14px;
}

.lb-input:focus {
  box-shadow: 0 0 0 2px var(--lb-accent);
}

.lb-join-btn {
  min-height: 44px;
  min-width: 78px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--lb-radius-ctl);
  background: var(--lb-text);
  color: var(--lb-bg);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: opacity var(--lb-dur-fast), transform var(--lb-dur-press) var(--lb-ease-out);
}

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

.lan-rooms-panel {
  background: var(--lb-surface);
  border-radius: var(--lb-radius-card);
  box-shadow: var(--lb-shadow);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lan-rooms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.lan-rooms-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--lb-text);
}

.lan-refresh-btn {
  position: relative;
  min-height: 32px;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--lb-surface-2);
  color: var(--lb-text-2);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lan-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
}

.lan-room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: var(--lb-radius-ctl);
  background: var(--lb-surface-2);
  cursor: pointer;
  transition: background var(--lb-dur-fast) var(--lb-ease-out);
}

.lan-room-card-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lan-room-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.lan-room-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lan-room-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--lb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lan-room-host {
  font-size: 11px;
  color: var(--lb-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lan-room-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lan-room-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--lb-text-2);
  background: var(--lb-surface);
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.lan-room-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--lb-accent);
}

.lan-rooms-empty {
  font-size: 12px;
  color: var(--lb-text-3);
  padding: 8px 0;
  text-align: center;
}

/* Last Game Shortcut Chip */
.last-game-row {
  display: flex;
}

.lb-last-chip {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--lb-radius-chip);
  background: var(--lb-surface);
  box-shadow: var(--lb-chip-ring);
  color: var(--lb-text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Filter Tabs (C1 sliding category underline) */
.lb-filters {
  min-width: 0;
}

.lb-chips {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 44px;
  padding: 0;
  min-width: 0;
  box-shadow: inset 0 -1px 0 var(--lb-border);
}

.lb-chips::-webkit-scrollbar {
  display: none;
}

.lb-cat-chip {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--lb-text-2);
  font-size: 15px;
  font-weight: 600;
  line-height: 24px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 140ms var(--lb-ease-out);
}

.lb-cat-chip:focus-visible,
.lb-count-chip:focus-visible {
  outline-offset: -2px;
}

.lb-chip-ind {
  position: absolute;
  top: auto;
  bottom: 0;
  left: 0;
  z-index: 3;
  width: var(--w, 0px);
  height: 3px;
  border-radius: 3px;
  background: var(--lb-accent);
  pointer-events: none;
  transform: translateX(var(--x, 0px));
}

.lb-cat-chip.selected {
  color: var(--lb-text);
  font-weight: 700;
}

/* Section Header, Player-Count Segmented Control & Cover Grid */
.lb-browse {
  min-width: 0;
}

.lb-sec {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 8px;
  margin-bottom: 12px;
}

.lb-sec h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--lb-text);
  margin: 0;
}

.lb-sec-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--lb-text-2);
}

.lb-count-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  align-self: center;
  min-width: 0;
}

.lb-count-seg {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 38px;
  padding: 3px;
  border-radius: 999px;
  background: var(--lb-surface);
  box-shadow: var(--lb-chip-ring);
}

/* Sliding pill for player-count segmented control */
.lb-count-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  z-index: 0;
  width: var(--pill-w, 0px);
  border-radius: 999px;
  background: var(--lb-accent);
  pointer-events: none;
  transform: translateX(var(--pill-x, 0px));
  opacity: 0;
  will-change: transform, width;
}

.lb-count-seg.is-ready .lb-count-pill {
  opacity: 1;
}


.lb-count-chip {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--lb-text-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--lb-dur-fast) var(--lb-ease-out);
}

.lb-count-chip.selected {
  color: var(--lb-on-accent);
  font-weight: 700;
}

.lb-count-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--lb-text-2);
  white-space: nowrap;
}

/* Reserve the filled width so the right-aligned control does not slide when renderCountChips() fills it. */
@media (min-width: 600px) {
  .lb-count-seg {
    min-width: 266px;
  }
}

@media (max-width: 599px) {
  .lb-count-wrap {
    flex: 1 0 100%;
    margin-left: 0;
  }

  .lb-count-seg {
    display: flex;
    width: 100%;
  }

  .lb-count-chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 4px;
  }

  .lb-count-unit {
    display: none;
  }
}

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

.lb-grid[data-boot] {
  min-height: 100dvh;
}

.lb-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 0;
  padding: 0;
  border-radius: var(--lb-radius-card);
  overflow: hidden;
  background: var(--lb-thumb-bg);
  box-shadow: var(--lb-shadow);
  cursor: pointer;
  text-align: left;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--lb-dur-fast) var(--lb-ease-out),
    box-shadow var(--lb-dur-fast) var(--lb-ease-out);
}

.lb-card.selected {
  box-shadow: 0 0 0 2px var(--lb-accent), var(--lb-shadow);
}

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

.lb-card-media {
  position: absolute;
  inset: 0;
  background: var(--lb-thumb-bg);
}

.lb-card-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  color: #fff;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.12), transparent 55%),
    var(--lb-thumb-bg);
}

.lb-card-scrim {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: 11px 12px;
  background: linear-gradient(
    180deg,
    rgba(15, 16, 18, 0) 38%,
    rgba(15, 16, 18, 0.52) 72%,
    rgba(15, 16, 18, 0.88) 100%
  );
  color: #fff;
}

.lb-card-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  margin: 0;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.lb-card-meta {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.84);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-check {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--lb-accent);
  color: var(--lb-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.75);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: opacity var(--lb-dur-fast) var(--lb-ease-out), transform var(--lb-dur-fast) var(--lb-ease-out);
}

.lb-check svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.selected > .lb-check {
  opacity: 1;
  transform: scale(1);
}

.lb-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--lb-text-2);
  font-size: 14px;
}

/* Footer */
.lobby-footer {
  display: flex;
  justify-content: center;
  padding: 4px 0 8px;
}

.lobby-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--lb-text-3);
  font-size: 13px;
  text-decoration: none;
  transition: color var(--lb-dur-fast), background var(--lb-dur-fast);
}

/* Floating Create Room CTA */
body.lobby-page .quick-create-btn {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 35;
  min-height: 50px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--lb-accent);
  color: var(--lb-on-accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--lb-dur-press) var(--lb-ease-out), filter var(--lb-dur-fast) var(--lb-ease-out);
}

body.lobby-page .quick-create-btn .qc-label {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
}

body.lobby-page .quick-create-btn .qc-game {
  font-size: 15px;
  font-weight: 800;
}

body.lobby-page .quick-create-btn:active {
  transform: translateX(-50%) scale(0.97);
}

body.lobby-page .toast {
  bottom: calc(78px + var(--safe-bottom));
  background: var(--lb-text);
  color: var(--lb-bg);
}

/* Responsive Breakpoints (>=800px tablet landscape & desktop, >=1100px wide desktop) */
@media (min-width: 800px) {
  .lb-top.hide {
    transform: none;
  }

  .lb-top-in {
    padding-left: 24px;
    padding-right: 24px;
  }

  .lb-search-open {
    display: none;
  }

  .lb-bar {
    gap: 10px;
  }

  .lb-search-wrap {
    position: static;
    flex: 1 1 240px;
    max-width: 340px;
    clip-path: none;
    opacity: 1;
    pointer-events: auto;
    box-shadow: var(--lb-chip-ring);
  }

  .lb-search-wrap:not(.has-value) .lb-search-close {
    display: none;
  }

  .lobby-shell {
    padding-left: 24px;
    padding-right: 24px;
    gap: 20px;
  }

  .lb-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (min-width: 1100px) {
  .lb-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 600px), (orientation: landscape) and (max-height: 540px) {
  .lb-hero-card,
  .lb-hero-track:empty::before {
    flex: 0 0 calc(50% - 6px);
    width: calc(50% - 6px);
  }

  .lb-hero-dots:empty {
    display: none;
  }
}

/* Wide desktop: three "new this week" banners side by side (no hidden third card to scroll to). */
@media (min-width: 1100px) {
  .lb-hero-card {
    flex: 0 0 calc((100% - 24px) / 3);
    width: calc((100% - 24px) / 3);
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .lb-hero-card,
  .lb-hero-track:empty::before {
    max-height: 55vh;
  }

  .lb-hero-cap {
    padding: 12px 16px;
  }
}

@media (pointer: coarse) {
  .lan-refresh-btn::after {
    content: '';
    position: absolute;
    inset: -6px;
  }
}

/* Hover lift only on hover-capable devices */
@media (hover: hover) {
  .lb-icon-btn:hover {
    background: var(--lb-surface);
    box-shadow: var(--lb-chip-ring);
  }

  .lb-hero-card:hover,
  .lb-card:hover {
    transform: translateY(-2px);
  }

  .lb-cat-chip:not(.selected):hover,
  .lb-count-chip:not(.selected):hover {
    color: var(--lb-text);
  }

  .lb-last-chip:hover {
    background: var(--lb-surface-2);
  }

  .lb-join-btn:hover {
    opacity: 0.9;
  }

  .lb-resume-btn:hover,
  body.lobby-page .quick-create-btn:hover {
    filter: brightness(1.06);
  }

  .lan-refresh-btn:hover {
    color: var(--lb-text);
  }

  .lan-room-card:hover {
    background: var(--lb-border);
  }

  .lobby-footer-link:hover {
    color: var(--lb-text);
    background: var(--lb-surface-2);
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  body.lobby-page,
  body.lobby-page *,
  body.lobby-page *::before,
  body.lobby-page *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }

  .lobby-page.entrance-anim {
    animation: none;
  }

  .lb-hero-img,
  .lb-card-img {
    transform: none;
  }

  .lb-hero-img.is-loaded,
  .lb-card-img.is-loaded {
    transform: none;
  }
}

/* ====== Fullscreen Landscape Mode (pool, mahjong) ====== */
.fs-enter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

/* Fullscreen-only games: the room page shows a "tap to play fullscreen" card over the stage. */
#gameStage.fs-gated {
  position: relative;
  min-height: min(62vh, 520px);
}
#gameStage.fs-gated > :not(.fs-launch-card) {
  visibility: hidden;
}
.fs-launch-card {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  border: 0;
  border-radius: 24px;
  background:
    radial-gradient(120% 90% at 50% 40%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--surface);
  box-shadow: var(--ge-shadow-rest);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms cubic-bezier(0.23, 1, 0.32, 1);
}
.fs-launch-card[hidden] {
  display: none;
}
.fs-launch-card:active {
  transform: scale(.98);
}
.fs-launch-icon {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.fs-launch-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .08em;
}
@media (hover: hover) and (pointer: fine) {
  .fs-launch-card:hover .fs-launch-icon {
    transform: scale(1.04);
  }
  .fs-launch-icon {
    transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
  }
}

.fs-exit-btn {
  display: none;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: calc(env(safe-area-inset-left, 0px) + 8px);
  z-index: 45;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(18, 20, 24, 0.62);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background 0.15s ease;
}

.fs-exit-btn:active {
  transform: scale(0.94);
  background: rgba(18, 20, 24, 0.8);
}

.fs-exit-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html:has(body.gn-fs) {
  overflow: hidden !important;
  height: 100dvh !important;
}

html body.gn-fs,
body.gn-fs:has(.game-page-shell) {
  padding: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.gn-fs .fs-exit-btn {
  display: inline-flex;
}

body.gn-fs .game-topbar,
body.gn-fs #playerBar,
body.gn-fs .player-bar,
body.gn-fs #status,
body.gn-fs .game-status,
body.gn-fs #emojiRow,
body.gn-fs #stageInfo,
body.gn-fs #gameActions,
body.gn-fs .game-actions-fixed {
  display: none !important;
}

body.gn-fs .game-page-shell,
body.gn-fs .room-stage {
  max-width: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: 0;
  padding: 0;
  margin: 0;
}

body.gn-fs #gameStage.game-stage-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  gap: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

body.gn-fs #gameStage.game-stage-panel:has(.mj-wrap) {
  background: #14281d;
}

body.gn-fs #gameStage .board-wrap.stage-board {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  align-items: stretch;
}

body.gn-fs #boardArea {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
