/* ches-s.com — chess analysis theme.
 *
 * Palette and component spec from research/chess.com Game Review.
 * No emoji, no gradients, no rounded-everything: chess sites have a
 * specific industrial-warm character — keep edges where they belong. */

:root {
  /* surfaces */
  --bg-base:        #262421;
  --bg-surface:     #312e2b;
  --bg-surface-2:   #3d3a37;
  --bg-elevated:    #ffffff;
  --bg-overlay:     rgba(0, 0, 0, 0.55);
  --divider:        #3f3c39;

  /* text */
  --text-primary:    #f1f1f1;
  --text-secondary:  #9d9b98;
  --text-tertiary:   #6c6964;
  --text-on-light:   #2b2b2b;
  --text-on-light-2: #5b5b5b;

  /* brand */
  --accent:         #81b64c;
  --accent-hover:   #6e9f3f;
  --accent-dark:    #4e7837;
  --accent-faint:   rgba(129, 182, 76, 0.18);
  --accent-keyword: rgba(129, 182, 76, 0.22);

  /* move classifications */
  --c-brilliant:    #1bada6;
  --c-great:        #5b8baf;
  --c-best:         #95bb4a;
  --c-excellent:    #96bc4b;
  --c-good:         #96af8b;
  --c-book:         #a88865;
  --c-inaccuracy:   #f7c631;
  --c-mistake:      #e58f2a;
  --c-miss:         #ee6b55;
  --c-blunder:      #ca3431;
  --c-forced:       #9b9b9b;

  /* layout — board fluidly sizes to fit viewport without scroll */
  --topbar-h: 44px;
  --board-size: min(560px, calc(100vh - 180px));
  --panel-width: 340px;
  --evalbar-width: 20px;
  --radius-sm: 3px;
  --radius:    6px;
  --radius-lg: 10px;

  /* fonts */
  --font-sans: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
}

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

html, body { height: 100%; overflow: hidden; }
body.landing-body { overflow: auto; }

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid #1f1d1b;
  flex: 0 0 var(--topbar-h);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.5px;
  line-height: 1;
}
.brand .dash {
  color: var(--accent);
  font-weight: 900;
  display: inline-block;
  padding: 0 1px;
  transform: translateY(-1px);  /* nudge so it sits over the x-height midpoint */
}
.brand .domain {
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--divider);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1;
  position: relative;
  top: -1px;
}

.topbar nav {
  margin-left: auto;
  display: flex;
  gap: 22px;
  font-size: 13px;
  color: var(--text-secondary);
}
.topbar nav a { color: inherit; }
.topbar nav a:hover { color: var(--text-primary); }

/* ---------- landing page ---------- */

.landing {
  max-width: 980px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

.hero {
  max-width: 760px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}

.landing h1 {
  margin: 0 0 6px;
  font-size: 36px;
  letter-spacing: -1px;
  font-weight: 800;
}
.landing h1 .accent { color: var(--accent); }

.landing .lede {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 620px;
  margin: 0 0 12px;
}

.free-note {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 0 0 24px;
  padding: 5px 9px;
  background: var(--accent-faint);
  border: 1px solid rgba(129, 182, 76, 0.34);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.input-card {
  display: flex;
  align-items: stretch;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0;
}
.input-card input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  padding: 0 16px;
  outline: none;
  font-size: 15px;
  letter-spacing: -0.2px;
}
.input-card input::placeholder {
  color: var(--text-tertiary);
}
.input-card button {
  background: var(--accent);
  color: #1b1b1b;
  font-weight: 700;
  padding: 14px 26px;
  font-size: 14px;
}
.input-card button:hover { background: var(--accent-hover); color: #fff; }
.input-card button:disabled { background: var(--bg-surface-2); color: var(--text-tertiary); cursor: not-allowed; }

.input-hint {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}
.input-hint code {
  background: var(--bg-surface-2);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}
.input-hint .accent { color: var(--accent); font-weight: 600; }

.trick-explainer {
  margin-top: 56px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.trick-card {
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.trick-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  font-weight: 700;
}
.trick-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-primary);
}
.trick-card code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
}
.trick-card .diff {
  background: rgba(255, 80, 80, 0.18);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 80, 80, 0.55);
  padding: 0 2px;
  border-radius: 2px;
}
.trick-card .ins {
  background: var(--accent-faint);
  color: var(--accent);
  font-weight: 700;
  padding: 0 2px;
  border-radius: 2px;
}

.features {
  margin-top: 56px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 18px;
}
.feature-card .feat-icon {
  width: 30px; height: 30px;
  margin-bottom: 10px;
  display: block;
}
.feature-card h2,
.feature-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
}
.feature-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.cls-heading {
  margin: 56px 0 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.6px;
}

.input-card input.error { box-shadow: inset 0 0 0 2px var(--c-blunder); }

.form-message {
  min-height: 18px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: opacity 0.2s ease;
}
.form-message:empty { opacity: 0; }
.form-message.tone-warn { color: var(--c-inaccuracy); }
.form-message.tone-err  { color: var(--c-blunder); }
.form-message.tone-info { color: var(--accent); }

.classification-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.classification-grid .item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--divider);
}
.classification-grid .item .cls-icon { width: 26px; height: 26px; }
.classification-grid .item span {
  font-size: 13px;
  font-weight: 600;
}

.seo-section {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--divider);
}
.seo-section h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 800;
}
.seo-section p {
  max-width: 780px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
}
.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.keyword-list span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
}
.faq-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.faq-grid article {
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 16px;
}
.faq-grid h3 {
  margin: 0 0 8px;
  font-size: 14px;
}
.faq-grid p {
  font-size: 13px;
  line-height: 1.5;
}

.privacy-page {
  max-width: 820px;
}
.policy-updated {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 24px;
}
.policy-section {
  padding: 24px 0;
  border-top: 1px solid var(--divider);
}
.policy-section h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.policy-section p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.65;
}
.policy-section p + p {
  margin-top: 10px;
}

/* ---------- analysis page layout ---------- */

.analysis {
  display: grid;
  grid-template-columns: var(--evalbar-width) var(--board-size) var(--panel-width);
  grid-template-rows: 1fr;
  gap: 14px;
  padding: 12px 18px;
  align-items: stretch;
  justify-content: center;
  max-width: 1180px;
  margin: 0 auto;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.evalbar-col {
  align-self: start;
  padding-top: 0;
}

.board-col {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: start;
}

.panel-col {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-surface);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---------- panel header bar ---------- */
.panel-bar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 6px;
  border-bottom: 1px solid var(--divider);
  background: var(--bg-surface-2);
  flex: 0 0 40px;
}
.panel-bar .bar-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  border-radius: 4px;
}
.panel-bar .bar-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.panel-bar .bar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.panel-bar .bar-btn svg { width: 16px; height: 16px; }
.panel-bar .panel-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.panel-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.overview-block.mode-anim,
.review-block.mode-anim { animation: panel-mode-in 220ms ease-out; }
@keyframes panel-mode-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1100px) {
  .analysis {
    grid-template-columns: var(--evalbar-width) minmax(0, var(--board-size));
    grid-template-rows: auto auto;
    height: auto;
    width: 100%;
    overflow: auto;
  }
  html, body { overflow: auto; }
  .panel-col { grid-column: span 2; height: auto; }
}

@media (max-width: 760px) {
  :root {
    --evalbar-width: 16px;
    --board-size: min(calc(100vw - 40px), calc(100vh - 190px));
    --board-size: min(calc(100vw - 40px), calc(100svh - 190px));
  }
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    min-height: var(--topbar-h);
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 9px 12px;
  }
  .brand {
    font-size: 20px;
  }
  .brand .domain {
    display: none;
  }
  .topbar nav {
    width: 100%;
    margin-left: 0;
    gap: 16px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; }
  .analysis {
    grid-template-columns: var(--evalbar-width) var(--board-size);
    gap: 8px;
    padding: 8px 8px 18px;
    align-items: start;
    justify-content: center;
    max-width: 100%;
    overflow: visible;
  }
  .evalbar {
    width: var(--evalbar-width);
    height: var(--board-size);
  }
  .evalbar .label {
    font-size: 9px;
  }
  .board-col,
  .board-wrap {
    min-width: 0;
  }
  .board-wrap,
  .cg-wrap {
    width: var(--board-size);
    height: var(--board-size);
  }
  .panel-col {
    grid-column: 1 / -1;
    width: 100%;
    height: min(620px, calc(100vh - 20px));
    height: min(620px, calc(100svh - 20px));
    min-height: 430px;
    border-radius: var(--radius);
  }
  .panel-bar {
    height: 44px;
    flex-basis: 44px;
  }
  .panel-bar .bar-btn {
    width: 38px;
    height: 38px;
  }
  .panel-bar .panel-title {
    font-size: 12px;
  }
  .panel,
  .overview-block {
    padding: 10px;
  }
  .coach {
    gap: 6px;
    padding: 8px 8px 4px;
  }
  .coach .avatar {
    width: 34px;
    height: 40px;
    flex-basis: 34px;
  }
  .coach .bubble {
    padding: 8px 10px 10px;
  }
  .coach .bubble .text {
    font-size: 13px;
  }
  .coach .bubble .eval-chip {
    padding: 2px 6px;
    font-size: 11px;
  }
  .coach-details .detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .action-row {
    gap: 8px;
    padding: 8px;
  }
  .action-btn {
    min-height: 44px;
    height: 44px;
    font-size: 12px;
    gap: 5px;
  }
  .action-btn svg {
    width: 15px;
    height: 15px;
  }
  .moves-panel {
    min-height: 140px;
  }
  .moves-list .move-row {
    height: 30px;
    padding: 0 8px;
    font-size: 13px;
  }
  .moves-list .cell {
    height: 26px;
    padding: 2px 6px;
  }
  .moves-list .cell .cls-icon,
  .moves-list .cell .mini-badge-empty {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
  }
  .eval-graph {
    padding: 6px 8px 2px;
  }
  .eval-graph .eval-svg {
    height: 62px;
  }
  .controls {
    gap: 8px;
    padding: 8px;
  }
  .ctrl-btn {
    height: 42px;
  }
  .landing {
    padding: 34px 16px 64px;
  }
  .landing h1 {
    font-size: 30px;
  }
  .input-card {
    flex-direction: column;
  }
  .input-card input {
    min-height: 46px;
  }
  .trick-card code,
  .input-hint code {
    overflow-wrap: anywhere;
  }
  .trick-explainer,
  .features,
  .faq-grid {
    grid-template-columns: 1fr;
  }
  .classification-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 380px) {
  :root {
    --board-size: min(calc(100vw - 34px), calc(100vh - 176px));
    --board-size: min(calc(100vw - 34px), calc(100svh - 176px));
  }
  .analysis {
    gap: 6px;
    padding-left: 6px;
    padding-right: 6px;
  }
  .topbar {
    padding-left: 10px;
    padding-right: 10px;
  }
  .coach .avatar {
    display: none;
  }
  .coach .bubble::before {
    display: none;
  }
}

/* ---------- eval bar ---------- */

.evalbar {
  width: var(--evalbar-width);
  height: var(--board-size);
  background: #111;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--divider);
}
.evalbar .white-share {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #f5f3ee;
  transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.evalbar .midline {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(255,255,255,0.18);
}
.evalbar .label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.5px;
  pointer-events: none;
}
.evalbar .label.top    { top: 4px; color: var(--text-primary); }
.evalbar .label.bottom { bottom: 4px; color: var(--text-on-light); }

/* ---------- board container ---------- */

.board-wrap {
  width: var(--board-size);
}

.cg-wrap {
  width: var(--board-size);
  height: var(--board-size);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* Move classification badge over the destination square. The SVG carries
 * its own circular fill and shadow, so this wrapper is just for positioning. */
.move-marker {
  position: absolute;
  pointer-events: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  z-index: 5;
  animation: marker-pop 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: left 0.2s ease, top 0.2s ease;
}
@keyframes marker-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}
.move-marker img { width: 30px; height: 30px; display: block; }
.cls-icon { display: inline-block; vertical-align: middle; }

.cg-wrap cg-board svg.cg-shapes path {
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
}

/* ---------- coach callout (top of right panel) ---------- */

.coach {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex: 0 0 auto;
  min-height: 0;
  padding: 10px 10px 4px;
  position: relative;
  z-index: 20;
  overflow: visible;
}
.coach:empty { display: none; }
.coach .bubble { transition: background 0.18s ease, border-left-color 0.18s ease; }
.coach .text { transition: opacity 0.18s ease; }
.coach .avatar {
  width: 44px;
  height: 50px;
  border-radius: 6px;
  background: var(--bg-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  overflow: hidden;
  border: 1px solid var(--divider);
}
.coach .avatar .clippy {
  width: 96%;
  height: 96%;
  object-fit: contain;
}

.coach .bubble {
  background: var(--bg-elevated);
  color: var(--text-on-light);
  padding: 8px 12px 10px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  flex: 1;
  min-height: 50px;
  min-width: 0;
  overflow: visible;
}
.coach .bubble::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 14px;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 5px solid var(--bg-elevated);
}
.coach .bubble .header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.coach .bubble .cls-icon { width: 22px; height: 22px; flex: 0 0 22px; }
.coach .bubble .cls-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-on-light);
}
.coach .bubble .eval-chip {
  margin-left: auto;
  background: #f0efea;
  color: var(--text-on-light);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.coach .bubble .eval-chip.positive { color: #2e7d32; }
.coach .bubble .eval-chip.negative { color: #c62828; }
.coach .bubble .text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-on-light);
  overflow: visible;
}
.coach .bubble .text .kw {
  position: relative;
  display: inline-block;
  background: var(--accent-keyword);
  color: var(--accent-dark);
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 700;
  cursor: help;
  border-bottom: 1px dotted var(--accent-dark);
  transition: background 0.12s ease;
}
.coach .bubble .text .kw:hover,
.coach .bubble .text .kw:focus-visible {
  background: rgba(129, 182, 76, 0.40);
  outline: none;
}
.coach-details .kw {
  position: relative;
  display: inline-block;
  background: var(--accent-keyword);
  color: var(--accent-dark);
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 700;
  cursor: help;
  border-bottom: 1px dotted var(--accent-dark);
}
.coach-details .kw:hover,
.coach-details .kw:focus-visible {
  background: rgba(129, 182, 76, 0.40);
  outline: none;
}
.coach .bubble .loading {
  display: inline-flex;
  gap: 4px;
}
.coach .bubble .loading span {
  width: 6px; height: 6px;
  background: var(--text-on-light-2);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
.coach .bubble .loading span:nth-child(2) { animation-delay: 0.15s; }
.coach .bubble .loading span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse {
  0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1.1); }
}

.coach-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e0d8;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  overflow: visible;
}
.coach-details.loading-detail {
  min-height: 28px;
  justify-content: center;
}
.coach-details .detail-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  align-items: start;
}
.coach-details .detail-row strong {
  color: var(--accent-dark);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.coach-details .detail-row span {
  color: var(--text-on-light);
  line-height: 1.35;
}

/* "Show best move" reveal panel under the coach card */
.best-reveal {
  margin-top: -8px;
  margin-bottom: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
}
.best-reveal.hidden { display: none; }
.best-reveal .row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.best-reveal .row + .row { margin-top: 6px; }
.best-reveal strong {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

/* ---------- side panel (player comparison) ---------- */

.panel,
.overview-block {
  padding: 12px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.review-block {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
}
.review-cta {
  margin-top: 12px;          /* sits right under the panel content */
  background: var(--accent);
  color: #1b1b1b;
  height: 40px;
  border-radius: 4px;
  font-weight: 800;
  font-size: 13.5px;
  letter-spacing: 0.2px;
  flex: 0 0 40px;
  transition: background 0.15s ease;
}
.review-cta:hover { background: var(--accent-hover); color: #fff; }
.player-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.panel-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.player-block {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.player-block .avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  flex: 0 0 36px;
  overflow: hidden;
  position: relative;
}
.player-block .avatar svg,
.player-block .avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.player-block .avatar img.avatar-photo {
  position: absolute;
  inset: 0;
}
.player-block .meta { min-width: 0; }
.player-block .username {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-block .rating {
  font-size: 11px;
  color: var(--text-secondary);
}
.player-block.right {
  flex-direction: row-reverse;
  text-align: right;
}
.player-block.right .meta { text-align: right; }

.accuracy-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.acc-box {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}
.acc-box.high { background: #f1efe9; color: var(--text-on-light); }
.acc-box .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}
.acc-box.high .label { color: var(--text-on-light-2); }
.acc-box .value {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.acc-box { padding: 4px 8px; }
.acc-box .label { font-size: 9px; letter-spacing: 0.8px; }

.cls-table {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
}
.cls-row {
  display: grid;
  grid-template-columns: 32px 22px 1fr 32px;
  gap: 10px;
  align-items: center;
  height: 24px;
  padding: 0 4px;
  border-top: 1px solid var(--divider);
  font-size: 13px;
}
.cls-row:first-child { border-top: 0; }
.cls-row .count {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-tertiary);
  font-size: 13px;
}
.cls-row .count.has { color: var(--text-primary); }
.cls-row .count.clickable {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s ease;
}
.cls-row .count.clickable:hover { background: var(--bg-surface-2); color: var(--accent); }
.cls-row .cls-icon { width: 22px; height: 22px; }
.cls-row .name {
  color: var(--text-primary);
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-rating-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rating-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rating-cell {
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rating-cell.high { background: #f1efe9; color: var(--text-on-light); }
.label-block {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  font-weight: 700;
  text-align: center;
}

.phase-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--divider);
}
.phase-row {
  display: grid;
  grid-template-columns: 1fr 38px 38px;
  align-items: center;
  height: 24px;
  font-size: 12px;
  padding: 0 2px;
}
.phase-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
}
.marker-cell {
  display: flex;
  justify-content: center;
  align-items: center;
}
.marker {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.marker svg { width: 13px; height: 13px; }
.marker.none {
  background: transparent;
  color: var(--text-tertiary);
  font-size: 16px;
  font-weight: 700;
}
.marker.none::before { content: "–"; }

/* ---------- move list / controls ---------- */

.moves-panel {
  background: var(--bg-surface);
  border-radius: var(--radius);
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 80px;
  overflow: hidden;
}
.moves-header {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--divider);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 700;
}
.moves-list {
  overflow-y: auto;
  flex: 1;
  padding: 2px 0 4px;
}
.moves-list .move-row {
  display: grid;
  grid-template-columns: 26px 1fr 1fr;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  font-size: 12.5px;
}
.moves-list .move-row .num {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.moves-list .cell {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  height: 20px;
  user-select: none;
}
.moves-list .cell:hover { background: var(--bg-surface-2); }
.moves-list .cell.active { background: rgba(129, 182, 76, 0.16); color: var(--accent); }
.moves-list .cell.active .san { color: var(--accent); }
.moves-list .cell .san {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.moves-list .cell .cls-icon { width: 14px; height: 14px; flex: 0 0 14px; }
.moves-list .cell .mini-badge-empty { width: 14px; height: 14px; flex: 0 0 14px; display: inline-block; }
.moves-list .cell.active { background: rgba(255, 255, 255, 0.08); }
.moves-list .cell.active .figurine { color: var(--text-primary); }

/* ---------- figurine notation glyphs ---------- */
.figurine {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
}
.figurine .piece-glyph { display: inline-block; vertical-align: middle; }
.figurine .san-text {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}
/* On a dark UI we draw black pieces in the SAME light fill as white pieces
 * but with a contrasting outline so the silhouette still reads correctly. */
.fig-white .piece-glyph path { fill: #f1efe9; stroke: #1a1a1a; stroke-width: 0.9; }
.fig-black .piece-glyph path { fill: #3c3a37; stroke: #d6d2c4; stroke-width: 1.1; }
.fig-white .san-text,
.fig-black .san-text { color: var(--text-primary); }
.moves-list .cell { gap: 5px; transition: background 0.15s ease, color 0.15s ease; }
.moves-list .cell:not(.empty):not(.active):hover { background: rgba(255, 255, 255, 0.04); }
.moves-list .cell.active {
  animation: active-glow 240ms ease-out;
}
@keyframes active-glow {
  from { background: rgba(129, 182, 76, 0.22); }
  to   { background: rgba(255, 255, 255, 0.08); }
}

/* ---------- eval graph at bottom of review panel ---------- */
.eval-graph {
  flex: 0 0 auto;
  padding: 8px 10px 4px;
  background: var(--bg-surface);
}
.eval-graph .eval-svg {
  width: 100%;
  height: 76px;
  display: block;
  border-radius: 4px;
}
.eval-graph .marker {
  cursor: pointer;
  transition: r 0.12s ease;
}
.eval-graph .marker:hover { r: 5; }
.moves-list .cell.empty { cursor: default; color: var(--text-tertiary); }
.moves-list .cell.empty:hover { background: transparent; }

/* Best-line variation chain shown under the coach bubble when "Best" is on. */
.coach.mode-best .bubble { background: #f9f7f0; border-left: 3px solid var(--accent); }
.coach.mode-try .bubble { background: #f7fbff; border-left: 3px solid #2fa7df; }
.best-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e0d8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-on-light);
}
.best-line .ply {
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: background 0.18s ease, color 0.18s ease;
}
.best-line .ply.played {
  background: rgba(129, 182, 76, 0.18);
  color: var(--accent-dark);
}
.best-line .ply.current {
  background: var(--accent);
  color: #1b1b1b;
  box-shadow: 0 0 0 2px rgba(129, 182, 76, 0.35);
}
.best-line .ply.pending {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-on-light-2);
  opacity: 0.6;
}
.best-line .ply .piece-glyph path { fill: currentColor; stroke: none; }
.best-line .arrow {
  color: var(--text-on-light-2);
  font-size: 12px;
  margin: 0 2px;
  opacity: 0.6;
}

/* ---------- review-mode 3-button action row ---------- */
.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 10px 10px 8px;
  flex: 0 0 auto;
}
.action-btn {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  height: 38px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.action-btn:hover { background: #4a4744; }
.action-btn svg { width: 14px; height: 14px; }
.action-btn.primary {
  background: var(--accent);
  color: #1b1b1b;
}
.action-btn.primary:hover { background: var(--accent-hover); color: #fff; }
.action-btn.active {
  background: var(--accent-dark);
  color: #fff;
}
.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.action-btn:disabled:hover { background: var(--bg-surface-2); }
.action-btn:focus-visible,
.ctrl-btn:focus-visible,
.bar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- bottom transport controls ---------- */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
  padding: 6px 10px 10px;
  flex: 0 0 auto;
}
.ctrl-btn {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  height: 32px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ctrl-btn:hover { background: #4a4744; }
.ctrl-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ctrl-btn svg { width: 14px; height: 14px; }

/* ---------- progress / loading ---------- */

.analysis-progress {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 10;
}
.analysis-progress .fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease-out;
}

.banner {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--divider);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  border-radius: var(--radius);
  margin: 16px 22px;
  font-size: 13px;
}
.banner.error { border-left-color: var(--c-blunder); }
.banner code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

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

.footer {
  margin-top: 56px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  padding: 18px;
  border-top: 1px solid var(--divider);
}
.footer p {
  max-width: 900px;
  margin: 0 auto;
  line-height: 1.6;
}
.footer p + p {
  margin-top: 8px;
}
.footer strong {
  color: var(--text-secondary);
}
.footer a { color: var(--text-secondary); }

/* ---------- chessground overrides ---------- */

cg-board square.move-classification-best { background-color: rgba(149, 187, 74, 0.30) !important; }
cg-board square.move-classification-brilliant { background-color: rgba(27, 173, 166, 0.32) !important; }
cg-board square.move-classification-great { background-color: rgba(91, 139, 175, 0.32) !important; }
cg-board square.move-classification-blunder { background-color: rgba(202, 52, 49, 0.32) !important; }
cg-board square.move-classification-mistake { background-color: rgba(229, 143, 42, 0.32) !important; }
cg-board square.move-classification-inaccuracy { background-color: rgba(247, 198, 49, 0.30) !important; }
cg-board square.move-classification-miss { background-color: rgba(238, 107, 85, 0.32) !important; }

/* The cburnett CSS embeds piece backgrounds; the .brown CSS uses a CSS gradient
 * for the board pattern that's a little harsh on dark theme. Soften it. */
.cg-wrap cg-board {
  background-color: #ebecd0;
  background-image:
    linear-gradient(45deg, #769656 25%, transparent 25%, transparent 75%, #769656 75%),
    linear-gradient(45deg, #769656 25%, transparent 25%, transparent 75%, #769656 75%);
  background-size: calc(var(--board-size) / 4) calc(var(--board-size) / 4);
  background-position: 0 0, calc(var(--board-size) / 8) calc(var(--board-size) / 8);
}

/* keyword tooltip on coach text */
.coach .bubble .text .kw { position: relative; }
.coach .bubble .text .kw:hover { background: var(--accent-faint); }

.coach .bubble .text .kw .kw-tip,
.coach-details .kw .kw-tip {
  display: none;
}

.floating-kw-tip {
  position: fixed;
  left: -9999px;
  top: -9999px;
  z-index: 9999;
  width: max-content;
  max-width: min(280px, calc(100vw - 16px));
  background: #2b2b2b;
  color: #f1f1f1;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 5px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: normal;
  text-align: left;
}
.floating-kw-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.floating-kw-tip::after {
  content: "";
  position: absolute;
  left: var(--tip-arrow-left, 50%);
  top: 100%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: #2b2b2b;
}
.floating-kw-tip.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #2b2b2b;
}

/* Final mobile overrides live at the end so later component rules cannot
 * shrink touch targets back to their desktop sizes. */
@media (max-width: 760px) {
  .coach {
    gap: 6px;
    padding: 8px 8px 4px;
  }
  .coach .avatar {
    width: 34px;
    height: 40px;
    flex-basis: 34px;
  }
  .coach .bubble {
    padding: 8px 10px 10px;
  }
  .coach .bubble .text {
    font-size: 13px;
  }
  .coach .bubble .eval-chip {
    padding: 2px 6px;
    font-size: 11px;
  }
  .coach-details .detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .action-row {
    gap: 8px;
    padding: 8px;
  }
  .action-btn {
    min-height: 44px;
    height: 44px;
    font-size: 12px;
    gap: 5px;
  }
  .action-btn svg {
    width: 15px;
    height: 15px;
  }
  .moves-panel {
    min-height: 140px;
  }
  .moves-list .move-row {
    height: 30px;
    padding: 0 8px;
    font-size: 13px;
  }
  .moves-list .cell {
    height: 26px;
    padding: 2px 6px;
  }
  .moves-list .cell .cls-icon,
  .moves-list .cell .mini-badge-empty {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
  }
  .eval-graph {
    padding: 6px 8px 2px;
  }
  .eval-graph .eval-svg {
    height: 62px;
  }
  .controls {
    gap: 8px;
    padding: 8px;
  }
  .ctrl-btn {
    min-height: 42px;
    height: 42px;
  }
}

@media (max-width: 380px) {
  .coach .avatar {
    display: none;
  }
  .coach .bubble::before {
    display: none;
  }
}
