/* ============================================================
   棋境 · EdgeOne AI 棋馆
   Design tokens: ink / jade / gold
   ============================================================ */
:root {
  --bg: #070a09;
  --bg-2: #0d1210;
  --ink: #050807;
  --panel: rgba(17, 23, 20, 0.72);
  --panel-solid: #111714;
  --line: rgba(217, 164, 65, 0.18);
  --line-soft: rgba(255, 255, 255, 0.07);
  --text: #ece6d6;
  --muted: #98a29a;
  --muted-2: #6f7a72;
  --gold: #d9a441;
  --gold-2: #f4d491;
  --gold-dim: #8c6a2b;
  --jade: #37c9a9;
  --jade-2: #8ff0da;
  --red: #c0392b;
  --red-2: #ff7a63;
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.55);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.4);
  --radius: 18px;
  --radius-sm: 11px;
  --serif: "Songti SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
code, pre { font-family: var(--mono); }
b { font-weight: 600; }

/* ---------- ambient background ---------- */
.ambient { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: radial-gradient(120% 90% at 78% -10%, #1a2118 0%, #0a0f0c 46%, #070a09 100%); }
#bgCanvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.65; }
.ambient-glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; pointer-events: none; }
.ambient-glow.g1 { width: 560px; height: 560px; left: -180px; top: -200px; background: radial-gradient(circle, rgba(55, 201, 169, 0.16), transparent 68%); }
.ambient-glow.g2 { width: 720px; height: 720px; right: -240px; top: 30%; background: radial-gradient(circle, rgba(217, 164, 65, 0.12), transparent 66%); }
.ambient-grid {
  position: absolute; inset: 0; opacity: 0.16;
  background-image: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 68px 68px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 20%, transparent 80%);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  height: 72px; padding: 0 clamp(18px, 4vw, 48px);
  background: linear-gradient(to bottom, rgba(7, 10, 9, 0.92), rgba(7, 10, 9, 0.55) 70%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--gold-2), var(--gold) 55%, #a97a22);
  color: #141007; font-family: var(--serif); font-size: 22px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(217, 164, 65, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.04); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.brand-text b { font-family: var(--serif); font-size: 19px; letter-spacing: 0.16em; }
.brand-text small { color: var(--muted-2); font-size: 9px; letter-spacing: 0.24em; }
.topnav { display: flex; align-items: center; gap: 6px; }
.nav-btn {
  color: var(--muted); font-size: 13px; letter-spacing: 0.06em; padding: 9px 14px;
  border-radius: 10px; border: 1px solid transparent; transition: all 0.25s;
}
.nav-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); border-color: var(--line-soft); }
.nav-btn.icon { width: 38px; padding: 0; height: 38px; display: grid; place-items: center; font-size: 17px; }
.nav-btn.icon .snd-off { display: none; color: var(--muted-2); }
.nav-btn.icon.muted .snd-on { display: none; }
.nav-btn.icon.muted .snd-off { display: inline; }

/* ---------- layout ---------- */
.main { width: min(1340px, 100%); margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px) 40px; }
.view { display: none; }
.view.is-active { display: block; animation: viewIn 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 10.5px; letter-spacing: 0.28em; color: var(--gold); text-transform: uppercase;
  font-weight: 600;
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 0 0 rgba(55, 201, 169, 0.6); animation: pulse 2.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(55, 201, 169, 0.55); } 70% { box-shadow: 0 0 0 9px rgba(55, 201, 169, 0); } 100% { box-shadow: 0 0 0 0 rgba(55, 201, 169, 0); } }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.08fr 0.92fr; gap: clamp(24px, 5vw, 64px);
  align-items: center; padding: clamp(34px, 6vh, 72px) 0 clamp(32px, 6vh, 60px);
}
.hero-copy h1 {
  font-family: var(--serif); font-size: clamp(38px, 5.4vw, 72px); line-height: 1.14;
  margin: 18px 0 22px; letter-spacing: 0.02em; font-weight: 700;
}
.hero-copy h1 em { font-style: normal; color: transparent; background: linear-gradient(100deg, var(--gold-2), var(--gold) 58%, #b07f2c); -webkit-background-clip: text; background-clip: text; }
.lead { color: var(--muted); font-size: clamp(14px, 1.4vw, 16.5px); max-width: 560px; margin: 0 0 28px; }
.lead b { color: var(--gold-2); font-weight: 600; }
.hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-stats {
  display: flex; gap: clamp(20px, 3vw, 44px); margin-top: 38px; padding-top: 24px;
  border-top: 1px solid var(--line-soft);
}
.hero-stats div { display: flex; flex-direction: column; gap: 2px; }
.hero-stats b { font-family: var(--serif); font-size: 23px; color: var(--text); letter-spacing: 0.04em; }
.hero-stats span { font-size: 11px; color: var(--muted-2); letter-spacing: 0.12em; }

.hero-visual { position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; min-height: 320px; }
#heroCanvas { width: 100%; height: 100%; border-radius: 50%; max-width: 520px; }
.hero-ring { position: absolute; border-radius: 50%; border: 1px solid rgba(217, 164, 65, 0.14); pointer-events: none; }
.ring-a { inset: 8%; animation: spin 42s linear infinite; border-style: dashed; }
.ring-b { inset: 17%; animation: spin 28s linear infinite reverse; border-color: rgba(55, 201, 169, 0.12); }
@keyframes spin { to { transform: rotate(360deg); } }
.hero-badge {
  position: absolute; right: 8%; top: 12%; font-size: 10px; letter-spacing: 0.18em; color: var(--muted);
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(10, 14, 12, 0.7);
  backdrop-filter: blur(8px);
}
.hero-badge span { color: var(--jade); font-weight: 700; }
.hero-caption { position: absolute; left: 6%; bottom: 9%; font-size: 11px; letter-spacing: 0.24em; color: var(--muted-2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 999px; padding: 13px 24px; font-size: 14px; font-weight: 600;
  letter-spacing: 0.04em; transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s, background 0.22s, border-color 0.22s;
  border: 1px solid transparent; white-space: nowrap;
}
.btn i { font-style: normal; transition: transform 0.25s; }
.btn:hover i { transform: translateX(3px); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 52%, #b6862f);
  color: #171106; box-shadow: 0 10px 30px rgba(217, 164, 65, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn.primary:hover { box-shadow: 0 14px 38px rgba(217, 164, 65, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.6); transform: translateY(-1px); }
.btn.ghost { border-color: var(--line); color: var(--text); background: rgba(255, 255, 255, 0.02); }
.btn.ghost:hover { border-color: rgba(217, 164, 65, 0.42); background: rgba(217, 164, 65, 0.06); }
.btn.link { color: var(--muted); padding-left: 6px; padding-right: 6px; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--line); }
.btn.link:hover { color: var(--gold-2); }
.btn.sm { padding: 9px 14px; font-size: 12.5px; border-radius: 10px; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none !important; box-shadow: none; }

/* ---------- section head ---------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 10px 0 22px; flex-wrap: wrap; }
.section-head h2 { font-family: var(--serif); font-size: clamp(22px, 2.6vw, 30px); margin: 8px 0 0; letter-spacing: 0.04em; }
.section-head p { color: var(--muted-2); font-size: 12px; letter-spacing: 0.12em; margin: 0; }

/* ---------- game cards ---------- */
.game-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.game-card {
  position: relative; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  background: linear-gradient(180deg, rgba(23, 30, 26, 0.9), rgba(13, 18, 15, 0.94));
  border: 1px solid var(--line-soft); box-shadow: var(--shadow-md);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.3s, box-shadow 0.3s;
  display: flex; flex-direction: column;
}
.game-card:hover, .game-card:focus-visible { transform: translateY(-6px); border-color: rgba(217, 164, 65, 0.38); box-shadow: 0 26px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(217, 164, 65, 0.12); outline: none; }
.card-art { position: relative; height: 172px; overflow: hidden; background: radial-gradient(120% 120% at 60% 0%, #202a21 0%, #0c110e 70%); }
.card-art canvas { width: 100%; height: 100%; display: block; opacity: 0.92; transition: transform 0.5s; }
.game-card:hover .card-art canvas { transform: scale(1.045); }
.card-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 55%, rgba(13, 18, 15, 0.92)); }
.art-tag {
  position: absolute; left: 16px; bottom: 14px; z-index: 2; font-size: 10px; letter-spacing: 0.2em;
  color: var(--gold-2); padding: 4px 9px; border: 1px solid rgba(217, 164, 65, 0.3); border-radius: 999px;
  background: rgba(8, 11, 9, 0.6); backdrop-filter: blur(6px);
}
.card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tag { font-size: 9.5px; letter-spacing: 0.24em; color: var(--gold); font-weight: 700; }
.card-body h3 { font-family: var(--serif); font-size: 22px; margin: 0; letter-spacing: 0.08em; }
.card-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: 7px; }
.card-meta span { font-size: 10.5px; color: var(--muted-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 3px 8px; }
.card-cta { margin-top: 6px; font-size: 12.5px; color: var(--gold-2); letter-spacing: 0.08em; display: flex; align-items: center; gap: 8px; }
.card-cta i { font-style: normal; transition: transform 0.25s; }
.game-card:hover .card-cta i { transform: translateX(4px); }

.mcp-card { background: linear-gradient(160deg, rgba(18, 34, 30, 0.95), rgba(10, 16, 13, 0.98)); border-color: rgba(55, 201, 169, 0.18); }
.mcp-card:hover { border-color: rgba(55, 201, 169, 0.45); }
.mcp-glyph {
  height: 172px; display: grid; place-items: center; font-family: var(--mono); font-size: 62px;
  color: var(--jade-2); background: radial-gradient(circle at 50% 45%, rgba(55, 201, 169, 0.16), transparent 62%);
  text-shadow: 0 0 40px rgba(55, 201, 169, 0.45); position: relative;
}
.mcp-glyph::before { content: ""; position: absolute; width: 130px; height: 130px; border: 1px dashed rgba(55, 201, 169, 0.28); border-radius: 50%; animation: spin 24s linear infinite; }
.endpoint-inline { display: block; font-size: 11.5px; color: var(--jade-2); background: rgba(55, 201, 169, 0.08); border: 1px solid rgba(55, 201, 169, 0.16); border-radius: 7px; padding: 7px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- feature strip ---------- */
.feature-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 26px; }
.feature { padding: 18px; border-radius: 14px; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.016); }
.feature .f-ico { color: var(--gold); font-size: 17px; }
.feature b { display: block; margin: 8px 0 5px; font-size: 13.5px; letter-spacing: 0.06em; }
.feature p { margin: 0; font-size: 11.5px; color: var(--muted-2); line-height: 1.65; }
.lobby-foot { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 34px 0 8px; color: var(--muted-2); font-size: 10.5px; letter-spacing: 0.14em; flex-wrap: wrap; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--gold-dim); }

/* ---------- game view ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 22px; padding-top: 18px; align-items: start; }
.game-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding: 10px 0 6px; }
.back-btn { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line-soft); transition: all 0.22s; }
.back-btn:hover { color: var(--gold-2); border-color: var(--line); }
.game-title { display: flex; flex-direction: column; line-height: 1.2; }
.game-title b { font-family: var(--serif); font-size: 21px; letter-spacing: 0.1em; }
.game-title span { font-size: 9.5px; letter-spacing: 0.22em; color: var(--muted-2); }
.head-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 10.5px; letter-spacing: 0.1em; color: var(--muted); border: 1px solid var(--line-soft); border-radius: 999px; padding: 6px 12px; }
.pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 8px var(--jade); }
.pill.edge i { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.pill.llm i { background: var(--red-2); box-shadow: 0 0 8px var(--red-2); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-soft); color: var(--muted); display: grid; place-items: center; font-size: 14px; transition: all 0.2s; }
.icon-btn:hover { color: var(--gold-2); border-color: var(--line); }

.board-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 0; }
.board-frame {
  position: relative; width: min(100%, 700px); aspect-ratio: 1 / 1;
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(217, 164, 65, 0.22);
  background: #17120c; isolation: isolate; touch-action: manipulation;
}
.board-frame.is-chess { aspect-ratio: 9 / 10; width: min(100%, 620px); }
.board-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fxCanvas { pointer-events: none; z-index: 3; }
.board-shine { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(120% 90% at 30% 0%, rgba(255, 255, 255, 0.08), transparent 55%); mix-blend-mode: screen; }
.board-frame::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 0 60px rgba(0, 0, 0, 0.35); pointer-events: none; z-index: 4; }

.thinking {
  position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 14px); z-index: 5;
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 999px;
  background: rgba(8, 11, 9, 0.82); border: 1px solid rgba(55, 201, 169, 0.3);
  backdrop-filter: blur(10px); color: var(--jade-2); font-size: 11.5px; letter-spacing: 0.12em;
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s;
}
.thinking.show { opacity: 1; transform: translate(-50%, 0); }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--jade); animation: blink 1.1s infinite; }
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.board-toast {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.9); z-index: 6;
  font-family: var(--serif); font-size: clamp(30px, 6vw, 54px); font-weight: 700; letter-spacing: 0.18em;
  color: var(--gold-2); text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8), 0 0 40px rgba(217, 164, 65, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.35s, transform 0.45s cubic-bezier(0.2, 1.4, 0.3, 1);
  white-space: nowrap;
}
.board-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.board-toast.danger { color: var(--red-2); text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8), 0 0 40px rgba(192, 57, 43, 0.6); }

.turnbar {
  width: min(100%, 700px); display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.02);
}
.board-frame.is-chess + .turnbar { width: min(100%, 620px); }
.turn-side { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.turn-side .dot { width: 12px; height: 12px; border-radius: 50%; background: #202020; border: 1px solid rgba(255, 255, 255, 0.25); box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.18); }
.turn-side .dot.white { background: #efece2; }
.turn-side .dot.red { background: radial-gradient(circle at 35% 30%, #e05a45, #a3261c); border-color: rgba(255, 120, 100, 0.5); }
.turn-side .dot.ai { box-shadow: 0 0 0 3px rgba(55, 201, 169, 0.18); }
.turn-info { font-size: 11.5px; color: var(--muted-2); letter-spacing: 0.08em; }

/* ---------- side panel ---------- */
.panel { display: flex; flex-direction: column; gap: 14px; }
.panel-block { border: 1px solid var(--line-soft); border-radius: 14px; background: var(--panel); padding: 16px; backdrop-filter: blur(12px); }
.panel-block h4 { margin: 0 0 12px; font-size: 11px; letter-spacing: 0.2em; color: var(--muted-2); font-weight: 600; text-transform: uppercase; display: flex; align-items: center; justify-content: space-between; }
.panel-block h4 .mini { font-size: 10px; color: var(--gold); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; letter-spacing: 0.06em; }
.panel-block h4 .mini:hover { background: rgba(217, 164, 65, 0.1); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field span { font-size: 11px; color: var(--muted-2); letter-spacing: 0.08em; }
.field select {
  appearance: none; -webkit-appearance: none; width: 100%; border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03); border-radius: 9px; padding: 10px 32px 10px 12px; font-size: 12.5px; color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d9a441' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  transition: border-color 0.2s;
}
.field select:focus { outline: none; border-color: rgba(217, 164, 65, 0.45); }
.field select option { background: #121815; color: var(--text); }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-top: 4px; }
.panel-actions .btn { padding-left: 8px; padding-right: 8px; }
.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-grid div { text-align: center; padding: 9px 4px; border-radius: 9px; background: rgba(255, 255, 255, 0.022); border: 1px solid var(--line-soft); }
.status-grid span { display: block; font-size: 9.5px; color: var(--muted-2); letter-spacing: 0.1em; margin-bottom: 3px; }
.status-grid b { font-size: 14px; font-weight: 600; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.captured { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 10px; min-height: 22px; }
.captured span { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-size: 11px; background: #e7dcc3; color: #17120c; border: 1px solid rgba(0, 0, 0, 0.2); }
.captured span.black { background: #1b1b1b; color: #e7dcc3; }
.captured span.red { background: #a3261c; color: #f4e6c8; }

.record-block { flex: 1; }
.record { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.record li { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 4px; font-size: 12px; padding: 5px 6px; border-radius: 6px; color: var(--muted); }
.record li:nth-child(odd) { background: rgba(255, 255, 255, 0.02); }
.record li .rn { color: var(--muted-2); font-size: 10px; }
.record li .mv { color: var(--text); }
.record li .mv.ai { color: var(--jade); }
.record li .mv.latest { color: var(--gold-2); font-weight: 600; }
.record li.empty { display: block; color: var(--muted-2); font-size: 11.5px; text-align: center; padding: 18px 0; background: none; }
.record::-webkit-scrollbar { width: 4px; }
.record::-webkit-scrollbar-thumb { background: rgba(217, 164, 65, 0.25); border-radius: 4px; }

.mcp-mini code { display: block; font-size: 10.5px; color: var(--jade-2); background: rgba(55, 201, 169, 0.07); border: 1px solid rgba(55, 201, 169, 0.15); border-radius: 7px; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcp-mini .row { display: flex; gap: 7px; margin-top: 8px; }
.mcp-mini .row .btn { flex: 1; }
.hint { font-size: 10.5px; color: var(--muted-2); line-height: 1.6; margin: 9px 0 0; }
.hint b { color: var(--jade); font-weight: 500; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 4, 0.72); backdrop-filter: blur(8px); animation: fadeIn 0.3s both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #141a16, #0d120f); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px; box-shadow: var(--shadow-lg);
  animation: modalIn 0.4s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
.modal-card.wide { width: min(880px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-card h3 { font-family: var(--serif); font-size: 25px; margin: 10px 0 8px; letter-spacing: 0.06em; }
.modal-card h4 { font-size: 11px; letter-spacing: 0.18em; color: var(--muted-2); margin: 22px 0 10px; text-transform: uppercase; }
.modal-lead { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.modal-close { position: absolute; right: 16px; top: 16px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-soft); color: var(--muted); display: grid; place-items: center; font-size: 12px; }
.modal-close:hover { color: var(--gold-2); border-color: var(--line); }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row code { flex: 1; font-size: 12px; color: var(--jade-2); background: rgba(55, 201, 169, 0.07); border: 1px solid rgba(55, 201, 169, 0.18); border-radius: 9px; padding: 11px 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.code-block { background: #080c0a; border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; font-size: 11.5px; line-height: 1.7; color: #cfe6dc; overflow-x: auto; margin: 0; }
.tool-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tool-list li { display: flex; align-items: baseline; gap: 10px; font-size: 11.5px; padding: 7px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.022); border: 1px solid var(--line-soft); }
.tool-list code { color: var(--gold-2); font-size: 11px; min-width: 148px; }
.tool-list span { color: var(--muted-2); font-size: 10.5px; }
.note-box { margin-top: 16px; padding: 13px 15px; border-radius: 10px; border: 1px solid rgba(217, 164, 65, 0.2); background: rgba(217, 164, 65, 0.05); font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.note-box b { color: var(--gold-2); }
.note-box code { color: var(--jade-2); background: rgba(55, 201, 169, 0.08); padding: 1px 5px; border-radius: 4px; }
.note-box.subtle { border-color: var(--line-soft); background: rgba(255, 255, 255, 0.02); margin-top: 10px; }
.note-box.subtle b { color: var(--text); }

/* ---------- result ---------- */
.result-card { text-align: center; width: min(440px, 100%); }
.result-emblem {
  width: 92px; height: 92px; margin: 4px auto 14px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--serif); font-size: 40px; font-weight: 700; color: #171106;
  background: linear-gradient(150deg, var(--gold-2), var(--gold) 60%, #a97a22);
  box-shadow: 0 14px 40px rgba(217, 164, 65, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.result-emblem.lose { background: linear-gradient(150deg, #5b6a62, #2f3a34); color: #d8d2c2; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); }
.result-emblem.draw { background: linear-gradient(150deg, #cfd6d0, #8e9a91); color: #1a201c; }
.result-card h3 { font-size: 29px; margin: 4px 0 6px; }
.result-card p { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.result-stats div { padding: 11px 6px; border-radius: 10px; background: rgba(255, 255, 255, 0.025); border: 1px solid var(--line-soft); }
.result-stats span { display: block; font-size: 9.5px; color: var(--muted-2); letter-spacing: 0.12em; margin-bottom: 3px; }
.result-stats b { font-size: 16px; color: var(--gold-2); font-family: var(--serif); }
.result-actions { display: flex; gap: 10px; justify-content: center; }
.result-actions .btn { flex: 1; max-width: 170px; }

/* ---------- toast / confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); z-index: 120;
  padding: 11px 20px; border-radius: 10px; background: rgba(15, 21, 17, 0.95); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text); box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity 0.28s, transform 0.28s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 110; overflow: hidden; }
.confetti { position: absolute; width: 8px; height: 13px; border-radius: 2px; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0% { transform: translateY(-8vh) rotate(0); opacity: 1; } 100% { transform: translateY(105vh) rotate(720deg); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .game-cards { grid-template-columns: 1fr 1fr; }
  .mcp-card { grid-column: span 2; }
  .feature-strip { grid-template-columns: 1fr 1fr; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-visual { order: -1; max-width: 380px; margin: 0 auto; width: 100%; min-height: 0; }
  .hero-copy { text-align: left; }
  .game-layout { grid-template-columns: 1fr; }
  .game-head { grid-column: auto; }
  .panel { order: 2; }
  .board-frame, .board-frame.is-chess { width: min(100%, 620px); margin: 0 auto; }
  .turnbar, .board-frame.is-chess + .turnbar { margin: 0 auto; }
  .panel-block.record-block { max-height: none; }
  .modal-grid { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { height: 62px; }
  .brand-text small { display: none; }
  .brand-mark { width: 34px; height: 34px; font-size: 19px; }
  .hero { padding-top: 18px; }
  .hero-copy h1 { font-size: clamp(34px, 10vw, 46px); }
  .hero-stats { gap: 18px; flex-wrap: wrap; }
  .hero-stats b { font-size: 19px; }
  .game-cards { grid-template-columns: 1fr; }
  .mcp-card { grid-column: auto; }
  .card-art, .mcp-glyph { height: 140px; }
  .feature-strip { grid-template-columns: 1fr; }
  .game-layout { gap: 14px; }
  .game-head { gap: 10px; flex-wrap: wrap; }
  .game-title b { font-size: 18px; }
  .back-btn span { display: none; }
  .panel-block { padding: 14px; }
  .panel-actions { grid-template-columns: 1fr 1fr; }
  .panel-actions #resignBtn { grid-column: span 2; }
  .modal-card { padding: 22px 18px; border-radius: 16px; }
  .modal-card h3 { font-size: 21px; }
  .copy-row { flex-direction: column; }
  .tool-list li { align-items: flex-start; flex-direction: column; gap: 2px; }
  .tool-list code { min-width: 0; }
  .result-emblem { width: 76px; height: 76px; font-size: 32px; }
  .record { max-height: 140px; }
  .turnbar { padding: 9px 12px; }
}
@media (max-height: 820px) and (min-width: 901px) {
  .board-frame { width: min(100%, 590px); }
  .board-frame.is-chess { width: min(100%, 540px); }
  .turnbar, .board-frame.is-chess + .turnbar { width: min(100%, 590px); }
}

/* ---------- live rooms ---------- */
#roomModal .modal-card { width: min(720px, 100%); }
.room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.room-panel { padding: 16px; border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(255, 255, 255, 0.02); }
.room-panel h4 { margin: 0 0 12px; }
.room-panel .field { margin-bottom: 10px; }
.room-panel input {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  background: rgba(5, 8, 7, 0.72); border: 1px solid var(--line-soft);
  color: var(--text); font-family: var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
}
.room-panel input:focus { outline: none; border-color: rgba(217, 164, 65, 0.55); }
.room-panel .btn { width: 100%; justify-content: center; }
.room-active {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-top: 16px; padding: 18px; text-align: center;
  border: 1px solid rgba(217, 164, 65, 0.26); border-radius: 14px;
  background: radial-gradient(80% 90% at 50% 0%, rgba(217, 164, 65, 0.08), transparent 70%);
}
.room-active[hidden] { display: none; }
.room-code-label { font-size: 10px; letter-spacing: 0.2em; color: var(--muted-2); }
.room-code { font-family: var(--mono); font-size: 30px; letter-spacing: 0.26em; color: var(--gold-2); }
.room-hint { font-size: 13px; color: var(--muted); }
.storage-warn {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.6; color: #f0c36d;
  background: rgba(217, 164, 65, 0.1); border: 1px solid rgba(217, 164, 65, 0.28);
}
.storage-warn code { color: var(--gold-2); }
.storage-warn[hidden] { display: none; }
.room-error { min-height: 18px; margin: 10px 0 0; font-size: 12.5px; color: var(--red-2); text-align: center; }
.room-book { margin-top: 16px; }
.room-book-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.room-book-head h4 { margin: 0; }
.room-book ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 170px; overflow-y: auto;
}
.room-book li {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.room-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.room-info code { font-size: 14px; letter-spacing: 0.12em; color: var(--gold-2); }
.room-info span { font-size: 12px; color: var(--muted); }
.room-ops { display: flex; align-items: center; gap: 6px; }
.room-book li.is-missing { opacity: 0.62; }
.room-book li.is-missing .room-info span { color: var(--red-2); }
.room-del.confirm {
  color: #fff; background: rgba(192, 57, 43, 0.85);
  border-color: transparent;
}
.room-del.confirm:hover { background: rgba(192, 57, 43, 1); }
.room-badge {
  margin-left: auto; padding: 2px 9px; border-radius: 999px;
  border: 1px solid rgba(217, 164, 65, 0.28); color: var(--gold);
  font-size: 11px; letter-spacing: 0.04em; white-space: nowrap;
}
@media (max-width: 640px) {
  .room-grid { grid-template-columns: 1fr; }
  .room-badge { display: none; }
}

/* ---------- access gate ---------- */
.gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; animation: gateIn 0.35s ease both; }
.gate[hidden] { display: none; }
.gate-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(90% 70% at 50% 20%, rgba(20, 28, 24, 0.94), rgba(4, 6, 5, 0.98));
  backdrop-filter: blur(18px) saturate(0.8);
  -webkit-backdrop-filter: blur(18px) saturate(0.8);
}
.gate-card {
  position: relative; width: min(420px, 100%); padding: 34px 30px 26px;
  border-radius: 22px; border: 1px solid rgba(217, 164, 65, 0.3);
  background: linear-gradient(160deg, rgba(24, 32, 27, 0.97), rgba(12, 16, 14, 0.99));
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: center; overflow: hidden;
}
.gate-card::before {
  content: ''; position: absolute; inset: -1px; border-radius: 22px; pointer-events: none;
  background: radial-gradient(60% 40% at 50% 0%, rgba(217, 164, 65, 0.16), transparent 70%);
}
.gate-seal {
  position: relative; width: 66px; height: 66px; margin: 0 auto 14px;
  display: grid; place-items: center; border-radius: 50%;
  font-family: var(--serif); font-size: 30px; color: #0b0f0e;
  background: radial-gradient(circle at 35% 28%, var(--gold-2), var(--gold) 55%, var(--gold-dim));
  box-shadow: 0 0 0 6px rgba(217, 164, 65, 0.08), 0 12px 30px rgba(217, 164, 65, 0.22);
}
.gate-card .eyebrow { justify-content: center; font-size: 10px; letter-spacing: 0.22em; color: var(--gold); }
.gate-card h2 { margin: 6px 0 8px; font-family: var(--serif); font-size: 28px; letter-spacing: 0.08em; }
.gate-lead { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.gate-lead code { color: var(--gold-2); font-size: 12px; }
.gate-field { display: block; text-align: left; margin-bottom: 12px; }
.gate-field span { display: block; margin-bottom: 6px; font-size: 11px; letter-spacing: 0.14em; color: var(--muted-2); }
.gate-field input {
  width: 100%; padding: 13px 15px; border-radius: 12px;
  background: rgba(5, 8, 7, 0.75); border: 1px solid var(--line-soft);
  color: var(--text); letter-spacing: 0.08em;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gate-field input:focus { outline: none; border-color: rgba(217, 164, 65, 0.6); box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.12); }
.gate-remember { display: flex; align-items: center; gap: 8px; margin: 0 0 18px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.gate-remember input { accent-color: var(--gold); }
.gate-submit { width: 100%; justify-content: center; }
.gate-submit.is-busy { opacity: 0.7; pointer-events: none; }
.gate-error { min-height: 20px; margin: 10px 0 0; font-size: 12.5px; color: var(--red-2); opacity: 0; transition: opacity 0.2s; }
.gate-error.show { opacity: 1; }
.gate-foot { margin: 18px 0 0; font-size: 11px; color: var(--muted-2); }
.gate.shake .gate-card { animation: gateShake 0.4s ease; }
body.gate-locked { overflow: hidden; }
.access-note .btn { margin-left: 6px; vertical-align: middle; }
@keyframes gateIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes gateShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

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

/* ---------- grid board games ---------- */
.board-mount {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; padding: 12px;
}
.board-mount[hidden] { display: none; }
.board-frame.is-grid { aspect-ratio: 1; }
.grid-board {
  display: grid; gap: 6px; width: min(94%, 560px); padding: 10px;
  border-radius: 16px; background: rgba(10, 16, 13, 0.62);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.28);
}
.grid-tictactoe { aspect-ratio: 1; }
.grid-connect4 { aspect-ratio: 7 / 6; background: linear-gradient(180deg, #16324a, #0e2233); }
.grid-othello { aspect-ratio: 1; background: #14503a; }
.gcell {
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(255, 255, 255, 0.04);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}
.grid-connect4 .gcell { border-radius: 50%; background: rgba(0, 0, 0, 0.24); }
.gcell.playable { cursor: pointer; box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.45); }
.gcell.playable:hover { background: rgba(217, 164, 65, 0.14); }
.disc { width: 78%; aspect-ratio: 1; border-radius: 50%; display: block; }
.disc.p1 { background: radial-gradient(circle at 35% 30%, #ff8a7a, #c0392b); }
.disc.p2 { background: radial-gradient(circle at 35% 30%, #ffe08a, #e0a800); }
.grid-othello .disc.p1 { background: radial-gradient(circle at 35% 30%, #5a6a75, #101619); }
.grid-othello .disc.p2 { background: radial-gradient(circle at 35% 30%, #ffffff, #cfd8dc); }
.mark { font-family: var(--serif); font-size: clamp(26px, 6vw, 58px); line-height: 1; }
.mark.p1 { color: #f0c36d; }
.mark.p2 { color: #9fd8c0; }
.hint-dot { width: 22%; aspect-ratio: 1; border-radius: 50%; background: rgba(217, 164, 65, 0.55); }
.pop { animation: cellPop 0.28s ease; }
@keyframes cellPop {
  from { transform: scale(0.4); opacity: 0.3; }
  to { transform: scale(1); opacity: 1; }
}

/* lobby cards for the new games */
.tt-art, .c4-art, .oth-art { display: grid; place-items: center; }
.mini-grid { display: grid; gap: 4px; }
.mini-3 { grid-template-columns: repeat(3, 34px); grid-auto-rows: 34px; }
.mini-7 { grid-template-columns: repeat(7, 16px); grid-auto-rows: 16px; }
.mini-8 { grid-template-columns: repeat(8, 15px); grid-auto-rows: 15px; }
.mini-grid span {
  background: rgba(255, 255, 255, 0.06); border-radius: 4px;
  display: grid; place-items: center; color: var(--gold-2);
  font-family: var(--serif); font-size: 22px;
}
.mini-7 span, .mini-8 span { font-size: 10px; }
.mini-grid .r { background: #c0392b; border-radius: 50%; }
.mini-grid .y { background: #e0a800; border-radius: 50%; }
.mini-grid .b { background: #101619; border-radius: 50%; }
.mini-grid .w { background: #e8eef0; border-radius: 50%; }
