/* ============================================================
   KanChess — online chess
   ============================================================ */

:root {
  --bg: #090c11;
  --bg-2: #0d1118;
  --panel: #11161f;
  --card: rgba(255, 255, 255, 0.042);
  --card-hover: rgba(255, 255, 255, 0.065);
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef2f7;
  --muted: #8e99ab;
  --muted-2: #687386;
  --gold: #e2b45f;
  --gold-2: #f5d99b;
  --gold-dim: rgba(226, 180, 95, 0.16);
  --mint: #6ee7b7;
  --red: #f87171;
  --blue: #7dd3fc;
  --board-light: #efdfc4;
  --board-dark: #a87a58;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(226, 180, 95, 0.12), transparent 62%),
    radial-gradient(800px 480px at 92% 4%, rgba(110, 231, 183, 0.07), transparent 60%),
    radial-gradient(700px 700px at 50% 110%, rgba(125, 211, 252, 0.045), transparent 65%);
}

.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

main {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  flex: 1;
  padding: 28px 0 40px;
}

/* ---------------- top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 14px max(20px, calc((100vw - 1240px) / 2));
  background: rgba(9, 12, 17, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f3d391, #d5a248 58%, #b9832f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease;
}

.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.04); }

.brand-mark img { width: 27px; height: 27px; filter: drop-shadow(0 1px 0 rgba(255,255,255,.2)); }

.brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-name span { color: var(--gold); }

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.nav-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}

.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav-link.active { color: var(--text); background: rgba(255, 255, 255, 0.07); }

.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  white-space: nowrap;
}

.online-pill b { color: var(--text); }

.online-dot, .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.13), 0 0 10px rgba(110, 231, 183, 0.6);
  flex-shrink: 0;
}

.online-label { color: var(--muted-2); }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  cursor: pointer;
  transition: 0.18s ease;
}

.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.06); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.off { color: var(--muted-2); opacity: 0.6; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: 0.18s ease;
}

.user-chip:hover { border-color: rgba(226, 180, 95, 0.4); background: rgba(226, 180, 95, 0.07); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  color: #17110a;
  background: linear-gradient(145deg, #f3d391, #d5a248);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.avatar.lg { width: 44px; height: 44px; font-size: 17px; }
.avatar.xl { width: 64px; height: 64px; font-size: 25px; }

.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-name { font-size: 13px; font-weight: 700; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-rating { font-size: 11.5px; color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.chev { color: var(--muted-2); font-size: 18px; line-height: 1; margin-left: 2px; }

.conn-banner {
  position: sticky;
  top: 67px;
  z-index: 39;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #1a1206;
  background: linear-gradient(90deg, #e8bd6b, #f3d391);
}

/* ---------------- generic ---------------- */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.048), rgba(255, 255, 255, 0.026));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: translateY(1px) scale(0.99); }

.btn.primary {
  background: linear-gradient(140deg, #f5d99b, #e2b45f 45%, #cf9c43);
  color: #1c1305;
  box-shadow: 0 10px 30px rgba(226, 180, 95, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn.primary:hover { box-shadow: 0 14px 40px rgba(226, 180, 95, 0.33), inset 0 1px 0 rgba(255, 255, 255, 0.6); transform: translateY(-1px); }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn:disabled { cursor: not-allowed; }

body.modal-open { overflow: hidden; }

.btn.ghost {
  background: rgba(255, 255, 255, 0.035);
  border-color: var(--border);
  color: var(--text);
}

.btn.ghost:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--border-strong); }
.btn.ghost.danger:hover { border-color: rgba(248, 113, 113, 0.45); color: #fecaca; background: rgba(248, 113, 113, 0.09); }
.btn.danger:not(.ghost), .btn.primary.danger { background: linear-gradient(140deg, #fca5a5, #ef4444); color: #1a0505; }
.btn.small { padding: 8px 13px; font-size: 12.5px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn.xl { padding: 17px 30px; font-size: 16.5px; border-radius: 15px; }

.muted { color: var(--muted); }
.tiny { font-size: 11.5px; color: var(--muted-2); margin: 12px 0 0; text-align: center; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.spinner.tiny { width: 14px; height: 14px; border-width: 2px; border-top-color: #1a1206; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- lobby ---------------- */

.view { animation: viewIn 0.35s ease both; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.lobby {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 20px;
  align-items: start;
}

.hero {
  padding: 38px 40px 30px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -140px;
  top: -190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(226, 180, 95, 0.12), transparent 65%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  position: relative;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(36px, 4.4vw, 58px);
  line-height: 1.02;
  letter-spacing: -2.2px;
  font-weight: 800;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, #f7e2b3, #e2b45f 55%, #c8953c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  margin: 16px 0 0;
  max-width: 470px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.hero-rating {
  text-align: right;
  flex-shrink: 0;
  padding-top: 4px;
}

.hero-rating-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted-2);
  font-weight: 700;
}

.hero-rating-value {
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  color: var(--gold-2);
}

.hero-rating-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 3px; }

.tc-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 30px 0 18px;
}

.tc-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 15px 16px 13px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.024);
  cursor: pointer;
  text-align: left;
  transition: 0.2s ease;
  position: relative;
  overflow: hidden;
}

.tc-card:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--border-strong); transform: translateY(-1px); }

.tc-card.active {
  border-color: rgba(226, 180, 95, 0.65);
  background: linear-gradient(160deg, rgba(226, 180, 95, 0.13), rgba(226, 180, 95, 0.035));
  box-shadow: 0 0 0 1px rgba(226, 180, 95, 0.15) inset, 0 10px 30px rgba(0, 0, 0, 0.2);
}

.tc-card.active::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1206;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.tc-top { display: flex; align-items: center; gap: 7px; }
.tc-icon { font-size: 13px; color: var(--gold); width: 16px; text-align: center; }
.tc-name { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0.2px; }
.tc-card.active .tc-name { color: var(--text); }
.tc-time { font-family: var(--mono); font-size: 21px; font-weight: 700; letter-spacing: -0.8px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tc-desc { font-size: 10.5px; color: var(--muted-2); }

.play-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.play-icon { font-size: 21px; line-height: 1; margin-top: -2px; }

.play-meta { display: flex; flex-direction: column; gap: 2px; }

.queue-online {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
}

.queue-online b { color: var(--text); font-variant-numeric: tabular-nums; }
.queue-hint { font-size: 11.5px; color: var(--muted-2); }

.searching {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(226, 180, 95, 0.3);
  border-radius: 15px;
  background: rgba(226, 180, 95, 0.06);
  animation: viewIn 0.25s ease both;
}

.radar {
  position: relative;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(226, 180, 95, 0.07);
  border: 1px solid rgba(226, 180, 95, 0.28);
}

.radar img { width: 30px; height: 30px; position: relative; z-index: 2; }

.radar span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(226, 180, 95, 0.55);
  animation: radar 2.4s ease-out infinite;
}

.radar span:nth-child(2) { animation-delay: 0.8s; }
.radar span:nth-child(3) { animation-delay: 1.6s; }

@keyframes radar {
  from { transform: scale(0.45); opacity: 0.9; }
  to { transform: scale(1.45); opacity: 0; }
}

.search-copy { display: flex; flex-direction: column; gap: 1px; }
.search-copy b { font-size: 14.5px; }
.search-copy span { font-size: 12px; color: var(--muted); }

.search-timer {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}

.resume-game {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 16px;
  border: 1px solid rgba(110, 231, 183, 0.25);
  border-radius: 13px;
  background: rgba(110, 231, 183, 0.06);
  font-size: 13px;
  color: #c8f7e4;
}

.resume-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.12);
}

.resume-game .btn { margin-left: auto; }

.hero-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11.5px;
  color: var(--muted-2);
}

.hero-foot b { color: var(--muted); }
.sep { opacity: 0.4; }

.lobby-side { display: flex; flex-direction: column; gap: 16px; }

.leaderboard-card { padding: 20px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2, .card-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.card-head h3 { font-size: 13px; }

.season-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--gold);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--gold-dim);
  border: 1px solid rgba(226, 180, 95, 0.18);
}

.lb-list { display: flex; flex-direction: column; gap: 2px; }

.lb-row {
  display: grid;
  grid-template-columns: 26px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  transition: background 0.15s;
}

.lb-row:hover { background: rgba(255, 255, 255, 0.04); }
.lb-row.me { background: rgba(226, 180, 95, 0.08); box-shadow: inset 0 0 0 1px rgba(226, 180, 95, 0.2); }

.lb-rank {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-2);
  text-align: center;
}

.lb-row:nth-child(1) .lb-rank { color: #f3d391; }
.lb-row:nth-child(2) .lb-rank { color: #d6dde8; }
.lb-row:nth-child(3) .lb-rank { color: #d7a679; }

.lb-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-name .lb-badge { font-size: 10px; color: var(--gold); margin-left: 5px; }

.lb-games { font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.lb-rating {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: right;
}

.lb-skeleton {
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(90deg, rgba(255,255,255,.035), rgba(255,255,255,.07), rgba(255,255,255,.035));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 4px;
}

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

.lb-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px 4px;
  font-size: 12.5px;
  color: var(--muted-2);
}

.lb-empty img { width: 38px; height: 38px; opacity: 0.5; }

.mini-profile { padding: 20px; }

.mini-profile-head { display: flex; align-items: center; gap: 12px; }
.mini-name { font-weight: 700; font-size: 15px; }
.mini-sub { font-size: 11.5px; color: var(--muted-2); }

.mini-rating-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 14px;
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mini-rating-row > div { display: flex; flex-direction: column; gap: 1px; }
.mini-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted-2); font-weight: 600; }
.mini-rating-row b { font-family: var(--mono); font-size: 17px; font-variant-numeric: tabular-nums; }

.form-row { display: flex; gap: 5px; align-items: center; min-height: 18px; margin-bottom: 12px; }

.form-dot {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
}

.form-dot.w { background: rgba(110, 231, 183, 0.18); color: var(--mint); }
.form-dot.l { background: rgba(248, 113, 113, 0.16); color: var(--red); }
.form-dot.d { background: rgba(255, 255, 255, 0.09); color: var(--muted); }
.form-dot.empty { background: rgba(255, 255, 255, 0.04); }

.mini-open {
  border: 0;
  background: transparent;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.mini-open:hover { color: var(--gold-2); }

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.feature {
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.feature-num {
  position: absolute;
  top: 16px;
  right: 18px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
}

.feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--gold-dim);
  border: 1px solid rgba(226, 180, 95, 0.16);
  color: var(--gold);
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 14px;
}

.feature h3 { margin: 0 0 6px; font-size: 14px; }
.feature p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }

/* ---------------- game ---------------- */

.game-shell { max-width: 1040px; margin: 0 auto; }

.game-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.game-top .arrow { font-size: 15px; }
.game-badge {
  margin: 0 auto;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.game-top-right { display: flex; gap: 8px; margin-left: auto; }

.game-tour-tag {
  margin-left: 8px;
  color: var(--gold-2);
  font-weight: 800;
  animation: tourTagPulse 1.8s ease-in-out infinite;
}

@keyframes tourTagPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 620px) 330px;
  gap: 22px;
  justify-content: center;
  align-items: start;
}

.board-col { min-width: 0; }

.player-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.032);
  margin-bottom: 10px;
  transition: border-color 0.2s, background 0.2s;
}

.player-strip.me { margin: 10px 0 0; }
.player-strip.active-turn { border-color: rgba(226, 180, 95, 0.32); background: rgba(226, 180, 95, 0.05); }

.player-strip .avatar { width: 38px; height: 38px; font-size: 15px; }
.avatar.bot-avatar { background: linear-gradient(145deg, rgba(226, 180, 95, 0.3), rgba(226, 180, 95, 0.08)); border: 1px solid rgba(226, 180, 95, 0.35); font-size: 19px; }
.replay-player .avatar.is-white { background: linear-gradient(145deg, #f7f1e4, #d9cdb6); color: #2a2115; }
.replay-player .avatar.is-black { background: linear-gradient(145deg, #4a5261, #2b303a); color: #e8edf6; }
.player-strip.is-black .avatar { background: linear-gradient(145deg, #4a5261, #2b303a); color: #e8edf6; box-shadow: inset 0 1px 0 rgba(255,255,255,.16); }
.player-strip.is-white .avatar { background: linear-gradient(145deg, #f7f1e4, #d9cdb6); color: #2a2115; }

.player-main { min-width: 0; flex: 1; }
.player-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player-name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-rating { font-size: 11.5px; color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); flex-shrink: 0; opacity: 0.9; }
.conn-dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.13); }

.captured { display: flex; align-items: center; gap: 1px; min-height: 18px; margin-top: 1px; }
.captured img { width: 17px; height: 17px; opacity: 0.8; margin-right: -4px; }
.captured .adv { font-size: 10.5px; color: var(--muted); margin-left: 7px; font-weight: 700; }

.clock {
  font-family: var(--mono);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.8px;
  font-variant-numeric: tabular-nums;
  padding: 6px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  min-width: 88px;
  text-align: center;
  transition: 0.2s ease;
}

.clock.active { color: var(--gold-2); border-color: rgba(226, 180, 95, 0.42); background: rgba(226, 180, 95, 0.08); box-shadow: 0 0 22px rgba(226, 180, 95, 0.1); }
.clock.low { color: #fecaca; border-color: rgba(248, 113, 113, 0.5); background: rgba(248, 113, 113, 0.09); }
.clock.critical { animation: clockPulse 1s infinite; }

@keyframes clockPulse {
  50% { background: rgba(248, 113, 113, 0.2); box-shadow: 0 0 26px rgba(248, 113, 113, 0.2); }
}

.board-frame {
  position: relative;
  width: 100%;
  padding: 10px;
  border-radius: 18px;
  background: linear-gradient(150deg, #3a2a1f, #241a13 45%, #17110c);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border-radius: 9px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.sq {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  cursor: default;
}

.sq.light { background: var(--board-light); }
.sq.dark { background: var(--board-dark); }

.sq::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}

.sq.last::before { background: rgba(226, 180, 95, 0.42); opacity: 1; }

.sq.selected::before { background: rgba(110, 231, 183, 0.38); opacity: 1; }
.sq.selected { box-shadow: inset 0 0 0 3px rgba(110, 231, 183, 0.85); }

.sq.check { box-shadow: inset 0 0 0 3px rgba(248, 113, 113, 0.9), inset 0 0 34px rgba(248, 113, 113, 0.55); }

.sq.drag-over::before { background: rgba(255, 255, 255, 0.28); opacity: 1; }

.sq.legal::after {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(15, 20, 27, 0.38);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
  pointer-events: none;
  animation: dotIn 0.12s ease both;
}

.sq.legal.capture::after {
  width: 84%;
  height: 84%;
  background: transparent;
  border: 5px solid rgba(15, 20, 27, 0.34);
  box-shadow: none;
}

@keyframes dotIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sq.movable { cursor: grab; }
.sq.movable:active { cursor: grabbing; }
.sq.target { cursor: pointer; }

.piece {
  width: 88%;
  height: 88%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.32));
  position: relative;
  z-index: 2;
  transition: transform 0.08s ease;
}

.sq.dragging .piece { opacity: 0.25; }

.coord {
  position: absolute;
  font-size: clamp(8px, 1.1vw, 10.5px);
  font-weight: 700;
  font-family: var(--mono);
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
}

.coord.file { right: 4px; bottom: 2px; }
.coord.rank { left: 3px; top: 2px; }
.sq.light .coord { color: #6d4a30; }
.sq.dark .coord { color: #f0e2cd; }

.board-veil {
  position: absolute;
  inset: 10px;
  border-radius: 9px;
  background: rgba(8, 11, 16, 0.55);
  display: grid;
  place-items: center;
  backdrop-filter: blur(1px);
  z-index: 5;
}

.game-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.game-actions .btn { flex: 1; }
.game-actions .only-mobile { display: none; }

.half-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(90deg, #fff 50%, transparent 50%);
  border: 1.5px solid var(--muted);
  display: inline-block;
}

.flag-icon {
  width: 11px;
  height: 13px;
  display: inline-block;
  border-left: 2px solid currentColor;
  position: relative;
}

.flag-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  border-top: 4px solid currentColor;
  border-bottom: 4px solid currentColor;
  border-right: 7px solid transparent;
  border-left: 0;
  width: 0;
  height: 0;
}

.offer-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(226, 180, 95, 0.32);
  background: rgba(226, 180, 95, 0.08);
  font-size: 12.5px;
  animation: viewIn 0.2s ease both;
}

.offer-actions { display: flex; gap: 6px; margin-left: auto; }

.game-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 88px; }

.moves-card, .chat-card { padding: 17px 17px 14px; }

.move-list {
  height: 300px;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.move-list::-webkit-scrollbar, .chat-log::-webkit-scrollbar { width: 6px; }
.move-list::-webkit-scrollbar-thumb, .chat-log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.13); border-radius: 4px; }

.move-empty { color: var(--muted-2); font-size: 12px; padding: 8px 2px; }

.move-row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  gap: 4px;
  align-items: center;
  padding: 4px 5px;
  border-radius: 7px;
  font-size: 13px;
}

.move-row:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.move-row .num { color: var(--muted-2); font-size: 10.5px; font-family: var(--mono); }
.move-row .san { font-family: var(--mono); font-size: 12.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; }
.move-row .san.last { background: rgba(226, 180, 95, 0.16); color: var(--gold-2); }
.move-row .san.empty { color: transparent; }

.chat-log {
  height: 148px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.chat-empty { color: var(--muted-2); font-size: 11.5px; padding: 6px 2px; }

.chat-msg { max-width: 88%; padding: 7px 10px; border-radius: 10px; font-size: 12.5px; line-height: 1.4; animation: msgIn 0.18s ease both; word-break: break-word; }
.chat-msg .who { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted-2); margin-bottom: 1px; }
.chat-msg.opp { background: rgba(255, 255, 255, 0.06); border-bottom-left-radius: 3px; align-self: flex-start; }
.chat-msg.me { background: rgba(226, 180, 95, 0.14); border: 1px solid rgba(226, 180, 95, 0.16); border-bottom-right-radius: 3px; align-self: flex-end; }

@keyframes msgIn { from { opacity: 0; transform: translateY(3px); } }

.quick-chat { display: flex; gap: 5px; flex-wrap: wrap; margin: 10px 0 7px; }
.quick-chat button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.15s;
}
.quick-chat button:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.06); }

.chat-form { display: flex; gap: 6px; }
.chat-form input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 12.5px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.18s;
}
.chat-form input:focus { border-color: rgba(226, 180, 95, 0.45); }
.chat-form button {
  width: 36px;
  border: 1px solid rgba(226, 180, 95, 0.35);
  background: rgba(226, 180, 95, 0.12);
  color: var(--gold);
  border-radius: 9px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.chat-form button:hover { background: rgba(226, 180, 95, 0.2); }

/* ---------------- footer ---------------- */

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 26px 20px 34px;
  font-size: 11px;
  color: var(--muted-2);
  border-top: 1px solid rgba(255, 255, 255, 0.045);
}
.footer-sep { opacity: 0.4; }

/* ---------------- modals ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease both;
}

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

.modal-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: linear-gradient(180deg, #141a24, #0e131b);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  padding: 28px;
  animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.modal-card h2 { margin: 0 0 6px; font-size: 23px; letter-spacing: -0.6px; }
.modal-card p { margin: 0; }

/* auth */

.auth-card { width: min(410px, 100%); text-align: center; padding-top: 24px; }

.auth-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f3d391, #d5a248 58%, #b9832f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 12px 30px rgba(0, 0, 0, 0.35);
}
.auth-mark img { width: 40px; height: 40px; }

.auth-sub { font-size: 12.5px; margin-bottom: 20px !important; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 11px;
  margin-bottom: 18px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.18s;
}

.segmented button.active { background: rgba(255, 255, 255, 0.09); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }

.field { display: block; text-align: left; margin-bottom: 12px; }
.field span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted-2); margin-bottom: 6px; }
.field input {
  width: 100%;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input:focus { border-color: rgba(226, 180, 95, 0.55); box-shadow: 0 0 0 3px rgba(226, 180, 95, 0.1); }
.field input::placeholder { color: var(--muted-2); }

.form-error {
  text-align: left;
  font-size: 12px;
  color: #fecaca;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.22);
  border-radius: 9px;
  padding: 9px 11px;
  margin: 4px 0 12px;
}

/* result */

.result-card { width: min(420px, 100%); text-align: center; }

.result-emblem {
  width: 86px;
  height: 86px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 42px;
  background: radial-gradient(circle at 35% 30%, rgba(243, 211, 145, 0.35), rgba(226, 180, 95, 0.06));
  border: 1px solid rgba(226, 180, 95, 0.32);
  box-shadow: 0 0 50px rgba(226, 180, 95, 0.14);
}

.result-card.loss .result-emblem { background: radial-gradient(circle at 35% 30%, rgba(248, 113, 113, 0.25), rgba(248, 113, 113, 0.03)); border-color: rgba(248, 113, 113, 0.28); box-shadow: 0 0 50px rgba(248, 113, 113, 0.1); }
.result-card.draw .result-emblem { background: radial-gradient(circle at 35% 30%, rgba(148, 163, 184, 0.25), rgba(148, 163, 184, 0.03)); border-color: rgba(148, 163, 184, 0.28); box-shadow: none; }

.result-kicker { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.8px; color: var(--muted-2); font-weight: 700; }
.result-card h2 { font-size: 34px; letter-spacing: -1.2px; margin: 2px 0 2px; }
.result-card.win h2 { color: var(--gold-2); }
.result-card.loss h2 { color: #fecaca; }
.result-reason { color: var(--muted); font-size: 13px; }

.result-rating {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 20px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.result-rating .delta { font-family: var(--mono); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-rating .delta.plus { color: var(--mint); }
.result-rating .delta.minus { color: var(--red); }
.result-rating .delta.zero { color: var(--muted); }
.result-rating .new-rating { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.result-actions { display: flex; gap: 9px; }
.result-actions .btn { flex: 1; }

.rematch-status { min-height: 18px; margin-top: 12px; font-size: 11.5px; color: var(--muted); }

/* promotion */

.promo-card { width: auto; text-align: center; }
.promo-card h2 { font-size: 16px; margin-bottom: 14px; }
.promo-options { display: flex; gap: 8px; }

.promo-options button {
  width: 68px;
  height: 68px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.16s;
}
.promo-options button:hover { border-color: var(--gold); background: rgba(226, 180, 95, 0.12); transform: translateY(-2px); }
.promo-options img { width: 48px; height: 48px; }

/* profile */

.profile-card { width: min(560px, 100%); max-height: min(88vh, 760px); overflow-y: auto; padding-top: 24px; }

.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-right: 30px; }
.profile-head h2 { margin: 0; font-size: 22px; }
.profile-rating { margin-left: auto; text-align: right; display: flex; flex-direction: column; }
.profile-rating b { font-family: var(--mono); font-size: 28px; color: var(--gold-2); line-height: 1; font-variant-numeric: tabular-nums; }
.profile-rating span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted-2); font-weight: 700; }

.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; }
.profile-stat { padding: 11px; border-radius: 11px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--border); text-align: center; }
.profile-stat b { display: block; font-family: var(--mono); font-size: 18px; font-variant-numeric: tabular-nums; }
.profile-stat span { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted-2); font-weight: 700; }

.profile-chart { margin-bottom: 18px; }
.profile-chart .card-head { margin-bottom: 8px; }
#ratingChart { height: 74px; }
#ratingChart svg { width: 100%; height: 100%; overflow: visible; }

.profile-history .card-head { margin-bottom: 6px; }
.hist-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  font-size: 12px;
}
.hist-row:last-child { border-bottom: 0; }
.hist-opp { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-res { font-weight: 700; font-size: 10.5px; padding: 2px 7px; border-radius: 5px; }
.hist-res.w { color: var(--mint); background: rgba(110, 231, 183, 0.12); }
.hist-res.l { color: var(--red); background: rgba(248, 113, 113, 0.11); }
.hist-res.d { color: var(--muted); background: rgba(255, 255, 255, 0.07); }
.hist-delta { font-family: var(--mono); font-size: 11.5px; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.hist-delta.plus { color: var(--mint); }
.hist-delta.minus { color: var(--red); }
.hist-empty { font-size: 12px; color: var(--muted-2); padding: 10px 4px; }

/* how to */

.how-card { width: min(520px, 100%); }
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.how-grid b { font-size: 12.5px; }
.how-grid p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.how-note { font-size: 11.5px; color: var(--muted); background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 11px; padding: 13px; line-height: 1.6; }

/* confirm */

.confirm-card { width: min(390px, 100%); text-align: center; }
.confirm-card h2 { font-size: 21px; }
.confirm-card p { margin-bottom: 18px; font-size: 12.5px; }

/* toasts */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border-radius: 11px;
  background: rgba(18, 24, 34, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  font-size: 12.5px;
  line-height: 1.45;
  animation: toastIn 0.24s ease both;
  backdrop-filter: blur(10px);
}

.toast::before { content: "♟"; color: var(--gold); font-size: 14px; line-height: 1.2; }
.toast.ok::before { content: "✓"; color: var(--mint); }
.toast.warn::before { content: "!"; color: var(--gold); font-weight: 800; }
.toast.error::before { content: "×"; color: var(--red); font-weight: 800; }
.toast.out { animation: toastOut 0.25s ease both; }

@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* confetti */

.confetti { position: fixed; inset: 0; z-index: 150; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0.9; }
}

/* ---------------- extra modes ---------------- */

.mode-row { display: flex; gap: 9px; margin-top: 12px; }

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.028);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.2s, background 0.2s;
}
.mode-btn:hover { transform: translateY(-1px); border-color: rgba(226, 180, 95, 0.38); background: rgba(226, 180, 95, 0.07); }
.mode-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: rgba(226, 180, 95, 0.11); border: 1px solid rgba(226, 180, 95, 0.16); flex-shrink: 0; }
.mode-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mode-copy b { font-size: 12.5px; }
.mode-copy small { font-size: 10.5px; color: var(--muted-2); }

.admin-btn { color: var(--gold); border-color: rgba(226, 180, 95, 0.28); background: rgba(226, 180, 95, 0.08); font-size: 15px; }

/* ---------------- spectator & bot thinking ---------------- */

.spectator-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid rgba(125, 211, 252, 0.28);
  background: rgba(125, 211, 252, 0.07);
  color: #bae6fd;
  font-size: 12.5px;
}
.spectator-banner .live-dot { background: var(--blue); }
.spectator-who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spectator-banner .btn { margin-left: auto; }

.game-shell.spectating .game-actions,
.game-shell.spectating .chat-card,
.game-shell.spectating .offer-banner { display: none; }

.bot-thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  margin-bottom: 12px;
  border-radius: 999px;
  border: 1px solid rgba(226, 180, 95, 0.26);
  background: rgba(226, 180, 95, 0.08);
  color: var(--gold-2);
  font-size: 11.5px;
  font-weight: 700;
  animation: fadeIn 0.2s ease both;
}
.bot-face { font-size: 14px; }
.dots { display: inline-flex; gap: 3px; margin-left: 1px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: dotBounce 1s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ---------------- animations ---------------- */

.board-intro .sq { animation: sqIn 0.42s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes sqIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }

.piece.slide-in { animation: pieceSlide 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes pieceSlide {
  from { transform: translate(calc(var(--dx, 0) * 100%), calc(var(--dy, 0) * 100%)) scale(1.04); }
  to { transform: none; }
}

.move-row { animation: moveRowIn 0.2s ease both; }
@keyframes moveRowIn { from { opacity: 0; transform: translateX(4px); } }

.hero-rating-value.bump { animation: ratingBump 0.45s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes ratingBump { 40% { transform: scale(1.08); color: var(--gold-2); } }

.live-dot { animation: livePulse 1.8s ease-in-out infinite; }
@keyframes livePulse { 50% { box-shadow: 0 0 0 5px rgba(110, 231, 183, 0.06); opacity: 0.75; } }

/* ---------------- bot modal ---------------- */

.bot-card { width: min(520px, 100%); text-align: center; }
.bot-mark { width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 17px; display: grid; place-items: center; font-size: 29px; background: linear-gradient(145deg, rgba(226, 180, 95, 0.24), rgba(226, 180, 95, 0.05)); border: 1px solid rgba(226, 180, 95, 0.3); }
.bot-sub { font-size: 12px; margin-bottom: 16px !important; }

.bot-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.bot-levels button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 8px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: 0.18s;
}
.bot-levels button:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.bot-levels button.active { border-color: rgba(226, 180, 95, 0.55); background: rgba(226, 180, 95, 0.1); box-shadow: 0 0 0 3px rgba(226, 180, 95, 0.07); }
.bot-level-icon { font-size: 22px; color: var(--gold); line-height: 1.1; }
.bot-levels b { font-size: 12.5px; }
.bot-level-rating { font-family: var(--mono); font-size: 11px; color: var(--gold-2); }
.bot-levels small { font-size: 9.5px; color: var(--muted-2); }

.bot-options { display: grid; gap: 12px; margin-bottom: 18px; text-align: left; }
.opt-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted-2); font-weight: 700; margin-bottom: 6px; }
#botColors, #botTC { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }

/* ---------------- admin ---------------- */

.admin-card { width: min(760px, 100%); max-height: min(90vh, 820px); overflow-y: auto; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-right: 28px; margin-bottom: 16px; }
.admin-kicker { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted-2); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.admin-head h2 { margin: 2px 0 0; }
.admin-refresh { font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-bottom: 18px; }
.admin-stat { padding: 10px 9px; border-radius: 11px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--border); text-align: center; }
.admin-stat b { display: block; font-family: var(--mono); font-size: 17px; font-variant-numeric: tabular-nums; }
.admin-stat span { font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted-2); font-weight: 700; }

.admin-section { margin-bottom: 18px; }
.admin-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; }
.admin-section-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.9px; color: var(--muted); }
.admin-count { font-family: var(--mono); font-size: 12px; color: var(--gold); }
.admin-list { display: flex; flex-direction: column; gap: 6px; }
.admin-empty { font-size: 12px; color: var(--muted-2); padding: 10px 2px; }

.admin-game {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.028);
  font-size: 12px;
  transition: border-color 0.18s, background 0.18s;
}
.admin-game:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }
.admin-game.clickable { cursor: pointer; }
.admin-game-main { flex: 1; min-width: 0; }
.admin-game-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.admin-game-line b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-game-vs { color: var(--muted-2); font-size: 10px; flex-shrink: 0; }
.admin-game-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 10px; color: var(--muted-2); }
.admin-badge { font-size: 9px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.admin-badge.live { color: var(--mint); border-color: rgba(110, 231, 183, 0.3); background: rgba(110, 231, 183, 0.07); }
.admin-badge.bot { color: var(--gold-2); border-color: rgba(226, 180, 95, 0.28); background: rgba(226, 180, 95, 0.07); }
.admin-game .clock { min-width: 58px; font-size: 13px; padding: 3px 6px; border-radius: 6px; }

/* ---------------- replay ---------------- */

.replay-card { width: min(620px, 100%); max-height: min(92vh, 900px); overflow-y: auto; }
.replay-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-right: 28px; margin-bottom: 14px; }
.replay-head h2 { margin: 2px 0 0; }

.replay-list { display: flex; flex-direction: column; gap: 6px; }
.replay-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.028);
  cursor: pointer;
  transition: 0.18s;
}
.replay-item:hover { border-color: rgba(226, 180, 95, 0.38); background: rgba(226, 180, 95, 0.06); transform: translateX(2px); }
.replay-item-main { flex: 1; min-width: 0; }
.replay-item-title { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-item-sub { font-size: 10.5px; color: var(--muted-2); margin-top: 1px; }
.replay-item-result { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); color: var(--muted); white-space: nowrap; }
.replay-item-result.w { color: var(--mint); background: rgba(110, 231, 183, 0.1); }
.replay-item-result.b { color: #fecaca; background: rgba(248, 113, 113, 0.1); }

.replay-stage { display: flex; flex-direction: column; gap: 10px; }
.replay-players { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 12px; }
.replay-player { display: flex; align-items: center; gap: 6px; min-width: 0; }
.replay-player .avatar { width: 26px; height: 26px; font-size: 11px; }
.replay-player b { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-vs { color: var(--muted-2); font-size: 10px; }

.replay-board-wrap { width: min(360px, 100%); margin: 0 auto; padding: 7px; border-radius: 14px; background: linear-gradient(150deg, #3a2a1f, #241a13 45%, #17110c); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); }
.replay-board { border-radius: 7px; }

.replay-result { text-align: center; font-size: 12px; color: var(--muted); }
.replay-result b { color: var(--text); }

.replay-controls { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.replay-controls .icon-btn { width: 34px; height: 34px; font-size: 16px; }
.replay-controls .btn { padding: 7px 13px; }
.replay-ply { font-family: var(--mono); font-size: 11.5px; color: var(--muted-2); margin-left: 4px; font-variant-numeric: tabular-nums; }

.replay-moves { max-height: 120px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 2px; }
.replay-move { border: 1px solid var(--border); background: rgba(255, 255, 255, 0.03); color: var(--muted); font-size: 11px; padding: 3px 7px; border-radius: 6px; cursor: pointer; font-family: var(--mono); transition: 0.14s; }
.replay-move:hover { color: var(--text); border-color: var(--border-strong); }
.replay-move.active { color: #1c1305; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.replay-move .num { color: var(--muted-2); margin-right: 3px; }

.hist-row.clickable { cursor: pointer; border-radius: 8px; transition: background 0.15s; }
.hist-row.clickable:hover { background: rgba(255, 255, 255, 0.045); }

/* ---------------- tournaments & medals ---------------- */

.tournament-card { width: min(980px, 100%); max-height: min(92vh, 920px); overflow-y: auto; }
.tournament-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.tournament-chip { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); background: rgba(255,255,255,.04); padding: 3px 8px; border-radius: 999px; }
.tournament-chip.live { color: var(--mint); border-color: rgba(110,231,183,.32); background: rgba(110,231,183,.07); }
.tournament-chip.draft { color: var(--gold-2); border-color: rgba(226,180,95,.3); background: rgba(226,180,95,.07); }
.tournament-chip.done { color: var(--muted); }
.tournament-champion { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--gold-2); }
.tournament-champion .medal-mini { font-size: 18px; filter: drop-shadow(0 0 8px rgba(226,180,95,.45)); animation: medalFloat 3s ease-in-out infinite; }

.tournament-list { display: flex; flex-direction: column; gap: 8px; }
.tournament-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.028);
  cursor: pointer;
  transition: transform .18s ease, border-color .2s, background .2s;
  animation: lbIn .35s both;
}
.tournament-item:hover { transform: translateX(3px); border-color: rgba(226,180,95,.4); background: rgba(226,180,95,.055); }
.tournament-item-main { flex: 1; min-width: 0; }
.tournament-item-title { font-size: 13.5px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.tournament-item-sub { font-size: 10.5px; color: var(--muted-2); margin-top: 2px; }
.tournament-item-trophy { font-size: 25px; filter: drop-shadow(0 0 10px rgba(226,180,95,.3)); }
.tournament-empty { font-size: 12px; color: var(--muted-2); padding: 16px 4px; text-align: center; }

.bracket-wrap { overflow-x: auto; padding: 8px 2px 18px; scrollbar-width: thin; }
.bracket { display: flex; gap: 26px; min-width: max-content; align-items: stretch; }
.bracket-round { display: flex; flex-direction: column; min-width: 175px; animation: bracketIn .45s cubic-bezier(.2,.9,.3,1) both; animation-delay: calc(var(--r, 0) * 90ms); }
.bracket-round-head { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted-2); font-weight: 800; text-align: center; padding: 0 0 8px; }
.bracket-matches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.bracket-match { position: relative; border: 1px solid var(--border); border-radius: 10px; background: linear-gradient(180deg, rgba(22,28,38,.9), rgba(16,21,29,.9)); padding: 4px; box-shadow: 0 8px 18px rgba(0,0,0,.18); animation: matchPop .35s both; }
.bracket-match.live { border-color: rgba(110,231,183,.5); box-shadow: 0 0 0 3px rgba(110,231,183,.07), 0 8px 20px rgba(0,0,0,.25); }
.bracket-match.live::after { content: ''; position: absolute; inset: -1px; border-radius: 10px; border: 1px solid rgba(110,231,183,.4); animation: liveGlow 2.2s ease-in-out infinite; pointer-events: none; }
.bracket-slot { display: flex; align-items: center; gap: 6px; padding: 5px 7px; border-radius: 7px; font-size: 11.5px; min-height: 29px; transition: background .15s; }
.bracket-slot + .bracket-slot { margin-top: 2px; }
.bracket-slot .seed { font-family: var(--mono); font-size: 8.5px; color: var(--muted-2); min-width: 13px; }
.bracket-slot .b-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bracket-slot .b-rating { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); }
.bracket-slot.win { background: rgba(110,231,183,.1); color: var(--mint); }
.bracket-slot.win .b-rating { color: rgba(110,231,183,.7); }
.bracket-slot.lose { opacity: .48; }
.bracket-slot.bot .b-name { color: var(--gold-2); font-weight: 700; }
.bracket-slot.empty { color: var(--muted-2); font-style: italic; }
.bracket-slot.empty.pick { cursor: pointer; border: 1px dashed rgba(226,180,95,.28); background: rgba(226,180,95,.03); }
.bracket-slot.empty.pick:hover { background: rgba(226,180,95,.1); border-color: rgba(226,180,95,.5); color: var(--gold-2); }
.bracket-slot .b-live { margin-left: auto; font-size: 8px; font-weight: 800; letter-spacing: .7px; color: var(--mint); }
.bracket-start { width: 100%; margin-top: 4px; padding: 4px 6px; font-size: 10px; border-radius: 6px; border: 1px solid rgba(226,180,95,.35); background: rgba(226,180,95,.1); color: var(--gold-2); cursor: pointer; font-weight: 700; }
.bracket-start:hover { background: rgba(226,180,95,.18); }

.tournament-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.admin-hint { margin-top: 10px; font-size: 11px; color: var(--muted-2); text-align: center; }

/* admin tournament + medal forms */

.admin-create { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 9px; }
.admin-input {
  background: rgba(255,255,255,.045);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.admin-input:focus { border-color: rgba(226,180,95,.45); box-shadow: 0 0 0 3px rgba(226,180,95,.08); }
.admin-create .admin-input { flex: 1 1 180px; }
.segmented.compact { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.segmented.compact button { padding: 5px 9px; font-size: 10.5px; border-radius: 6px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.segmented.compact button.active { background: rgba(226,180,95,.16); color: var(--gold-2); }

.admin-tour-item { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 11px; border: 1px solid var(--border); background: rgba(255,255,255,.028); }
.admin-tour-main { flex: 1; min-width: 0; }
.admin-tour-title { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tour-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.admin-tour-btns .btn, .admin-tour-btns .icon-btn { padding: 4px 7px; font-size: 10px; height: auto; min-height: 24px; }

.admin-medal-form { display: flex; flex-direction: column; gap: 6px; }
.admin-medal-row { display: flex; gap: 6px; }
.admin-medal-row .admin-input { flex: 1; }
.medal-icon-input { flex: 0 0 54px !important; text-align: center; }

.picker-card { width: min(460px, 100%); max-height: 80vh; overflow-y: auto; }
.picker-list { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; }
.picker-item { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: rgba(255,255,255,.03); cursor: pointer; font-size: 12px; transition: .15s; }
.picker-item:hover { border-color: rgba(226,180,95,.45); background: rgba(226,180,95,.07); }
.picker-item .b-rating { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--muted-2); }
.picker-item .avatar { width: 24px; height: 24px; font-size: 10px; }
.picker-group { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted-2); font-weight: 800; margin: 8px 2px 2px; }

/* medals */

.profile-medals { margin-bottom: 16px; }
.medal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 7px; margin-top: 8px; }
.medal-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.032);
  animation: medalIn .45s cubic-bezier(.2,.9,.3,1.1) both;
  transition: transform .18s, border-color .2s, background .2s;
}
.medal-card:hover { transform: translateY(-2px); border-color: var(--border-strong); background: rgba(255,255,255,.055); }
.medal-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.16) 46%, transparent 62%);
  transform: translateX(-130%);
  animation: medalShine 5s ease-in-out infinite;
  pointer-events: none;
}
.medal-card .medal-ico { font-size: 22px; line-height: 1; filter: drop-shadow(0 2px 5px rgba(0,0,0,.35)); animation: medalFloat 4s ease-in-out infinite; }
.medal-copy { min-width: 0; }
.medal-title { font-size: 11px; font-weight: 800; line-height: 1.25; }
.medal-detail { font-size: 9.5px; color: var(--muted-2); margin-top: 1px; line-height: 1.25; }
.medal-date { font-size: 8.5px; color: var(--muted-2); margin-top: 2px; font-family: var(--mono); opacity: .75; }
.medal-card.gold { border-color: rgba(245,217,155,.4); background: linear-gradient(150deg, rgba(226,180,95,.17), rgba(226,180,95,.04)); }
.medal-card.silver { border-color: rgba(203,213,225,.35); background: linear-gradient(150deg, rgba(203,213,225,.13), rgba(203,213,225,.03)); }
.medal-card.bronze { border-color: rgba(217,138,92,.36); background: linear-gradient(150deg, rgba(217,138,92,.15), rgba(217,138,92,.03)); }
.medal-card.special { border-color: rgba(125,211,252,.33); background: linear-gradient(150deg, rgba(125,211,252,.12), rgba(125,211,252,.03)); }
.medal-card.achievement { border-color: rgba(110,231,183,.3); background: linear-gradient(150deg, rgba(110,231,183,.1), rgba(110,231,183,.02)); }
.medal-empty { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted-2); padding: 10px 2px; }

.lb-medal { font-size: 11px; margin-left: 5px; filter: drop-shadow(0 0 5px rgba(226,180,95,.4)); }
.lb-row { animation: lbIn .32s both; animation-delay: calc(var(--i, 0) * 28ms); }
.lb-row.clickable { cursor: pointer; }
.lb-row.clickable:hover { background: rgba(226,180,95,.06); border-radius: 8px; }

/* ---------------- extra game animations ---------------- */

.clock.low { color: #fca5a5; border-color: rgba(248,113,113,.42); background: rgba(248,113,113,.08); animation: clockLow 1s ease-in-out infinite; }
@keyframes clockLow { 50% { box-shadow: 0 0 0 4px rgba(248,113,113,.08); } }

.sq.in-check::before {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px rgba(248,113,113,.85);
  border-radius: inherit;
  animation: checkPulse 1.25s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}
@keyframes checkPulse { 50% { box-shadow: inset 0 0 0 2px rgba(248,113,113,.35), inset 0 0 18px rgba(248,113,113,.35); } }

.sq .ripple { position: absolute; left: 50%; top: 50%; width: 130%; height: 130%; border-radius: 50%; background: radial-gradient(circle, rgba(226,180,95,.35), transparent 65%); transform: translate(-50%,-50%) scale(0); animation: rippleOut .55s ease-out forwards; pointer-events: none; z-index: 3; }
@keyframes rippleOut { to { transform: translate(-50%,-50%) scale(1); opacity: 0; } }

.capture-burst { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.burst-particle { position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: var(--gold-2); box-shadow: 0 0 8px rgba(226,180,95,.7); animation: burstOut .5s cubic-bezier(.15,.8,.4,1) forwards; }
@keyframes burstOut {
  from { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--bx, 0px)), calc(-50% + var(--by, 0px))) scale(.25); opacity: 0; }
}

.board.capture-shake { animation: boardShake .2s ease; }
@keyframes boardShake { 25% { transform: translateX(-2px) rotate(-.2deg); } 75% { transform: translateX(2px) rotate(.2deg); } }

.board.flip-anim { animation: boardFlip .34s ease; }
@keyframes boardFlip { 45% { transform: perspective(900px) rotateX(5deg) scale(.985); } }

.promotion-glow { position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(circle, rgba(245,217,155,.55), transparent 70%); animation: promoGlow .7s ease-out forwards; pointer-events: none; z-index: 4; }
@keyframes promoGlow { from { opacity: 1; transform: scale(.4); } to { opacity: 0; transform: scale(1.4); } }

.btn.primary { position: relative; overflow: hidden; }
.btn.primary::after { content: ''; position: absolute; top: 0; left: -60%; width: 45%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.34), transparent); transform: translateX(-120%); pointer-events: none; }
.btn.primary:hover::after { animation: btnSheen .75s ease; }
@keyframes btnSheen { to { transform: translateX(340%); } }

.result-emblem { animation: emblemFloat 3.4s ease-in-out infinite; }
@keyframes emblemFloat { 50% { transform: translateY(-4px) scale(1.025); } }

.move-row:last-child .san { animation: movePulse .45s ease; }
@keyframes movePulse { 40% { color: var(--gold-2); transform: translateX(2px); } }

.mode-btn { overflow: hidden; }
.mode-btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 35%, rgba(226,180,95,.12) 50%, transparent 65%); transform: translateX(-120%); pointer-events: none; }
.mode-btn { position: relative; }
.mode-btn:hover::after { animation: btnSheen 1s ease; }

@keyframes medalIn { from { opacity: 0; transform: translateY(8px) scale(.95); } }
@keyframes medalFloat { 50% { transform: translateY(-2px); } }
@keyframes medalShine { 0%, 72% { transform: translateX(-130%); } 88%, 100% { transform: translateX(130%); } }
@keyframes bracketIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes matchPop { from { opacity: 0; transform: scale(.96); } }
@keyframes liveGlow { 50% { box-shadow: 0 0 0 6px rgba(110,231,183,.03); opacity: .55; } }
@keyframes lbIn { from { opacity: 0; transform: translateX(-4px); } }

/* ---------------- friends & duels ---------------- */

.friends-btn { position: relative; }
.friends-btn svg { width: 18px; height: 18px; }
.friends-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(140deg, #fca5a5, #ef4444);
  color: #2a0707;
  font-size: 10px;
  font-weight: 900;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-1, #0b0f16);
  animation: badgePop .3s cubic-bezier(.2,.9,.3,1.4) both;
}
@keyframes badgePop { from { transform: scale(.4); opacity: 0; } }

.friends-card { width: min(590px, 100%); max-height: min(90vh, 820px); overflow-y: auto; }
.friends-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-right: 26px; }
.friends-head h2 { margin: 0; font-size: 23px; }
.friends-online {
  margin-left: auto;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(110, 231, 183, 0.24);
  background: rgba(110, 231, 183, 0.08);
  color: var(--mint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.friends-search { display: flex; gap: 8px; margin-bottom: 10px; }
.friends-search .admin-input { flex: 1; min-width: 0; }
.friends-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
  padding: 9px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid rgba(226, 180, 95, 0.16);
  background: rgba(226, 180, 95, 0.035);
  animation: fadeIn .18s both;
}

.friends-tabs { display: flex; gap: 6px; margin: 4px 0 12px; padding: 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--border); }
.friends-tabs button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.friends-tabs button.active { background: rgba(226, 180, 95, 0.13); color: var(--text); box-shadow: inset 0 0 0 1px rgba(226, 180, 95, 0.22); }
.friends-tabs button span {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 10px;
  line-height: 17px;
  font-weight: 800;
}
.friends-tabs button.active span { background: rgba(226, 180, 95, 0.22); color: var(--gold-2); }

.friends-list { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow-y: auto; padding-right: 2px; }
.friends-group-head { margin: 8px 0 2px; font-size: 9.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted-2); font-weight: 800; }
.friends-group-head:first-child { margin-top: 0; }

.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.028);
  animation: friendIn .28s cubic-bezier(.2,.9,.3,1) both;
  transition: border-color .16s, background .16s;
}
.friend-row:hover { border-color: rgba(226, 180, 95, 0.22); background: rgba(255, 255, 255, 0.045); }
@keyframes friendIn { from { opacity: 0; transform: translateY(5px); } }
.friend-row.incoming { border-color: rgba(226, 180, 95, 0.28); background: rgba(226, 180, 95, 0.045); }
.friend-row.search { background: rgba(255, 255, 255, 0.048); }

.friend-avatar {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, rgba(243, 211, 145, 0.22), rgba(185, 131, 47, 0.1));
  border: 1px solid rgba(226, 180, 95, 0.24);
  color: var(--gold-2);
  font-size: 15px;
  font-weight: 800;
}
.friend-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 2px #11161f, 0 0 9px rgba(110, 231, 183, 0.5);
}
.friend-dot.busy { background: var(--gold-2); box-shadow: 0 0 0 2px #11161f, 0 0 9px rgba(226, 180, 95, 0.45); }

.friend-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.friend-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.friend-name { font-size: 13.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-tag { padding: 1px 6px; border-radius: 999px; background: rgba(226, 180, 95, 0.16); color: var(--gold-2); font-size: 8.5px; letter-spacing: .4px; text-transform: uppercase; font-weight: 800; }
.friend-tag.muted { background: rgba(255, 255, 255, 0.07); color: var(--muted-2); }
.friend-sub { font-size: 10.5px; color: var(--muted-2); font-family: var(--mono); }
.friend-actions { margin-left: auto; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.btn.tiny-btn { padding: 6px 9px; font-size: 10.5px; border-radius: 8px; }
.friends-empty { padding: 22px 16px; text-align: center; color: var(--muted-2); font-size: 12.5px; line-height: 1.55; }

.duel-card { width: min(390px, 100%); text-align: center; padding-top: 30px; }
.duel-mark { font-size: 46px; line-height: 1; margin-bottom: 12px; filter: drop-shadow(0 6px 18px rgba(226,180,95,.25)); animation: duelFloat 2.10s ease-in-out infinite; }
@keyframes duelFloat { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
.duel-card h2 { margin: 8px 0 4px; font-size: 26px; }
.duel-card .admin-kicker { justify-content: center; }
.duel-timer {
  width: 74px;
  height: 74px;
  margin: 18px auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--gold-2);
  border: 2px solid rgba(226, 180, 95, 0.36);
  background: radial-gradient(circle at 50% 30%, rgba(226,180,95,.13), rgba(226,180,95,.03) 70%);
  box-shadow: 0 0 0 6px rgba(226,180,95,.05), inset 0 1px 0 rgba(255,255,255,.06);
  animation: duelTick 1s ease-in-out infinite;
}
@keyframes duelTick { 50% { border-color: rgba(226, 180, 95, 0.7); box-shadow: 0 0 0 9px rgba(226,180,95,.03); } }
.duel-actions { display: flex; gap: 8px; }
.duel-actions .btn { flex: 1; }

@media (max-width: 520px) {
  .friend-row { flex-wrap: wrap; }
  .friend-actions { width: 100%; margin-left: 0; justify-content: stretch; }
  .friend-actions .btn { flex: 1; }
  .friends-search { flex-direction: column; }
  .friends-search .btn { width: 100%; }
}

/* ---------------- responsive ---------------- */

@media (max-width: 1080px) {
  .lobby { grid-template-columns: 1fr; }
  .lobby-side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .game-grid { grid-template-columns: minmax(0, 1fr) 310px; }
  .game-side { position: static; }
}

@media (max-width: 900px) {
  .game-grid { grid-template-columns: 1fr; max-width: 620px; margin: 0 auto; }
  .game-side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .move-list { height: 220px; }
  .chat-log { height: 140px; }
}

@media (max-width: 720px) {
  .tc-card.active::after { display: none; }
  main { width: min(100% - 24px, 620px); padding-top: 16px; }
  .topbar { gap: 12px; padding: 11px 14px; }
  .topnav { display: none; }
  .brand-name { font-size: 18px; }
  .brand-mark { width: 34px; height: 34px; }
  .online-label { display: none; }
  .hero { padding: 26px 22px 22px; }
  .hero-top { flex-direction: column; gap: 18px; }
  .hero-rating { text-align: left; display: flex; align-items: baseline; gap: 10px; padding: 0; }
  .hero-rating-label { order: 2; }
  .hero-rating-value { font-size: 34px; }
  .hero-rating-sub { display: none; }
  .hero h1 { font-size: clamp(32px, 9vw, 44px); letter-spacing: -1.4px; }
  .tc-picker { gap: 7px; margin-top: 22px; }
  .tc-card { padding: 11px 11px 10px; }
  .tc-time { font-size: 17px; }
  .tc-desc { display: none; }
  .play-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .btn.xl { width: 100%; }
  .mode-row { flex-direction: column; }
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-card { padding: 18px; }
  .replay-card { padding: 18px; }
  .replay-players { flex-wrap: wrap; gap: 7px; }
  .bot-levels { gap: 6px; }
  .bot-levels button { padding: 10px 5px; }
  .bot-levels small { display: none; }
  .searching { flex-wrap: wrap; }
  .search-timer { margin-left: auto; }
  .searching .btn { width: 100%; }
  .lobby-side { grid-template-columns: 1fr; }
  .features { grid-template-columns: 1fr; }
  .feature { padding: 18px; }
  .game-side { grid-template-columns: 1fr; }
  .game-actions .only-mobile { display: inline-flex; }
  .game-badge { font-size: 11px; padding: 6px 10px; }
  .player-strip { padding: 8px 10px; }
  .clock { font-size: 19px; min-width: 74px; padding: 5px 8px; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .how-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 22px; }
  .footer { padding-bottom: 26px; text-align: center; }
}

@media (max-width: 460px) {
  .user-meta { display: none; }
  .user-chip { padding: 4px; border-radius: 50%; }
  .chev { display: none; }
  .online-pill { padding: 6px 9px; }
  .game-top { gap: 8px; }
  .game-top .btn { padding: 7px 10px; font-size: 11.5px; }
  .avatar.lg { width: 38px; height: 38px; }
  .profile-head { flex-wrap: wrap; }
  .profile-rating { margin-left: 0; }
}

@media (min-width: 901px) {
  .game-grid { grid-template-columns: minmax(0, min(620px, 56vh)) 330px; }
}

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