[hidden] { display: none !important; }

/* ---------- fonts (bundled, work offline) ---------- */
@font-face { font-family: Heebo; font-weight: 400; font-display: swap; src: url(fonts/heebo-hebrew-400-normal.woff2) format("woff2"); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: Heebo; font-weight: 400; font-display: swap; src: url(fonts/heebo-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Heebo; font-weight: 500; font-display: swap; src: url(fonts/heebo-hebrew-500-normal.woff2) format("woff2"); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: Heebo; font-weight: 500; font-display: swap; src: url(fonts/heebo-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Heebo; font-weight: 700; font-display: swap; src: url(fonts/heebo-hebrew-700-normal.woff2) format("woff2"); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: Heebo; font-weight: 700; font-display: swap; src: url(fonts/heebo-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 500; font-display: swap; src: url(fonts/frank-ruhl-libre-hebrew-500-normal.woff2) format("woff2"); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 500; font-display: swap; src: url(fonts/frank-ruhl-libre-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- tokens ---------- */
:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface2: #f2f0ec;
  --line: #e8e5df;
  --line2: #d9d5cd;
  --text: #1d1d1f;
  --text2: #55534f;
  --muted: #8d8a84;
  --ink: #1d1d1f;
  --ink-text: #ffffff;
  --accent: #9a7b4f;
  --accent-soft: #f3ece1;
  --good: #3f8f5f;
  --bad: #c2453d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-board: 0 1px 2px rgba(29, 29, 31, .06), 0 18px 40px -18px rgba(29, 29, 31, .28);
  --shadow-pop: 0 24px 60px -20px rgba(29, 29, 31, .35);
  --serif: "Frank Ruhl Libre", "Times New Roman", Georgia, serif;
  --sans: Heebo, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --light: #efe9de;
  --dark: #c4b39a;
  --hl: rgba(214, 172, 92, .42);
  --sel: rgba(154, 123, 79, .38);
  --dotc: rgba(40, 32, 20, .2);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111213; --surface: #18191b; --surface2: #1f2023; --line: #26272a; --line2: #333438;
    --text: #f2f1ee; --text2: #c6c4bf; --muted: #8b8984; --ink: #f2f1ee; --ink-text: #111213;
    --accent: #c9a56e; --accent-soft: #2a241b;
    --good: #6cc08c; --bad: #e46b62;
    --shadow-board: 0 1px 2px rgba(0, 0, 0, .4), 0 24px 50px -20px rgba(0, 0, 0, .7);
    --shadow-pop: 0 30px 70px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

body[data-board="night"] { --light: #ece4cc; --dark: #849781; }
body[data-board="sand"] { --light: #efe9de; --dark: #c4b39a; }
body[data-board="sage"] { --light: #e8ece3; --dark: #9aae95; --sel: rgba(70, 100, 70, .35); --hl: rgba(206, 196, 100, .45); }
body[data-board="stone"] { --light: #e9e8e5; --dark: #a9a7a1; --sel: rgba(60, 60, 60, .3); }
body[data-board="mist"] { --light: #e6ebef; --dark: #9eb0bf; --sel: rgba(50, 80, 110, .35); --hl: rgba(240, 200, 110, .45); }
body[data-board="walnut"] { --light: #ecd9b9; --dark: #a87c56; --sel: rgba(90, 50, 20, .35); }
body[data-board="green"] { --light: #eeeed2; --dark: #769656; --sel: rgba(20, 85, 30, .45); --hl: rgba(255, 221, 64, .45); }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ic { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  max-width: 1120px; margin: 0 auto;
  padding: 18px max(20px, env(safe-area-inset-left)) 14px max(20px, env(safe-area-inset-right));
}
.brand { display: flex; align-items: center; gap: 10px; font: 500 24px/1 var(--serif); letter-spacing: .01em; }
.tabs { display: flex; gap: 26px; margin-inline-start: auto; }
.tab {
  border: 0; background: transparent; padding: 8px 0; color: var(--muted); font-weight: 500; font-size: 15px;
  position: relative; transition: color .2s;
}
.tab:hover { color: var(--text); }
.tab::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 1.5px; background: var(--text); transform: scaleX(0); transition: transform .25s ease; }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.icon-btn {
  border: 1px solid var(--line); background: transparent; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text2); transition: border-color .2s, color .2s;
}
.icon-btn:hover { border-color: var(--line2); color: var(--text); }

/* ---------- home ---------- */
.home { display: none; max-width: 1120px; margin: 0 auto; padding: 18px 20px 48px; }
body[data-mode="home"] .home { display: block; }
body[data-mode="home"] .layout { display: none; }
.hero { padding: 26px 0 30px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.hero h1 { margin: 0; font: 500 clamp(34px, 5vw, 52px)/1.1 var(--serif); letter-spacing: -.01em; }
.hgrid { display: grid; grid-template-columns: 1.35fr 1fr; grid-template-rows: auto auto; gap: 18px; }
.hcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.hmain { grid-row: span 2; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; padding: 28px; align-items: center; }
.hdaily { display: grid; grid-template-columns: 140px 1fr; gap: 20px; padding: 20px; align-items: center; }
.hbody h2 { margin: 0 0 6px; font: 500 28px/1.2 var(--serif); }
.hbody h3 { margin: 0 0 4px; font: 500 19px/1.3 var(--serif); }
.hbody .muted { margin: 0 0 14px; }
.hactions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.hdaily .btn { margin-top: 10px; }
.lvgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.lvbtn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start; transition: border-color .2s, background .2s, transform .1s;
}
.lvbtn:hover { border-color: var(--text); }
.lvbtn:active { transform: scale(.98); }
.lvbtn b { font-weight: 500; }
.lvbtn small { color: var(--muted); font-size: 12px; }
.linkbtn { border: 0; background: none; padding: 0; margin-top: 16px; color: var(--text2); font-size: 14px; display: inline-flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--line2); padding-bottom: 2px; }
[dir="rtl"] .ic-arrow { transform: scaleX(-1); }
.hcol { display: flex; flex-direction: column; gap: 10px; }
.hsmall {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; text-align: start; width: 100%;
  transition: border-color .2s, transform .1s;
}
.hsmall:hover { border-color: var(--line2); }
.hsmall:active { transform: scale(.99); }
.hsmall span { display: flex; flex-direction: column; flex: 1; }
.hsmall b { font-weight: 500; }
.hsmall small { color: var(--muted); font-size: 13px; }
.hsmall > .ic:first-child { color: var(--accent); }
.hsmall > .ic:last-child { color: var(--muted); }
.hstats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 30px 0 0; border-top: 1px solid var(--line); }
.hstats div { padding: 18px 0 0; }
.hstats dt { color: var(--muted); font-size: 13px; }
.hstats dd { margin: 2px 0 0; font: 500 30px/1.1 var(--serif); }

.mini { display: grid; grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr)); aspect-ratio: 1; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-board); }
.mini i { position: relative; display: block; }
.mini i.light { background: var(--light); }
.mini i.dark { background: var(--dark); }
.mini i.last::before { content: ""; position: absolute; inset: 0; background: var(--hl); }
.mini img { position: relative; width: 100%; height: 100%; display: block; }
.mini.empty { background: var(--surface2); box-shadow: none; }

/* ---------- play layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px;
  max-width: 1120px; margin: 0 auto; padding: 8px 20px 36px; align-items: start;
}
.board-col { --bsize: min(100%, calc(100vh - 200px)); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.board-row { display: flex; gap: 10px; width: 100%; justify-content: center; direction: ltr; }
.board-wrap { width: var(--bsize); max-width: 680px; min-width: 0; flex: 0 1 auto; }
.player-bar {
  width: var(--bsize); max-width: 680px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 2px 2px; min-height: 40px;
}
body:has(#evalbar:not([hidden])) .player-bar { width: calc(var(--bsize) - 22px); max-width: 658px; margin-left: 22px; }
body:has(#evalbar:not([hidden])) .board-wrap { width: calc(var(--bsize) - 22px); max-width: 658px; }
.pinfo { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pname { font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.pcap { display: flex; align-items: center; flex-wrap: wrap; direction: ltr; }
.pcap img { width: 18px; height: 18px; margin-inline-end: -5px; }
.pcap b { margin-inline-start: 9px; font-size: 12px; font-weight: 500; color: var(--muted); }
.dotc { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; box-shadow: inset 0 0 0 1px var(--line2); }
.dotc.w { background: #fbfaf8; } .dotc.b { background: #2a2a2c; box-shadow: none; }
.player-bar.turn .pname::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.clock {
  font: 500 19px/1 var(--mono); direction: ltr; letter-spacing: .02em;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); min-width: 88px; text-align: center;
  transition: background .2s, color .2s;
}
.clock.run { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.clock.run.low { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ---------- eval bar ---------- */
.evalbar { width: 12px; flex: none; border-radius: 999px; overflow: hidden; position: relative; background: #3b3a38; display: flex; flex-direction: column-reverse; box-shadow: 0 0 0 1px var(--line2); }
.evalbar.flipped { flex-direction: column; }
.evalfill { background: #f6f4f0; transition: height .5s cubic-bezier(.2, .8, .2, 1); }
.evaltext { position: absolute; left: -2px; right: -2px; bottom: 4px; text-align: center; font-size: 8px; font-weight: 700; color: #3b3a38; }
.evaltext.dark { bottom: auto; top: 4px; color: #e8e6e2; }
.evalbar.flipped .evaltext { bottom: auto; top: 4px; }
.evalbar.flipped .evaltext.dark { top: auto; bottom: 4px; }

/* ---------- board ---------- */
.cb { position: relative; width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-board); touch-action: none; user-select: none; -webkit-user-select: none; }
.cb-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.cb-sq { position: relative; }
.cb-sq.light { background: var(--light); }
.cb-sq.dark { background: var(--dark); }
.cb-sq.last::before, .cb-sq.sel::before, .cb-sq.hover::before, .cb-sq.hint::before { content: ""; position: absolute; inset: 0; }
.cb-sq.last::before { background: var(--hl); }
.cb-sq.sel::before { background: var(--sel); }
.cb-sq.hover::before { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .7); }
.cb-sq.hint::before { background: rgba(110, 150, 220, .5); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.cb-sq.check { background-image: radial-gradient(circle, rgba(220, 60, 50, .85) 0%, rgba(220, 60, 50, .45) 38%, rgba(220, 60, 50, 0) 72%); }
.cb-sq.dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--dotc); z-index: 3; pointer-events: none; }
.cb-sq.cap::after { content: ""; position: absolute; inset: 5%; border-radius: 50%; border: max(3px, .55vmin) solid var(--dotc); z-index: 3; pointer-events: none; }
.coord { position: absolute; font-size: clamp(8px, 1.4vmin, 11px); font-weight: 500; pointer-events: none; opacity: .9; }
.coord.file { right: 5%; bottom: 3%; }
.coord.rank { left: 5%; top: 3%; }
.cb-sq.light .coord { color: var(--dark); }
.cb-sq.dark .coord { color: var(--light); }
.cb-pieces { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.cb-pc { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; padding: .45%; will-change: transform; }
.cb-pc.dragging { z-index: 10; transition: none !important; scale: 1.12; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .25)); }
.cb-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
.arrow { stroke-linecap: round; }
.arrow-g { stroke: #3f7a52; } .ah-g path { fill: #3f7a52; }
.arrow-b { stroke: #4a72b8; } .ah-b path { fill: #4a72b8; }
.cb-promo { position: absolute; inset: 0; background: rgba(20, 20, 20, .35); backdrop-filter: blur(2px); z-index: 20; }
.cb-promo-btn { position: absolute; width: 12.5%; height: 12.5%; border: 0; padding: 5%; background: #fbfaf8; border-radius: 50%; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); transition: border-radius .15s; }
.cb-promo-btn:hover { border-radius: 18%; }
.cb-promo-btn img { width: 100%; height: 100%; display: block; }

/* ---------- side ---------- */
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding-top: 50px; }
.status { font: 500 26px/1.25 var(--serif); padding: 0 2px 4px; min-height: 36px; }
.status.think::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-inline-start: 10px; vertical-align: 1px; border: 1.5px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status.end { color: var(--accent); }
.status.good { color: var(--good); }
.status.bad { color: var(--bad); }
.panel:empty { display: none; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: 13px; color: var(--text2); }
.chip b { font-weight: 600; color: var(--text); }
.opening { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--radius-sm); color: var(--text); }
.opening .ic { color: var(--accent); margin-top: 3px; }
.op-name { font: 500 17px/1.3 var(--serif); }
.op-sub { color: var(--text2); font-size: 12.5px; margin-top: 2px; text-align: start; }
[dir="rtl"] .op-sub { text-align: right; }
.eco { font: 600 11px/1 var(--mono); color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 1px 4px; margin-inline-end: 4px; }
.delta { font: 500 28px/1 var(--serif); margin: 0; direction: ltr; text-align: end; }
.delta.good { color: var(--good); } .delta.bad { color: var(--bad); }
.engine-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.engine-head span:first-child { color: var(--text); font-weight: 500; }
.pvs { display: flex; flex-direction: column; gap: 2px; direction: ltr; border-top: 1px solid var(--line); }
.pv { text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 8px 2px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text2); }
.pv b { display: inline-block; min-width: 46px; color: var(--text); font-weight: 600; }
.pv:hover { color: var(--text); }

.moves-box { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.moves { max-height: 250px; min-height: 80px; overflow-y: auto; padding: 6px 0; direction: ltr; scrollbar-width: thin; }
.moves .muted { text-align: center; margin: 22px 0; font-size: 14px; }
.mlist { list-style: none; margin: 0; padding: 0; }
.mlist li { display: grid; grid-template-columns: 36px 1fr 1fr; align-items: center; }
.no { color: var(--muted); font-size: 12px; padding-left: 4px; font-variant-numeric: tabular-nums; }
.mv { border: 0; background: transparent; text-align: left; padding: 5px 8px; border-radius: 8px; font-weight: 500; font-size: 14px; }
.mv:hover { background: var(--surface2); }
.mv.cur { background: var(--ink); color: var(--ink-text); }
.mv.ph { color: var(--muted); }
.ann { font-weight: 700; margin-left: 2px; }
.blunder, .mv.blunder .ann { color: #d0453c; }
.mistake, .mv.mistake .ann { color: #d4842f; }
.inaccuracy, .mv.inaccuracy .ann { color: #b59a1f; }
.mv.cur .ann { color: inherit; }
.result-tag { text-align: center; font: 500 16px/1 var(--serif); margin: 10px 0 4px; }
.navbar { display: grid; grid-template-columns: repeat(4, 1fr); direction: ltr; border-top: 1px solid var(--line); }
.nav-btn { border: 0; background: transparent; padding: 9px 0; color: var(--muted); font-size: 13px; }
.nav-btn:hover { color: var(--text); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 14px; color: var(--text); transition: border-color .2s, background .2s, transform .08s;
}
.btn .ic { color: var(--text2); }
.btn:hover { border-color: var(--line2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn.primary .ic { color: inherit; }
.btn.primary:hover { opacity: .9; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { border-color: var(--line); }
.btn.danger { color: var(--bad); }
.actions .btn.primary { grid-column: 1 / -1; }

/* ---------- review ---------- */
.review { display: flex; flex-direction: column; gap: 10px; }
.review p { margin: 0; }
.progress { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); transition: width .2s; }
.graph { width: 100%; height: 72px; display: block; border-radius: 10px; cursor: pointer; direction: ltr; }
.gbg { fill: #3b3a38; }
.gfill { fill: #f6f4f0; }
.gmid { stroke: #8d8a84; stroke-width: .6; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.gcur { stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.gdot.blunder { fill: #d0453c; } .gdot.mistake { fill: #d4842f; }
.acc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.acc-table th, .acc-table td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.acc-table thead th { font-weight: 500; color: var(--muted); font-size: 12px; }
.acc-table tbody th { text-align: start; display: flex; align-items: center; gap: 7px; font-weight: 500; }
.acc-table td.acc { font: 500 18px/1 var(--serif); }

/* ---------- dialog ---------- */
.dlg { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 22px; padding: 0; width: min(470px, calc(100vw - 32px)); box-shadow: var(--shadow-pop); }
.dlg[open] { animation: rise .25s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dlg::backdrop { background: rgba(20, 20, 20, .35); backdrop-filter: blur(4px); }
.dlg form { padding: 26px; display: flex; flex-direction: column; gap: 18px; }
.dlg h2 { margin: 0; font: 500 26px/1.2 var(--serif); }
.field { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-size: 13px; color: var(--muted); }
.lbl b { color: var(--text); font-weight: 500; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { flex: 1 1 auto; }
.seg input, .swatches input, .tog input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s; }
.seg span:hover { border-color: var(--line2); }
.seg span img { width: 30px; height: 30px; }
.seg input:checked + span { border-color: var(--ink); background: var(--surface2); box-shadow: inset 0 0 0 1px var(--ink); }
.seg input:focus-visible + span, .tog input:focus-visible + span, .sw input:focus-visible ~ i { outline: 2px solid var(--accent); outline-offset: 2px; }
.pieces-seg span { min-height: 56px; }
.pieces-seg span img { width: 36px; height: 36px; }
form.human .ai-only { display: none; }
input[type="range"] { width: 100%; accent-color: var(--ink); }
textarea { width: 100%; font: 13px/1.45 var(--mono); background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; resize: vertical; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dlg-actions .btn { flex: 1 1 auto; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.sw { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; width: 44px; height: 44px; border-radius: 10px; overflow: hidden; cursor: pointer; outline: 1px solid var(--line); outline-offset: 0; transition: outline-offset .15s; }
.sw i:nth-of-type(1), .sw::after { background: var(--sl); }
.sw i:nth-of-type(2), .sw::before { background: var(--sd); }
.sw::before, .sw::after { content: ""; }
.sw::before { order: 3; } .sw::after { order: 4; }
.sw:has(input:checked) { outline: 2px solid var(--ink); outline-offset: 3px; }
.sw[data-theme="night"] { --sl: #ece4cc; --sd: #849781; }
.sw[data-theme="sand"] { --sl: #efe9de; --sd: #c4b39a; }
.sw[data-theme="sage"] { --sl: #e8ece3; --sd: #9aae95; }
.sw[data-theme="stone"] { --sl: #e9e8e5; --sd: #a9a7a1; }
.sw[data-theme="mist"] { --sl: #e6ebef; --sd: #9eb0bf; }
.sw[data-theme="walnut"] { --sl: #ecd9b9; --sd: #a87c56; }
.sw[data-theme="green"] { --sl: #eeeed2; --sd: #769656; }
.field.col { gap: 0; border-top: 1px solid var(--line); }
.tog { display: flex; cursor: pointer; border-bottom: 1px solid var(--line); }
.tog span { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 11px 0; font-size: 14px; }
.tog span::after { content: ""; flex: none; width: 40px; height: 24px; border-radius: 999px; background: radial-gradient(circle at 12px 50%, var(--surface) 8px, transparent 8.5px), var(--line2); transition: background .2s; }
.tog input:checked + span::after { background: radial-gradient(circle at 28px 50%, var(--ink-text) 8px, transparent 8.5px), var(--ink); }
[dir="rtl"] .tog span::after { transform: scaleX(-1); }
.statline { margin: 0; font-size: 14px; color: var(--text2); }
.statline b { color: var(--text); font-weight: 600; }
.about summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.about p { color: var(--text2); }
.result-dlg { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 4px; }
.result-dlg .big { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font: 500 30px/1 var(--serif); }
.result-dlg h2 { margin-top: 8px; }
.result-dlg p { margin: 0 0 8px; }
.result-dlg .dlg-actions { width: 100%; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: var(--ink-text); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: .3s cubic-bezier(.2, .8, .2, 1); z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- tablet & phone ---------- */
@media (max-width: 960px) {
  .hgrid { grid-template-columns: 1fr; }
  .hmain { grid-row: auto; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 16px; padding: 0 12px 28px; }
  .board-col { --bsize: 100%; }
  .board-row { gap: 6px; }
  .evalbar { width: 10px; }
  body:has(#evalbar:not([hidden])) .player-bar { width: calc(100% - 16px); margin-left: 16px; }
  body:has(#evalbar:not([hidden])) .board-wrap { width: calc(100% - 16px); }
  .side { padding-top: 0; gap: 12px; }
  .status { font-size: 22px; min-height: 0; }
  .moves { max-height: 130px; min-height: 0; }
  .moves .muted { margin: 8px 0; }
  .actions { grid-template-columns: repeat(3, 1fr); }
  .actions .btn { padding: 10px 6px; font-size: 13px; flex-direction: column; gap: 4px; }
  .topbar .tabs { gap: 18px; }
}
@media (max-width: 600px) {
  .topbar { gap: 12px; padding: 12px 14px 8px; flex-wrap: wrap; }
  .brand { font-size: 21px; }
  .tabs { order: 3; width: 100%; justify-content: space-between; gap: 0; margin: 0; border-bottom: 1px solid var(--line); }
  .tab { flex: 1; padding: 10px 0; }
  .icon-btn { margin-inline-start: auto; width: 36px; height: 36px; }
  .home { padding: 6px 14px 36px; }
  .hero { padding: 16px 0 20px; }
  .hmain { grid-template-columns: 1fr; padding: 18px; gap: 18px; }
  .hmain .hboard { max-width: 280px; width: 100%; margin: 0 auto; }
  .hdaily { grid-template-columns: 104px 1fr; padding: 14px; gap: 14px; }
  .hstats { grid-template-columns: repeat(2, 1fr); row-gap: 8px; }
  .hstats dd { font-size: 26px; }
  .clock { font-size: 17px; min-width: 74px; padding: 6px 9px; }
  .pcap img { width: 15px; height: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- review status ---------- */
.status.rv { font: 500 21px/1.35 var(--sans); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.status.rv bdi { font-weight: 700; }
.rv-label { font-family: var(--serif); }
.status.rv.best .rv-label { color: var(--good); }
.status.rv.inaccuracy .rv-label { color: #b59a1f; }
.status.rv.mistake .rv-label { color: #d4842f; }
.status.rv.blunder .rv-label { color: #d0453c; }
.rv-best { flex-basis: 100%; font-size: 14px; font-weight: 400; color: var(--text2); }
.rv-best bdi { font-weight: 600; color: var(--good); }

/* ---------- phone: full-width board, fixed move bar, swipeable move strip ---------- */
@media (max-width: 600px) {
  body:not([data-mode="home"]) { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .layout { padding: 0 0 16px; gap: 10px; }
  .board-col { gap: 6px; }
  .player-bar { padding: 0 12px; min-height: 38px; }
  body:has(#evalbar:not([hidden])) .player-bar { width: 100%; margin-left: 0; padding-left: 26px; }
  .board-row { gap: 4px; padding: 0 0 0 0; }
  body:has(#evalbar:not([hidden])) .board-row { padding-left: 4px; }
  .cb { border-radius: 0; box-shadow: none; }
  .side { padding: 0 12px; display: flex; }
  .status { order: 1; font-size: 20px; }
  .moves-box { order: 2; border: 0; }
  .panel { order: 3; }
  .actions { order: 4; }
  .moves { max-height: none; min-height: 44px; overflow-x: auto; overflow-y: hidden; padding: 4px 0; scrollbar-width: none; }
  .moves::-webkit-scrollbar { display: none; }
  .mlist { display: flex; flex-wrap: nowrap; gap: 2px; width: max-content; }
  .mlist li { display: flex; align-items: center; background: none !important; }
  .mlist .no { padding: 0 2px 0 8px; }
  .mv { padding: 7px 9px; font-size: 15px; white-space: nowrap; }
  .moves .muted { margin: 8px 0; }
  .result-tag { display: none; }
  .navbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -8px 24px -16px rgba(0, 0, 0, .25);
  }
  .nav-btn { height: 60px; font-size: 22px; color: var(--text); }
  .nav-btn:active { background: var(--surface2); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* phone: header in one compact row so the board and status fit on screen */
@media (max-width: 600px) {
  .topbar { flex-wrap: nowrap; padding: 8px 12px; gap: 10px; }
  .brand span { display: none; }
  .tabs { order: 0; width: auto; flex: 1; border-bottom: 0; justify-content: space-around; }
  .tab { flex: none; padding: 8px 2px; font-size: 15px; }
  .icon-btn { margin: 0; }
}

/* =====================================================================
   Club style (default): a dark, focused room around the board
   ===================================================================== */
body[data-ui="arena"] {
  --bg: #14221f; --surface: #1d302a; --surface2: #283e35; --line: #354b40; --line2: #506658;
  --text: #f3f0e5; --text2: #d5dbce; --muted: #acbbae;
  --ink: #dfbe76; --ink-text: #1a1206; --accent: #dfbe76; --accent-soft: #2a2a2a;
  --good: #7fd08a; --bad: #e5574e;
  --serif: "Frank Ruhl Libre", Georgia, serif;
  --shadow-board: 0 2px 0 rgba(0, 0, 0, .25), 0 24px 50px -18px rgba(0, 0, 0, .8);
  --shadow-pop: 0 30px 70px -20px rgba(0, 0, 0, .85);
  color-scheme: dark;
  background: var(--bg);
  background-color: var(--bg);
}
body[data-ui="arena"] .topbar { max-width: none; background: #101d19; border-bottom: 1px solid #314439; padding-top: 12px; padding-bottom: 12px; }
body[data-ui="arena"] .brand { font: 800 21px/1 var(--sans); }
body[data-ui="arena"] .tab { font-weight: 600; }
body[data-ui="arena"] .tab[aria-selected="true"]::after { background: var(--accent); height: 3px; border-radius: 2px; }
body[data-ui="arena"] .hero h1, body[data-ui="arena"] .hbody h2 { font-weight: 800; letter-spacing: -.02em; }
body[data-ui="arena"] .hstats dd { font-weight: 800; }
body[data-ui="arena"] .layout { padding-top: 22px; }

/* chunky game buttons */
body[data-ui="arena"] .btn {
  background: var(--surface2); border: 0; border-bottom: 3px solid rgba(0, 0, 0, .35); border-radius: 8px;
  font-weight: 700; padding: 11px 14px; color: var(--text);
}
body[data-ui="arena"] .btn .ic { color: var(--text2); }
body[data-ui="arena"] .btn:hover { background: #344e40; }
body[data-ui="arena"] .btn:active { transform: translateY(2px); border-bottom-width: 1px; }
body[data-ui="arena"] .btn.primary { background: #dfbe76; border-bottom-color: #a38852; color: #1a1206; font-size: 16px; }
body[data-ui="arena"] .btn.primary:hover { background: #efd392; opacity: 1; }
body[data-ui="arena"] .btn.ghost { background: transparent; border-bottom-color: transparent; }
body[data-ui="arena"] .lvbtn { background: var(--surface2); border: 0; border-bottom: 3px solid rgba(0, 0, 0, .35); border-radius: 8px; }
body[data-ui="arena"] .lvbtn:hover { background: #344e40; }
body[data-ui="arena"] .hcard { border: 0; border-radius: 10px; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
body[data-ui="arena"] .dlg { border: 0; border-radius: 12px; }
body[data-ui="arena"] .seg span { border-radius: 8px; background: var(--surface2); border-color: transparent; }
body[data-ui="arena"] .seg input:checked + span { background: #344e40; box-shadow: inset 0 0 0 2px var(--accent); border-color: transparent; }

/* side panel as one card */
body[data-ui="arena"] .side { background: var(--surface); border-radius: 10px; padding: 16px; margin-top: 50px; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
body[data-ui="arena"] .status { font: 700 21px/1.3 var(--sans); }
body[data-ui="arena"] .status.end { color: #1a1206; background: linear-gradient(135deg, #dfbe76, #d9822b); margin: -16px -16px 0; padding: 14px 16px; border-radius: 10px 10px 0 0; }
body[data-ui="arena"] .moves-box { border-color: var(--line); background: #15251f; border-radius: 6px; border: 0; }
body[data-ui="arena"] .mlist li:nth-child(odd) { background: rgba(255, 255, 255, .025); }
body[data-ui="arena"] .mv { font-weight: 700; color: var(--text2); }
body[data-ui="arena"] .mv.cur { background: #405d49; color: #fff; border-bottom: 2px solid rgba(0, 0, 0, .3); }
body[data-ui="arena"] .navbar { border-top-color: var(--line); }
body[data-ui="arena"] .chip { border-color: transparent; background: var(--surface2); color: var(--text2); }
body[data-ui="arena"] .opening { background: #15251f; }
body[data-ui="arena"] .op-name { font-weight: 700; }

/* player cards */
.avatar { flex: none; width: 40px; height: 40px; border-radius: 6px; display: grid; place-items: center; overflow: hidden; background: var(--surface2); color: var(--text2); }
.avatar img { width: 88%; height: 88%; }
.avatar.me { background: linear-gradient(160deg, #f6b452, #d9822b); }
.avatar.bot { color: #fff; background: linear-gradient(160deg, hsl(var(--h, 210) 45% 52%), hsl(var(--h, 210) 50% 36%)); }
.avatar.lv1, .avatar.lv2 { --h: 140; } .avatar.lv3, .avatar.lv4 { --h: 190; } .avatar.lv5, .avatar.lv6 { --h: 230; }
.avatar.lv7, .avatar.lv8 { --h: 280; } .avatar.lv9 { --h: 15; } .avatar.lv10 { --h: 355; }
.avatar.w { background: #e9e6e0; } .avatar.b { background: #3c3a37; }
.player-bar { gap: 10px; justify-content: flex-start; }
.player-bar .pinfo { flex-direction: column; align-items: flex-start; gap: 1px; flex: 1; min-width: 0; }
.player-bar .clock { margin-inline-start: auto; }
.pname { gap: 6px; font-weight: 700; font-size: 15px; }
.prating { color: var(--muted); font-weight: 400; }
.psub { color: var(--muted); font-weight: 400; font-size: 12px; border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; }
.pcap { min-height: 18px; }
/* Reserve one line above the board as captures and material scores change. */
.reviewing .pcap { flex-wrap: nowrap; height: 18px; line-height: 18px; max-width: 100%; }
.reviewing .pcap img { min-width: 0; object-fit: contain; }
.reviewing .side { overflow-anchor: none; }
.player-bar.turn .pname::after { display: none; }
.player-bar.turn .avatar { box-shadow: 0 0 0 2px var(--accent); }
.clock { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.clock .ic { opacity: 0; }
.clock.run .ic { opacity: .8; }
body[data-ui="arena"] .clock { border: 0; background: #0d1420; color: #6f7f98; font-size: 22px; font-weight: 700; padding: 8px 12px; border-radius: 6px; min-width: 110px; }
body[data-ui="arena"] .clock.run { background: #f3f0e5; color: #0d1420; }
body[data-ui="arena"] .clock.run.low { background: #d9433b; color: #fff; }
body[data-ui="arena"] .cb { border-radius: 4px; }

/* =====================================================================

body[data-ui="arena"] { --hl: rgba(242, 163, 58, .42); --sel: rgba(242, 163, 58, .5); --dotc: rgba(15, 22, 36, .28); }
body[data-ui="arena"] .opening .ic, body[data-ui="arena"] .eco { color: var(--accent); }
body[data-ui="arena"] .hsmall > .ic:first-child { color: var(--accent); }

   Move classifications: colors, badges on the board and in lists
   ===================================================================== */
.k-brilliant { --k: #23b8a0; } .k-great { --k: #5b8bd6; } .k-best { --k: #7fb24a; } .k-excellent { --k: #93bd52; }
.k-good { --k: #8aa978; } .k-book { --k: #a88764; } .k-inaccuracy { --k: #e9b51b; } .k-mistake { --k: #e8862a; } .k-blunder { --k: #d9433b; }
.rv-badge {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--k, #888); color: #fff; font: 800 11px/1 var(--sans); box-shadow: 0 1px 0 rgba(0, 0, 0, .3);
}
.rv-badge svg { width: 62%; height: 62%; }
.rv-badge b { font-weight: 800; letter-spacing: -.04em; }
.status.rv { align-items: center; }
.status.rv .rv-label { color: var(--k, inherit); font-family: var(--sans); font-weight: 700; }
.status.rv .rv-badge { width: 26px; height: 26px; font-size: 12px; }
.status.rv.brilliant .rv-label { color: #23b8a0; } .status.rv.great .rv-label { color: #5b8bd6; }
.status.rv.excellent .rv-label, .status.rv.best .rv-label { color: #7fb24a; } .status.rv.good .rv-label { color: #8aa978; }
.status.rv.book .rv-label { color: #a88764; }
.mv.brilliant .ann { color: #23b8a0; } .mv.great .ann { color: #5b8bd6; }

.cb-fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.cb-badge {
  position: absolute; width: 5.4%; height: 5.4%; border-radius: 50%; display: grid; place-items: center;
  background: var(--k); color: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .35); font: 800 clamp(9px, 1.9vmin, 15px)/1 var(--sans);
}
.cb-badge svg { width: 64%; height: 64%; }
.cb-badge b { letter-spacing: -.05em; }
.cb-badge.anim-pop { animation: badge-pop .35s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes badge-pop { from { transform: scale(0); } }

/* brilliant: glow, burst, shine and a banner */
.cb-badge.anim-brilliant { animation: badge-brill 1s cubic-bezier(.2, 1.4, .3, 1) both; overflow: hidden; }
.cb-badge.anim-brilliant::after { content: ""; position: absolute; inset: -40%; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .85) 50%, transparent 60%); animation: shine 1.2s .6s ease both; }
@keyframes badge-brill { 0% { transform: scale(0) rotate(-200deg); } 60% { transform: scale(1.5) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.cb-glow { position: absolute; width: 12.5%; height: 12.5%; background: radial-gradient(circle, rgba(35, 184, 160, .75), rgba(35, 184, 160, 0) 70%); animation: glow 2.2s ease-out both; }
@keyframes glow { 0% { transform: scale(.4); opacity: 0; } 20% { transform: scale(2.2); opacity: 1; } 100% { transform: scale(3.6); opacity: 0; } }
.cb-burst { position: absolute; width: 0; height: 0; }
.cb-burst i {
  position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 2px;
  background: #3fe0c5; box-shadow: 0 0 8px #23b8a0; transform: rotate(var(--a)) translateY(0) scale(var(--s));
  animation: fly 1.3s cubic-bezier(.1, .8, .3, 1) both;
}
.cb-burst i:nth-child(3n) { background: #fff; border-radius: 50%; }
.cb-burst i:nth-child(3n+1) { background: #ffd95a; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); width: 14px; height: 14px; }
@keyframes fly { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(var(--s)); } 100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(-1 * var(--d))) scale(0); } }
.cb-banner {
  position: absolute; left: 50%; top: 50%; display: flex; align-items: center; gap: 12px;
  background: rgba(20, 30, 28, .88); color: #fff; padding: 12px 22px 12px 14px; border-radius: 999px;
  font: 800 clamp(18px, 3.4vmin, 28px)/1 var(--sans); white-space: nowrap; box-shadow: 0 0 0 2px #23b8a0, 0 0 40px rgba(35, 184, 160, .6);
  animation: banner 2.4s cubic-bezier(.2, 1.2, .3, 1) both;
}
.cb-banner-badge { width: 1.6em; height: 1.6em; border-radius: 50%; display: grid; place-items: center; background: #23b8a0; font-size: .8em; }
.cb-banner-badge b { letter-spacing: -.05em; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  25%, 78% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(.96); }
}

/* review summary */
.acc-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acc-card { border-radius: 8px; padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.acc-card.w { background: #f1efeb; color: #0d1420; } .acc-card.b { background: #0a101b; color: #f3f0e5; box-shadow: inset 0 0 0 1px var(--line); }
.acc-card b { font: 800 26px/1.1 var(--sans); }
.acc-card small { font-size: 12px; opacity: .7; }
.kinds { width: 100%; border-collapse: collapse; font-size: 14px; }
.kinds th { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 5px 4px; justify-content: center; }
.kinds td { width: 44px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.kinds tr:nth-child(odd) { background: rgba(127, 127, 127, .06); }
.gdot.brilliant { fill: #23b8a0; } .gdot.great { fill: #5b8bd6; }
.rating-line { font-size: 15px; }
.rating-line .up { color: var(--good); font-weight: 800; } .rating-line .down { color: var(--bad); font-weight: 800; }

@media (max-width: 860px) {
  body[data-ui="arena"] .side { margin-top: 0; }
}
@media (max-width: 600px) {
  body[data-ui="arena"] .side { border-radius: 0; box-shadow: none; background: transparent; padding: 4px 12px; }
  body[data-ui="arena"] .status.end { margin: 0; border-radius: 8px; }
  body[data-ui="arena"] .layout { padding-top: 6px; }
  body[data-ui="arena"] .clock { font-size: 19px; min-width: 92px; padding: 6px 10px; }
  .avatar { width: 34px; height: 34px; }
  body[data-ui="arena"] .cb { border-radius: 0; }
  body[data-ui="arena"] .navbar { background: #101d19; }
}

/* desktop: the side column scrolls by itself and keeps the move buttons in view */
@media (min-width: 861px) {
  .side { position: sticky; top: 12px; max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }
  .reviewing .side { height: calc(100vh - 100px); }
  .side .navbar { position: sticky; bottom: -16px; margin: 0 -16px -16px; background: var(--surface); border-top: 1px solid var(--line); z-index: 2; }
  body:not([data-ui="arena"]) .side .navbar { margin: 0; bottom: 0; background: var(--bg); }
  .side .nav-btn { padding: 12px 0; font-size: 16px; }
  .moves { max-height: 220px; }
}
body[data-ui="arena"] .cb-sq.last::before { background: rgba(242, 163, 58, .16); box-shadow: inset 0 0 0 3px #dfbe76, inset 0 0 18px rgba(242, 163, 58, .45); }
body[data-ui="arena"] .cb-sq.sel::before { background: rgba(242, 163, 58, .45); box-shadow: none; }
body[data-ui="arena"] .mini i.last::before { background: rgba(242, 163, 58, .5); }

/* ---------- opponents with personality ---------- */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.pcard {
  display: flex; align-items: center; gap: 10px; text-align: start; padding: 9px 10px;
  background: var(--surface2); border: 0; border-bottom: 3px solid rgba(0, 0, 0, .35); border-radius: 10px; color: var(--text);
  transition: background .15s, transform .08s;
}
.pcard:hover { background: #344e40; }
.pcard:active { transform: translateY(2px); }
.pav { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 24px; line-height: 1;
  background: linear-gradient(160deg, hsl(var(--h, 210) 45% 46%), hsl(var(--h, 210) 50% 30%)); }
.ptxt { display: flex; flex-direction: column; min-width: 0; }
.ptxt b { font-weight: 700; font-size: 14px; }
.ptxt small { color: var(--muted); font-size: 11.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard.lv1, .pcard.lv2 { --h: 140; } .pcard.lv3, .pcard.lv4 { --h: 190; } .pcard.lv5, .pcard.lv6 { --h: 230; }
.pcard.lv7, .pcard.lv8 { --h: 280; } .pcard.lv9 { --h: 15; } .pcard.lv10 { --h: 355; }
.avatar .emoji { font-size: 24px; line-height: 1; }
.avatar.persona { font-size: 24px; }
.pseg label { flex: 1 1 30%; }
.pseg span { justify-content: flex-start; gap: 8px; min-height: 46px; }
.pseg .pav { width: 30px; height: 30px; font-size: 18px; border-radius: 8px; background: var(--surface); }
form.has-persona .lv-only { display: none; }

.player-bar { position: relative; }
.bubble {
  position: absolute; z-index: 25; inset-inline-start: 54px; top: calc(100% + 4px); max-width: min(320px, 80%);
  background: #f3f0e5; color: #0d1420; font-weight: 600; font-size: 14.5px; line-height: 1.35; padding: 9px 13px; border-radius: 14px;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .6); opacity: 0; transform: translateY(-6px) scale(.96); transform-origin: top; pointer-events: none;
  transition: opacity .2s, transform .25s cubic-bezier(.2, 1.4, .4, 1);
}
.bubble::before { content: ""; position: absolute; top: -6px; inset-inline-start: 14px; width: 12px; height: 12px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.bubble.show { opacity: 1; transform: none; }
#barBottom .bubble { top: auto; bottom: calc(100% + 4px); transform-origin: bottom; }
#barBottom .bubble::before { top: auto; bottom: -6px; }
.psub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
@media (max-width: 600px) {
  .pgrid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .ptxt small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .psub { display: none; }
}
.hbody { min-width: 0; }
.pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pcard { min-width: 0; }
.hmain:has(.pgrid) { grid-template-columns: 230px minmax(0, 1fr); gap: 24px; }
@media (max-width: 600px) { .hmain:has(.pgrid) { grid-template-columns: 1fr; } .hmain:has(.pgrid) .hboard { max-width: 200px; } }

/* ---------- rating test ---------- */
.hassess { gap: 12px; padding: 12px 14px; border: 1px solid rgba(242, 163, 58, .35) !important; background: linear-gradient(135deg, rgba(242, 163, 58, .12), transparent 60%), var(--surface) !important; }
.hassess .pav { --h: 35; }
.hassess .btn { padding: 8px 14px; flex: none; }
.hassess > span:nth-child(2) { flex: 1; min-width: 0; }
.assess-intro { display: flex; flex-direction: column; gap: 10px; text-align: start; }
.assess-intro .big, .rep-head .big { font-size: 40px; line-height: 1; }
.assess-intro ul { margin: 0; padding-inline-start: 20px; color: var(--text2); display: flex; flex-direction: column; gap: 4px; }
.assess-intro p { margin: 0; color: var(--text2); }
.progress.wide { width: 100%; height: 6px; margin-top: 6px; }
.dlg.wide { width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
.report { display: flex; flex-direction: column; gap: 12px; }
.report h3 { margin: 8px 0 0; font-size: 15px; color: var(--muted); font-weight: 600; }
.rep-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 4px; }
.rep-num { font: 800 64px/1 var(--sans); color: var(--accent); letter-spacing: -.03em; animation: rise .5s cubic-bezier(.2, 1.4, .3, 1) both; }
.rep-games { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rg { background: var(--surface2); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 2px; text-align: center; border-top: 3px solid var(--line2); }
.rg.w { border-top-color: #7fd08a; } .rg.l { border-top-color: #e5574e; } .rg.d { border-top-color: #acbbae; }
.rg b { font-size: 17px; }
.rg small { color: var(--muted); font-size: 12px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.phases { display: flex; flex-direction: column; gap: 8px; }
.ph { display: grid; grid-template-columns: 92px 1fr 36px; align-items: center; gap: 10px; font-size: 14px; }
.ph .bar { height: 10px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.ph .bar i { display: block; height: 100%; border-radius: 999px; transition: width .6s; }
.ph .bar i.hi { background: #7fd08a; } .ph .bar i.mid { background: #dfbe76; } .ph .bar i.lo { background: #e5574e; }
.ph b { text-align: center; }
.note { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface2); border-inline-start: 4px solid var(--line2); }
.note.good { border-inline-start-color: #7fd08a; } .note.bad { border-inline-start-color: #dfbe76; }
.note span { color: var(--text2); font-size: 14px; }
.tip { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 10px; background: var(--surface2); }
.tip .tn { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #1a1206; font-weight: 800; }
.tip p { margin: 4px 0 8px; color: var(--text2); font-size: 14px; }
.tip .btn { padding: 7px 12px; font-size: 13px; }
@media (max-width: 600px) { .rep-num { font-size: 54px; } .rep-games { gap: 6px; } .ph { grid-template-columns: 80px 1fr 32px; } }
.hassess > .pav { flex: none; display: grid; width: 42px; height: 42px; font-size: 26px; }

/* ---------- chess.com import ---------- */
.cc-dlg { display: flex; flex-direction: column; gap: 12px; }
.report-dlg { display: flex; flex-direction: column; gap: 12px; }
.report-reasons { display: grid; gap: 8px; }
.report-reasons label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.report-dlg textarea { font-family: inherit; }
.cc-dlg p { margin: 0; }
.cc-dlg input[type="text"] { width: 100%; font: 600 17px/1 var(--sans); padding: 13px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); }
.cc-dlg input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }
.cc-dlg .err { color: var(--bad); font-weight: 600; }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-head .btn { flex: none; padding: 7px 12px; font-size: 13px; }
.cc-report { width: 100%; }
.cclist { display: flex; flex-direction: column; gap: 6px; max-height: min(52vh, 520px); overflow-y: auto; padding: 2px; scrollbar-width: thin; }
.ccg { display: flex; align-items: center; gap: 12px; text-align: start; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--surface2); color: var(--text); border-bottom: 2px solid rgba(0, 0, 0, .3); }
.ccg:hover { background: #344e40; }
.ccres { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; color: #0d1420; }
.ccres.w { background: #7fd08a; } .ccres.l { background: #e5574e; color: #fff; } .ccres.d { background: #acbbae; }
.ccmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ccmain b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccmain small { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ccme { flex: none; font-weight: 700; color: var(--text2); font-variant-numeric: tabular-nums; }
.avatar .initial { font: 800 19px/1 var(--sans); color: #fff; }
.avatar.cc { background: linear-gradient(160deg, #5d7396, #506658); }
.progress i.indeterminate { width: 35% !important; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-120%); } to { transform: translateX(320%); } }
[dir="rtl"] .progress i.indeterminate { animation-name: indet-rtl; }
@keyframes indet-rtl { from { transform: translateX(120%); } to { transform: translateX(-320%); } }
.rep-games.many { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.rep-games small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-acc { margin: 0; font-size: 13px; color: var(--muted); text-align: center; } .cc-acc b { color: var(--text); }

/* ---------- drawn portraits (replace emoji) ---------- */
.portrait { display: block; flex: none; border-radius: 12px; }
.avatar.persona { background: none; padding: 0; overflow: visible; }
.avatar.persona .portrait { width: 100%; height: 100%; border-radius: 9px; }
.pcard { padding: 8px 10px 8px 12px; gap: 11px; }
.pcard .portrait { width: 42px; height: 42px; }
.pcard .ptxt { flex: 1; }
.pcard .ptxt small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prate { flex: none; align-self: center; font: 700 12.5px/1 var(--sans); color: var(--accent); background: rgba(242, 163, 58, .12); border-radius: 6px; padding: 5px 7px; font-variant-numeric: tabular-nums; }
.pseg span .portrait { width: 30px; height: 30px; border-radius: 8px; }
.hassess > .portrait { width: 42px; height: 42px; }
.big .portrait { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .6); }
.result-dlg .big, .assess-intro .big, .rep-head .big { width: auto; height: auto; background: none; display: block; }
.assess-intro .big .portrait { margin: 0; }
.hero h1 { font-size: clamp(30px, 4.4vw, 46px); }
.hbody h3 { margin-bottom: 6px; }
.hsmall { padding: 14px 16px; }
.linkbtn { margin-top: 14px; }
@media (max-width: 600px) {
  .pgrid { grid-template-columns: 1fr; }
  .pcard .ptxt small { -webkit-line-clamp: 1; }
}
.hmain.hchoose { grid-template-columns: 1fr; padding: 24px; }
.hchoose .pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hchoose .pcard { padding: 10px 12px; }
.hchoose .pcard .portrait { width: 48px; height: 48px; }
.hchoose .ptxt b { font-size: 15px; }
.hchoose .ptxt small { font-size: 12.5px; }
@media (max-width: 600px) { .hchoose .pgrid { grid-template-columns: 1fr; } .hmain.hchoose { padding: 16px; } }
.hmain.hchoose { align-items: start; align-content: start; }

/* ---------- puzzles from my mistakes ---------- */
.pk { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.pk button { border: 0; background: transparent; color: var(--muted); font-weight: 700; padding: 9px 8px; border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.pk button.on { background: var(--surface2); color: var(--text); box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.pk i { font-style: normal; background: var(--accent); color: #1a1206; font-size: 11.5px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 10px; display: inline-grid; place-items: center; padding: 0 5px; }
.mine-card { background: var(--surface2); border-radius: 10px; padding: 12px 14px; border-inline-start: 4px solid var(--k); display: flex; flex-direction: column; gap: 6px; }
.mine-card p { margin: 0; color: var(--text2); font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.mine-card .rv-badge { width: 20px; height: 20px; font-size: 10px; }
.san { font-weight: 800; color: var(--text); }
.mine-res { margin: 0; font-size: 15px; font-weight: 600; }
.mine-res.good { color: var(--good); } .mine-res.bad { color: var(--accent); }
.mine-empty { margin: 0; color: var(--text2); line-height: 1.6; }
@media (max-width: 600px) {
  body[data-mode="puzzle"] .panel { order: 2; }
  body[data-mode="puzzle"] .moves-box { order: 3; }
}

/* ---------- opening trainer ---------- */
h4.sub { margin: 6px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.fams { display: flex; flex-direction: column; gap: 7px; }
.fam { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto; align-items: center; gap: 10px; font-size: 14px; }
.fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbar { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.fbar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.fstat { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.weaks { display: flex; flex-direction: column; gap: 6px; }
.weak { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: start; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--surface2); color: var(--text); border-bottom: 2px solid rgba(0, 0, 0, .3); border-inline-start: 4px solid var(--accent); }
.weak:hover { background: #344e40; }
.weak b { font-weight: 700; }
.weak small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weak span { font-size: 13.5px; color: var(--text2); }
.weak em { grid-row: 1; grid-column: 2; font-style: normal; color: var(--muted); font-size: 12px; }
.san.bad { color: var(--bad); } .san.good { color: var(--good); }
@media (max-width: 600px) {
  body[data-mode="openings"] .panel { order: 2; }
  body[data-mode="openings"] .moves-box { order: 3; }
}
body[data-mode="openings"]:not(.o-drill) .moves-box { display: none; }
.hclone { gap: 12px; } .hclone > .portrait { width: 42px; height: 42px; }

/* compact new-game card; opponents open in a dialog */
.hmain.hplay { grid-template-columns: 1fr; padding: 24px; align-content: center; }
.pstrip { display: flex; margin: 14px 0 4px; padding-inline-start: 8px; }
.pstrip .portrait { width: 40px; height: 40px; margin-inline-start: -8px; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface); }
.hplay .hactions .btn .portrait { width: 22px; height: 22px; border-radius: 6px; }
.chooser { display: flex; flex-direction: column; gap: 14px; }
.chooser .pgrid { margin: 0; max-height: min(62vh, 560px); overflow-y: auto; padding: 2px; }
.chooser .pcard .portrait { width: 46px; height: 46px; }
@media (max-width: 600px) { .chooser .pgrid { grid-template-columns: 1fr; } .hmain.hplay { padding: 18px; } }
@media (min-width: 961px) {
  .hgrid { grid-template-columns: 1.2fr 1fr; align-items: stretch; }
  .hmain { grid-row: auto; }
  .hcol { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .hcol .hassess { grid-column: 1 / -1; }
}

/* Club front page and shared interaction states */
.club-front {display:grid;grid-template-columns:minmax(0,2.25fr) minmax(210px,1fr);gap:18px;margin:26px 0}
.club-match,.club-daily {border:1px solid var(--line2);border-radius:14px;overflow:hidden}
.club-match {background:var(--surface);display:grid;grid-template-columns:1.1fr 1fr;align-items:center;gap:20px;padding:clamp(20px,3vw,44px)}
.club-copy h1 {font:500 clamp(38px,4.6vw,68px)/1.04 var(--serif);margin:0;letter-spacing:-.035em}
.club-copy p,.club-daily p {color:var(--text2);margin:.85em 0;font-size:15px}
.club-position {padding:7px;border:1px solid var(--line2);background:var(--surface2);border-radius:5px}
.club-position .mini,.club-daily .mini {border-radius:2px;box-shadow:none;direction:ltr}
.club-daily {display:grid;align-content:center;justify-items:start;gap:6px;padding:22px;background:var(--surface2)}
.club-daily h2 {font:500 28px/1.2 var(--serif);margin:0}
.club-daily .mini {width:min(112px,100%)} .club-daily>.ic {color:var(--accent)}
.club-library {margin:26px 0 12px}
.club-groups {display:flex;gap:24px;border-bottom:1px solid var(--line2)}
.club-groups button {min-height:46px;background:transparent;border:0;border-bottom:3px solid transparent;font:600 18px var(--sans);color:var(--muted);cursor:pointer}
.club-groups button[aria-pressed="true"] {color:var(--text);border-color:var(--accent)}
.club-rows {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:32px}
.club-row {cursor:pointer;display:flex;align-items:center;gap:15px;text-align:start;background:transparent;border:0;border-bottom:1px solid var(--line);padding:17px 6px;color:var(--text);font:inherit}
.club-row:hover {background:var(--surface)} .club-row>span {flex:1} .club-row strong,.club-row small {display:block}
.club-row small {color:var(--muted)} .club-row>.ic {color:var(--accent)}
body[data-ui="arena"] .btn {border:1px solid var(--line2);box-shadow:none;border-radius:6px}
body[data-ui="arena"] .btn.primary {border-color:var(--accent)} body[data-ui="arena"] .btn.primary .ic {color:inherit}
body[data-ui="arena"] .btn:active {transform:none;border-bottom-width:1px}
body[data-ui="arena"] .status.end {background:var(--surface2);color:var(--text)}
.navbar[hidden]{display:none} .nav-btn:disabled {opacity:.4;cursor:default}
body:not([data-mode="home"]):has(.navbar[hidden]) {padding-bottom:0}
.game-options {grid-column:1/-1;order:2}.game-options summary,.review summary {color:var(--text2);padding:10px 2px;cursor:pointer}.game-options>div,.review-lesson {display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.cb-sq:focus-visible {outline:3px solid #183d84;outline-offset:-4px;z-index:1}
@media(max-width:760px){.club-front{grid-template-columns:1fr;margin:12px 0;gap:12px}.club-daily{grid-template-columns:1fr auto;align-items:center;gap:4px 16px;padding:16px}.club-daily>.mini,.club-daily>.ic{grid-column:2;grid-row:1/4;max-width:80px}.club-copy h1{font-size:clamp(32px,7vw,48px)}.club-rows{grid-template-columns:1fr}.club-match{gap:14px;padding:20px}.club-daily p{margin:.25em 0}}
@media(max-width:420px){.club-match{grid-template-columns:minmax(0,1.4fr) minmax(90px,1fr);padding:16px}.club-copy .hactions{gap:6px}.club-copy .btn{font-size:14px;padding:8px}.club-daily .mini{width:68px}}
