/* =========================================================================
   Chessdotcom AI Coach — "Gambit"
   A warm, editorial light theme: parchment surfaces, board-green accent,
   brass detail. Spectral (display), Instrument Sans (body), JetBrains Mono.
   ========================================================================= */

:root {
  /* Surfaces */
  --bg: #f2ede1;
  --paper: #fbf8f0;
  --paper-2: #f6f0e2;
  --line: rgba(43, 38, 33, 0.1);
  --line-soft: rgba(43, 38, 33, 0.06);

  /* Ink */
  --ink: #2b2621;
  --ink-2: #3a3128;
  --ink-dim: #7a7064;
  --ink-mute: #9a9084;
  --ink-faint: #a79c8d;

  /* Accents */
  --green: #4a7a52;
  --green-dark: #3c6444;
  --green-soft: rgba(74, 122, 82, 0.12);
  --green-line: rgba(74, 122, 82, 0.4);
  --brass: #b78e54;
  --live-red: #d0463b;

  /* Dark chrome (header, login aside, player bars) */
  --chrome: #231a12;
  --chrome-bar: rgba(35, 26, 18, 0.97);
  --chrome-ink: #f4ecdd;
  --chrome-ink-dim: #c3b6a3;
  --chrome-line: rgba(183, 142, 84, 0.2);

  /* Board */
  --sq-light: #ecdfbf;
  --sq-dark: #6f8f5c;
  --board-frame: #e8dcc6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 2px 8px -4px rgba(43, 38, 33, 0.2);
  --shadow-lift: 0 14px 30px -14px rgba(43, 38, 33, 0.4);

  --font-display: "Spectral", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Grows to push the footer to the bottom on short pages. */
.app-main {
  flex: 1 0 auto;
}

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

input {
  font-family: inherit;
}
::placeholder {
  color: var(--ink-faint);
}

.mono {
  font-family: var(--font-mono);
}

@keyframes gm-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.82);
  }
}

/* ===================== App header (dark, sticky) ===================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--chrome-bar);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--chrome-line);
}
.app-header__inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 28px;
  min-height: 64px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
  color: #f6f1e6;
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--chrome-ink);
  line-height: 1.05;
}
.brand__sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--brass);
  line-height: 1.3;
}
.brand__version {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--chrome-ink-dim);
  border: 1px solid var(--chrome-line);
  border-radius: 4px;
  padding: 1px 5px;
  user-select: none;
}

.back-link {
  margin-left: 6px;
  white-space: nowrap;
  font-size: 14px;
  color: #b0a48f;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.back-link:hover {
  color: var(--chrome-ink);
}

.app-header__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
}
.user-chip__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--chrome);
}
.user-chip__name {
  font-size: 13px;
  color: #e7dcc8;
  font-weight: 500;
}
.logout {
  color: #b0a48f;
  font-size: 15px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.logout:hover {
  color: var(--chrome-ink);
}

/* ===================== Page shell ===================== */
.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 38px 28px 48px;
}
.page--wide {
  max-width: 1300px;
  padding: 28px 28px 48px;
}

/* ===================== Buttons ===================== */
.btn {
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn--accent {
  background: var(--green);
  color: var(--paper);
}
.btn--accent:hover {
  background: var(--green-dark);
  color: var(--paper);
}
.btn--ghost {
  background: var(--paper);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn--ghost:hover {
  border-color: var(--green-line);
  color: var(--green-dark);
}
.btn--sm {
  font-size: 13px;
  padding: 9px 14px;
}
.btn--block {
  width: 100%;
}
.btn[disabled] {
  opacity: 0.7;
  cursor: default;
}
/* In-flight state while HTMX is fetching (e.g. the home Sync button) */
.btn.htmx-request {
  opacity: 0.7;
  cursor: default;
}
/* Sync reads as running for as long as the import runs (`is-syncing`), not for
   the length of the request that queued it — two milliseconds, too short for a
   one-second pulse to show at all. */
.btn.is-syncing {
  opacity: 0.7;
  cursor: default;
}
.btn.htmx-request .fa-arrows-rotate,
.btn.is-syncing .fa-arrows-rotate {
  animation: gm-pulse 1s linear infinite;
}

/* ===================== Badges ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--green);
  background: var(--green-soft);
  padding: 4px 8px;
  border-radius: 5px;
}
/* Past-game outcome badges (win / loss / draw), relative to the user. */
.badge--win {
  color: var(--green);
  background: var(--green-soft);
}
.badge--loss {
  color: var(--live-red);
  background: rgba(208, 70, 59, 0.12);
}
.badge--draw {
  color: var(--ink-dim);
  background: rgba(154, 144, 132, 0.16);
}

/* ===================== Chessboard (glyph) ===================== */
.board {
  width: var(--board-size, 100%);
  max-width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  container-type: inline-size;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.board--mini {
  --board-size: 236px;
}
.board--lg {
  --board-size: 520px;
}
.board__sq {
  display: flex;
  align-items: center;
  justify-content: center;
}
.board__sq--light {
  background: var(--sq-light);
}
.board__sq--dark {
  background: var(--sq-dark);
}
.board__sq--hl {
  box-shadow: inset 0 0 0 1.3cqw rgba(183, 142, 84, 0.92);
}
.board__pc {
  font-size: 11.5cqw;
  line-height: 1;
  /* Unicode chess glyphs carry extra metric space below the baseline, so the
     ink sits high in the line box; nudge it down to optically centre the piece. */
  display: block;
  transform: translateY(12%);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols2", "Arial Unicode MS", serif;
}
.board__pc--w {
  color: #faf6ec;
  text-shadow: 0 0 1px #23201b, 0.6px 0.6px 0 #23201b, -0.6px -0.6px 0 #23201b,
    0.6px -0.6px 0 #23201b, -0.6px 0.6px 0 #23201b;
}
.board__pc--b {
  color: #23201b;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}

/* ===================== Home ===================== */
.home__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.home__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  margin: 0 0 6px;
}
.home__sub {
  font-size: 14px;
  color: var(--ink-dim);
  margin: 0;
}
.home__filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Time-control filter ----------------------------------------------
   Chips sit between the page head and the grid. They read as controls, not
   badges, so they borrow the ghost button's shape; the selected one takes the
   board green the rest of the app uses for "this is the one". */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.filter-chip {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.filter-chip:hover {
  border-color: var(--green-line);
  color: var(--green-dark);
}
.filter-chip--on {
  color: var(--green-dark);
  background: var(--green-soft);
  border-color: var(--green-line);
  font-weight: 600;
}

/* ---- Pager ------------------------------------------------------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}
.pager__at {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(292px, 100%), 1fr));
  gap: 22px;
}

.gm-card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  color: inherit;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow-card);
}
.gm-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  color: inherit;
}
.gm-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.gm-card__head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gm-card__player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 8px;
}
.gm-card__player--white {
  padding: 8px 14px 14px;
}
.gm-card__avatar {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  flex: none;
}
.gm-card__avatar--b {
  background: #2b2621;
}
.gm-card__avatar--w {
  background: #f4ecdd;
  border: 1px solid rgba(43, 38, 33, 0.15);
}
.gm-card__id {
  flex: 1;
  min-width: 0;
}
.gm-card__name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gm-card__meta {
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}
.gm-card__board {
  padding: 2px 14px;
  display: flex;
  justify-content: center;
}
.gm-card__board-frame {
  padding: 6px;
  background: var(--board-frame);
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(43, 38, 33, 0.08);
}

/* ===================== Game detail layout ===================== */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 600px) minmax(360px, 1fr);
  gap: 32px;
  align-items: start;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.detail-meta__text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
}

/* Player bars around the board */
.pbar {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
}
.pbar--top {
  background: #2b2621;
  border-radius: 9px 9px 0 0;
}
.pbar--bottom {
  background: #3a2c20;
  border-radius: 0 0 9px 9px;
}
.pbar__avatar {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  flex: none;
}
.pbar__avatar--b {
  background: #4a3f34;
}
.pbar__avatar--w {
  background: #f4ecdd;
  border: 1px solid rgba(43, 38, 33, 0.2);
}
.pbar__id {
  flex: 1;
  min-width: 0;
}
.pbar__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--chrome-ink);
}
.pbar__meta {
  font-size: 11px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

/* Board stage: eval bar + board on the parchment frame */
.board-stage {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: var(--board-frame);
  box-shadow: inset 0 0 0 1px rgba(43, 38, 33, 0.08);
}
.board-stage__board {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.evalbar {
  width: 16px;
  border-radius: 3px;
  overflow: hidden;
  background: #2b2621;
  position: relative;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
/* Board flipped for a black-perspective view: flip the bar too so White's
   fill grows from White's (now top) side. */
.evalbar--flipped {
  transform: scaleY(-1);
}
.evalbar__fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f2ecdd;
  transition: height 0.5s;
}
.evalbar__mid {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--brass);
}

/* Last-move footer */
.movebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.movebar__last {
  font-size: 12px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}
.movebar__nav {
  display: flex;
  gap: 6px;
  color: #5c5346;
  font-size: 15px;
}
.movebar__nav span {
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(43, 38, 33, 0.05);
}

/* ===================== Coach card ===================== */
.game-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.coach {
  background: linear-gradient(165deg, var(--paper) 0%, var(--paper-2) 100%);
  border: 1px solid rgba(74, 122, 82, 0.28);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 30px -18px rgba(43, 38, 33, 0.5);
}
.coach__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--green);
  color: var(--chrome-ink);
}
.coach__head-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.coach__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin: 0;
}
.coach__tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 8px;
  border-radius: 5px;
}
.coach__body {
  padding: 22px;
}

.coach__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 14px 0 22px;
  color: var(--ink-dim);
}
.coach__placeholder-icon {
  font-size: 30px;
  color: var(--green);
  opacity: 0.55;
}

.coach__rec {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.coach__rec-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8072;
  margin-bottom: 4px;
}
.coach__move {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 56px;
  line-height: 0.9;
  color: var(--ink);
}
.coach__eval {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: #f2ecdd;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 7px;
}
.coach__badge {
  margin-left: auto;
  margin-bottom: 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--green);
  background: rgba(74, 122, 82, 0.14);
  padding: 5px 9px;
  border-radius: 20px;
}
.coach__summary {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 18px 0 0;
  white-space: pre-line;
}
.coach__actions {
  padding: 0 22px 22px;
}
.coach__reanalyze {
  margin-top: 16px;
}

/* ===================== Login (split panel) ===================== */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: radial-gradient(
    120% 90% at 50% -10%,
    #3a2c20 0%,
    #241b14 60%,
    #1b140e 100%
  );
}
.login__card {
  width: 100%;
  max-width: 940px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(183, 142, 84, 0.22);
}
.login__aside {
  padding: 52px 46px;
  background: linear-gradient(160deg, #2c2118 0%, #221a12 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  min-height: 520px;
}
.login__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 18px;
}
.login__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 42px;
  line-height: 1.08;
  margin: 0 0 18px;
  color: #f6efe0;
}
.login__text {
  font-size: 15px;
  line-height: 1.6;
  color: #c3b6a3;
  margin: 0;
  max-width: 340px;
}
.login__stats {
  display: flex;
  gap: 26px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #8f8271;
}
.login__stats b {
  color: #e7dcc8;
  font-size: 15px;
  font-weight: 600;
}
.login__brand .brand__name {
  font-size: 16px;
}

.login__form {
  padding: 52px 46px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login__form-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  margin: 0 0 6px;
}
.login__form-sub {
  font-size: 14px;
  color: var(--ink-dim);
  margin: 0 0 30px;
  line-height: 1.55;
}

/* ===================== Form fields ===================== */
.field {
  margin-bottom: 16px;
}
.field__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #5c5346;
  display: block;
  margin-bottom: 8px;
}
.input {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid rgba(43, 38, 33, 0.16);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: #fff;
  transition: border-color 0.15s;
}
.input:focus-within {
  border-color: var(--green-line);
}
.input__icon {
  font-size: 16px;
  line-height: 1;
  color: #b1a795;
}
.input input {
  border: 0;
  outline: 0;
  padding: 14px 0;
  font-size: 15px;
  flex: 1;
  background: transparent;
  color: var(--ink);
}

/* ===================== Empty / alert / error ===================== */
.empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 30px 26px;
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-dim);
}
.empty i {
  font-size: 22px;
  color: var(--brass);
}
.empty h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
}
.empty p {
  margin: 0;
  font-size: 14px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.alert--danger {
  background: rgba(208, 70, 59, 0.1);
  border: 1px solid rgba(208, 70, 59, 0.3);
  color: #a23b31;
}

.error-wrap {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.error-card {
  max-width: 520px;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-card);
}
.error-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 10px;
}

/* ===================== HTMX indicator / spinner ===================== */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.htmx-request .coach__prompt-label {
  display: none;
}
.spinner {
  /* inline-block so width/height apply even outside a flex parent (e.g. the
     button label), otherwise an inline span collapses to a thin bar. */
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(183, 142, 84, 0.25);
  border-top-color: #b78e54;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===================== Coach history (timeline) ===================== */
.coach__history {
  border-top: 1px solid var(--line);
  padding: 18px 22px 22px;
}
.coach__history-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 12px;
}
.coach__history-count {
  margin-left: auto;
  background: var(--green-soft);
  color: var(--green-dark);
  border-radius: 20px;
  padding: 2px 9px;
  font-weight: 600;
}
.coach-hist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.coach-hist__item {
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.coach-hist__top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.coach-hist__move {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.coach-hist__best {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
}
.coach-hist__time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.coach-hist__eval {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green-dark);
  margin-bottom: 4px;
}
.coach-hist__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0;
}

/* ===================== Moves list ===================== */
.moves {
  margin-top: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.moves__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.moves__list {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.moves__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.moves__item--analyzed {
  background: var(--green-soft);
}
.moves__no {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-mute);
  min-width: 32px;
}
.moves__san {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
}
.moves__badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--brass);
  background: rgba(183, 142, 84, 0.14);
  padding: 3px 8px;
  border-radius: 20px;
}
.moves__badge--followed {
  color: var(--green-dark);
  background: var(--green-soft);
}

.gm-card--past {
  opacity: 0.9;
}
.gm-card__ended {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}

/* ===================== Game review (move-by-move) ===================== */
/* Board with an SVG arrow overlay; the wrapper bounds width so the arrows
   (positioned in %) stay aligned with the squares. */
.gr-board-wrap {
  position: relative;
  width: 100%;
  max-width: 520px;
}
.gr-board-wrap .board {
  --board-size: 100%;
}
.gr-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.pbar__you {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--brass);
}

/* Move navigator buttons */
.gr-navwrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gr-nav {
  display: flex;
  gap: 6px;
}
.gr-nav button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(43, 38, 33, 0.12);
  background: var(--paper-2);
  color: #5c5346;
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.gr-nav button:hover {
  border-color: var(--green-line);
  color: var(--green-dark);
}

/* Coach-panel glyph (start / un-analysed states) */
.gr-glyph {
  font-size: 34px;
  color: var(--green);
  opacity: 0.55;
  line-height: 1;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols2", serif;
}
.gr-glyph--sm {
  font-size: 30px;
  opacity: 0.5;
}
.gr-opp .coach__rec-label {
  margin-bottom: 8px;
}
.gr-opp .coach__summary {
  margin-top: 6px;
}
.gr-bigmove {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
  color: var(--ink);
}

/* Played-vs-coach comparison */
.gr-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: 10px;
  margin-top: 14px;
}
.gr-compare__cell {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  background: var(--paper-2);
}
.gr-compare__cell--good {
  border-color: rgba(74, 122, 82, 0.45);
  background: rgba(74, 122, 82, 0.1);
}
.gr-compare__cell--diff {
  border-color: rgba(183, 142, 84, 0.5);
  background: rgba(183, 142, 84, 0.1);
}
.gr-compare__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.gr-compare__val {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  min-width: 0;
  gap: 8px;
}
.gr-compare__san {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
}
.gr-compare__eval {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
}
.gr-compare__eval--green {
  color: var(--green-dark);
}

/* Followed / differed status chip */
.gr-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  padding: 6px 11px;
  border-radius: 20px;
}
.gr-status--followed {
  color: var(--green-dark);
  background: rgba(74, 122, 82, 0.14);
}
.gr-status--differed {
  color: #8a6a2e;
  background: rgba(183, 142, 84, 0.16);
}

/* Arrow legend */
.gr-legend {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.gr-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.gr-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.gr-legend__dot--brass {
  background: var(--brass);
}
.gr-legend__dot--green {
  background: var(--green);
}

/* Neutral card (analysis-history timeline) */
.gr-card {
  background: linear-gradient(165deg, var(--paper) 0%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.gr-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.gr-card__count {
  margin-left: auto;
  background: var(--green-soft);
  color: var(--green-dark);
  border-radius: 20px;
  padding: 2px 9px;
  font-weight: 600;
  letter-spacing: 0;
}
/* ---- Whole-game analysis ----------------------------------------------
   Sits under the coach card. Quieter than the card on purpose: it is the
   control that starts the work, not the work itself. */
.gr-analyse {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.gr-analyse__state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-dim);
}
.gr-analyse__state .fa-circle-check {
  color: var(--green);
}
.gr-hist {
  list-style: none;
  margin: 0;
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
}
.gr-hist__item {
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.gr-hist__item:hover {
  border-color: var(--green-line);
}
.gr-hist__item--sel {
  background: #f0e9d6;
  border-color: rgba(183, 142, 84, 0.6);
}
.gr-hist__top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.gr-hist__no {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.gr-hist__san {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
}
.gr-hist__eval {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green-dark);
  margin-bottom: 4px;
}
.gr-hist__prose {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0;
}
.gr-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
}
.gr-tag--followed {
  color: var(--green-dark);
  background: rgba(74, 122, 82, 0.14);
}
.gr-tag--differed {
  color: #8a6a2e;
  background: rgba(183, 142, 84, 0.16);
}

/* Moves grid (click to review) */
.gr-moves {
  margin-top: 24px;
}
.gr-moves-grid {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.gr-move {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
  background: transparent;
  transition: background 0.15s, box-shadow 0.15s;
}
.gr-move:hover {
  background: var(--paper-2);
}
.gr-move--analyzed {
  background: var(--green-soft);
}
.gr-move--sel {
  background: #f0e9d6;
  box-shadow: 0 0 0 2px rgba(183, 142, 84, 0.7);
}
.gr-move__no {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-mute);
  min-width: 32px;
}
.gr-move__san {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
}
.gr-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.gr-badge--followed {
  color: var(--green-dark);
  background: rgba(74, 122, 82, 0.14);
}
.gr-badge--differed {
  color: #8a6a2e;
  background: rgba(183, 142, 84, 0.16);
}
.gr-badge--pending {
  color: var(--ink-mute);
  background: var(--line-soft);
}

/* ===================== Responsive ===================== */
@media (max-width: 860px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .board--lg {
    --board-size: 100%;
  }
  .login__card {
    grid-template-columns: 1fr;
    max-width: 460px;
  }
  .login__aside {
    min-height: auto;
    gap: 28px;
  }
}
@media (max-width: 640px) {
  .app-header__inner {
    padding: 0 16px;
    gap: 12px;
  }
  .brand__version {
    margin-left: 6px;
    border: none;
    padding: 0;
  }
  .user-chip__name {
    display: none;
  }
  .page {
    padding: 26px 16px 40px;
  }
  .coach__move {
    font-size: 44px;
  }
}

@media (max-width: 440px) {
  .app-header__inner {
    gap: 10px;
    min-height: 56px;
  }
  .app-header__right {
    gap: 12px;
  }
  .brand__sub,
  .brand__version {
    display: none;
  }
  .back-link__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .login__aside,
  .login__form {
    padding: 32px 22px;
  }
  .login__stats {
    gap: 16px;
  }
  .login__title {
    font-size: 30px;
  }
}

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