/* ============================================================================
   ExadokoChess — design system
   ========================================================================== */

/* ---------------- tokens ---------------- */
:root {
  color-scheme: dark;

  --bg: #07090f;
  --bg-grad-1: rgba(99, 102, 241, 0.16);
  --bg-grad-2: rgba(16, 185, 129, 0.10);
  --bg-grad-3: rgba(244, 180, 76, 0.07);
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.055);
  --surface-solid: #0e1119;
  --panel: rgba(17, 21, 32, 0.82);
  --panel-solid: #111520;
  --elev: rgba(22, 27, 40, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f8;
  --text-2: #b8c0d4;
  --muted: #8992a8;
  --faint: #626b80;

  --accent: #f4b44c;
  --accent-2: #ffc978;
  --accent-ink: #241803;
  --accent-soft: rgba(244, 180, 76, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);
  --warn: #fbbf24;
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);

  --board-light: #ebecd0;
  --board-dark: #6f9455;
  --board-frame: #2a3040;
  --sq-last: rgba(244, 180, 76, 0.34);
  --sq-check: rgba(251, 113, 133, 0.62);
  --sq-sel: rgba(96, 165, 250, 0.45);
  --sq-hover: rgba(255, 255, 255, 0.14);
  --dot: rgba(20, 24, 32, 0.34);
  --ring: rgba(20, 24, 32, 0.34);

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 8px 24px rgba(0, 0, 0, 0.32);
  --sh-3: 0 24px 60px rgba(0, 0, 0, 0.48);
  --sh-glow: 0 0 0 1px rgba(244, 180, 76, 0.32), 0 12px 40px rgba(244, 180, 76, 0.14);

  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --nav-h: 64px;
  --maxw: 1360px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------------- accents ---------------- */
[data-accent='emerald'] {
  --accent: #34d399; --accent-2: #6ee7b7; --accent-ink: #04231a;
  --accent-soft: rgba(52, 211, 153, 0.15);
  --sh-glow: 0 0 0 1px rgba(52, 211, 153, 0.32), 0 12px 40px rgba(52, 211, 153, 0.14);
}
[data-accent='azure'] {
  --accent: #60a5fa; --accent-2: #93c5fd; --accent-ink: #041428;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --sh-glow: 0 0 0 1px rgba(96, 165, 250, 0.32), 0 12px 40px rgba(96, 165, 250, 0.14);
}
[data-accent='violet'] {
  --accent: #a78bfa; --accent-2: #c4b5fd; --accent-ink: #170b34;
  --accent-soft: rgba(167, 139, 250, 0.15);
  --sh-glow: 0 0 0 1px rgba(167, 139, 250, 0.32), 0 12px 40px rgba(167, 139, 250, 0.14);
}
[data-accent='rose'] {
  --accent: #fb7185; --accent-2: #fda4af; --accent-ink: #2c0710;
  --accent-soft: rgba(251, 113, 133, 0.15);
  --sh-glow: 0 0 0 1px rgba(251, 113, 133, 0.32), 0 12px 40px rgba(251, 113, 133, 0.14);
}

/* ---------------- light theme ---------------- */
[data-theme='light'] {
  color-scheme: light;
  --bg: #f2f4f9;
  --bg-grad-1: rgba(99, 102, 241, 0.13);
  --bg-grad-2: rgba(16, 185, 129, 0.10);
  --bg-grad-3: rgba(244, 180, 76, 0.14);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --elev: #ffffff;
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent-ink: #241803;
  --board-frame: #d7dce6;
  --sh-1: 0 1px 2px rgba(15, 23, 42, 0.08);
  --sh-2: 0 10px 30px rgba(15, 23, 42, 0.10);
  --sh-3: 0 30px 70px rgba(15, 23, 42, 0.16);
  --dot: rgba(30, 41, 59, 0.30);
  --ring: rgba(30, 41, 59, 0.30);
}
[data-theme='light'][data-accent='gold'] { --accent: #d9922b; --accent-2: #eab04f; --accent-ink: #241803; }
[data-theme='light'][data-accent='emerald'] { --accent: #059669; --accent-ink: #ecfdf5; }
[data-theme='light'][data-accent='azure'] { --accent: #2563eb; --accent-ink: #eff6ff; }
[data-theme='light'][data-accent='violet'] { --accent: #7c3aed; --accent-ink: #f5f3ff; }
[data-theme='light'][data-accent='rose'] { --accent: #e11d48; --accent-ink: #fff1f2; }

/* ---------------- board palettes ---------------- */
[data-board='exa'] { --board-light: #ebecd0; --board-dark: #6f9455; }
[data-board='wood'] { --board-light: #f0d9b5; --board-dark: #b58863; }
[data-board='ocean'] { --board-light: #dee3e6; --board-dark: #788a94; }
[data-board='slate'] { --board-light: #dbe3ee; --board-dark: #68809b; }
[data-board='violet'] { --board-light: #efe8f6; --board-dark: #977fb8; }
[data-board='ember'] { --board-light: #f6e3d3; --board-dark: #c96f4a; }
[data-board='graphite'] { --board-light: #d9dde3; --board-dark: #4d5563; }
[data-board='mint'] { --board-light: #e7f4ec; --board-dark: #5fa883; }

/* ---------------- base ---------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 620px at 88% -12%, var(--bg-grad-1), transparent 62%),
    radial-gradient(820px 520px at -12% 4%, var(--bg-grad-2), transparent 60%),
    radial-gradient(700px 460px at 50% 108%, var(--bg-grad-3), transparent 62%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
}
[data-theme='light'] body::before {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
}

h1, h2, h3, h4 { margin: 0 0 10px; font-weight: 800; line-height: 1.16; letter-spacing: -0.022em; }
h1 { font-size: clamp(28px, 4.2vw, 44px); }
h2 { font-size: clamp(20px, 2.6vw, 26px); }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; }
.row.gap { gap: 12px; }
.row.gap-sm { gap: 7px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.spacer { flex: 1; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

::selection { background: var(--accent); color: var(--accent-ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ---------------- layout ---------------- */
.page {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 22px 70px;
  animation: pageIn 0.42s var(--ease-out) both;
}
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--sh-2);
}
.panel.flat { background: var(--surface); box-shadow: none; }
.panel-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px;
}
.panel-title .ico { color: var(--accent); }

/* every stroke icon gets a sane default size; contexts override */
.ico { width: 18px; height: 18px; flex: none; }

/* ---------------- buttons ---------------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--line);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s var(--ease), background 0.18s, border-color 0.18s, box-shadow 0.18s, color 0.18s;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn .ico { width: 17px; height: 17px; flex: none; }

.btn.primary {
  --btn-bg: linear-gradient(180deg, var(--accent-2), var(--accent));
  --btn-fg: var(--accent-ink);
  --btn-bd: transparent;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: var(--sh-glow); }
.btn.danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-bd: rgba(251, 113, 133, 0.3); }
.btn.danger:hover { background: rgba(251, 113, 133, 0.22); border-color: var(--danger); }
.btn.ghost { --btn-bg: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.ghost-light { --btn-bg: rgba(255, 255, 255, 0.10); --btn-fg: #fff; --btn-bd: rgba(255, 255, 255, 0.22); }
[data-theme='light'] .btn.ghost-light { --btn-bg: rgba(15, 23, 42, 0.06); --btn-fg: var(--text); --btn-bd: var(--line-strong); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: var(--r-xs); }
.btn.lg { padding: 14px 24px; font-size: 16px; border-radius: var(--r-md); }
.btn.block { width: 100%; }
.btn.icon-only { padding: 9px; }
.btn.on { --btn-bg: var(--accent-soft); --btn-fg: var(--accent); --btn-bd: rgba(244, 180, 76, 0.36); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.seg-btn {
  padding: 7px 13px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 700; cursor: pointer; transition: 0.16s var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); box-shadow: var(--sh-1); }
.seg.seg-sm .seg-btn { padding: 5px 10px; font-size: 12px; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font-size: 13px; font-weight: 700; cursor: pointer;
  transition: 0.16s var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-sm { padding: 4px 10px; font-size: 12px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.bad { background: var(--danger-soft); color: var(--danger); }

/* inputs */
.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: 0.16s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 72px; font-family: var(--font-num); font-size: 13px; line-height: 1.5; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.lbl { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }

input[type='range'] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track { height: 5px; border-radius: 99px; background: var(--line-strong); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 17px; height: 17px; margin-top: -6px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel-solid); box-shadow: var(--sh-1); }
input[type='range']::-moz-range-track { height: 5px; border-radius: 99px; background: var(--line-strong); }
input[type='range']::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel-solid); }

/* ---------------- navbar ---------------- */
.nav {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 76%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 20px;
  height: var(--nav-h); display: flex; align-items: center; gap: 18px;
}
.nav-logo { display: flex; align-items: center; gap: 10px; color: var(--text); flex: none; }
.nav-logo:hover { text-decoration: none; }
.nav-logo .mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.35)); }
.wordmark { font-size: 17px; font-weight: 800; letter-spacing: -0.03em; }
.wordmark b { color: var(--accent); font-weight: 800; }

.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.nav-link {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: var(--r-xs);
  color: var(--muted); font-size: 14px; font-weight: 700;
  transition: 0.16s var(--ease);
}
.nav-link .ico { width: 17px; height: 17px; }
.nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-link.active { color: var(--text); }
.nav-link.active::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px;
  border-radius: 2px; background: var(--accent);
}
.nav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r-xs);
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: 0.16s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.kbd-hint {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: var(--r-xs);
  border: 1px solid var(--line); background: var(--surface); color: var(--faint);
  font-size: 12px; cursor: pointer; transition: 0.16s;
}
.kbd-hint:hover { color: var(--text-2); border-color: var(--line-strong); }
kbd {
  font-family: var(--font-num); font-size: 11px; padding: 1px 5px;
  border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-2);
}

.nav-burger { display: none; }

/* compact nav for medium-wide screens so the account area always fits */
@media (max-width: 1720px) {
  .nav-inner { gap: 10px; padding: 0 14px; }
  .nav-links { gap: 0; margin-left: 2px; }
  .nav-link { padding: 8px 7px; font-size: 12.5px; gap: 5px; }
  .nav-link .ico { width: 15px; height: 15px; }
  .nav-link.active::after { left: 7px; right: 7px; }
  .wordmark { font-size: 15.5px; }
}
@media (max-width: 1720px) {
  .kbd-hint kbd { display: none; }
  .kbd-hint { padding: 8px; }
}
@media (max-width: 1500px) {
  .nav-link { padding: 8px 5px; font-size: 12px; }
  .nav-link .ico { width: 14px; height: 14px; }
  .nav-right { gap: 5px; }
  #lang-switch { display: none; }
}
.chat-head b { display: inline-flex; align-items: center; gap: 8px; }
.pop-menu[hidden] { display: none; }

/* mobile tab bar */
.tabbar { display: none; }

/* ---------------- footer ---------------- */
.footer { position: relative; z-index: 1; border-top: 1px solid var(--line); margin-top: 20px; background: color-mix(in srgb, var(--bg) 60%, transparent); }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 26px 22px 34px;
  display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: flex-start;
}
.footer-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; }
.footer-brand .mark { width: 24px; height: 24px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.footer-links a { color: var(--muted); font-size: 13.5px; }
.footer-links a:hover { color: var(--text); }
.footer-note { width: 100%; color: var(--faint); font-size: 12.5px; }

/* ============================================================================
   Board
   ========================================================================== */
.board-wrap { position: relative; width: 100%; }
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--board-dark);
  box-shadow: var(--sh-3), 0 0 0 1px rgba(0, 0, 0, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  isolation: isolate;
}
.board:focus { outline: none; }
.squares, .pieces { position: absolute; inset: 0; }
.squares { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; }
.sq.light { background: var(--board-light); }
.sq.dark { background: var(--board-dark); }
.sq::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: transparent; transition: background 0.14s;
}
.sq.mark-last::after { background: var(--sq-last); }
.sq.mark-check::after { background: radial-gradient(circle at 50% 50%, var(--sq-check) 0%, rgba(251, 113, 133, 0.16) 62%, transparent 78%); }
.sq.mark-sel::after { background: var(--sq-sel); }
.sq.mark-hover::after { background: var(--sq-hover); }
.sq.mark-hint::after { background: rgba(96, 165, 250, 0.4); }
.sq.pulse::after { animation: pulseSq 1.1s ease-out 2; }
@keyframes pulseSq {
  0% { background: rgba(96, 165, 250, 0.75); }
  100% { background: rgba(96, 165, 250, 0); }
}

.coord {
  position: absolute; font-size: 10px; font-weight: 800; letter-spacing: 0.02em;
  pointer-events: none; opacity: 0.72; font-family: var(--font);
}
.coord-file { right: 3px; bottom: 1px; }
.coord-rank { left: 3px; top: 1px; }
.sq.light .coord { color: var(--board-dark); }
.sq.dark .coord { color: var(--board-light); }

.dot, .cap-ring { position: absolute; pointer-events: none; z-index: 2; }
.dot {
  left: 50%; top: 50%; width: 27%; height: 27%; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--dot);
  animation: dotIn 0.16s var(--ease-out) both;
}
@keyframes dotIn { from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } }
.cap-ring {
  inset: 3%; border-radius: 50%;
  border: 4px solid var(--ring);
  animation: dotIn 0.16s var(--ease-out) both;
}

.piece {
  position: absolute; left: 0; top: 0;
  width: 12.5%; height: 12.5%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.19s var(--ease-out);
  will-change: transform;
  cursor: grab;
  z-index: 3;
}
.piece img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }
.piece.dragging { z-index: 20; cursor: grabbing; transition: none; }
.piece.dragging img { transform: scale(1.1); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.45)); }
.piece.capturing { z-index: 1; animation: capOut 0.22s var(--ease) forwards; }
@keyframes capOut { to { opacity: 0; transform: var(--tf, none) scale(0.55); } }
.piece.premove img { opacity: 0.55; }
.board.no-anim .piece { transition: none; }
.board.drag-active .piece:not(.dragging) { pointer-events: none; }
.board.shake { animation: shake 0.42s var(--ease); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); }
}
.arrows-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 15; }

/* promotion picker */
.promo {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 12, 0.62);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.14s both;
}
@keyframes fadeIn { from { opacity: 0; } }
.promo-box {
  display: flex; gap: 8px; padding: 12px;
  background: var(--elev); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--sh-3);
  animation: popIn 0.2s var(--ease-out) both;
}
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } }
.promo-opt {
  width: 62px; height: 62px; padding: 4px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; transition: 0.14s;
}
.promo-opt:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.promo-opt img { width: 100%; height: 100%; object-fit: contain; }

/* eval bar */
.eval-bar {
  position: relative; width: 20px; height: 100%; flex: none;
  border-radius: 6px; overflow: hidden; background: #1b1f2a;
  border: 1px solid var(--line);
}
.eval-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  background: linear-gradient(180deg, #fbfcff, #d7dbe6);
  transition: height 0.45s var(--ease-out);
}
.eval-bar.black-orientation .eval-fill { top: 0; bottom: auto; }
.eval-num {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 4px;
  font-family: var(--font-num); font-size: 9.5px; font-weight: 700; color: #6b7280;
  mix-blend-mode: difference; color: #fff;
}
.board-with-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  max-width: var(--board-max, 640px);
}
.board-col { flex: 1; min-width: 0; width: 100%; max-width: var(--board-max, 640px); }
.board-with-bar .board-col { flex: 1; min-width: 0; }
/* the board itself must never collapse: it is sized by aspect-ratio */
.board-wrap { min-width: 0; }
.gcol-board { width: 100%; }
.gcol-board .board-col { margin: 0 auto; }
.puzzle-page, .editor-page, .explorer-page, .learn-page { --board-max: 620px; }
.analysis-page, .game-page { --board-max: 620px; }

/* ============================================================================
   Home
   ========================================================================== */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  padding: clamp(28px, 5vw, 62px);
  background:
    radial-gradient(900px 460px at 82% 12%, var(--accent-soft), transparent 62%),
    linear-gradient(160deg, color-mix(in srgb, var(--panel-solid) 92%, transparent), color-mix(in srgb, var(--bg) 70%, transparent));
  box-shadow: var(--sh-3);
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.55;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.035) 75%);
  background-size: 44px 44px; background-position: 0 0, 22px 22px;
  mask-image: radial-gradient(circle at 78% 22%, #000, transparent 68%);
  -webkit-mask-image: radial-gradient(circle at 78% 22%, #000, transparent 68%);
}
.hero-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 34px; align-items: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: var(--r-pill);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  margin-bottom: 18px;
}
.hero-badge .pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.8s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.hero h1 { margin-bottom: 14px; }
.hero h1 .grad {
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 60%, var(--text));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: clamp(15px, 1.5vw, 18px); color: var(--text-2); max-width: 56ch; margin-bottom: 26px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 11px; }
.hero-points { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 24px; }
.hero-points span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.hero-points .ico { width: 16px; height: 16px; color: var(--ok); }

.hero-board-card {
  position: relative; padding: 16px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line-strong));
  background: linear-gradient(160deg, color-mix(in srgb, var(--panel-solid) 92%, transparent), color-mix(in srgb, var(--bg) 78%, transparent));
  box-shadow: var(--sh-3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: floaty 7s ease-in-out infinite;
}
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-mini {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 12px; overflow: hidden; aspect-ratio: 1;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 26px rgba(0, 0, 0, 0.16);
}
.hero-mini i { display: block; min-width: 0; min-height: 0; position: relative; }
.hero-mini i.l { background: var(--board-light); }
.hero-mini i.d { background: var(--board-dark); }
.hero-mini i b { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-weight: 400; }
.hero-mini i[data-f='a']::before { content: attr(data-r); position: absolute; top: 2px; left: 3px; font-size: 9px; font-weight: 800; opacity: 0.78; pointer-events: none; }
.hero-mini i[data-r='1']::after { content: attr(data-f); position: absolute; bottom: 1px; right: 3px; font-size: 9px; font-weight: 800; opacity: 0.78; pointer-events: none; }
.hero-mini i.l::before, .hero-mini i.l::after { color: var(--board-dark); }
.hero-mini i.d::before, .hero-mini i.d::after { color: var(--board-light); }
.hero-mini img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3)); animation: pieceIn 0.5s var(--ease-out) both; }
@keyframes pieceIn { from { opacity: 0; transform: scale(0.6); } }

.stats-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; margin: 22px 0;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.stat { padding: 18px 16px; background: var(--panel-solid); text-align: center; }
.stat b { display: block; font-size: 27px; font-weight: 800; letter-spacing: -0.03em; font-family: var(--font-num); }
.stat span { font-size: 12px; color: var(--muted); }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 40px 0 18px; flex-wrap: wrap; }
.section-head p { margin: 0; color: var(--muted); max-width: 60ch; }

.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.feature-card {
  position: relative; overflow: hidden;
  padding: 20px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line);
  transition: transform 0.24s var(--ease), border-color 0.24s, box-shadow 0.24s;
}
.feature-card::before {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(320px 180px at 12% 0%, var(--accent-soft), transparent 70%);
}
.feature-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--sh-2); }
.feature-card:hover::before { opacity: 1; }
.feature-card > * { position: relative; }
.feature-ico {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 13px;
}
.feature-ico .ico { width: 21px; height: 21px; }
.feature-card h3 { margin-bottom: 6px; }
.feature-card p { margin: 0; font-size: 14px; color: var(--muted); }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.quick-card {
  display: flex; gap: 14px; align-items: center;
  padding: 16px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text); text-align: left; cursor: pointer;
  transition: 0.2s var(--ease);
}
.quick-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--sh-2); text-decoration: none; }
.quick-card .qico { width: 42px; height: 42px; flex: none; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.quick-card .qico .ico { width: 22px; height: 22px; }
.quick-card b { display: block; font-size: 15px; }
.quick-card span { font-size: 13px; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.step { padding: 18px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.step-n {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 14px; margin-bottom: 11px;
}

.faq { display: grid; gap: 10px; }
.faq-item { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.faq-q {
  width: 100%; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 15px 17px; background: transparent; border: 0; cursor: pointer;
  font-size: 15px; font-weight: 700; text-align: left; color: var(--text);
}
.faq-q .chev { width: 18px; height: 18px; color: var(--muted); transition: transform 0.24s var(--ease); flex: none; }
.faq-item.open .faq-q .chev { transform: rotate(180deg); color: var(--accent); }
.faq-a { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.28s var(--ease); }
.faq-item.open .faq-a { grid-template-rows: 1fr; }
.faq-a > div { overflow: hidden; }
.faq-a p { margin: 0; padding: 0 17px 16px; color: var(--muted); font-size: 14px; }

.cta-band {
  display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap;
  margin-top: 34px; padding: 26px;
  border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  background: linear-gradient(120deg, var(--accent-soft), transparent 70%), var(--panel);
}

/* ============================================================================
   Game / analysis / puzzles layouts
   ========================================================================== */
.game-layout { display: grid; grid-template-columns: minmax(250px, 300px) minmax(320px, 1fr) minmax(250px, 330px); gap: 16px; align-items: start; }
.an-layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(260px, 360px) minmax(240px, 300px); gap: 16px; align-items: start; }
.pz-layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(270px, 380px); gap: 16px; align-items: start; }
.gcol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.gcol-board { align-items: stretch; }

.player-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.player-card.active { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 0 0 1px var(--accent-soft), var(--sh-2); }
.pc-avatar {
  width: 38px; height: 38px; flex: none; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.pc-avatar .ico { width: 21px; height: 21px; }
.pc-avatar.bot { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.pc-info { flex: 1; min-width: 0; }
.pc-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 17px; }
.captured { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; }
.cap-piece { width: 17px; height: 17px; object-fit: contain; opacity: 0.85; }
.cap-diff { font-family: var(--font-num); font-size: 12px; font-weight: 700; color: var(--text-2); margin-left: 4px; }
.clock {
  font-family: var(--font-num); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 6px 11px; border-radius: var(--r-xs);
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2);
  min-width: 84px; text-align: center;
}
.clock.active { background: var(--text); color: var(--bg); border-color: var(--text); }
[data-theme='light'] .clock.active { background: var(--text); color: #fff; }
.clock.low { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); animation: lowPulse 1s infinite; }
.clock.active.low { background: var(--danger); color: #fff; border-color: var(--danger); }
@keyframes lowPulse { 50% { opacity: 0.62; } }

.moves-panel { display: flex; flex-direction: column; min-height: 0; }
.move-list { max-height: min(46vh, 400px); overflow-y: auto; padding-right: 4px; }
.ml-row { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 4px; align-items: center; padding: 1px 0; }
.ml-num { font-family: var(--font-num); font-size: 12px; color: var(--faint); text-align: right; padding-right: 6px; }
.ml-move {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 8px; border-radius: 7px; border: 0; background: transparent;
  color: var(--text-2); font-size: 14px; font-weight: 700; cursor: pointer; text-align: left;
  transition: 0.13s;
}
.ml-move:hover { background: var(--surface-2); color: var(--text); }
.ml-move.cur { background: var(--accent-soft); color: var(--accent); }
.ml-move:empty { cursor: default; }
.ml-move:empty:hover { background: transparent; }
.ml-empty { padding: 12px; text-align: center; }
.nav-btns { display: flex; gap: 5px; margin-bottom: 8px; }
.nav-btns .btn { flex: 1; padding: 6px; }
.class-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.cd-best { background: var(--ok); }
.cd-excellent { background: #7dd3a0; }
.cd-good { background: #93c5fd; }
.cd-book { background: #c4b5fd; }
.cd-inaccuracy { background: #fcd34d; }
.cd-mistake { background: #fb923c; }
.cd-blunder { background: var(--danger); }
.cd-forced { background: var(--faint); }

.opening-name { font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--accent); margin-left: auto; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-height: 20px; }
.status-line .ico { width: 15px; height: 15px; }
.dots { display: inline-flex; gap: 3px; }
.dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: dotBounce 1.1s infinite; }
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

.controls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.controls-grid .btn { width: 100%; }

.engine-meta { font-family: var(--font-num); font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.an-lines { display: flex; flex-direction: column; gap: 5px; }
.an-line {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 9px; border-radius: var(--r-xs); background: var(--surface);
  font-size: 13.5px; cursor: pointer; transition: 0.14s;
}
.an-line:hover { background: var(--surface-2); }
.an-line.main { background: var(--accent-soft); }
.eval-badge {
  font-family: var(--font-num); font-size: 12px; font-weight: 700;
  padding: 2px 6px; border-radius: 5px; flex: none; min-width: 46px; text-align: center;
}
.eval-badge.pos { background: var(--ok-soft); color: var(--ok); }
.eval-badge.neg { background: var(--danger-soft); color: var(--danger); }
.eval-badge.mid { background: var(--surface-2); color: var(--text-2); }
.pv-san { font-family: var(--font-num); font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wdl { display: flex; height: 5px; border-radius: 99px; overflow: hidden; width: 54px; flex: none; }
.wdl i { display: block; height: 100%; }
.wdl .w { background: var(--text); }
.wdl .d { background: var(--muted); }
.wdl .l { background: #3a4152; }
[data-theme='light'] .wdl .l { background: #cbd5e1; }
.an-line-empty { padding: 10px; text-align: center; }

.an-graph-wrap { margin-top: 12px; }
.an-graph { width: 100%; height: 82px; display: block; border-radius: var(--r-xs); background: var(--surface); cursor: crosshair; border: 1px solid var(--line); }
.graph-hint { font-size: 11.5px; text-align: center; margin-top: 5px; }

.full-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.full-bar { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.full-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.25s; }

.accuracy-row { display: flex; gap: 8px; margin-top: 10px; }
.acc-box { flex: 1; padding: 10px; border-radius: var(--r-xs); background: var(--surface); text-align: center; }
.acc-box b { display: block; font-family: var(--font-num); font-size: 20px; }
.acc-box span { font-size: 11px; color: var(--muted); }

/* puzzles */
.pz-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.pz-title { margin-bottom: 4px; }
.pz-feedback { min-height: 24px; font-size: 14px; font-weight: 700; }
.pz-feedback.ok { color: var(--ok); }
.pz-feedback.bad { color: var(--danger); }
.pz-feedback.hint { color: var(--info); }
.pz-feedback.big { font-size: 17px; }
.pz-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.pz-stat { padding: 10px; border-radius: var(--r-xs); background: var(--surface); text-align: center; }
.pz-stat b { display: block; font-family: var(--font-num); font-size: 20px; }
.pz-stat span { font-size: 11px; color: var(--muted); }
.pz-progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.pz-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* library */
.lib-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.lib-toolbar .input { width: auto; min-width: 200px; flex: 1; }
.game-list { display: grid; gap: 10px; }
.game-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 15px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line);
  transition: 0.18s var(--ease);
}
.game-row:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--sh-2); }
.gr-result {
  width: 44px; height: 44px; flex: none; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; font-family: var(--font-num);
}
.gr-result.win { background: var(--ok-soft); color: var(--ok); }
.gr-result.loss { background: var(--danger-soft); color: var(--danger); }
.gr-result.draw { background: var(--surface-2); color: var(--muted); }
.gr-main { flex: 1; min-width: 0; }
.gr-title { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.gr-actions { display: flex; gap: 6px; flex: none; }
.empty-state { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty-state .ico { width: 46px; height: 46px; color: var(--faint); margin-bottom: 12px; }

/* profile */
.profile-grid { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.rating-hero { text-align: center; padding: 24px 18px; }
.rating-num { font-family: var(--font-num); font-size: 58px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.rating-delta { font-family: var(--font-num); font-size: 14px; font-weight: 700; }
.rating-delta.up { color: var(--ok); }
.rating-delta.down { color: var(--danger); }
.spark { width: 100%; height: 62px; display: block; margin-top: 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-card { padding: 14px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); }
.stat-card b { display: block; font-family: var(--font-num); font-size: 23px; }
.stat-card span { font-size: 12px; color: var(--muted); }
.level-bars { display: grid; gap: 9px; }
.level-bar { display: grid; grid-template-columns: 120px 1fr 84px; gap: 10px; align-items: center; font-size: 13px; }
.lb-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.lb-track i { display: block; height: 100%; }
.lb-track .w { background: var(--ok); }
.lb-track .d { background: var(--muted); }
.lb-track .l { background: var(--danger); }
.lb-num { font-family: var(--font-num); font-size: 12px; color: var(--muted); text-align: right; }
.heatmap { display: grid; grid-template-columns: repeat(auto-fill, 13px); gap: 3px; }
.hm-cell { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); }
.hm-cell.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.hm-cell.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.hm-cell.l3 { background: color-mix(in srgb, var(--accent) 80%, var(--surface-2)); }
.hm-cell.l4 { background: var(--accent); }

/* editor */
.editor-layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(260px, 340px); gap: 16px; align-items: start; }
.piece-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pp-item {
  aspect-ratio: 1; padding: 4px; border-radius: var(--r-xs);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: 0.14s;
}
.pp-item:hover { border-color: var(--line-strong); }
.pp-item.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.pp-item img { width: 100%; height: 100%; object-fit: contain; }
.pp-item.eraser { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.pp-item.eraser .ico { width: 22px; height: 22px; }

/* lessons */
.lesson-list { display: grid; gap: 10px; }
.lesson-card {
  display: flex; gap: 14px; align-items: center; text-align: left;
  padding: 15px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line); cursor: pointer;
  transition: 0.18s var(--ease); width: 100%;
}
.lesson-card:hover { border-color: var(--accent); transform: translateX(3px); }
.lesson-card .lnum {
  width: 38px; height: 38px; flex: none; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-family: var(--font-num);
}
.lesson-card.done .lnum { background: var(--ok-soft); color: var(--ok); }
.lesson-body { flex: 1; min-width: 0; }
.lesson-body b { display: block; font-size: 15px; }
.lesson-body span { font-size: 13px; color: var(--muted); }
.lesson-view { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(260px, 380px); gap: 16px; align-items: start; }
.lesson-text { font-size: 14.5px; color: var(--text-2); }
.lesson-text ul { padding-left: 20px; }
.lesson-text li { margin-bottom: 6px; }

/* openings explorer */
.oe-layout { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(280px, 400px); gap: 16px; align-items: start; }
.oe-name { font-size: 17px; font-weight: 800; }
.oe-eco { font-family: var(--font-num); font-size: 12px; color: var(--accent); }
.oe-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.oe-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.oe-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.oe-table tr:hover td { background: var(--surface); }
.oe-move { font-family: var(--font-num); font-weight: 700; color: var(--text); cursor: pointer; }
.oe-move:hover { color: var(--accent); }
.oe-bar { display: flex; height: 7px; border-radius: 99px; overflow: hidden; background: var(--surface-2); min-width: 70px; }
.oe-bar i { display: block; height: 100%; }
.oe-bar .w { background: var(--text); }
.oe-bar .d { background: var(--muted); }
.oe-bar .b { background: #39404f; }
[data-theme='light'] .oe-bar .b { background: #94a3b8; }
.oe-crumb { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; margin-bottom: 10px; }
.oe-crumb button { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 5px; }
.oe-crumb button:hover { color: var(--accent); background: var(--surface); }
.oe-crumb .sep { color: var(--faint); }

/* ============================================================================
   Modals, toasts, palette
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(3, 5, 10, 0.68);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  opacity: 0; transition: opacity 0.2s;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  width: min(520px, 100%); max-height: min(86vh, 780px); overflow: auto;
  background: var(--elev); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--sh-3);
  padding: 22px;
  transform: translateY(14px) scale(0.97); transition: transform 0.24s var(--ease-out);
}
.modal-backdrop.show .modal { transform: none; }
.modal.wide { width: min(760px, 100%); }
.modal-title { font-size: 19px; font-weight: 800; margin-bottom: 14px; letter-spacing: -0.02em; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }

#toast-root { position: fixed; z-index: 300; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 11px 17px; border-radius: var(--r-pill);
  background: var(--elev); border: 1px solid var(--line-strong); color: var(--text);
  font-size: 14px; font-weight: 600; box-shadow: var(--sh-3);
  opacity: 0; transform: translateY(12px); transition: 0.26s var(--ease-out);
  max-width: min(90vw, 460px);
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

.palette-backdrop {
  position: fixed; inset: 0; z-index: 250; padding: 12vh 20px 20px;
  background: rgba(3, 5, 10, 0.6); backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: flex-start;
  opacity: 0; transition: opacity 0.16s;
}
.palette-backdrop.show { opacity: 1; }
.palette {
  width: min(600px, 100%); background: var(--elev);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--sh-3); overflow: hidden;
  transform: translateY(-8px) scale(0.98); transition: transform 0.2s var(--ease-out);
}
.palette-backdrop.show .palette { transform: none; }
.palette-input {
  width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--text); font-size: 16px;
}
.palette-input:focus { outline: none; }
.palette-list { max-height: min(52vh, 420px); overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; border-radius: var(--r-xs); border: 0; background: transparent;
  color: var(--text-2); font-size: 14px; text-align: left; cursor: pointer;
}
.palette-item .ico { width: 17px; height: 17px; color: var(--muted); flex: none; }
.palette-item .pi-hint { margin-left: auto; font-size: 12px; color: var(--faint); }
.palette-item.sel { background: var(--accent-soft); color: var(--accent); }
.palette-item.sel .ico { color: var(--accent); }
.palette-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* settings */
.settings-box { display: grid; gap: 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.set-row > span:first-child { font-size: 14px; font-weight: 600; }
.set-row .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.board-themes, .piece-sets { display: flex; flex-wrap: wrap; gap: 8px; }
.set-board {
  width: 52px; height: 34px; padding: 4px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); display: flex; gap: 3px;
  transition: 0.14s;
}
.set-board:hover { border-color: var(--line-strong); }
.set-board.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.set-board .sw { flex: 1; border-radius: 4px; }
.set-piece {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 76px; padding: 8px 4px; border-radius: var(--r-xs); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-size: 11.5px; color: var(--muted);
  transition: 0.14s;
}
.set-piece img { width: 34px; height: 34px; object-fit: contain; }
.set-piece:hover { border-color: var(--line-strong); }
.set-piece.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.accent-dots { display: flex; gap: 8px; }
.accent-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.accent-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--text); }

/* setup */
.setup-page { max-width: 780px; }
.setup-panel { padding: 26px; }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.setup-head h1 { margin: 0; }
.levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.level-card {
  padding: 12px 10px; border-radius: var(--r-sm); cursor: pointer; text-align: center;
  border: 1px solid var(--line); background: var(--surface); transition: 0.16s var(--ease);
}
.level-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.level-card.active { border-color: var(--accent); background: var(--accent-soft); }
.lc-num { display: block; font-family: var(--font-num); font-size: 21px; font-weight: 800; color: var(--accent); }
.lc-name { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 700; }
.lc-elo { display: block; font-size: 11px; color: var(--muted); font-family: var(--font-num); }
.tc-chips { display: flex; flex-wrap: wrap; gap: 7px; }

.result-box { text-align: center; padding: 12px 0 4px; }
.result-score { font-family: var(--font-num); font-size: 46px; font-weight: 800; letter-spacing: -0.03em; }
.result-rows { display: grid; gap: 8px; margin-top: 16px; text-align: left; }
.result-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 8px 11px; border-radius: var(--r-xs); background: var(--surface); }
.result-row b { font-family: var(--font-num); }
.delta-up { color: var(--ok); }
.delta-down { color: var(--danger); }

.pgn-box textarea, .import-box textarea { width: 100%; }
.import-box { display: grid; gap: 8px; }

.about-page { max-width: 900px; }
.about-panel { padding: 30px; }
.about-panel h2 { margin-top: 26px; }
.keys-list { display: grid; gap: 7px; padding: 0; list-style: none; }
.keys-list li { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.keys-list kbd { min-width: 30px; text-align: center; }
.about-links { display: grid; gap: 6px; padding-left: 18px; }

/* loading */
.boot-splash {
  position: fixed; inset: 0; z-index: 400;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg);
}
.boot-mark { width: 62px; height: 62px; animation: bootSpin 2.4s var(--ease) infinite; }
@keyframes bootSpin { 0% { transform: rotateY(0); } 50% { transform: rotateY(180deg); } 100% { transform: rotateY(360deg); } }
.boot-bar { width: 160px; height: 3px; border-radius: 99px; background: var(--line-strong); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: var(--accent); animation: bootSlide 1.1s var(--ease) infinite; }
@keyframes bootSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: var(--r-xs); }
@keyframes skel { to { background-position: -200% 0; } }

.history-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 13px; border-radius: var(--r-sm);
  background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 35%, transparent);
  color: var(--info); font-size: 13.5px; font-weight: 700;
}

/* ============================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); }
  .gcol-moves { grid-column: 1 / -1; order: 3; }
  .an-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); }
  .an-layout .gcol-moves { grid-column: 1 / -1; order: 3; }
}

@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-burger { display: inline-flex; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-board-card { display: none; }
  .game-layout, .an-layout, .pz-layout, .editor-layout, .lesson-view, .oe-layout, .profile-grid { grid-template-columns: minmax(0, 1fr); }
  .gcol-moves { order: 0; }
  .move-list { max-height: 220px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; border-radius: var(--r-xs);
    color: var(--faint); font-size: 10.5px; font-weight: 700;
  }
  .tabbar a .ico { width: 20px; height: 20px; }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
  .page { padding: 16px 14px calc(86px + env(safe-area-inset-bottom)); }
  .kbd-hint { display: none; }
  .footer { padding-bottom: 60px; }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .page { padding-left: 11px; padding-right: 11px; }
  .panel { padding: 13px; border-radius: var(--r-sm); }
  .hero { padding: 24px 18px; border-radius: var(--r-lg); }
  .controls-grid { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
  .game-row { flex-wrap: wrap; }
  .gr-actions { width: 100%; }
  .level-bar { grid-template-columns: 92px 1fr 70px; font-size: 12px; }
  .modal { padding: 17px; border-radius: var(--r-md); }
}

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

@media print {
  .nav, .footer, .tabbar { display: none !important; }
}

/* ============================================================================
   ExadokoChess — page layouts & components (supplement)
   ========================================================================== */

/* ---------------- shared page chrome ---------------- */
.page { padding: 22px clamp(14px, 3vw, 34px) 60px; max-width: 1460px; margin: 0 auto; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-title { font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.page-sub { color: var(--muted); margin: 6px 0 0; font-size: 14px; max-width: 62ch; }

/* three-column layout shared by play / analysis / puzzles / editor / explorer */
.game-layout,
.puzzle-layout,
.editor-layout,
.explorer-layout,
.lesson-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(320px, 1fr) minmax(280px, 360px);
  gap: 16px;
  align-items: start;
}
.puzzle-layout { grid-template-columns: minmax(320px, 1fr) minmax(280px, 360px); }
.editor-layout,
.explorer-layout,
.lesson-layout { grid-template-columns: minmax(320px, 1fr) minmax(280px, 380px); }

.gcol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.gcol-board { align-items: center; }
.gcol-side { gap: 12px; }
.gcol-moves { gap: 10px; }

/* ---------------- board toolbar ---------------- */
.board-toolbar {
  display: flex; align-items: center; gap: 6px;
  width: 100%; max-width: 640px; margin-top: 10px;
  padding: 6px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.board-toolbar .spacer { flex: 1; }
.board-toolbar .icon-btn.active { color: var(--accent); background: var(--accent-soft); }

/* ---------------- analysis ---------------- */
.analysis-page .panel { padding: 14px; }
.engine-panel .row { margin-bottom: 8px; }
.pv-lines { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; }
.pv-line {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 9px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px;
}
.pv-score { font-family: var(--mono, ui-monospace, monospace); font-weight: 700; min-width: 52px; }
.pv-score.pos { color: var(--ok); }
.pv-score.neg { color: var(--danger); }
.pv-moves { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.report-panel .accuracy-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acc-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 8px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.acc-card.w { border-color: rgba(255, 255, 255, 0.2); }
.acc-card.b { border-color: var(--line-strong); background: var(--surface-2); }
.acc-val { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.acc-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.class-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 12px 0; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.eval-graph-wrap { margin-top: 6px; border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.eval-graph-wrap canvas { display: block; width: 100%; cursor: pointer; }

.controls-panel .controls-grid { grid-template-columns: 1fr 1fr; }
.pc-score { font-size: 15px; font-weight: 700; color: var(--accent); }

/* ---------------- game page ---------------- */
.game-page .moves-panel { flex: 1; min-height: 220px; }

/* ---------------- puzzles ---------------- */
.puzzle-page .puzzle-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.puzzle-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 8px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line);
}
.stat-num { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.puzzle-feedback {
  width: 100%; max-width: 640px; margin-top: 12px;
  padding: 12px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  text-align: center; font-weight: 600; transition: background 0.18s, border-color 0.18s;
}
.puzzle-feedback.good { background: var(--ok-soft); border-color: rgba(52, 211, 153, 0.45); color: var(--ok); }
.puzzle-feedback.bad { background: var(--danger-soft); border-color: rgba(251, 113, 133, 0.45); color: var(--danger); }
.puzzle-feedback.info { background: var(--info-soft); border-color: rgba(96, 165, 250, 0.4); color: var(--info); }
.pf-text { font-size: 14px; }

.motif-bars { display: flex; flex-direction: column; gap: 7px; }
.motif-row { display: grid; grid-template-columns: 108px 1fr 34px; align-items: center; gap: 8px; font-size: 12px; }
.motif-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.motif-bar { height: 7px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.motif-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; }
.motif-count { text-align: right; color: var(--muted); font-family: var(--mono, ui-monospace, monospace); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------------- library ---------------- */
.library-page .filter-panel {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px; margin-bottom: 14px;
}
.library-page .filter-panel .input { flex: 1; min-width: 180px; }
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color 0.16s, transform 0.16s;
}
.game-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.gc-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.gc-result {
  min-width: 78px; text-align: center; padding: 5px 8px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--surface-2); color: var(--text-2);
}
.gc-result.w { background: var(--ok-soft); color: var(--ok); }
.gc-result.l { background: var(--danger-soft); color: var(--danger); }
.gc-result.d { background: var(--info-soft); color: var(--info); }
.gc-info { min-width: 0; }
.gc-players { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-meta { font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-actions { display: flex; align-items: center; gap: 4px; flex: none; }

/* ---------------- editor ---------------- */
.editor-page .editor-hint { font-size: 12px; margin-top: 8px; text-align: center; }
.piece-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pp-btn {
  aspect-ratio: 1; display: grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; transition: 0.14s;
  font-size: 26px; line-height: 1;
}
.pp-btn:hover { background: var(--surface-2); }
.pp-btn.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--sh-glow); }
.castling-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.validation {
  display: flex; flex-direction: column; gap: 4px; margin: 8px 0;
  font-size: 12px; color: var(--muted);
}
.validation span { display: flex; align-items: center; gap: 6px; }
.validation.ok { color: var(--ok); }
.validation.bad { color: var(--warn); }

/* ---------------- opening explorer ---------------- */
.oe-name { font-size: 17px; font-weight: 700; }
.oe-eco { margin: 6px 0; }
.oe-line { font-size: 12px; line-height: 1.6; word-break: break-word; margin-top: 6px; }
.oe-table { display: flex; flex-direction: column; gap: 3px; }
.oe-head,
.oe-row {
  display: grid; grid-template-columns: 1fr 96px 78px;
  align-items: center; gap: 8px; padding: 7px 9px; font-size: 13px;
}
.oe-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.oe-row {
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--surface); cursor: pointer; text-align: left; width: 100%;
  transition: 0.14s;
}
.oe-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.oe-san { font-weight: 700; display: flex; flex-direction: column; }
.oe-ru { font-size: 11px; font-weight: 500; }
.oe-bar { position: relative; height: 16px; border-radius: var(--r-xs); background: var(--surface-2); overflow: hidden; }
.oe-bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-right: 2px solid var(--accent); }
.oe-bar b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.oe-wdl { display: flex; height: 12px; border-radius: var(--r-pill); overflow: hidden; background: var(--surface-2); }
.oe-wdl i.w { background: #e9edf5; }
.oe-wdl i.d { background: #8b93a7; }
.oe-wdl i.l { background: #30374a; }
.oe-groups { display: flex; flex-direction: column; gap: 4px; }
.oe-group {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid transparent;
  color: var(--text-2); font-size: 13px; cursor: pointer; text-align: left; transition: 0.14s;
}
.oe-group:hover { border-color: var(--accent); color: var(--text); }

/* ---------------- learn ---------------- */
.learn-progress { padding: 14px; margin-bottom: 16px; }
.lp-bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.lp-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.lp-text { margin-top: 7px; font-size: 12px; }
.lp-dots { display: flex; gap: 4px; align-items: center; }
.lp-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); }
.lp-dots i.done { background: var(--ok); }
.lp-dots i.cur { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.lesson-card {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 14px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line);
  cursor: pointer; transition: 0.16s; color: var(--text);
}
.lesson-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--sh-2); }
.lesson-card.done { border-color: rgba(52, 211, 153, 0.4); }
.lc-ico { color: var(--accent); flex: none; }
.lc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.lc-t { font-weight: 700; font-size: 15px; }
.lc-d { font-size: 12.5px; }
.lc-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; font-size: 11px; }

.lesson-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.lesson-layout { align-items: start; }
.lesson-text p { font-size: 15px; line-height: 1.65; color: var(--text-2); margin: 8px 0 12px; }

/* ---------------- profile ---------------- */
.profile-hero {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  padding: 20px; margin-bottom: 16px;
}
.ph-rating { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.ph-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ph-num {
  font-size: 46px; font-weight: 800; letter-spacing: -0.03em; line-height: 1;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ph-peak { font-size: 12px; }
.ph-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 14px; flex: 1; }
.ph-stat { display: flex; flex-direction: column; gap: 2px; }
.ph-stat b { font-size: 21px; font-weight: 800; }
.ph-stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.profile-grid canvas { display: block; width: 100%; }

.heatmap { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat-col { display: flex; flex-direction: column; gap: 3px; }
.heat-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); }
.heat-cell.empty { background: transparent; }
.heat-cell.l1 { background: rgba(244, 180, 76, 0.32); }
.heat-cell.l2 { background: rgba(244, 180, 76, 0.55); }
.heat-cell.l3 { background: rgba(244, 180, 76, 0.78); }
.heat-cell.l4 { background: var(--accent); }
.legend-line { font-size: 12px; margin-top: 8px; }

.level-table { display: flex; flex-direction: column; gap: 6px; }
.lvl-row { display: grid; grid-template-columns: 22px 1fr 90px 70px; align-items: center; gap: 8px; font-size: 12.5px; }
.lvl-id {
  width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 7px; background: var(--surface-2); font-weight: 700; font-size: 11px;
}
.lvl-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl-bar { height: 7px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.lvl-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.lvl-nums { text-align: right; font-family: var(--mono, ui-monospace, monospace); font-size: 11px; }

.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ach {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line);
  opacity: 0.42; filter: grayscale(1);
}
.ach.got { opacity: 1; filter: none; border-color: rgba(244, 180, 76, 0.4); background: var(--accent-soft); }
.ach-ico { color: var(--accent); flex: none; display: grid; place-items: center; }
.ach-name { font-size: 12px; font-weight: 600; }

/* ---------------- misc ---------------- */
.empty .heat-cell { visibility: hidden; }
.modal-body { padding: 4px 2px; }

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  .game-layout,
  .analysis-page .game-layout { grid-template-columns: minmax(280px, 1fr) minmax(280px, 360px); }
  .gcol-moves { grid-column: 1 / -1; order: 3; }
  .puzzle-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .game-layout,
  .puzzle-layout,
  .editor-layout,
  .explorer-layout,
  .lesson-layout { grid-template-columns: 1fr; }
  .gcol-board { order: -1; }
  .oe-head, .oe-row { grid-template-columns: 1fr 78px 64px; }
}
@media (max-width: 560px) {
  .page { padding: 16px 12px 56px; }
  .puzzle-stats { grid-template-columns: repeat(2, 1fr); }
  .ph-num { font-size: 36px; }
  .piece-palette { grid-template-columns: repeat(3, 1fr); }
  .gc-main { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* page scope markers */
.home-page .page-title { font-size: clamp(26px, 3.4vw, 40px); }
.learn-page.lesson-open .lesson-layout { align-items: start; }
.profile-page .panel,
.library-page .panel,
.explorer-page .panel { padding: 14px; }

/* ============================================================================
   Premium polish layer
   ========================================================================== */

/* ---- ambient aurora drifting behind everything ---- */
body::after {
  content: '';
  position: fixed;
  inset: -18%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(36% 30% at 16% 10%, var(--bg-grad-2), transparent 70%),
    radial-gradient(42% 34% at 86% 16%, var(--bg-grad-1), transparent 72%),
    radial-gradient(38% 32% at 52% 92%, var(--bg-grad-3), transparent 70%);
  filter: blur(34px);
  opacity: 0.75;
  animation: aurora 30s var(--ease) infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  50%  { transform: translate3d(2%, 1.6%, 0) scale(1.07); }
  100% { transform: translate3d(-1.2%, 2%, 0) scale(1.02); }
}
[data-theme='light'] body::after { opacity: 0.45; filter: blur(44px); }

/* ---- navbar: gradient hairline + living wordmark ---- */
.nav::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  pointer-events: none; opacity: 0.75;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--accent) 60%, transparent) 26%,
    color-mix(in srgb, var(--accent) 22%, transparent) 62%, transparent);
}
.wordmark b {
  background: linear-gradient(120deg, var(--accent-2), var(--accent) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav-logo .mark { transition: transform 0.3s var(--ease-out), filter 0.3s; }
.nav-logo:hover .mark { transform: rotate(-6deg) scale(1.06); filter: drop-shadow(0 4px 14px color-mix(in srgb, var(--accent) 55%, transparent)); }
.nav-link.active::after {
  height: 2.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* ---- primary buttons: travelling shine ---- */
.btn.primary { overflow: hidden; }
.btn.primary::after {
  content: '';
  position: absolute; top: -20%; bottom: -20%; left: -75%; width: 46%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-18deg);
  transition: left 0.55s var(--ease);
  pointer-events: none;
}
.btn.primary:hover::after { left: 135%; }

/* ---- hero: bigger type, animated gradient, board halo ---- */
.hero h1 { font-size: clamp(30px, 4.8vw, 54px); letter-spacing: -0.035em; }
.hero h1 .grad { background-size: 220% 100%; animation: gradShift 5.5s var(--ease) infinite alternate; }
@keyframes gradShift { to { background-position: 100% 0; } }
.hero-badge { box-shadow: 0 0 22px -6px color-mix(in srgb, var(--accent) 55%, transparent); }
.hero-board-card { border-color: color-mix(in srgb, var(--accent) 24%, var(--line)); }
.hero-board-card::before {
  content: '';
  position: absolute; inset: -16%; z-index: -1; border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, var(--accent-soft), transparent 72%);
  filter: blur(12px);
  animation: haloPulse 5.5s ease-in-out infinite;
}
@keyframes haloPulse { 50% { opacity: 0.5; transform: scale(1.07); } }
.hero-mini i { transition: box-shadow 0.3s; }
.hero-mini i.demo-hl { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 70%, transparent); }

/* ---- staggered entrance for card grids ---- */
.quick-grid > *, .features > *, .steps > * { animation: riseIn 0.6s var(--ease-out) both; }
.quick-grid > :nth-child(1), .features > :nth-child(1), .steps > :nth-child(1) { animation-delay: 0.04s; }
.quick-grid > :nth-child(2), .features > :nth-child(2), .steps > :nth-child(2) { animation-delay: 0.09s; }
.quick-grid > :nth-child(3), .features > :nth-child(3), .steps > :nth-child(3) { animation-delay: 0.14s; }
.quick-grid > :nth-child(4), .features > :nth-child(4) { animation-delay: 0.19s; }
.quick-grid > :nth-child(5), .features > :nth-child(5) { animation-delay: 0.24s; }
.quick-grid > :nth-child(6), .features > :nth-child(6) { animation-delay: 0.29s; }
.features > :nth-child(7) { animation-delay: 0.34s; }
.features > :nth-child(8) { animation-delay: 0.39s; }
.features > :nth-child(9) { animation-delay: 0.44s; }
.features > :nth-child(10) { animation-delay: 0.49s; }
.features > :nth-child(11) { animation-delay: 0.54s; }
.features > :nth-child(12) { animation-delay: 0.59s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(16px) scale(0.985); } }

/* home sections cascade in on load (no scroll dependency) */
.home-page .page > * { animation: riseIn 0.6s var(--ease-out) both; }
.home-page .page > :nth-child(1) { animation-delay: 0.02s; }
.home-page .page > :nth-child(2) { animation-delay: 0.10s; }
.home-page .page > :nth-child(3) { animation-delay: 0.16s; }
.home-page .page > :nth-child(4) { animation-delay: 0.20s; }
.home-page .page > :nth-child(5) { animation-delay: 0.28s; }
.home-page .page > :nth-child(6) { animation-delay: 0.32s; }
.home-page .page > :nth-child(7) { animation-delay: 0.40s; }
.home-page .page > :nth-child(8) { animation-delay: 0.44s; }
.home-page .page > :nth-child(9) { animation-delay: 0.52s; }
.home-page .page > :nth-child(10) { animation-delay: 0.56s; }
.home-page .page > :nth-child(11) { animation-delay: 0.64s; }

/* ---- section heads with accent bar ---- */
.section-head h2 { position: relative; padding-left: 14px; }
.section-head h2::before {
  content: '';
  position: absolute; left: 0; top: 5px; bottom: 5px; width: 4px; border-radius: 4px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ---- cards: hover glow rings ---- */
.feature-card:hover, .quick-card:hover {
  box-shadow: var(--sh-2), 0 0 0 1px color-mix(in srgb, var(--accent) 38%, transparent);
}
.lesson-card:hover, .game-card:hover, .game-row:hover {
  box-shadow: var(--sh-2), 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* ---- panels: top hairline light ---- */
.panel { background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 30%); }
[data-theme='light'] .panel { background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 34%); }

/* ---- board: dimensional squares + accent aura ---- */
.sq.light { background: linear-gradient(135deg, var(--board-light), color-mix(in srgb, var(--board-light) 84%, var(--board-dark))); }
.sq.dark {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--board-dark) 86%, #ffffff),
    var(--board-dark) 55%,
    color-mix(in srgb, var(--board-dark) 86%, #000000));
}
.board {
  box-shadow: var(--sh-3), 0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 46px -16px color-mix(in srgb, var(--accent) 42%, transparent);
}
.sq.mark-last::after {
  background: linear-gradient(135deg, color-mix(in srgb, var(--sq-last) 70%, transparent), var(--sq-last));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent);
}
.sq.mark-sel::after {
  background: color-mix(in srgb, var(--sq-sel) 62%, transparent);
  box-shadow: inset 0 0 0 2px var(--sq-sel);
}
.piece img { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.42)); }

/* ---- cta band glow ---- */
.cta-band { position: relative; overflow: hidden; }
.cta-band::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(430px 150px at 6% 0%, var(--accent-soft), transparent 72%);
}

/* ---- overlays: faint accent top wash ---- */
.palette, .modal {
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 24%);
}

/* ---- footer hairline ---- */
.footer::before {
  content: '';
  position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--accent) 45%, transparent) 40%, transparent);
  opacity: 0.7; pointer-events: none;
}

/* ---- confetti overlay ---- */
.confetti-fx { position: fixed; inset: 0; z-index: 350; pointer-events: none; }

/* ---- scrollbar: accent thumb ---- */
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 42%, var(--line-strong));
  border-radius: 99px; border: 3px solid transparent; background-clip: content-box;
}

/* ============================================================
   Community: tournaments / clubs / forum / auth / account
   ============================================================ */
.community-list { display: flex; flex-direction: column; gap: 14px; }
.community-card { padding: 16px 18px; display: block; text-align: left; width: 100%; }
button.community-card { cursor: pointer; font: inherit; color: inherit; border: var(--border-soft); }
.cc-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.cc-name { font-size: 16px; }
.cc-meta { font-size: 12.5px; margin-top: 2px; }
.cc-desc { font-size: 13px; margin: 8px 0 0; }
.cc-table { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; border-top: 1px dashed var(--line-soft, var(--border-soft)); padding-top: 10px; }
.cc-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13.5px; }
.cc-pos { width: 22px; text-align: center; font-weight: 700; color: var(--muted); font-size: 12px; }
.cc-pos.top { color: var(--gold, #f3c969); }
.cc-nick { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-pts { font-size: 12.5px; color: var(--muted); }
.cc-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.lb-panel { padding: 12px 18px; }
.tag.ok { color: var(--ok, #59c37d); border-color: color-mix(in oklab, var(--ok, #59c37d) 40%, transparent); }

/* auth */
.auth-page { display: flex; justify-content: center; padding-top: 34px; }
.auth-panel { width: min(460px, 100%); padding: 26px; }
.auth-head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { margin-top: 6px; justify-content: center; }
.auth-form.hidden { display: none; }

/* account card on profile */
.acct-card { padding: 14px 18px; margin-bottom: 6px; }
.acct-guest, .acct-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.acct-id { display: flex; gap: 10px; align-items: center; }
.acct-id .icon { width: 20px; height: 20px; color: var(--muted); }
.acct-id b { display: block; }
.acct-id .muted { font-size: 12px; }
.acct-stats { display: flex; gap: 8px; }
@media (max-width: 560px) { .acct-row { justify-content: flex-start; } }

/* forum thread in modal */
.forum-thread { display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.forum-post { border: 1px solid var(--border-soft); border-radius: 12px; padding: 10px 12px; background: var(--panel-2, var(--panel)); }
.forum-post .fp-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.forum-post p { margin: 6px 0 0; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }

/* keep the nav tidy with 9 links */
@media (max-width: 1280px) {
  .nav-link span { display: none; }
  .nav-link { padding: 8px 10px; }
  .nav-link .icon { margin: 0; }
}
@media (min-width: 1281px) {
  .nav-links { gap: 1px; }
}
.forum-row { transition: border-color .15s ease, transform .15s ease; }
.forum-row:hover { border-color: var(--gold-line, rgba(243,201,105,.4)); }
.tag.gold { color: var(--gold, #f3c969); border-color: color-mix(in oklab, var(--gold, #f3c969) 45%, transparent); }

/* ============================================================
   Social layer: account chip, notifications, chat, friends, online
   ============================================================ */
.user-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line-strong)); background: var(--accent-soft);
  color: var(--text); cursor: pointer; font: inherit; }
.user-chip .icon { width: 15px; height: 15px; color: var(--accent); }
.user-chip b { font-size: 13px; }
#nav-account { display: inline-flex; }
.badge { position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  background: var(--danger, #e5484d); color: #fff; font: 800 10px/15px var(--mono, monospace); text-align: center; font-style: normal; }
#btn-notif { position: relative; }
.pop-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 90; min-width: 250px;
  background: var(--panel-solid, var(--panel)); border: 1px solid var(--line-strong); border-radius: 14px;
  box-shadow: var(--sh-3); padding: 6px; display: flex; flex-direction: column; }
.pop-menu a, .pop-menu button { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px;
  color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.pop-menu a:hover, .pop-menu button:hover { background: var(--panel-2, rgba(128,128,128,.12)); }
.pop-menu .icon { width: 15px; height: 15px; color: var(--muted); }
#nav-account, #notif-wrap { position: relative; display: inline-flex; }
.notif-pop { min-width: 320px; max-width: 92vw; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; }
.pop-empty { padding: 14px 10px; color: var(--muted); font-size: 13px; }
.ntf-item { display: flex; flex-direction: column; gap: 2px; }
.ntf-item.un { background: var(--accent-soft); }
.ntf-time { font-size: 11px; }

/* chat */
.chat-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.chat-left { padding: 12px; max-height: 72vh; overflow-y: auto; }
.chat-side-btn { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 9px 10px;
  border-radius: 10px; border: 0; background: none; color: var(--text); cursor: pointer; font: inherit; }
.chat-side-btn:hover { background: var(--panel-2, rgba(128,128,128,.12)); }
.chat-side-btn.active { background: var(--accent-soft); }
.chat-side-btn.thin { flex-direction: row; justify-content: space-between; }
.chat-side-btn i { font-style: normal; font-size: 12px; }
.chat-right { display: flex; flex-direction: column; height: 72vh; padding: 0; overflow: hidden; }
.chat-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-feed { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { display: flex; flex-direction: column; max-width: 75%; padding: 8px 12px; border-radius: 12px;
  background: var(--panel-2, rgba(128,128,128,.1)); font-size: 13.5px; }
.chat-msg.mine { align-self: flex-end; background: var(--accent-soft); }
.chat-msg i { font-size: 10.5px; font-style: normal; align-self: flex-end; }
.chat-nick { font-size: 12px; color: var(--accent); cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }

/* friends */
.fr-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.fr-list { display: flex; flex-direction: column; gap: 6px; }
.fr-nick { background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 0; text-align: left; }
.fr-btns { display: inline-flex; gap: 6px; margin-left: auto; }
.row { display: flex; align-items: center; }
.gap-sm { gap: 8px; }

/* online */
.onl-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.onl-left { display: flex; flex-direction: column; gap: 14px; }
.onl-list { display: flex; flex-direction: column; gap: 8px; }
.onl-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; font-size: 13.5px; }
.onl-row .cc-nick { flex: 0 1 auto; }
.onl-row .btn { margin-left: auto; }
.onl-row .btn + .btn { margin-left: 0; }
.btn.block { width: 100%; justify-content: center; }
.onl-game { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.onl-board-col { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.onl-player { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border-soft); font-size: 13.5px; }
.onl-clock { margin-left: auto; font-size: 16px; }
.onl-clock.low { color: var(--danger, #e5484d); }
.onl-moves { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.mv-row { display: grid; grid-template-columns: 30px 1fr 1fr; font-size: 13px; font-family: var(--mono, monospace); padding: 2px 4px; }
.ucard { display: flex; flex-direction: column; gap: 8px; }
.ucard-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
@media (max-width: 980px) {
  .chat-grid, .onl-grid, .onl-game, .fr-cols { grid-template-columns: minmax(0, 1fr); }
  .chat-left { max-height: 40vh; }
  .chat-right { height: 60vh; }
}
.ucard-btn { background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 0; font-weight: 600; }
.ucard-btn:hover { color: var(--accent); }
.ucard-open { cursor: pointer; }
.onl-side { display: flex; flex-direction: column; gap: 14px; }

/* ================= home v3 — premium & clean ================= */
.section-head h2 { padding-left: 0; }
.section-head h2::before { display: none; }
.section-head { margin: 46px 0 16px; }

.hero2 {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(28px, 4.5vw, 70px); align-items: center;
  padding: clamp(30px, 6vh, 70px) 0 6px;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 14px; border-radius: var(--r-pill);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase;
}
.hero-eyebrow .pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.8s infinite; }
.hero2-left { min-width: 0; }
.hero2-title { font-size: clamp(38px, 4.7vw, 62px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.04; margin: 20px 0 16px; }
.hero2-title .grad {
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 60%, var(--text));
  background-size: 220% 100%; animation: gradShift 5.5s var(--ease) infinite alternate;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero2-sub { font-size: clamp(15px, 1.35vw, 17px); line-height: 1.7; color: var(--text-2); max-width: 54ch; margin: 0 0 30px; }
.hero-board-card {
  position: relative; border-radius: 26px; padding: 12px;
  background: linear-gradient(160deg, rgba(255,255,255,0.055), rgba(255,255,255,0.015));
  border: 1px solid var(--line-strong);
  box-shadow: 0 34px 90px -34px rgba(0,0,0,0.7), inset 0 0 0 1px rgba(255,255,255,0.03);
}
@media (max-width: 980px) {
  .hero2 { grid-template-columns: 1fr; }
  .hero-board-card { max-width: 520px; }
}

.livebar {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  margin: 34px 0 4px; padding: 16px 26px; border-radius: 18px;
  background: var(--panel-solid); border: 1px solid var(--line);
}
.live-head { display: inline-flex; align-items: center; gap: 9px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok, #46a758); animation: livepulse 2s infinite; }
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 rgba(70, 167, 88, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(70, 167, 88, 0); }
  100% { box-shadow: 0 0 0 0 rgba(70, 167, 88, 0); }
}
.live-stats { display: flex; gap: clamp(18px, 4vw, 56px); margin-left: auto; flex-wrap: wrap; }
.live-stats > div { text-align: right; }
.live-stats b { display: block; font-family: var(--font-num); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.live-stats span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; }

.play-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .play-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .play-grid { grid-template-columns: 1fr; } }
.play-card {
  position: relative; display: flex; flex-direction: column; gap: 7px;
  padding: 22px 20px 20px; border-radius: 18px;
  background: var(--panel-solid); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; overflow: hidden;
  transition: transform 0.18s var(--ease), border-color 0.18s, box-shadow 0.18s;
}
.play-card::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 0% 0%, var(--accent-soft), transparent 55%);
  opacity: 0; transition: opacity 0.2s;
}
.play-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); box-shadow: 0 18px 44px -18px rgba(0,0,0,0.65); text-decoration: none; }
.play-card:hover::after { opacity: 1; }
.play-card > * { position: relative; z-index: 1; }
.pc-ico { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 13px; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.pc-ico .ico { width: 21px; height: 21px; }
.play-card b { font-size: 16.5px; letter-spacing: -0.01em; }
.pc-d { font-size: 13px; color: var(--muted); line-height: 1.5; }
.pc-arrow { position: absolute; right: 18px; top: 26px; color: var(--accent); opacity: 0; transform: translateX(-6px); transition: 0.2s; }
.pc-arrow .ico { width: 17px; height: 17px; }
.play-card:hover .pc-arrow { opacity: 1; transform: none; }

.comm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .comm-grid { grid-template-columns: 1fr; } }
.comm-panel { padding: 18px; min-height: 148px; }
.cm-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; font-size: 13.5px; color: var(--text); text-decoration: none; }
a.cm-row.link:hover .cm-nick { color: var(--accent); }
.cm-nick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cm-pos { width: 24px; height: 24px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font: 800 12px var(--font-num); background: var(--surface-2); color: var(--muted); flex: none; }
.cm-pos.p1 { background: linear-gradient(140deg, #f6c453, #b07a1c); color: #201503; }
.cm-pos.p2 { background: linear-gradient(140deg, #d7d7d7, #8f8f8f); color: #1c1c1c; }
.cm-pos.p3 { background: linear-gradient(140deg, #d99a6c, #96603a); color: #241207; }
.cm-empty { padding: 14px 2px; color: var(--muted); font-size: 13px; }
.cm-empty a { color: var(--accent); font-weight: 700; }
.cm-cnt { font-style: normal; }

.cta-final {
  display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap;
  margin: 50px 0 10px; padding: 30px 34px; border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 13%, var(--panel-solid)), var(--panel-solid) 58%);
}
.cta-final h2 { font-size: 24px; letter-spacing: -0.02em; }
.cta-final p { margin: 6px 0 0; color: var(--muted); }

/* online: friend codes + right column */
.onl-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.code-card { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.code-card > div:first-child { display: flex; flex-direction: column; margin-right: auto; }
.code-big { font-size: 19px; letter-spacing: 0.14em; }

/* ================= guest gate + upgrade bars ================= */
.gate-card {
  max-width: 660px; margin: clamp(30px, 8vh, 90px) auto 0; text-align: center;
  padding: clamp(30px, 5vw, 54px) clamp(22px, 4vw, 48px);
  border-radius: 26px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  background:
    radial-gradient(90% 70% at 50% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--panel-solid);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7);
}
.gate-card .pc-ico { margin: 0 auto 16px; width: 54px; height: 54px; }
.gate-card .pc-ico .ico { width: 26px; height: 26px; }
.gate-card h2 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -0.02em; margin: 0 0 10px; }
.gate-card p { max-width: 46ch; margin: 0 auto 24px; line-height: 1.6; }
.gate-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.guest-bar, .upgrade-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 16px; padding: 11px 16px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--text-2); font-size: 13.5px;
}
.guest-bar.hidden, .upgrade-bar.hidden { display: none; }
.guest-bar .ico, .upgrade-bar .ico { width: 16px; height: 16px; color: var(--accent); flex: none; }
.guest-bar p, .upgrade-bar p { margin: 0; }
.guest-bar a, .upgrade-bar a { color: var(--accent); font-weight: 700; }
.auth-panel .upgrade-bar { margin-bottom: 16px; }

/* ================= why-we-win (investor story) ================= */
.why-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .why-grid { grid-template-columns: 1fr; } }
.why-card {
  position: relative; display: flex; flex-direction: column; gap: 7px;
  padding: 24px 22px; border-radius: 18px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 6%, var(--panel-solid)), var(--panel-solid) 60%);
  border: 1px solid var(--line);
}
.why-card b { font-size: 16.5px; }
.why-card .pc-d { font-size: 13.5px; line-height: 1.6; }

/* ================= hero premium glow ================= */
.home-page { position: relative; }
.home-page::before {
  content: ''; position: absolute; inset: -70px 0 auto 0; height: 560px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(46% 60% at 78% 18%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%),
    radial-gradient(40% 55% at 12% 8%, color-mix(in srgb, var(--accent-2, #7aa2f7) 10%, transparent), transparent 72%);
  filter: blur(6px);
}
.hero-board-card {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--panel-solid), var(--panel-solid)) padding-box,
    linear-gradient(150deg, color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--accent) 12%, var(--line-strong)) 45%, color-mix(in srgb, var(--accent) 40%, transparent)) border-box;
}

/* ================= left sidebar layout ================= */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 9px; height: 58px; padding: 0 18px; }
.tb-spacer { flex: 1; }
.tb-logo { display: none; align-items: center; gap: 9px; color: var(--text); text-decoration: none; }

.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 236px; z-index: 70;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel-solid); border-right: 1px solid var(--line);
  padding: 14px 12px 12px; overflow-y: auto;
}
.sb-logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; color: var(--text); text-decoration: none; }
.sb-logo:hover { text-decoration: none; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; background: none; border-radius: 10px;
  color: var(--text-2); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
  transition: background .15s, color .15s;
}
.sb-head:hover { background: var(--surface); color: var(--text); }
.sb-head .ico { width: 16px; height: 16px; color: var(--accent); flex: none; }
.sb-head .ico:last-child { margin-left: auto; width: 13px; height: 13px; color: var(--muted); transition: transform .28s var(--ease); }
.sb-group.open .sb-head .ico:last-child { transform: rotate(90deg); }
.sb-items { max-height: 0; overflow: hidden; transition: max-height .32s var(--ease); }
.sb-group.open .sb-items { max-height: 320px; }
.sb-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 15px; border-radius: 10px;
  color: var(--muted); font-size: 13.5px; font-weight: 600; text-decoration: none;
  transition: background .15s, color .15s;
}
.sb-item .ico { width: 16px; height: 16px; flex: none; }
.sb-item:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.sb-item.active { color: var(--text); background: var(--accent-soft); }
.sb-item.active::before {
  content: ''; position: absolute; left: 3px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 3px; background: var(--accent);
}
.sb-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.sb-patron {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
  transition: background .15s, transform .15s;
}
.sb-patron:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); transform: translateY(-1px); }
.sb-raccoon { font-size: 18px; }
.sb-ver { font-size: 11px; text-align: center; }
.sb-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, 0.55); opacity: 0; pointer-events: none; transition: opacity .25s; }
.sb-backdrop.show { opacity: 1; pointer-events: auto; }

@media (min-width: 1001px) {
  .topbar, main#view, .footer { margin-left: 236px; }
  .sb-toggle, .sb-backdrop { display: none; }
}
@media (max-width: 1000px) {
  .sidebar { transform: translateX(-102%); transition: transform .32s var(--ease); width: 264px; box-shadow: 24px 0 60px -30px rgba(0, 0, 0, 0.7); }
  .sidebar.open { transform: none; }
  .tb-logo { display: flex; }
}

/* ================= honors: checks, patron raccoon, titles ================= */
.h-badge { display: inline-flex; width: 15px; height: 15px; margin-left: 5px; vertical-align: -2.5px; color: var(--ok, #46a758); }
.h-badge svg { width: 100%; height: 100%; }
.h-badge.owner { color: #f6c453; filter: drop-shadow(0 0 6px rgba(246, 196, 83, 0.55)); }
.h-badge.dev { color: #62d9b6; filter: drop-shadow(0 0 6px rgba(98, 217, 182, 0.5)); }
.h-badge.mod { color: #7aa2f7; }
.h-badge.ver { color: var(--ok, #46a758); }
.h-patron { margin-left: 5px; font-size: 14px; }
.h-title {
  margin-left: 7px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase;
  vertical-align: 1.5px; white-space: nowrap;
}

/* patron tiers */
.patron-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .patron-tiers { grid-template-columns: 1fr; } }
.patron-tier {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; transition: border-color .15s, background .15s, transform .15s;
}
.patron-tier:hover { transform: translateY(-2px); }
.patron-tier.sel { border-color: var(--accent); background: var(--accent-soft); }
.patron-tier b { font-size: 19px; font-family: var(--font-num); }
.pt-rac { font-size: 30px; }

/* ================= entrance animations ================= */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.livebar { animation: rise 0.55s var(--ease) 0.05s backwards; }
.play-card, .why-card, .comm-panel { animation: rise 0.55s var(--ease) backwards; }
.play-card:nth-child(2), .why-card:nth-child(2), .comm-panel:nth-child(2) { animation-delay: 0.08s; }
.play-card:nth-child(3), .why-card:nth-child(3), .comm-panel:nth-child(3) { animation-delay: 0.16s; }
.play-card:nth-child(4) { animation-delay: 0.24s; }
.cta-final { animation: rise 0.55s var(--ease) 0.1s backwards; }
.gate-card { animation: rise 0.5s var(--ease) backwards; }
.sb-item, .sb-head { animation: none; }

/* inline forum */
.forum-back { margin-bottom: 12px; }
.forum-panel { padding: 18px 20px; animation: rise 0.4s var(--ease) backwards; }
.forum-thead { display: flex; flex-direction: column; gap: 3px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.forum-thead b { font-size: 18px; letter-spacing: -0.01em; }

/* trophies & grant */
.ucard-trophies { margin-top: 12px; }
.ucard-trophies .lbl { margin-bottom: 8px; }
.ucard-trophies { display: block; }
.trophy {
  display: inline-flex; align-items: center; gap: 7px; margin: 0 8px 8px 0;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; color: var(--text-2);
}
.trophy b { font-size: 15px; }
.trophy i { font-style: normal; font-weight: 700; }
.grant-ver { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13.5px; color: var(--text-2); }

/* daily puzzle strip */
.daily-strip {
  display: flex; align-items: center; gap: 14px;
  margin: 26px 0 4px; padding: 16px 20px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--text); text-decoration: none;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.daily-strip:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.daily-strip .ds-ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.daily-strip .ds-ico svg { width: 22px; height: 22px; }
.daily-strip b { display: block; font-size: 15px; }
.daily-strip div span { color: var(--text-2); font-size: 12.5px; }
.daily-strip .pc-arrow { margin-left: auto; color: var(--accent); }
