/* ============================================================
   超级九宫格 · 在线对战
   ============================================================ */

:root {
  --bg: #0a1311;
  --bg-2: #0f1d19;
  --bg-3: #142721;
  --panel: rgba(246, 238, 218, 0.055);
  --panel-strong: rgba(246, 238, 218, 0.085);
  --line: rgba(238, 227, 199, 0.14);
  --line-strong: rgba(238, 227, 199, 0.24);
  --cream: #f4ecd9;
  --cream-2: #e5d9bd;
  --muted: #a9a48f;
  --muted-2: #7e8272;
  --gold: #e3b45f;
  --gold-2: #f4d18c;
  --gold-deep: #b98535;
  --x: #e2604b;
  --x-2: #ff8a6f;
  --o: #74aee8;
  --o-2: #a5ccf5;
  --danger: #d9594b;
  --ok: #6fc08a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    radial-gradient(1100px 700px at 82% -10%, rgba(64, 105, 84, 0.30), transparent 62%),
    radial-gradient(900px 600px at -8% 35%, rgba(120, 85, 37, 0.18), transparent 60%),
    linear-gradient(160deg, #08100e 0%, #0b1714 45%, #091210 100%);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(244, 236, 217, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 236, 217, 0.025) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse at 50% 20%, #000 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 20%, #000 10%, transparent 75%);
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}
.bg-glow-a { width: 440px; height: 440px; right: -120px; top: 120px; background: rgba(33, 91, 74, 0.5); }
.bg-glow-b { width: 380px; height: 380px; left: -140px; bottom: -80px; background: rgba(150, 105, 43, 0.25); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
::selection { background: rgba(227, 180, 95, 0.35); }

/* ------------------------------------------------------------ 顶栏 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: rgba(8, 16, 14, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(238, 227, 199, 0.08);
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  width: 28px; height: 28px;
  padding: 5px;
  border: 1px solid rgba(227, 180, 95, 0.55);
  border-radius: 7px;
  background: rgba(227, 180, 95, 0.08);
}
.brand-mark i { background: rgba(227, 180, 95, 0.55); border-radius: 1px; }
.brand-mark i:nth-child(5) { background: var(--gold); box-shadow: 0 0 8px rgba(227, 180, 95, 0.8); }
.brand-text { font-family: var(--serif); font-size: 19px; letter-spacing: 0.06em; white-space: nowrap; }
.brand-text em {
  font-family: var(--sans);
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--gold);
  margin-left: 10px;
  vertical-align: middle;
  opacity: 0.85;
}
.header-nav { display: flex; align-items: center; gap: 10px; }

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--cream-2);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  letter-spacing: 0.04em;
  transition: 0.2s ease;
}
.ghost-btn:hover { border-color: var(--gold); color: var(--gold-2); background: rgba(227, 180, 95, 0.06); }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream-2);
  transition: 0.2s ease;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold-2); }
.sound-wave { transition: opacity 0.2s; }
body.sound-off .sound-wave { opacity: 0.12; }

.conn-dot {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; letter-spacing: 0.12em;
  color: var(--muted);
  padding-left: 4px;
}
.conn-dot i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px rgba(111, 192, 138, 0.8); }
.conn-dot.offline i { background: var(--danger); box-shadow: 0 0 8px rgba(217, 89, 75, 0.8); }
.conn-dot.offline span { color: var(--danger); }

/* ------------------------------------------------------------ 通用 */
.app-main { position: relative; z-index: 1; }
.screen { display: none; }
.screen.active { display: block; animation: screenIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 9px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}
.eyebrow span { width: 26px; height: 1px; background: var(--gold); opacity: 0.7; }

.muted { color: var(--muted); font-size: 12px; }

.primary-btn, .secondary-btn, .danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.primary-btn {
  color: #1b1407;
  border: 1px solid rgba(255, 224, 164, 0.55);
  background: linear-gradient(135deg, #f4d18c, #dfa84e 60%, #c78f38);
  box-shadow: 0 10px 26px rgba(188, 132, 47, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(188, 132, 47, 0.34); }
.primary-btn:active { transform: translateY(0); }
.secondary-btn {
  color: var(--cream);
  border: 1px solid var(--line-strong);
  background: rgba(244, 236, 217, 0.04);
}
.secondary-btn:hover { border-color: var(--gold); background: rgba(227, 180, 95, 0.08); transform: translateY(-1px); }
.secondary-btn.small { width: auto; padding: 8px 16px; font-size: 12px; }
.danger-btn { color: #fff1ec; border: 1px solid rgba(217, 89, 75, 0.6); background: rgba(217, 89, 75, 0.16); }
.danger-btn:hover { background: rgba(217, 89, 75, 0.28); }

.primary-btn:disabled, .secondary-btn:disabled {
  opacity: 0.38;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

.text-btn {
  border: 0; background: none; color: var(--gold);
  font-size: 13px; letter-spacing: 0.04em;
  padding: 4px 0;
  border-bottom: 1px solid rgba(227, 180, 95, 0.35);
}
.text-btn:hover { color: var(--gold-2); border-color: var(--gold-2); }

/* ------------------------------------------------------------ 首页 */
.home-wrap { max-width: 1180px; margin: 0 auto; padding: clamp(28px, 5vw, 62px) clamp(18px, 4vw, 44px) 40px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: clamp(24px, 5vw, 70px);
  align-items: center;
  min-height: 340px;
  margin-bottom: clamp(26px, 4vw, 40px);
}
.hero-copy h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(52px, 7.6vw, 92px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  margin: 0 0 22px;
}
.hero-copy h1 strong {
  color: var(--gold-2);
  font-weight: 600;
  position: relative;
}
.hero-copy h1 strong::after {
  content: "";
  position: absolute;
  left: 2%; right: 2%; bottom: 4px;
  height: 10px;
  background: linear-gradient(90deg, rgba(227, 180, 95, 0.34), rgba(227, 180, 95, 0));
  border-radius: 50%;
  z-index: -1;
}
.hero-sub { color: var(--muted); font-size: 15px; line-height: 1.95; margin: 0 0 24px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 9px; }
.hero-tags span {
  font-size: 11px; letter-spacing: 0.1em;
  color: var(--cream-2);
  border: 1px solid var(--line);
  background: rgba(244, 236, 217, 0.03);
  border-radius: 999px;
  padding: 6px 13px;
}

.hero-art { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hero-board {
  width: min(340px, 100%);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  padding: 12px;
  background: linear-gradient(145deg, #1c2d27, #101d19);
  border: 1px solid rgba(227, 180, 95, 0.22);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: rotate(-2.5deg);
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hero-board:hover { transform: rotate(0deg) translateY(-4px); }
.hb-sub {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 2px;
  background: rgba(244, 236, 217, 0.06);
  border: 1px solid rgba(244, 236, 217, 0.08);
  border-radius: 10px;
  overflow: hidden;
}
.hb-sub.owned { background: rgba(226, 96, 75, 0.14); border-color: rgba(226, 96, 75, 0.45); }
.hb-sub.owned b { position: absolute; top: 3px; right: 5px; font-family: var(--serif); color: var(--x); font-size: 12px; }
.hb-sub.focus { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 30px rgba(227, 180, 95, 0.28); background: rgba(227, 180, 95, 0.10); }
.hb-mark { font-family: var(--serif); font-size: clamp(22px, 3.2vw, 34px); line-height: 1; opacity: 0.9; }
.hb-mark.x { color: var(--x-2); }
.hb-mark.o { color: var(--o-2); }
.hb-sub.focus .hb-mark { transform: scale(1.1); }
.hb-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); position: absolute; opacity: 0.55; }
.hb-dot:nth-of-type(1) { top: 16%; left: 20%; }
.hb-dot:nth-of-type(2) { bottom: 18%; right: 22%; }
.hero-caption {
  margin-top: 18px;
  display: flex; align-items: center; gap: 9px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.hero-caption i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px rgba(227, 180, 95, 0.7); }

.nick-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.nick-row > label { font-size: 12px; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.nick-input { flex: 1; display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.nick-input input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  outline: none;
  font-family: var(--serif);
  font-size: 19px;
  color: var(--cream);
  padding: 2px 0 4px;
  transition: border-color 0.2s;
}
.nick-input input::placeholder { color: rgba(169, 164, 143, 0.55); }
.nick-input input:focus { border-color: var(--gold); }
#nickHint { font-size: 11px; color: var(--muted-2); white-space: nowrap; }

.action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.action-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 20px 20px;
  background: linear-gradient(160deg, rgba(246, 238, 218, 0.075), rgba(246, 238, 218, 0.035));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
  overflow: hidden;
}
.action-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(227, 180, 95, 0.55), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}
.action-card:hover { transform: translateY(-4px); border-color: rgba(227, 180, 95, 0.28); background: linear-gradient(160deg, rgba(246, 238, 218, 0.09), rgba(246, 238, 218, 0.04)); }
.action-card:hover::before { opacity: 1; }
.card-create { border-top-color: rgba(226, 96, 75, 0.4); }
.card-join { border-top-color: rgba(116, 174, 232, 0.4); }
.card-solo { border-top-color: rgba(227, 180, 95, 0.4); }
.card-top { display: flex; gap: 13px; align-items: flex-start; }
.card-icon {
  flex: none;
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(244, 236, 217, 0.05);
  color: var(--gold-2);
}
.card-icon svg { width: 20px; height: 20px; }
.card-top h2 { font-family: var(--serif); font-weight: 600; font-size: 21px; margin: 0 0 2px; letter-spacing: 0.03em; }
.card-top p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 11px; letter-spacing: 0.13em; color: var(--muted); }
.field input {
  width: 100%;
  background: rgba(8, 16, 14, 0.45);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
  color: var(--cream);
  transition: border-color 0.2s, background 0.2s;
}
.field input:focus { border-color: var(--gold); background: rgba(8, 16, 14, 0.65); }
.field input::placeholder { color: rgba(169, 164, 143, 0.5); }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 52px; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted);
  font-size: 11px; padding: 5px 7px; border-radius: 5px;
}
.eye:hover { color: var(--gold); }

.segmented { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: rgba(8, 16, 14, 0.3); }
.segmented button {
  flex: 1;
  border: 0; background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 7px 4px;
  border-radius: 6px;
  transition: 0.18s;
  white-space: nowrap;
}
.segmented button:hover { color: var(--cream); }
.segmented button.on { background: rgba(227, 180, 95, 0.15); color: var(--gold-2); box-shadow: inset 0 0 0 1px rgba(227, 180, 95, 0.25); }

.code-input {
  font-family: var(--mono) !important;
  font-size: 18px !important;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.level-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.level-list button {
  display: flex; flex-direction: column; gap: 1px; align-items: center;
  padding: 8px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 16, 14, 0.3);
  color: var(--muted);
  transition: 0.18s;
}
.level-list button b { font-size: 12px; font-weight: 600; color: var(--cream-2); }
.level-list button small { font-size: 9px; letter-spacing: 0.02em; }
.level-list button:hover { border-color: rgba(227, 180, 95, 0.4); }
.level-list button.on { border-color: var(--gold); background: rgba(227, 180, 95, 0.13); }
.level-list button.on b { color: var(--gold-2); }

.model-note { margin: -4px 0 0; font-size: 10px; color: var(--muted-2); text-align: center; letter-spacing: 0.03em; }

.rule-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.rule-strip-item { display: flex; gap: 11px; align-items: flex-start; }
.rule-strip-item b { font-family: var(--serif); font-size: 12px; color: var(--gold); padding-top: 1px; }
.rule-strip-item span { font-size: 11px; line-height: 1.6; color: var(--muted); }
.rule-strip-item strong { display: block; color: var(--cream-2); font-weight: 500; font-size: 12px; }
.home-footer { margin-top: 30px; text-align: center; font-size: 10px; letter-spacing: 0.08em; color: var(--muted-2); }

/* ------------------------------------------------------------ 房间等待 */
.lobby-wrap { max-width: 1080px; margin: 0 auto; padding: clamp(30px, 5vw, 56px) clamp(18px, 4vw, 40px) 50px; }
.lobby-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; flex-wrap: wrap; }
.room-code-row { display: flex; align-items: center; gap: 16px; }
.room-code-row h2 { font-family: var(--mono); font-size: clamp(38px, 6vw, 58px); letter-spacing: 0.16em; margin: 0; line-height: 1; color: var(--gold-2); text-shadow: 0 0 40px rgba(227, 180, 95, 0.22); }
.copy-mini {
  border: 1px solid var(--line); background: rgba(244, 236, 217, 0.04);
  color: var(--muted); border-radius: 7px; font-size: 11px; padding: 4px 10px;
}
.copy-mini:hover { color: var(--gold); border-color: var(--gold); }
.lobby-head-actions { display: flex; align-items: center; gap: 10px; }

.lobby-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr); gap: 18px; align-items: start; }
.lobby-main { display: flex; flex-direction: column; gap: 14px; }
.invite-panel {
  display: grid;
  grid-template-columns: 0.7fr 0.7fr 1.6fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}
.invite-item { background: rgba(11, 22, 19, 0.78); padding: 12px 15px; display: flex; flex-direction: column; gap: 2px; }
.invite-item span { font-size: 10px; letter-spacing: 0.14em; color: var(--muted-2); }
.invite-item b { font-size: 14px; font-weight: 500; color: var(--cream-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-item.link b { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seat {
  position: relative;
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(155deg, rgba(246, 238, 218, 0.06), rgba(246, 238, 218, 0.02));
  display: flex; gap: 14px; align-items: flex-start;
  transition: 0.2s;
}
.seat.empty { border-style: dashed; background: rgba(246, 238, 218, 0.015); align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--muted-2); }
.seat.empty .seat-avatar { border-style: dashed; color: var(--muted-2); background: transparent; }
.seat.x { border-color: rgba(226, 96, 75, 0.3); }
.seat.o { border-color: rgba(116, 174, 232, 0.3); }
.seat-avatar {
  flex: none;
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 16, 14, 0.35);
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
}
.seat.x .seat-avatar { color: var(--x-2); border-color: rgba(226, 96, 75, 0.4); background: rgba(226, 96, 75, 0.08); }
.seat.o .seat-avatar { color: var(--o-2); border-color: rgba(116, 174, 232, 0.4); background: rgba(116, 174, 232, 0.08); }
.seat-info { min-width: 0; flex: 1; }
.seat-name { font-family: var(--serif); font-size: 19px; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-sub { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.seat-tag { font-size: 9px; letter-spacing: 0.08em; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--muted); }
.seat-tag.host { color: var(--gold); border-color: rgba(227, 180, 95, 0.35); }
.seat-tag.you { color: var(--ok); border-color: rgba(111, 192, 138, 0.35); }
.seat-status { margin-top: 14px; font-size: 11px; color: var(--muted-2); display: flex; align-items: center; gap: 6px; }
.seat-status .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.seat-status.off .dot { background: var(--danger); }
.seat.empty .empty-title { font-size: 13px; color: var(--cream-2); }
.seat.empty .empty-sub { font-size: 10px; letter-spacing: 0.06em; }
.empty-spinner { width: 22px; height: 22px; border: 1px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.lobby-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 4px 0; }
.lobby-actions .primary-btn { width: auto; min-width: 190px; padding: 12px 28px; }
.lobby-actions .secondary-btn { width: auto; padding: 11px 20px; }
.lobby-tip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; padding: 6px 2px; }
.lobby-tip p { margin: 0; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); position: relative; flex: none; }
.pulse-dot::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 1px solid var(--gold); animation: pulse 2s ease-out infinite; }
@keyframes pulse { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(1.8); opacity: 0; } }

/* ------------------------------------------------------------ 面板 / 聊天 */
.panel {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(155deg, rgba(246, 238, 218, 0.055), rgba(246, 238, 218, 0.018));
  overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px 0; }
.panel-head h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 14px; letter-spacing: 0.06em; }
.chat-panel { display: flex; flex-direction: column; min-height: 300px; max-height: 480px; }
.chat-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-list { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; scrollbar-width: thin; scrollbar-color: rgba(238, 227, 199, 0.2) transparent; }
.chat-list::-webkit-scrollbar { width: 5px; }
.chat-list::-webkit-scrollbar-thumb { background: rgba(238, 227, 199, 0.18); border-radius: 5px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted-2); font-size: 11px; line-height: 1.8; }
.chat-msg { display: flex; flex-direction: column; gap: 1px; max-width: 88%; }
.chat-msg .cm-name { font-size: 9px; letter-spacing: 0.06em; color: var(--muted-2); padding-left: 2px; }
.chat-msg .cm-bubble { background: rgba(244, 236, 218, 0.07); border: 1px solid rgba(244, 236, 218, 0.06); border-radius: 9px; padding: 6px 10px; font-size: 12px; line-height: 1.55; word-break: break-word; white-space: pre-wrap; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.mine .cm-bubble { background: rgba(227, 180, 95, 0.14); border-color: rgba(227, 180, 95, 0.22); }
.chat-msg.x .cm-bubble { border-left: 2px solid rgba(226, 96, 75, 0.6); }
.chat-msg.o .cm-bubble { border-left: 2px solid rgba(116, 174, 232, 0.6); }
.chat-sys { align-self: center; text-align: center; font-size: 10px; color: var(--muted-2); line-height: 1.6; padding: 2px 14px; max-width: 92%; }
.chat-sys b { color: var(--muted); font-weight: 500; }
.chat-form { display: flex; gap: 7px; padding: 9px 10px; border-top: 1px solid var(--line); background: rgba(8, 16, 14, 0.2); }
.chat-form input { flex: 1; min-width: 0; background: rgba(8, 16, 14, 0.5); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; outline: none; font-size: 12px; color: var(--cream); }
.chat-form input:focus { border-color: var(--gold); }
.chat-form input::placeholder { color: var(--muted-2); }
.chat-form button { flex: none; width: 34px; height: 34px; border: 1px solid rgba(227, 180, 95, 0.3); background: rgba(227, 180, 95, 0.12); color: var(--gold-2); border-radius: 8px; font-size: 17px; line-height: 1; }
.chat-form button:hover { background: rgba(227, 180, 95, 0.22); }
.collapse-btn { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 3px 6px; }
.game-chat.collapsed .chat-body { display: none; }
.game-chat.collapsed { min-height: 0; }

/* ------------------------------------------------------------ 对局 */
.game-wrap { max-width: 1260px; margin: 0 auto; padding: 18px clamp(14px, 3vw, 34px) 44px; }
.game-topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0 16px; }
.back-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--muted); font-size: 12px; padding: 4px 2px; }
.back-btn:hover { color: var(--cream); }
.back-btn svg { width: 16px; height: 16px; }
.game-room-chip { display: inline-flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 11px; background: rgba(244, 236, 217, 0.03); }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px rgba(111, 192, 138, 0.7); }
.game-room-chip b { font-family: var(--mono); letter-spacing: 0.14em; color: var(--cream-2); font-weight: 500; }
.game-room-chip em { font-style: normal; color: var(--muted-2); padding-left: 8px; border-left: 1px solid var(--line); }
.game-top-actions { display: flex; align-items: center; gap: 6px; }
.icon-text-btn { border: 1px solid transparent; background: none; color: var(--muted); font-size: 12px; border-radius: 7px; padding: 6px 10px; }
.icon-text-btn:hover { color: var(--cream); border-color: var(--line); background: rgba(244, 236, 217, 0.03); }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: clamp(18px, 3vw, 34px); align-items: start; }
.board-area { min-width: 0; display: flex; flex-direction: column; align-items: center; }

.turn-banner {
  width: min(100%, 660px);
  display: flex; align-items: center; gap: 13px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(120deg, rgba(246, 238, 218, 0.06), rgba(246, 238, 218, 0.02));
  margin-bottom: 13px;
  transition: border-color 0.3s, background 0.3s;
}
.turn-banner.your-turn { border-color: rgba(227, 180, 95, 0.5); background: linear-gradient(120deg, rgba(227, 180, 95, 0.12), rgba(227, 180, 95, 0.03)); }
.turn-banner.result-available { cursor: pointer; }
.turn-banner.result-available:hover { border-color: rgba(227, 180, 95, 0.45); }
.turn-symbol {
  flex: none; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  font-family: var(--serif); font-size: 22px; line-height: 1;
  border: 1px solid var(--line);
  background: rgba(8, 16, 14, 0.3);
}
.turn-banner.your-turn .turn-symbol { color: var(--gold-2); border-color: rgba(227, 180, 95, 0.5); }
.turn-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.turn-text b { font-size: 14px; font-weight: 500; letter-spacing: 0.03em; }
.turn-text span { font-size: 11px; color: var(--muted); }
.turn-timer { font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
.thinking-dots { display: inline-flex; gap: 3px; align-items: center; }
.thinking-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); animation: blink 1.2s infinite; }
.thinking-dots i:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.board-shell { position: relative; width: min(100%, 660px); margin: 0 auto; }
.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(7px, 1.1vw, 12px);
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  padding: clamp(8px, 1.2vw, 13px);
  background:
    radial-gradient(120% 100% at 20% 0%, rgba(255, 255, 255, 0.06), transparent 55%),
    linear-gradient(145deg, #1b2d26, #0e1a16);
  border: 1px solid rgba(227, 180, 95, 0.22);
  border-radius: clamp(14px, 2vw, 20px);
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  user-select: none;
}
.sub {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  min-width: 0;
  min-height: 0;
  gap: clamp(3px, 0.5vw, 5px);
  padding: clamp(4px, 0.6vw, 6px);
  border-radius: clamp(7px, 1.2vw, 11px);
  background: rgba(4, 10, 8, 0.42);
  border: 1px solid rgba(244, 236, 217, 0.06);
  transition: background 0.3s, box-shadow 0.3s, border-color 0.3s;
}
.sub.owned-x { background: rgba(226, 96, 75, 0.13); border-color: rgba(226, 96, 75, 0.42); box-shadow: inset 0 0 24px rgba(226, 96, 75, 0.10); }
.sub.owned-o { background: rgba(116, 174, 232, 0.12); border-color: rgba(116, 174, 232, 0.42); box-shadow: inset 0 0 24px rgba(116, 174, 232, 0.10); }
.sub.forced { border-color: rgba(227, 180, 95, 0.8); box-shadow: 0 0 0 1px rgba(227, 180, 95, 0.55), 0 0 26px rgba(227, 180, 95, 0.17), inset 0 0 24px rgba(227, 180, 95, 0.07); }
.sub.win { animation: winGlow 1.6s ease-in-out infinite alternate; }
@keyframes winGlow { from { box-shadow: 0 0 0 2px rgba(244, 209, 140, 0.55), 0 0 34px rgba(244, 209, 140, 0.18); } to { box-shadow: 0 0 0 3px rgba(244, 209, 140, 0.9), 0 0 54px rgba(244, 209, 140, 0.38); } }
.sub-badge {
  position: absolute;
  top: -7px; right: -7px;
  z-index: 3;
  display: grid; place-items: center;
  width: 21px; height: 21px;
  border-radius: 50%;
  font-family: var(--serif); font-size: 13px; line-height: 1;
  background: #0d1915;
  border: 1px solid currentColor;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}
.sub-badge.x { color: var(--x-2); }
.sub-badge.o { color: var(--o-2); }
.cell {
  position: relative;
  display: grid; place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(27, 43, 37, 0.08);
  border-radius: clamp(4px, 0.7vw, 6px);
  background: #f5edda;
  color: #22302a;
  font-family: var(--serif);
  font-size: clamp(17px, 3.3vw, 33px);
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 1px 2px rgba(0, 0, 0, 0.16);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cell:disabled { color: #22302a; }
.cell .mark { display: block; transform: translateY(-1px); }
.cell.x { color: #bf422d; }
.cell.o { color: #2c6398; }
.cell.x .mark { animation: markIn 0.22s cubic-bezier(0.2, 1.4, 0.4, 1); }
.cell.o .mark { animation: markIn 0.22s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes markIn { from { transform: scale(0.35); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cell.playable { cursor: pointer; }
.cell.playable::after {
  content: "";
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(27, 43, 37, 0.24);
  opacity: 0.7;
  transition: 0.15s;
}
@media (hover: hover) and (pointer: fine) {
  .cell.playable:hover { background: #fffdf4; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22); }
  .cell.playable:hover::after { opacity: 0; }
}
.cell.last { box-shadow: inset 0 0 0 2px rgba(227, 180, 95, 0.95), 0 0 12px rgba(227, 180, 95, 0.35); }
.cell.last::before { content: ""; position: absolute; inset: 3px; border: 1px dashed rgba(185, 133, 53, 0.55); border-radius: 3px; }
.cell.in-line { background: linear-gradient(160deg, #fff6d7, #f3dfae); }
.cell.win-cell { box-shadow: inset 0 0 0 2px rgba(227, 180, 95, 0.9), 0 0 14px rgba(227, 180, 95, 0.4); }
.cell.pending { opacity: 0.82; }
.cell.pending .mark { opacity: 0.65; }
.cell:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.board-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 12, 10, 0.68);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  border-radius: 20px;
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.result-card {
  width: min(400px, 100%);
  text-align: center;
  padding: 28px 26px 22px;
  border: 1px solid rgba(227, 180, 95, 0.35);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(25, 43, 36, 0.97), rgba(11, 22, 18, 0.98));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: resultIn 0.5s cubic-bezier(0.2, 1.2, 0.3, 1);
}
@keyframes resultIn { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }
.result-kicker { margin: 0 0 8px; font-size: 10px; letter-spacing: 0.26em; color: var(--gold); }
.result-card h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 4.6vw, 43px); margin: 0 0 5px; color: var(--gold-2); line-height: 1.15; }
.result-card h2.lose { color: var(--cream-2); }
.result-card h2.draw { color: var(--cream-2); }
.result-card > p { margin: 0 0 15px; color: var(--muted); font-size: 12px; }
.result-score { display: flex; justify-content: center; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; margin: 0 0 17px; }
.result-score span { flex: 1; background: rgba(8, 16, 14, 0.4); padding: 8px 4px; font-size: 10px; color: var(--muted); }
.result-score b { display: block; font-family: var(--mono); font-size: 16px; color: var(--cream-2); font-weight: 500; }
.result-actions { display: flex; flex-direction: column; gap: 8px; }
.result-actions .primary-btn { padding: 11px 16px; }
.result-wait { margin: 10px 0 0 !important; font-size: 11px !important; color: var(--gold) !important; min-height: 16px; }
.result-review { margin-top: 10px; font-size: 12px; color: var(--muted); border-color: var(--line-strong); }

.board-caption { width: min(100%, 660px); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px 0; color: var(--muted-2); font-size: 10px; letter-spacing: 0.04em; }
.legend { display: flex; align-items: center; gap: 6px; }
.lg { font-family: var(--serif); font-style: normal; font-size: 14px; line-height: 1; }
.lg.x { color: var(--x-2); }
.lg.o { color: var(--o-2); }
#boardHint { text-align: right; }

.game-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.players-panel { display: grid; grid-template-columns: 1fr; gap: 8px; }
.player-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(246, 238, 218, 0.035);
  transition: 0.25s;
}
.player-row.active { border-color: rgba(227, 180, 95, 0.55); background: linear-gradient(90deg, rgba(227, 180, 95, 0.12), rgba(227, 180, 95, 0.02)); }
.player-row.offline { opacity: 0.55; }
.player-avatar { flex: none; display: grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; border: 1px solid var(--line); background: rgba(8, 16, 14, 0.35); font-family: var(--serif); font-size: 20px; line-height: 1; }
.player-row.x .player-avatar { color: var(--x-2); border-color: rgba(226, 96, 75, 0.4); }
.player-row.o .player-avatar { color: var(--o-2); border-color: rgba(116, 174, 232, 0.4); }
.player-info { flex: 1; min-width: 0; }
.player-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-name .tag { font-size: 8px; font-weight: 400; letter-spacing: 0.06em; color: var(--gold); border: 1px solid rgba(227, 180, 95, 0.3); border-radius: 3px; padding: 0 4px; }
.player-name .tag.you { color: var(--ok); border-color: rgba(111, 192, 138, 0.3); }
.player-meta { font-size: 10px; color: var(--muted-2); display: flex; align-items: center; gap: 6px; }
.player-meta .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.player-meta.off .dot { background: var(--danger); }
.player-subs { flex: none; text-align: right; }
.player-subs b { display: block; font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--cream-2); line-height: 1.1; }
.player-subs span { font-size: 8px; color: var(--muted-2); letter-spacing: 0.06em; }

.control-panel { padding-bottom: 12px; }
.mini-map { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 11px 15px 8px; }
.mini-sub { position: relative; aspect-ratio: 1; border-radius: 5px; border: 1px solid var(--line); background: rgba(8, 16, 14, 0.35); display: grid; place-items: center; font-family: var(--serif); font-size: 13px; color: var(--muted-2); }
.mini-sub.owned-x { background: rgba(226, 96, 75, 0.22); border-color: rgba(226, 96, 75, 0.45); color: var(--x-2); }
.mini-sub.owned-o { background: rgba(116, 174, 232, 0.2); border-color: rgba(116, 174, 232, 0.45); color: var(--o-2); }
.mini-sub.current { box-shadow: 0 0 0 1px var(--gold); }
.mini-sub small { position: absolute; bottom: 1px; right: 3px; font-family: var(--sans); font-size: 7px; color: var(--muted-2); }
.count-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 15px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--line); }
.count-item { background: rgba(8, 16, 14, 0.35); padding: 7px 9px; display: flex; align-items: baseline; gap: 6px; }
.count-item b { font-family: var(--mono); font-size: 17px; font-weight: 500; }
.count-item.x b { color: var(--x-2); }
.count-item.o b { color: var(--o-2); }
.count-item span { font-size: 9px; color: var(--muted-2); }
.control-tip { margin: 8px 15px 0; font-size: 10px; color: var(--muted-2); }

.game-chat { flex: 1; min-height: 260px; max-height: 430px; }

/* ------------------------------------------------------------ 弹窗 */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 9, 8, 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fadeIn 0.25s ease; }
.modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  overflow-y: auto;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(227, 180, 95, 0.25);
  border-radius: 20px;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(58, 100, 82, 0.20), transparent 55%),
    linear-gradient(160deg, #14251f, #0a1511);
  box-shadow: var(--shadow);
  animation: modalIn 0.35s cubic-bezier(0.2, 1, 0.3, 1);
  scrollbar-width: thin;
  scrollbar-color: rgba(238, 227, 199, 0.2) transparent;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-card h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(26px, 3.4vw, 36px); margin: 0 0 10px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(8, 16, 14, 0.4);
  color: var(--muted);
  font-size: 20px; line-height: 1;
}
.modal-close:hover { color: var(--cream); border-color: var(--gold); }
.rules-lead { color: var(--muted); font-size: 13px; line-height: 1.9; margin: 0 0 24px; max-width: 620px; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rule-block { border: 1px solid var(--line); border-radius: 14px; padding: 17px 17px 15px; background: rgba(246, 238, 218, 0.028); }
.rule-num { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--gold); margin-bottom: 5px; }
.rule-block h3 { font-family: var(--serif); font-weight: 500; font-size: 17px; margin: 0 0 7px; }
.rule-block p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.85; }
.rule-block p b { color: var(--cream-2); font-weight: 500; }
.diagram { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 13px; min-height: 56px; }
.dg-board { display: grid; grid-template-columns: repeat(3, 26px); gap: 2px; }
.dg-sub { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 3px; border: 1px solid var(--line); font-size: 8px; color: var(--muted-2); background: rgba(8, 16, 14, 0.35); }
.dg-sub.dim { opacity: 0.45; }
.dg-sub.target { border-color: var(--gold); color: var(--gold-2); background: rgba(227, 180, 95, 0.12); }
.dg-sub.pulse { box-shadow: 0 0 0 1px var(--gold), 0 0 14px rgba(227, 180, 95, 0.3); }
.dg-arrow { color: var(--gold); font-size: 15px; opacity: 0.7; }
.mini-line { display: grid; grid-template-columns: repeat(3, 34px); gap: 3px; justify-content: start; }
.mini-line .dg-sub { width: 34px; height: 34px; font-family: var(--serif); font-size: 15px; color: var(--cream-2); }
.dg-sub.owned-x { display: flex; flex-direction: row; gap: 0; width: auto; padding: 0 4px; border-color: rgba(226, 96, 75, 0.45); background: rgba(226, 96, 75, 0.13); color: var(--x-2); }
.dg-sub.owned-x span { width: 10px; text-align: center; }
.free-diagram { justify-content: flex-start; }
.free-chip { border: 1px solid var(--line); border-radius: 5px; padding: 4px 9px; font-size: 9px; color: var(--muted); }
.free-chip.gold { border-color: rgba(227, 180, 95, 0.4); color: var(--gold-2); }
.win-diagram { display: grid; grid-template-columns: repeat(3, 28px); gap: 3px; justify-content: start; }
.win-diagram .dg-sub { width: 28px; height: 28px; font-family: var(--serif); font-size: 13px; }
.rules-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 10px; color: var(--muted-2); letter-spacing: 0.03em; }

.confirm-card { width: min(380px, 100%); padding: 28px; }
.confirm-card h2 { font-size: 24px; margin-bottom: 8px; }
.confirm-card p { color: var(--muted); font-size: 13px; line-height: 1.75; margin: 0 0 22px; }
.confirm-actions { display: flex; gap: 9px; }
.confirm-actions button { flex: 1; }

/* ------------------------------------------------------------ Toast */
.toast-stack { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 36px); }
.toast {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(227, 180, 95, 0.35);
  background: rgba(14, 28, 23, 0.94);
  color: var(--cream);
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s cubic-bezier(0.2, 1.2, 0.3, 1);
  backdrop-filter: blur(10px);
}
.toast.error { border-color: rgba(217, 89, 75, 0.5); color: #ffd9d2; }
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 1050px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .card-solo { grid-column: 1 / -1; }
  .rule-strip { grid-template-columns: 1fr 1fr; }
  .rule-strip .text-btn { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-art { display: none; }
  .lobby-layout { grid-template-columns: 1fr; }
  .lobby-layout .chat-panel { max-height: 320px; }
  .rules-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .site-header { padding: 11px max(16px, env(safe-area-inset-right)) 11px max(16px, env(safe-area-inset-left)); }
  .brand-text { font-size: 16px; }
  .brand-text em { display: none; }
  .header-nav .ghost-btn { display: none; }
  .home-wrap { padding-top: 26px; }
  .hero { margin-bottom: 18px; }
  .hero-copy h1 { font-size: clamp(46px, 13vw, 64px); }
  .hero-sub { font-size: 13px; }
  .desktop-only { display: none; }
  .nick-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .nick-input { width: 100%; }
  #nickHint { display: none; }
  .action-grid { grid-template-columns: 1fr; }
  .card-solo { grid-column: auto; }
  .rule-strip { grid-template-columns: 1fr; gap: 14px; }
  .rule-strip .text-btn { grid-column: auto; }
  .game-wrap { padding: 8px max(10px, env(safe-area-inset-right)) max(30px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .game-topbar { padding-bottom: 10px; }
  .game-top-actions .icon-text-btn { padding: 5px 6px; }
  .game-layout { grid-template-columns: 1fr; gap: 14px; }
  .board-area { width: 100%; }
  .turn-banner { width: 100%; margin-bottom: 9px; padding: 9px 12px; }
  .board-shell { width: 100%; }
  .board { gap: 8px; padding: 8px; border-radius: 14px; }
  .sub { gap: 3px; padding: 3px; border-radius: 7px; border-color: rgba(244, 236, 217, 0.12); }
  .cell { border-radius: 4px; font-size: clamp(16px, 5.8vw, 30px); }
  .cell.x .mark, .cell.o .mark { animation: none; }
  .sub-badge { width: 18px; height: 18px; font-size: 11px; top: -6px; right: -6px; }
  .board-caption { width: 100%; font-size: 9px; }
  .game-side { gap: 10px; }
  .players-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-row { min-width: 0; padding: 8px 9px; gap: 8px; }
  .player-name .tag { flex: none; }
  .field input, .chat-form input { font-size: 16px; }
  .player-avatar { width: 30px; height: 30px; font-size: 17px; }
  .player-name { font-size: 12px; }
  .player-meta { font-size: 9px; }
  .player-subs { display: none; }
  .control-panel .mini-map { max-width: 170px; }
  .game-chat { min-height: 240px; max-height: 340px; }
  .board-overlay { position: fixed; inset: 0; z-index: 70; padding: 16px; border-radius: 0; overflow-y: auto; }
  .result-card { margin: auto; padding: 14px 12px 12px; border-radius: 14px; }
  .result-kicker { margin-bottom: 4px; letter-spacing: 0.18em; }
  .result-card h2 { font-size: 26px; margin-bottom: 2px; }
  .result-card > p { margin-bottom: 8px; }
  .result-score { margin-bottom: 9px; }
  .result-score span { padding: 5px 3px; }
  .result-score b { font-size: 14px; }
  .result-actions { gap: 6px; }
  .result-actions .primary-btn { padding: 8px 12px; }
  .result-wait { margin-top: 6px !important; }
  .lobby-wrap { padding: 26px 16px 40px; }
  .room-code-row h2 { font-size: 40px; }
  .invite-panel { grid-template-columns: 1fr 1fr; }
  .invite-item.link { grid-column: 1 / -1; }
  .seats { grid-template-columns: 1fr; }
  .seat { min-height: 105px; }
  .lobby-actions .primary-btn { width: 100%; }
  .lobby-actions .secondary-btn { flex: 1; }
  .modal-card { padding: 24px 18px; max-height: 90vh; }
  .modal-close { top: 10px; right: 10px; }
  .rules-grid { gap: 12px; }
  .toast-stack { bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .cell { font-size: 18px; }
  .players-panel { grid-template-columns: 1fr; }
  .player-subs { display: none; }
  .game-room-chip em { display: none; }
}

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