:root {
  --bg-dark: #0a0806;
  --gold: #d4a373;
  --gold-dim: rgba(212,163,115,0.4);
  --paper: #f5e6c8;
  --ink: #1a1a1a;
  --board-display-size: auto;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { min-height: 100%; }

body {
  background: radial-gradient(ellipse at 30% 20%, #1e1208 0%, #0a0806 60%);
  min-height: 100vh;
  color: var(--paper);
  font-family: 'Noto Serif SC', serif;
  overflow: hidden;
}

/* ─── 粒子背景 ─── */
#particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

.site-lang-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2100;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(212,163,115,0.22);
  border-radius: 999px;
  background: rgba(10,8,6,0.58);
  backdrop-filter: blur(10px);
}
.site-lang-switch button {
  min-width: 34px;
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(245,230,200,0.62);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.76rem;
}
.site-lang-switch button.active {
  background: rgba(212,163,115,0.9);
  color: #1c1209;
}
.site-lang-switch button:hover:not(.active) {
  color: var(--gold);
  background: rgba(212,163,115,0.1);
}

/* ─── 游戏选择大厅 ─── */
#lobby {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 60px; padding: 40px;
  overflow-y: auto;
  animation: fadeIn 1.5s ease;
}
#lobby.hide { animation: fadeOut 0.6s ease forwards; pointer-events: none; }

.lobby-title {
  text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.lobby-title h1 {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: clamp(3rem, 6vw, 5rem);
  color: var(--gold);
  letter-spacing: 12px;
  text-shadow: 0 0 60px rgba(212,163,115,0.4), 0 0 120px rgba(212,163,115,0.1);
  animation: glow 4s ease-in-out infinite;
}
html[lang="en"] .lobby-title h1,
html[lang="en"] .game-name,
html[lang="en"] .mode-game-name,
html[lang="en"] .color-title,
html[lang="en"] .legal-panel h1 {
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 2px;
}
@keyframes glow {
  0%,100% { text-shadow: 0 0 40px rgba(212,163,115,0.3); }
  50% { text-shadow: 0 0 80px rgba(212,163,115,0.6), 0 0 120px rgba(212,163,115,0.2); }
}
.lobby-title p {
  font-size: 0.75rem; letter-spacing: 8px;
  color: rgba(212,163,115,0.3);
}

.game-cards {
  display: flex; gap: 28px; flex-wrap: wrap; justify-content: center;
}

.site-footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  color: rgba(212,163,115,0.32);
  font-size: 0.78rem;
  letter-spacing: 1px;
}
.site-footer-links a {
  color: rgba(245,230,200,0.58);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
  border-bottom: 1px solid transparent;
}
.site-footer-links a:hover {
  color: var(--gold);
  border-bottom-color: rgba(212,163,115,0.45);
}
.game-card {
  width: 200px; padding: 36px 24px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(212,163,115,0.15);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
}
.game-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(212,163,115,0.08) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.4s;
}
.game-card:hover { 
  border-color: rgba(212,163,115,0.5);
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(212,163,115,0.2);
}
.game-card:hover::before { opacity: 1; }

.game-icon { font-size: 3rem; filter: drop-shadow(0 0 12px rgba(212,163,115,0.3)); }
.game-name { font-family: 'Ma Shan Zheng'; font-size: 1.6rem; color: var(--gold); letter-spacing: 4px; }
.game-tag {
  font-size: 0.7rem; letter-spacing: 3px;
  color: rgba(212,163,115,0.35);
}
.game-badge {
  position: absolute; top: 14px; right: 14px;
  background: rgba(212,163,115,0.1);
  border: 1px solid rgba(212,163,115,0.25);
  border-radius: 20px; padding: 3px 10px;
  font-size: 10px; color: var(--gold-dim); letter-spacing: 1px;
}

/* ─── 模式选择屏 ─── */
.mode-screen {
  position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(ellipse at center, #1e1208 0%, #0a0806 100%);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 50px; padding: 80px 24px 32px; overflow-y: auto; animation: fadeIn 0.5s ease;
}
.mode-screen.show { display: flex; }
.mode-screen.hide { animation: fadeOut 0.4s ease forwards; pointer-events: none; }

.mode-header { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.mode-game-name {
  font-family: 'Ma Shan Zheng'; font-size: 3rem; color: var(--gold);
  letter-spacing: 10px;
}
.mode-subtitle { font-size: 0.75rem; letter-spacing: 4px; color: var(--gold-dim); }

.mode-cards {
  display: flex; gap: 24px; flex-wrap: wrap; justify-content: center;
}
.mode-card {
  width: 170px; padding: 30px 20px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(212,163,115,0.15);
  border-radius: 18px; cursor: pointer;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.mode-card:hover {
  background: rgba(212,163,115,0.08);
  border-color: rgba(212,163,115,0.55);
  transform: translateY(-8px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}
.mode-icon { font-size: 2.6rem; }
.mode-name { font-size: 1rem; color: var(--gold); font-weight: 600; letter-spacing: 2px; }
.mode-desc { font-size: 0.72rem; color: rgba(245,230,200,0.4); line-height: 1.6; }

.mode-back {
  position: absolute; top: 24px; left: 24px;
  background: rgba(212,163,115,0.05); border: 1px solid var(--gold-dim);
  color: var(--gold-dim); padding: 7px 18px; border-radius: 20px;
  cursor: pointer; font-family: inherit; font-size: 12px; transition: 0.3s;
}
.mode-back:hover { background: rgba(212,163,115,0.12); color: var(--gold); }

/* ─── 棋色选择 ─── */
.color-screen {
  position: fixed; inset: 0; z-index: 1800;
  background: radial-gradient(circle at center, #2c1e12 0%, #0a0806 100%);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 36px; padding: 80px 24px 32px; overflow-y: auto;
}
.color-screen.show { display: flex; animation: fadeIn 0.4s ease; }
.color-title { font-family: 'Ma Shan Zheng'; font-size: 2rem; color: var(--gold); letter-spacing: 6px; }
.color-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.color-card {
  width: 150px; padding: 28px 16px; border-radius: 16px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(212,163,115,0.2);
  text-align: center; cursor: pointer; transition: 0.35s;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.color-card:hover {
  background: rgba(212,163,115,0.1); border-color: rgba(212,163,115,0.6);
  transform: translateY(-6px); box-shadow: 0 16px 40px rgba(0,0,0,0.4);
}
.color-piece { width: 52px; height: 52px; border-radius: 50%; }
.color-piece.black { background: radial-gradient(circle at 35% 35%, #666, #000); box-shadow: 0 4px 12px rgba(0,0,0,0.6); }
.color-piece.white { background: radial-gradient(circle at 35% 35%, #fff, #ccc); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.color-name { font-size: 1rem; color: var(--gold); font-weight: 600; letter-spacing: 2px; }
.color-desc { font-size: 0.75rem; color: rgba(245,230,200,0.45); line-height: 1.5; }
.color-back {
  position: absolute; top: 24px; left: 24px;
  background: rgba(212,163,115,0.05); border: 1px solid var(--gold-dim);
  color: var(--gold-dim); padding: 7px 18px; border-radius: 20px;
  cursor: pointer; font-family: inherit; font-size: 12px; transition: 0.3s;
}
.color-back:hover { background: rgba(212,163,115,0.12); color: var(--gold); }

/* ─── 游戏主界面 ─── */
#game-wrapper {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  overflow: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.back-btn {
  position: fixed; top: 16px; left: 16px; z-index: 300;
  background: rgba(212,163,115,0.06); border: 1px solid rgba(212,163,115,0.25);
  color: rgba(212,163,115,0.7); padding: 7px 16px; border-radius: 20px;
  cursor: pointer; font-family: inherit; font-size: 12px;
  transition: 0.3s; display: none;
}
.back-btn:hover { background: rgba(212,163,115,0.15); color: var(--gold); }

.game-header { text-align: center; margin-bottom: 16px; display: none; }
.game-title {
  font-family: 'Ma Shan Zheng'; font-size: 2.5rem; letter-spacing: 8px;
  color: var(--gold); text-shadow: 0 0 20px rgba(212,163,115,0.3);
}
.game-subtitle { font-size: 0.7rem; letter-spacing: 5px; color: var(--gold-dim); margin-top: 4px; }

.controls { display: none; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; justify-content: center; }
.btn {
  background: rgba(212,163,115,0.05); border: 1px solid var(--gold);
  color: var(--gold); padding: 7px 16px; border-radius: 30px;
  cursor: pointer; transition: 0.35s; font-family: inherit; font-size: 0.8rem;
}
.btn:hover:not(.disabled) { background: var(--gold); color: var(--bg-dark); box-shadow: 0 0 20px var(--gold); }
.btn.disabled { opacity: 0.2; cursor: wait; border-style: dashed; }
.theme-group { display: flex; gap: 6px; align-items: center; }
.theme-dot {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: 0.3s; padding: 0;
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
}
.theme-dot:hover, .theme-dot.active {
  border-color: var(--gold); transform: scale(1.2);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.55), 0 0 14px rgba(212,163,115,0.45);
}
.theme-dot:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.theme-dot.wood      { background: radial-gradient(#d4a05a, #8b5a2b); }
.theme-dot.bamboo    { background: radial-gradient(#b8cc7a, #5a7a2a); }
.theme-dot.porcelain { background: radial-gradient(#a8c8e8, #3a6a9a); }
.theme-dot.ink       { background: radial-gradient(#666, #111); }

.game-scene {
  display: none; gap: 24px; align-items: flex-start; justify-content: center; flex-wrap: wrap;
  width: 100%;
}

.info-sidebar { width: 190px; display: flex; flex-direction: column; gap: 12px; }
.player-box {
  padding: 14px; border-radius: 14px; background: rgba(0,0,0,0.4);
  border-left: 4px solid transparent; transition: 0.4s;
}
.player-box.active {
  border-left-color: var(--gold); background: rgba(212,163,115,0.08);
  transform: translateX(6px);
}
.timer-txt { font-family: 'Courier New', monospace; font-size: 1.5rem; color: var(--gold); margin-top: 6px; }
.poem-area {
  min-height: 60px; padding: 10px; border-top: 1px solid rgba(212,163,115,0.15);
  font-style: italic; color: rgba(245,230,200,0.5); text-align: center;
  line-height: 1.8; font-size: 0.8rem; transition: opacity 0.4s;
}

.board-container {
  padding: 14px; border-radius: 10px;
  box-shadow: 0 40px 100px rgba(0,0,0,0.8), inset 0 0 40px rgba(0,0,0,0.25);
  border: 4px solid #5d3a1a; background: #96633e;
  transition: background 0.6s, border-color 0.6s; position: relative;
  max-width: calc(100vw - 40px);
}
canvas { display: block; cursor: crosshair; }
#gameCanvas {
  width: var(--board-display-size);
  height: auto;
  max-width: 100%;
  touch-action: none;
}
.move-confirm { display: none; }

/* ─── 聊天面板 ─── */
.chat-panel { width: 170px; display: none; flex-direction: column; gap: 8px; }
.chat-label { font-size: 10px; color: rgba(212,163,115,0.4); letter-spacing: 2px; text-align: center; }
.chat-messages {
  height: 180px; overflow-y: auto; background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212,163,115,0.12); border-radius: 10px;
  padding: 8px; display: flex; flex-direction: column; gap: 5px;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(212,163,115,0.25); border-radius: 3px; }
.chat-msg {
  font-size: 11px; padding: 4px 8px; border-radius: 8px;
  background: rgba(212,163,115,0.07); color: rgba(245,230,200,0.8);
  word-break: break-all; animation: msgIn 0.3s ease;
}
.chat-msg.mine { background: rgba(212,163,115,0.18); text-align: right; }
.chat-msg.system { color: rgba(212,163,115,0.45); text-align: center; font-style: italic; font-size: 10px; background: none; }
@keyframes msgIn { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }
.emoji-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.emoji-btn {
  background: rgba(212,163,115,0.07); border: 1px solid rgba(212,163,115,0.15);
  border-radius: 5px; padding: 3px 5px; cursor: pointer; font-size: 14px; transition: 0.2s;
}
.emoji-btn:hover { background: rgba(212,163,115,0.22); transform: scale(1.15); }
.chat-input-row { display: flex; gap: 4px; }
.chat-input {
  flex: 1; background: rgba(0,0,0,0.3); border: 1px solid rgba(212,163,115,0.18);
  border-radius: 7px; padding: 5px 7px; color: var(--paper);
  font-family: inherit; font-size: 11px; outline: none;
}
.chat-input:focus { border-color: rgba(212,163,115,0.45); }
.chat-send {
  background: rgba(212,163,115,0.12); border: 1px solid rgba(212,163,115,0.25);
  color: var(--gold); border-radius: 7px; padding: 5px 7px;
  cursor: pointer; font-size: 11px; transition: 0.2s;
}
.chat-send:hover { background: rgba(212,163,115,0.28); }

/* ─── 弹窗通用 ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center; z-index: 500;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.3s; }
.modal-box {
  background: linear-gradient(160deg,#2c1e12,#1a0f06);
  border: 1px solid rgba(212,163,115,0.35); border-radius: 16px;
  padding: 28px 36px; text-align: center;
}
.modal-box h3 { font-family:'Ma Shan Zheng'; font-size:1.6rem; color:var(--gold); margin-bottom:10px; }
.modal-box p  { color:rgba(245,230,200,0.65); margin-bottom:20px; font-size:0.85rem; }
.modal-btns   { display:flex; gap:10px; justify-content:center; }

/* ─── 断线提醒 ─── */
.conn-banner {
  position: fixed; left: 50%; top: 50%;
  width: min(92vw, 360px);
  padding: 22px 20px 18px;
  background: linear-gradient(160deg, rgba(56,20,12,0.96), rgba(24,8,6,0.96));
  border: 1px solid rgba(212,163,115,0.28);
  border-radius: 18px;
  color: #fff;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 999;
}
.conn-banner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.conn-banner-icon {
  width: 44px; height: 44px; margin: 0 auto 12px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(212,163,115,0.12);
  border: 1px solid rgba(212,163,115,0.22);
  font-size: 20px;
}
.conn-banner-title {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 1.7rem;
  color: var(--gold);
  letter-spacing: 4px;
  margin-bottom: 8px;
}
.conn-banner-text {
  color: rgba(245,230,200,0.78);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 14px;
}
.conn-banner-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.conn-banner-btn {
  min-width: 110px;
  background: rgba(212,163,115,0.12);
  border: 1px solid rgba(212,163,115,0.3);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: 0.2s;
}
.conn-banner-btn:hover { background: rgba(212,163,115,0.24); }
.conn-banner-btn.primary {
  background: rgba(212,163,115,0.92);
  color: #1c1209;
  border-color: rgba(212,163,115,0.92);
}
.conn-banner-btn.primary:hover { background: #e0b180; }

/* ─── 胜利弹窗 ─── */
.win-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.95);
  display: none; align-items: center; justify-content: center; z-index: 1000;
  flex-direction: column;
}
.win-modal.show { display: flex; animation: fadeIn 1s; }

/* ─── 等待房间 ─── */
.waiting-room {
  position: fixed; inset: 0; z-index: 1500;
  background: radial-gradient(circle at center, #2c1e12 0%, #0a0806 100%);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px;
}
.waiting-room.show { display: flex; animation: fadeIn 0.5s ease; }
.waiting-title { font-family: 'Ma Shan Zheng'; font-size: 2rem; color: var(--gold); letter-spacing: 6px; }
.waiting-desc { font-size: 0.8rem; color: rgba(245,230,200,0.45); letter-spacing: 2px; }
.waiting-link-box {
  display: flex; gap: 10px; align-items: center;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(212,163,115,0.2);
  border-radius: 12px; padding: 12px 16px; max-width: 440px; width: 90%;
}
.waiting-link-text { flex: 1; font-size: 11px; color: rgba(245,230,200,0.45); word-break: break-all; line-height: 1.5; }
.waiting-copy-btn {
  flex-shrink: 0; background: rgba(212,163,115,0.12);
  border: 1px solid rgba(212,163,115,0.35); color: var(--gold);
  border-radius: 8px; padding: 7px 14px; cursor: pointer;
  font-family: inherit; font-size: 11px; transition: 0.2s; white-space: nowrap;
}
.waiting-copy-btn:hover { background: rgba(212,163,115,0.28); }
.waiting-spinner-wrap { display: flex; align-items: center; gap: 10px; color: rgba(212,163,115,0.5); font-size: 12px; }
.waiting-spinner {
  width: 20px; height: 20px; border: 2px solid rgba(212,163,115,0.12);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

/* ─── AI指导：辅助分析模式 ─── */
.coach-panel {
  width: 280px; max-height: 560px; background: rgba(14,10,7,0.92);
  border: 1px solid rgba(212,163,115,0.24); border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0,0,0,0.5);
  backdrop-filter: blur(14px);
  display: none; z-index: 220;
}
.coach-panel.show { display: block; animation: coachRise 0.28s ease forwards; }
@keyframes coachRise { from{opacity:0;transform:translateX(18px)} to{opacity:1;transform:translateX(0)} }
.coach-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px 8px; background: rgba(212,163,115,0.06);
  border-bottom: 1px solid rgba(212,163,115,0.1);
}
.coach-kicker {
  display: block; margin-bottom: 2px;
  font-size: 9px; color: rgba(212,163,115,0.45); letter-spacing: 2px;
}
.coach-title { display: block; font-size: 13px; font-weight: 700; color: var(--gold); letter-spacing: 1px; }
.coach-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(212,163,115,0.06); border: 1px solid rgba(212,163,115,0.12);
  color: rgba(212,163,115,0.55); cursor: pointer; font-size: 13px; transition: 0.2s;
}
.coach-close:hover { color: var(--gold); background: rgba(212,163,115,0.14); }
.coach-mode-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 8px 12px 0;
}
.coach-mode-tab {
  min-height: 30px; border-radius: 8px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(212,163,115,0.14);
  color: rgba(245,230,200,0.58); cursor: pointer; font-family: inherit; font-size: 12px;
  transition: 0.2s;
}
.coach-mode-tab:hover { color: var(--gold); border-color: rgba(212,163,115,0.32); }
.coach-mode-tab.active {
  color: #1c1209; background: rgba(212,163,115,0.92); border-color: rgba(212,163,115,0.92);
}
.coach-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px 14px; color: rgba(212,163,115,0.55); font-size: 12px; }
.coach-spinner { width: 18px; height: 18px; border: 2px solid rgba(212,163,115,0.12); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
.coach-content { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.coach-section {
  font-size: 13px; line-height: 1.55; color: rgba(245,230,200,0.84);
  background: rgba(255,255,255,0.025); border-radius: 8px; padding: 10px 12px;
  border-left: 3px solid rgba(212,163,115,0.45);
}
.coach-primary {
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; border-radius: 8px; background: rgba(212,163,115,0.08);
  border: 1px solid rgba(212,163,115,0.16);
  color: rgba(245,230,200,0.78); font-size: 12px; line-height: 1.5;
}
.coach-primary.show { display: flex; }
.coach-primary strong { color: var(--gold); font-size: 15px; white-space: nowrap; }
.coach-legend { display: flex; gap: 12px; padding: 4px 2px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 10px; color: rgba(245,230,200,0.5); }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid; flex-shrink: 0; }
.legend-dot.attack  { background: rgba(80,220,120,0.22); border-color: #50dc78; }
.legend-dot.defend  { background: rgba(220,80,80,0.22);  border-color: #dc5050; }
.legend-dot.threat  { background: rgba(255,180,0,0.18);  border-color: #ffb400; }
.coach-moves { display: grid; grid-template-columns: 1fr; gap: 6px; }
.coach-move-item { display: flex; align-items: flex-start; gap: 7px; font-size: 11px; color: rgba(245,230,200,0.68); padding: 7px 8px; background: rgba(255,255,255,0.025); border-radius: 7px; border: 1px solid rgba(255,255,255,0.045); }
.move-badge { flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; margin-top: 1px; }
.move-badge.attack { background: rgba(80,220,120,0.22); color: #50dc78; border: 1px solid #50dc78; }
.move-badge.defend { background: rgba(220,80,80,0.22);  color: #dc5050; border: 1px solid #dc5050; }
.coach-warning { background: rgba(255,120,0,0.08); border: 1px solid rgba(255,120,0,0.3); border-radius: 7px; padding: 8px 10px; font-size: 11px; color: rgba(255,180,80,0.88); line-height: 1.6; }
.coach-refresh {
  align-self: flex-end; background: transparent; border: 0; color: rgba(212,163,115,0.65);
  cursor: pointer; font-family: inherit; font-size: 11px; padding: 2px 0;
}
.coach-refresh:hover { color: var(--gold); }
.btn.coach-active { background: rgba(212,163,115,0.18); box-shadow: 0 0 12px rgba(212,163,115,0.25); }

@media (max-width: 720px) {
  .site-lang-switch {
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
  }
  body { overflow: hidden; }
  #lobby {
    justify-content: flex-start;
    min-height: 100dvh;
    gap: 28px;
    padding: 44px 16px 28px;
  }
  .lobby-title h1 { font-size: 3.2rem; letter-spacing: 8px; }
  .lobby-title p { font-size: 0.65rem; letter-spacing: 4px; }
  .game-cards, .mode-cards, .color-cards { width: 100%; gap: 12px; }
  .game-card {
    width: min(100%, 340px);
    min-height: 116px;
    padding: 18px 18px;
    border-radius: 14px;
    gap: 8px;
  }
  .game-icon { font-size: 2.2rem; }
  .game-name { font-size: 1.35rem; }
  .mode-screen, .color-screen {
    justify-content: flex-start;
    min-height: 100dvh;
    gap: 28px;
    padding: calc(64px + env(safe-area-inset-top)) 16px 28px;
  }
  .mode-screen {
    gap: 16px;
    padding: calc(50px + env(safe-area-inset-top)) 14px 18px;
  }
  .mode-header { gap: 4px; }
  .mode-game-name { font-size: 2.3rem; letter-spacing: 6px; }
  .mode-screen .mode-game-name { font-size: 2rem; letter-spacing: 5px; }
  .mode-screen .mode-subtitle { font-size: 0.66rem; letter-spacing: 3px; }
  .mode-screen .mode-cards {
    gap: 9px;
    max-width: 360px;
  }
  .mode-card, .color-card {
    width: min(100%, 340px);
    padding: 18px 16px;
    border-radius: 14px;
  }
  .mode-screen .mode-card {
    display: grid;
    grid-template-columns: 34px minmax(134px, 158px);
    grid-template-rows: auto auto;
    align-items: center;
    justify-content: center;
    gap: 3px 2px;
    min-height: 82px;
    padding: 12px 14px;
    text-align: center;
  }
  .mode-screen .mode-icon {
    grid-row: 1 / span 2;
    justify-self: center;
    font-size: 2rem;
    text-align: center;
  }
  .mode-screen .mode-name {
    font-size: 0.95rem;
    letter-spacing: 1px;
  }
  .mode-screen .mode-desc {
    font-size: 0.68rem;
    line-height: 1.35;
  }
  .mode-back, .color-back, .back-btn {
    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
  }
  #game-wrapper {
    align-items: stretch;
    padding: calc(48px + env(safe-area-inset-top)) 10px calc(18px + env(safe-area-inset-bottom));
  }
  .game-header {
    align-self: center;
    margin-bottom: 8px;
  }
  .game-title { font-size: 1.75rem; letter-spacing: 4px; }
  .game-subtitle { font-size: 0.58rem; letter-spacing: 2px; }
  .controls {
    width: 100%;
    gap: 8px;
    margin-bottom: 10px;
  }
  .btn {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.74rem;
  }
  .theme-group {
    flex: 1 1 100%;
    justify-content: center;
    padding-top: 2px;
  }
  .theme-dot { width: 24px; height: 24px; }
  .game-scene {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .board-container {
    order: 1;
    width: fit-content;
    max-width: calc(100vw - 24px);
    padding: 6px;
    border-width: 2px;
    box-shadow: 0 10px 26px rgba(0,0,0,0.55), inset 0 0 14px rgba(0,0,0,0.18);
  }
  #gameCanvas {
    width: min(var(--board-display-size), calc(100vw - 40px));
    max-height: calc(100svh - 245px);
    object-fit: contain;
  }
  .move-confirm {
    order: 2;
    display: none;
    width: 100%;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid rgba(212,163,115,0.2);
    border-radius: 10px;
    background: rgba(0,0,0,0.28);
  }
  .move-confirm.visible { display: flex; }
  .move-confirm.ready {
    background: rgba(212,163,115,0.1);
    border-color: rgba(212,163,115,0.42);
  }
  .move-confirm-text {
    min-width: 0;
    color: rgba(245,230,200,0.78);
    font-size: 0.78rem;
    line-height: 1.35;
  }
  .move-confirm-actions {
    display: flex;
    flex-shrink: 0;
    gap: 8px;
  }
  .move-confirm-btn {
    min-height: 34px;
    border-radius: 999px;
    padding: 7px 12px;
    border: 1px solid rgba(212,163,115,0.32);
    font-family: inherit;
    font-size: 0.76rem;
  }
  .move-confirm-btn.primary {
    background: rgba(212,163,115,0.94);
    color: #1c1209;
  }
  .move-confirm-btn.primary:disabled {
    opacity: 0.45;
  }
  .move-confirm-btn.secondary {
    background: rgba(212,163,115,0.06);
    color: rgba(245,230,200,0.72);
  }
  .info-sidebar {
    order: 3;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .player-box {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
  }
  .player-box.active { transform: none; }
  .timer-txt { font-size: 1.15rem; }
  .poem-area {
    flex: 1 1 100%;
    min-height: 42px;
    padding: 8px;
    font-size: 0.74rem;
    line-height: 1.6;
  }
  .coach-panel { width: min(100%, 560px); max-height: none; }
  .coach-panel { order: 4; }
  .coach-moves { grid-template-columns: 1fr; }
  .coach-primary { align-items: flex-start; flex-direction: column; }
  .chat-panel {
    order: 5;
    width: 100%;
  }
  .chat-messages { height: 120px; }
  .lobby-title h1 { animation: none; }
  .coach-panel { backdrop-filter: none; }
  .btn:hover:not(.disabled) { box-shadow: none; }
  .capture-info { flex: 1 1 100%; }
  .waiting-room { padding: 32px 16px; }
  .waiting-title { font-size: 1.8rem; letter-spacing: 4px; }
  .waiting-link-box {
    flex-direction: column;
    align-items: stretch;
  }
  .waiting-copy-btn { min-height: 38px; }
}

@media (max-width: 720px) {
  html[lang="en"] .site-lang-switch button {
    min-width: 32px;
    min-height: 26px;
    font-size: 0.7rem;
  }
  html[lang="en"] #lobby {
    gap: 18px;
    padding: calc(50px + env(safe-area-inset-top)) 14px 18px;
  }
  html[lang="en"] .lobby-title {
    gap: 6px;
  }
  html[lang="en"] .lobby-title h1 {
    max-width: 330px;
    font-size: 2.18rem;
    line-height: 1.12;
    letter-spacing: 1px;
  }
  html[lang="en"] .lobby-title p {
    font-size: 0.58rem;
    letter-spacing: 2px;
  }
  html[lang="en"] .game-cards {
    gap: 9px;
  }
  html[lang="en"] .game-card {
    min-height: 96px;
    padding: 13px 16px;
    gap: 5px;
  }
  html[lang="en"] .game-icon {
    font-size: 1.9rem;
  }
  html[lang="en"] .game-name {
    font-size: 1.08rem;
    line-height: 1.15;
  }
  html[lang="en"] .game-tag {
    font-size: 0.6rem;
    letter-spacing: 2px;
  }
  html[lang="en"] .game-badge {
    top: 10px;
    right: 10px;
    padding: 2px 8px;
    font-size: 9px;
  }
  html[lang="en"] .site-footer-links {
    max-width: 330px;
    gap: 7px;
    font-size: 0.68rem;
    line-height: 1.35;
  }
  html[lang="en"] .mode-screen {
    gap: 12px;
    padding: calc(48px + env(safe-area-inset-top)) 12px 14px;
  }
  html[lang="en"] .mode-header {
    gap: 3px;
  }
  html[lang="en"] .mode-screen .mode-game-name {
    font-size: 1.72rem;
    line-height: 1.1;
    letter-spacing: 1px;
  }
  html[lang="en"] .mode-screen .mode-subtitle {
    font-size: 0.6rem;
    letter-spacing: 1.5px;
  }
  html[lang="en"] .mode-screen .mode-cards {
    gap: 8px;
    max-width: 340px;
  }
  html[lang="en"] .mode-screen .mode-card {
    grid-template-columns: 32px minmax(146px, 170px);
    min-height: 76px;
    padding: 10px 12px;
    gap: 2px 3px;
  }
  html[lang="en"] .mode-screen .mode-icon {
    font-size: 1.75rem;
  }
  html[lang="en"] .mode-screen .mode-name {
    font-size: 0.88rem;
    line-height: 1.15;
    letter-spacing: 0;
  }
  html[lang="en"] .mode-screen .mode-desc {
    font-size: 0.62rem;
    line-height: 1.22;
  }
  html[lang="en"] .color-screen {
    gap: 18px;
    padding: calc(54px + env(safe-area-inset-top)) 14px 18px;
  }
  html[lang="en"] .color-title {
    font-size: 1.6rem;
    letter-spacing: 1px;
  }
  html[lang="en"] .color-card {
    padding: 14px 16px;
  }
  html[lang="en"] .color-name {
    font-size: 0.95rem;
  }
  html[lang="en"] .color-desc {
    font-size: 0.68rem;
  }
  html[lang="en"] .btn {
    min-height: 32px;
    padding: 7px 8px;
    font-size: 0.68rem;
  }
  html[lang="en"] .game-title {
    font-size: 1.55rem;
    letter-spacing: 1px;
  }
  html[lang="en"] .game-subtitle {
    font-size: 0.54rem;
    letter-spacing: 1.5px;
  }
  html[lang="en"] .legal-shell {
    width: min(100% - 22px, 920px);
    padding: calc(56px + env(safe-area-inset-top)) 0 36px;
  }
  html[lang="en"] .legal-panel {
    padding: 22px 20px;
  }
  html[lang="en"] .legal-panel h1 {
    font-size: 1.9rem;
    line-height: 1.15;
    letter-spacing: 1px;
  }
  html[lang="en"] .legal-panel h2 {
    font-size: 0.98rem;
    letter-spacing: 0.5px;
  }
  html[lang="en"] .legal-panel p {
    font-size: 0.88rem;
    line-height: 1.68;
  }
  html[lang="en"] .legal-panel section {
    margin-top: 22px;
  }
}

@media (max-width: 380px) {
  .btn { flex: 1 1 calc(50% - 8px); }
  .game-title { font-size: 1.55rem; }
  #gameCanvas { max-height: calc(100svh - 230px); }
  html[lang="en"] .lobby-title h1 { font-size: 1.95rem; }
  html[lang="en"] .game-card { min-height: 90px; }
  html[lang="en"] .mode-screen .mode-card {
    grid-template-columns: 30px minmax(138px, 160px);
    min-height: 74px;
  }
}

/* 围棋特有：提子计数 */
.capture-info { display: flex; justify-content: space-between; padding: 8px 12px; background: rgba(0,0,0,0.25); border-radius: 10px; font-size: 12px; }
.capture-item { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.capture-label { font-size: 10px; color: var(--gold-dim); }
.capture-count { font-size: 1.2rem; color: var(--gold); font-family: 'Courier New', monospace; }

/* 国际象棋：被吃棋子 */
.chess-captured { display: flex; flex-wrap: wrap; gap: 2px; min-height: 28px; padding: 5px; background: rgba(0,0,0,0.2); border-radius: 8px; }

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

/* 积分标签 */
.score-label { font-size: 11px; color: var(--gold-dim); margin-top: 2px; }

/* 国际象棋提示格 */
.chess-hint { fill: rgba(255,215,0,0.35); }

/* ─── 网站信息页面 ─── */
body.legal-page {
  overflow: auto;
  min-height: 100vh;
  background: radial-gradient(ellipse at 30% 20%, #1e1208 0%, #0a0806 68%);
}
.legal-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 64px;
}
.legal-back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 18px;
  color: rgba(245,230,200,0.62);
  text-decoration: none;
  font-size: 0.88rem;
}
.legal-back:hover { color: var(--gold); }
.legal-panel {
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(212,163,115,0.18);
  border-radius: 14px;
  padding: clamp(24px, 5vw, 48px);
  box-shadow: 0 28px 80px rgba(0,0,0,0.42);
}
.legal-kicker {
  color: rgba(212,163,115,0.45);
  letter-spacing: 4px;
  font-size: 0.72rem;
  margin-bottom: 10px;
}
.legal-panel h1 {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: clamp(2.3rem, 6vw, 4rem);
  color: var(--gold);
  letter-spacing: 6px;
  margin-bottom: 10px;
}
.legal-updated,
.legal-note {
  color: rgba(245,230,200,0.48);
  font-size: 0.86rem;
}
.legal-panel section { margin-top: 28px; }
.legal-panel h2 {
  color: var(--gold);
  font-size: 1.08rem;
  letter-spacing: 2px;
  margin-bottom: 10px;
}
.legal-panel p {
  color: rgba(245,230,200,0.76);
  line-height: 1.9;
  font-size: 0.96rem;
  margin-top: 10px;
}
.legal-panel a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(212,163,115,0.35);
}
.legal-panel a:hover { border-bottom-color: var(--gold); }
.contact-box {
  padding: 18px 20px;
  border: 1px solid rgba(212,163,115,0.16);
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
}

.lang-en { display: none; }
html[lang="en"] .lang-zh { display: none; }
html[lang="en"] .lang-en { display: block; }

.guide-shell {
  width: min(1040px, calc(100% - 32px));
}
.guide-hero {
  margin-bottom: 18px;
}
.guide-hero h1 {
  margin-bottom: 14px;
}
.guide-intro {
  max-width: 760px;
}
.guide-index {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding: 10px;
  border: 1px solid rgba(212,163,115,0.14);
  border-radius: 12px;
  background: rgba(10,8,6,0.68);
  backdrop-filter: blur(12px);
}
.guide-index a {
  min-width: 40px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(212,163,115,0.18);
  border-radius: 999px;
  color: rgba(245,230,200,0.72);
  text-decoration: none;
  font-size: 0.8rem;
}
.guide-index a:hover {
  color: var(--bg-dark);
  background: var(--gold);
  border-color: var(--gold);
}
.guide-list {
  display: grid;
  gap: 18px;
}
.guide-card {
  scroll-margin-top: 86px;
}
.guide-card h2 {
  margin-top: 0;
  font-size: clamp(1.22rem, 2.4vw, 1.7rem);
  line-height: 1.35;
  letter-spacing: 1px;
}
.guide-card p {
  font-size: 0.98rem;
}

@media (max-width: 720px) {
  .site-footer-links {
    margin-top: 4px;
    font-size: 0.74rem;
  }
  .legal-shell {
    width: min(100% - 24px, 920px);
    padding: 24px 0 42px;
  }
  .legal-panel {
    border-radius: 12px;
  }
  .guide-shell {
    width: min(100% - 24px, 1040px);
  }
  .guide-index {
    position: static;
    gap: 6px;
    padding: 8px;
  }
  .guide-index a {
    min-width: 36px;
    min-height: 30px;
    font-size: 0.74rem;
  }
  .guide-card p {
    font-size: 0.9rem;
    line-height: 1.78;
  }
}

/* ─── Final AI skin overrides: keep these last ─── */
:root {
  --bg-dark: #02070d;
  --gold: #f6c763;
  --gold-dim: rgba(246,199,99,0.42);
  --paper: #eef7ff;
  --ink: #08111b;
  --cyan: #25d8ff;
  --ui-accent: #25d8ff;
  --ui-accent-2: #f6c763;
  --ui-accent-rgb: 37,216,255;
  --ui-accent-2-rgb: 246,199,99;
  --ui-panel: rgba(7,22,35,0.74);
  --ui-panel-2: rgba(3,11,19,0.52);
  --ui-text: #eef7ff;
}

body[data-theme="wood"] {
  --ui-accent: #d69a55;
  --ui-accent-2: #f2d29a;
  --ui-accent-rgb: 214,154,85;
  --ui-accent-2-rgb: 242,210,154;
  --ui-panel: rgba(42,25,12,0.76);
  --ui-panel-2: rgba(18,10,5,0.58);
  --ui-text: #fff1d5;
}

body[data-theme="bamboo"] {
  --ui-accent: #9fca5d;
  --ui-accent-2: #e0ef9b;
  --ui-accent-rgb: 159,202,93;
  --ui-accent-2-rgb: 224,239,155;
  --ui-panel: rgba(18,36,15,0.76);
  --ui-panel-2: rgba(6,16,6,0.58);
  --ui-text: #f2ffd8;
}

body[data-theme="porcelain"] {
  --ui-accent: #7ecbff;
  --ui-accent-2: #d9f3ff;
  --ui-accent-rgb: 126,203,255;
  --ui-accent-2-rgb: 217,243,255;
  --ui-panel: rgba(8,30,54,0.76);
  --ui-panel-2: rgba(3,12,24,0.58);
  --ui-text: #eef9ff;
}

body[data-theme="ink"] {
  --ui-accent: #d8d8d8;
  --ui-accent-2: #ffffff;
  --ui-accent-rgb: 216,216,216;
  --ui-accent-2-rgb: 255,255,255;
  --ui-panel: rgba(28,28,28,0.78);
  --ui-panel-2: rgba(5,5,5,0.62);
  --ui-text: #f5f5f5;
}

body {
  background:
    radial-gradient(circle at 74% 22%, rgba(22,180,255,0.2) 0, transparent 34%),
    radial-gradient(circle at 28% 74%, rgba(246,199,99,0.14) 0, transparent 32%),
    linear-gradient(135deg, #01040a 0%, #06111d 48%, #02060d 100%);
  color: var(--paper);
  font-family: 'Noto Sans SC', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  display: none;
}

body::after {
  display: none;
}

#particles-canvas { opacity: 0.8 !important; mix-blend-mode: screen; }

#lobby {
  justify-content: flex-start;
  gap: 20px;
  padding: 0 clamp(18px, 4vw, 56px) 34px;
}

#lobby::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(2,7,13,0.58) 0%, rgba(2,7,13,0.36) 42%, rgba(2,7,13,0.24) 72%, rgba(2,7,13,0.58) 100%),
    linear-gradient(180deg, rgba(2,7,13,0.18) 0%, rgba(2,7,13,0.06) 42%, rgba(2,7,13,0.76) 100%),
    url('assets/ai-chess-hero-generated.png') center top / cover no-repeat,
    radial-gradient(circle at 72% 28%, rgba(37,216,255,0.22) 0, transparent 32%),
    radial-gradient(circle at 64% 66%, rgba(246,199,99,0.12) 0, transparent 34%),
    linear-gradient(90deg, rgba(2,7,13,0.96) 0%, rgba(2,7,13,0.78) 46%, rgba(2,7,13,0.9) 100%);
}

.lobby-shell {
  width: min(1180px, 100%);
  min-height: min(68vh, 620px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

.lobby-shell::after {
  content: '';
  position: absolute;
  left: -6vw;
  right: -6vw;
  bottom: -72px;
  height: clamp(150px, 18vh, 210px);
  z-index: 7;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(2,7,13,0) 0%,
    rgba(2,7,13,0.26) 46%,
    rgba(2,7,13,0.84) 100%
  );
  backdrop-filter: blur(3px);
}

.lobby-copy {
  position: relative;
  z-index: 8;
  min-width: 0;
  width: min(760px, 100%);
  padding-top: 24px;
}

.lobby-title {
  align-items: center;
  text-align: center;
  gap: 16px;
}

.lobby-kicker {
  width: fit-content;
  padding: 7px 12px;
  border: 1px solid rgba(37,216,255,0.28);
  background: rgba(37,216,255,0.08);
  color: var(--cyan);
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 3px;
  text-shadow: 0 0 18px rgba(37,216,255,0.8);
}

.lobby-title h1 {
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(4.4rem, 10vw, 9rem);
  line-height: 0.92;
  color: #fff7e8;
  letter-spacing: 0;
  text-shadow:
    0 3px 22px rgba(0,0,0,0.72),
    0 0 34px rgba(255,255,255,0.22),
    0 0 74px rgba(37,216,255,0.32);
}

html[lang="en"] .lobby-title h1,
html[lang="en"] .game-name,
html[lang="en"] .mode-game-name,
html[lang="en"] .color-title,
html[lang="en"] .legal-panel h1 {
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-weight: 900;
}

html[lang="en"] .lobby-title h1 {
  max-width: 620px;
  font-size: clamp(3.2rem, 6.4vw, 5.8rem);
  line-height: 0.98;
}

.lobby-title h1::first-letter { color: var(--gold); }

.lobby-title p:not(.lobby-kicker) {
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-weight: 800;
  color: rgba(238,247,255,0.78);
  letter-spacing: 5px;
  text-shadow: 0 2px 16px rgba(0,0,0,0.76), 0 0 22px rgba(37,216,255,0.34);
}

.lobby-metrics {
  justify-content: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.lobby-metrics span {
  padding: 9px 12px;
  border: 1px solid rgba(37,216,255,0.22);
  background: linear-gradient(135deg, rgba(37,216,255,0.1), rgba(246,199,99,0.06));
  color: rgba(238,247,255,0.78);
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 1.6px;
}

.lobby-visual {
  position: absolute;
  inset: -10px -4vw 0;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.lobby-visual::before {
  content: '';
  position: absolute;
  inset: 7% 2% 3% 0;
  background:
    radial-gradient(circle at 68% 26%, rgba(37,216,255,0.44), transparent 9%),
    radial-gradient(circle at 50% 42%, rgba(246,199,99,0.5), transparent 8%),
    linear-gradient(115deg, transparent 18%, rgba(246,199,99,0.24), transparent 38%),
    linear-gradient(65deg, transparent 46%, rgba(37,216,255,0.36), transparent 76%);
  filter: blur(0.2px);
  opacity: 0.95;
}

.hero-reference-art {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  opacity: 0.96;
  object-fit: cover;
  object-position: center 48%;
  filter: saturate(1.18) contrast(1.1) brightness(0.95);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 68%, rgba(0,0,0,0.72) 82%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 68%, rgba(0,0,0,0.72) 82%, transparent 100%);
}

.hero-art-mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(circle at 66% 58%, transparent 0 34%, rgba(2,7,13,0.08) 62%, rgba(2,7,13,0.54) 88%),
    linear-gradient(90deg, rgba(2,7,13,0.34) 0%, rgba(2,7,13,0.18) 28%, rgba(2,7,13,0.04) 58%, rgba(2,7,13,0.24) 100%),
    linear-gradient(180deg, rgba(2,7,13,0.16) 0%, rgba(2,7,13,0.02) 44%, rgba(2,7,13,0.62) 100%);
}

.hud-ring {
  position: absolute;
  z-index: 4;
  top: 8%;
  right: 10%;
  width: 170px;
  aspect-ratio: 1;
  border: 1px solid rgba(37,216,255,0.28);
  border-radius: 50%;
  box-shadow: inset 0 0 36px rgba(37,216,255,0.12), 0 0 36px rgba(37,216,255,0.14);
}

.hud-ring::before,
.hud-ring::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(37,216,255,0.24);
}

.hud-ring::before { inset: 28px; }
.hud-ring::after {
  inset: 68px;
  background: var(--cyan);
  box-shadow: 0 0 18px var(--cyan);
}

.neural-field span {
  position: absolute;
  z-index: 5;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 18px var(--cyan);
}

.neural-field span:nth-child(1) { left: 39%; top: 25%; background: var(--gold); box-shadow: 0 0 18px var(--gold); }
.neural-field span:nth-child(2) { left: 63%; top: 21%; }
.neural-field span:nth-child(3) { left: 78%; top: 47%; }
.neural-field span:nth-child(4) { left: 48%; top: 57%; background: var(--gold); box-shadow: 0 0 18px var(--gold); }
.neural-field span:nth-child(5) { left: 72%; top: 70%; }
.neural-field span:nth-child(6) { left: 55%; top: 78%; }

.hero-board {
  position: absolute;
  z-index: 3;
  left: 8%;
  right: 0;
  bottom: 4%;
  height: 34%;
  transform: perspective(680px) rotateX(58deg) rotateZ(-8deg);
  transform-origin: center bottom;
  background:
    linear-gradient(90deg, rgba(246,199,99,0.62) 0 1px, transparent 1px 12.5%),
    linear-gradient(rgba(37,216,255,0.45) 0 1px, transparent 1px 12.5%),
    linear-gradient(135deg, rgba(8,24,37,0.92), rgba(1,6,12,0.96));
  background-size: 12.5% 12.5%;
  border: 1px solid rgba(37,216,255,0.62);
  box-shadow: 0 24px 70px rgba(0,0,0,0.7), 0 0 42px rgba(37,216,255,0.28), inset 0 0 34px rgba(246,199,99,0.12);
}

.hero-board.digital-board {
  opacity: 0.18;
  mix-blend-mode: screen;
}

.piece {
  position: absolute;
  transform: rotateZ(8deg) rotateX(-58deg);
  text-align: center;
  font-family: Georgia, serif;
}

.digital-board .piece {
  opacity: 0;
}

.piece.king {
  left: 45%;
  bottom: 46%;
  color: #ffe1a0;
  font-size: clamp(7rem, 14vw, 12rem);
  text-shadow: 0 0 16px var(--gold), 0 0 46px rgba(246,199,99,0.68);
}

.piece.knight {
  left: 67%;
  bottom: 34%;
  color: #c9f5ff;
  font-size: clamp(5.8rem, 11vw, 10rem);
  text-shadow: 0 0 18px var(--cyan), 0 0 52px rgba(37,216,255,0.72);
}

.piece.pawn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff5cf, #f6c763 48%, #5e3a07);
  box-shadow: 0 0 20px rgba(246,199,99,0.75);
}

.piece.pawn.p1 { left: 22%; bottom: 28%; }
.piece.pawn.p2 {
  left: 83%;
  bottom: 24%;
  background: radial-gradient(circle at 35% 28%, #effcff, #25d8ff 48%, #05304a);
  box-shadow: 0 0 20px rgba(37,216,255,0.75);
}

.site-lang-switch {
  border-color: rgba(var(--ui-accent-rgb),0.28);
  background: rgba(3,13,22,0.72);
  box-shadow: 0 0 24px rgba(var(--ui-accent-rgb),0.16);
}

.site-lang-switch button { color: color-mix(in srgb, var(--ui-text) 62%, transparent); }
.site-lang-switch button.active {
  background: linear-gradient(135deg, var(--ui-accent), var(--ui-accent-2));
  color: #03101a;
}

.game-card,
.mode-card,
.color-card,
.player-box,
.chat-messages,
.capture-info,
.coach-panel,
.waiting-link-box,
.legal-panel {
  background: linear-gradient(145deg, var(--ui-panel), var(--ui-panel-2));
  border: 1px solid rgba(var(--ui-accent-rgb),0.2);
  border-radius: 8px;
  box-shadow: 0 22px 54px rgba(0,0,0,0.36), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
}

.game-cards { width: min(980px, 100%); gap: 16px; }
.game-card { width: 210px; min-height: 190px; }
.game-card {
  justify-content: center;
  background:
    linear-gradient(90deg, rgba(var(--ui-accent-2-rgb),0.08) 1px, transparent 1px),
    linear-gradient(rgba(var(--ui-accent-rgb),0.08) 1px, transparent 1px),
    linear-gradient(145deg, var(--ui-panel), var(--ui-panel-2));
  background-size: 22px 22px, 22px 22px, auto;
}
.game-card::before,
.mode-card::before { background: radial-gradient(circle at 50% 0%, rgba(var(--ui-accent-rgb),0.22) 0%, transparent 65%); }
.game-card:hover,
.mode-card:hover,
.color-card:hover {
  background: linear-gradient(145deg, color-mix(in srgb, var(--ui-panel) 82%, white 8%), var(--ui-panel-2));
  border-color: rgba(var(--ui-accent-rgb),0.62);
  box-shadow: 0 28px 70px rgba(0,0,0,0.5), 0 0 36px rgba(var(--ui-accent-rgb),0.18);
}

.game-card .game-name {
  font-size: 1.85rem;
}

.game-card .game-tag {
  padding-top: 2px;
  border-top: 1px solid rgba(var(--ui-accent-rgb),0.22);
}

.game-icon {
  position: relative;
  width: 96px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(246,199,99,0.2) 1px, transparent 1px),
    linear-gradient(rgba(37,216,255,0.18) 1px, transparent 1px),
    linear-gradient(145deg, rgba(9,28,40,0.92), rgba(2,8,14,0.98));
  background-size: 18px 18px, 18px 18px, auto;
  border: 1px solid rgba(37,216,255,0.22);
  box-shadow: inset 0 0 22px rgba(37,216,255,0.08), 0 14px 28px rgba(0,0,0,0.28);
}

.game-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 18%, rgba(255,255,255,0.16), transparent 34%);
  pointer-events: none;
}

.game-icon::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(37,216,255,0.72), transparent);
  box-shadow: 0 0 12px rgba(37,216,255,0.72);
}

.game-icon span {
  position: absolute;
  z-index: 2;
  display: block;
}

.icon-gomoku span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, #6b747c, #081018 72%);
  box-shadow: 0 5px 12px rgba(0,0,0,0.55), 0 0 10px rgba(37,216,255,0.2);
}

.icon-gomoku span:nth-child(1) { left: 31px; top: 18px; }
.icon-gomoku span:nth-child(2) { left: 49px; top: 18px; background: radial-gradient(circle at 34% 26%, #fff7df, #d7c9a8 68%); }
.icon-gomoku span:nth-child(3) { left: 40px; top: 35px; }
.icon-gomoku span:nth-child(4) { left: 58px; top: 35px; background: radial-gradient(circle at 34% 26%, #fff7df, #d7c9a8 68%); }
.icon-gomoku span:nth-child(5) { left: 22px; top: 35px; }

.icon-go {
  background-size: 14px 14px, 14px 14px, auto;
}

.icon-go span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 25%, #fff0bb, #d99f43 58%, #523006);
  box-shadow: 0 6px 13px rgba(0,0,0,0.48), 0 0 14px rgba(246,199,99,0.32);
}

.icon-go span:nth-child(1) { left: 25px; top: 20px; }
.icon-go span:nth-child(2) {
  left: 52px;
  top: 34px;
  background: radial-gradient(circle at 34% 26%, #effcff, #7bdff4 56%, #08202c);
  box-shadow: 0 6px 13px rgba(0,0,0,0.48), 0 0 14px rgba(37,216,255,0.34);
}
.icon-go span:nth-child(3) {
  left: 39px;
  top: 46px;
  width: 10px;
  height: 10px;
  opacity: 0.85;
}

.icon-chess {
  background:
    linear-gradient(45deg, rgba(246,199,99,0.14) 25%, transparent 25% 50%, rgba(37,216,255,0.16) 50% 75%, transparent 75%),
    linear-gradient(145deg, rgba(9,28,40,0.92), rgba(2,8,14,0.98));
  background-size: 24px 24px, auto;
}

.icon-chess span {
  position: relative;
  color: #dffaff;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 3.15rem;
  line-height: 1;
  text-shadow: 0 0 16px rgba(37,216,255,0.82), 0 10px 20px rgba(0,0,0,0.5);
  transform: translateY(-2px);
}

/*
.icon-go::after {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fff1bd 0 9%, #d59b3e 36%, #5a3106 76%);
  border: 1px solid rgba(246,199,99,0.45);
  box-shadow: 0 8px 20px rgba(0,0,0,0.52), 0 0 24px rgba(246,199,99,0.4);
}

.icon-chess::before {
  border-radius: 14px;
  background:
    linear-gradient(45deg, rgba(37,216,255,0.22) 25%, transparent 25% 50%, rgba(37,216,255,0.22) 50% 75%, transparent 75%),
    linear-gradient(145deg, rgba(6,22,34,0.9), rgba(2,9,16,0.96));
  background-size: 26px 26px, auto;
}

.icon-chess::after {
  width: 32px;
  height: 48px;
  background:
    radial-gradient(circle at 50% 15%, #effcff 0 18%, transparent 19%),
    linear-gradient(90deg, transparent 0 18%, #d9f7ff 18% 82%, transparent 82%),
    radial-gradient(ellipse at 50% 58%, #d4f6ff 0 42%, transparent 43%),
    linear-gradient(#9eeaff, #25d8ff);
  clip-path: polygon(39% 0, 61% 0, 67% 20%, 58% 28%, 72% 64%, 88% 64%, 94% 78%, 78% 78%, 88% 100%, 12% 100%, 22% 78%, 6% 78%, 12% 64%, 28% 64%, 42% 28%, 33% 20%);
  filter: drop-shadow(0 0 14px rgba(37,216,255,0.76));
}
*/

.mode-icon { filter: drop-shadow(0 0 18px rgba(37,216,255,0.52)); }

.game-name,
.mode-game-name,
.color-title,
.waiting-title,
.game-title,
.conn-banner-title,
.modal-box h3,
.legal-panel h1 {
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-weight: 900;
  color: var(--ui-accent-2);
  text-shadow: 0 0 24px rgba(var(--ui-accent-2-rgb),0.32);
}

.game-tag,
.game-badge,
.mode-subtitle,
.chat-label,
.capture-label,
.score-label {
  color: rgba(var(--ui-accent-rgb),0.66);
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-weight: 800;
}

.game-badge {
  background: rgba(var(--ui-accent-rgb),0.08);
  border-color: rgba(var(--ui-accent-rgb),0.32);
}

.mode-screen,
.color-screen,
.waiting-room,
body.legal-page {
  background:
    radial-gradient(circle at 74% 22%, rgba(37,216,255,0.18), transparent 34%),
    radial-gradient(circle at 24% 78%, rgba(246,199,99,0.12), transparent 32%),
    #02070d;
}

.btn,
.mode-back,
.color-back,
.back-btn,
.conn-banner-btn,
.waiting-copy-btn,
.chat-send,
.move-confirm-btn,
.coach-mode-tab {
  border-radius: 8px;
  border-color: rgba(var(--ui-accent-rgb),0.32);
  background: rgba(var(--ui-accent-rgb),0.08);
  color: color-mix(in srgb, var(--ui-text) 84%, transparent);
  box-shadow: inset 0 0 18px rgba(var(--ui-accent-rgb),0.04);
}

.btn:hover:not(.disabled),
.conn-banner-btn.primary,
.move-confirm-btn.primary,
.coach-mode-tab.active,
.waiting-copy-btn:hover,
.chat-send:hover {
  background: linear-gradient(135deg, var(--ui-accent), var(--ui-accent-2));
  border-color: transparent;
  color: #03101a;
  box-shadow: 0 0 24px rgba(var(--ui-accent-rgb),0.36);
}

.theme-group {
  padding: 5px 8px;
  border: 1px solid rgba(var(--ui-accent-rgb),0.16);
  border-radius: 8px;
  background: rgba(2,10,18,0.45);
}

.theme-dot.neural { background: radial-gradient(#f6c763 0 24%, #25d8ff 48%, #03111d 74%); }

.game-scene { gap: 18px; padding: 0 min(1vw, 14px); }

.board-container {
  border: 1px solid rgba(var(--ui-accent-rgb),0.48);
  border-radius: 8px;
  background: #1b3e55;
  box-shadow:
    0 28px 88px rgba(0,0,0,0.58),
    0 0 42px rgba(var(--ui-accent-rgb),0.18),
    inset 0 0 34px rgba(255,255,255,0.08);
}

.board-container::before {
  content: '';
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(246,199,99,0.24);
  border-radius: 12px;
  pointer-events: none;
  clip-path: polygon(0 0, 28% 0, 28% 1px, 72% 1px, 72% 0, 100% 0, 100% 100%, 72% 100%, 72% calc(100% - 1px), 28% calc(100% - 1px), 28% 100%, 0 100%);
}

.info-sidebar,
.chat-panel { width: 210px; }

.player-box {
  border-left: 0;
  border-top: 2px solid rgba(var(--ui-accent-rgb),0.18);
}

.player-box.active {
  border-top-color: var(--ui-accent-2);
  background: linear-gradient(145deg, rgba(var(--ui-accent-2-rgb),0.12), rgba(var(--ui-accent-rgb),0.08));
  transform: translateY(-2px);
}

.timer-txt {
  color: var(--ui-accent);
  font-family: 'Noto Sans SC', monospace;
  font-weight: 800;
}

.poem-area {
  border-top-color: rgba(var(--ui-accent-rgb),0.22);
  color: color-mix(in srgb, var(--ui-text) 62%, transparent);
}

.coach-panel,
.modal-box,
.conn-banner,
.win-modal {
  background: linear-gradient(145deg, rgba(7,22,35,0.94), rgba(2,8,14,0.94));
  border-color: rgba(var(--ui-accent-rgb),0.32);
}

.coach-header {
  background: linear-gradient(90deg, rgba(var(--ui-accent-rgb),0.12), rgba(var(--ui-accent-2-rgb),0.08));
  border-bottom-color: rgba(var(--ui-accent-rgb),0.16);
}

.coach-title,
.coach-primary strong,
.capture-count { color: var(--ui-accent); }

.coach-section,
.coach-primary,
.coach-move-item {
  background: rgba(var(--ui-accent-rgb),0.055);
  border-color: rgba(var(--ui-accent-rgb),0.12);
}

.win-modal h2 {
  font-family: 'Noto Sans SC', system-ui, sans-serif !important;
  font-weight: 900 !important;
  color: #fff4d5 !important;
}

@media (max-width: 900px) {
  .lobby-shell {
    min-height: 560px;
  }
  .lobby-visual {
    inset: 0 -18px;
  }
  .hero-reference-art { object-position: center 48%; }
  .game-card { width: min(100%, 280px); min-height: 184px; }
}

@media (max-width: 720px) {
  body::before { background-size: 42px 42px; }
  #lobby {
    justify-content: flex-start;
    gap: 18px;
    padding: 0 14px 22px;
  }
  .lobby-shell {
    min-height: 520px;
    width: 100%;
  }
  .lobby-shell::after {
    left: -18px;
    right: -18px;
    bottom: -42px;
    height: 135px;
    backdrop-filter: blur(2px);
  }
  #lobby::before {
    background:
      linear-gradient(90deg, rgba(2,7,13,0.62) 0%, rgba(2,7,13,0.28) 48%, rgba(2,7,13,0.52) 100%),
      linear-gradient(180deg, rgba(2,7,13,0.1) 0%, rgba(2,7,13,0.04) 44%, rgba(2,7,13,0.82) 100%),
      radial-gradient(circle at 50% 28%, rgba(37,216,255,0.2) 0, transparent 44%),
      linear-gradient(90deg, rgba(2,7,13,0.94), rgba(2,7,13,0.84));
  }
  .lobby-copy {
    padding-top: calc(62px + env(safe-area-inset-top));
  }
  .lobby-visual { min-height: 0; width: auto; }
  .hero-reference-art {
    object-fit: contain;
    object-position: center 16%;
    transform: scale(1.04);
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 74%, rgba(0,0,0,0.78) 88%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, #000 74%, rgba(0,0,0,0.78) 88%, transparent 100%);
  }
  .hero-art-mask {
    background:
      radial-gradient(circle at 62% 56%, transparent 0 28%, rgba(2,7,13,0.08) 56%, rgba(2,7,13,0.58) 86%),
      linear-gradient(90deg, rgba(2,7,13,0.38) 0%, rgba(2,7,13,0.16) 48%, rgba(2,7,13,0.24) 100%),
      linear-gradient(180deg, rgba(2,7,13,0.16) 0%, rgba(2,7,13,0.03) 42%, rgba(2,7,13,0.66) 100%);
  }
  .hud-ring { width: 102px; }
  .piece.king { font-size: 5.5rem; }
  .piece.knight { font-size: 4.6rem; }
  .piece.pawn { width: 32px; height: 32px; }
  .lobby-title h1 {
    font-size: clamp(3rem, 17vw, 4.6rem);
    letter-spacing: 0;
  }
  html[lang="en"] .lobby-title h1 {
    max-width: 330px;
    font-size: clamp(2.2rem, 12vw, 3.2rem);
    line-height: 1.02;
  }
  .lobby-title p:not(.lobby-kicker) {
    font-size: 0.58rem;
    letter-spacing: 2.6px;
  }
  .lobby-metrics span {
    padding: 7px 9px;
    font-size: 0.56rem;
  }
  .game-card {
    min-height: 104px;
    width: min(100%, 360px);
  }
  .mode-card,
  .color-card,
  .player-box,
  .chat-messages,
  .capture-info,
  .coach-panel {
    backdrop-filter: none;
  }
  .board-container::before { inset: -5px; }
  .info-sidebar,
  .chat-panel { width: 100%; }
}
