/* ============================================================
   Réti — opening trainer
   A soft, paper-and-sage palette; Fraunces for display, Inter for UI.
   ============================================================ */

@font-face {
  font-family: 'Fraunces';
  src: url('../assets/fonts/fraunces.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #fcfaf7;
  --paper-2: #f5f1ea;
  --card: rgba(255, 255, 255, 0.74);
  --card-solid: #fffefb;

  --ink: #3b352e;
  --ink-soft: #7c756a;
  --ink-faint: #aca499;

  --sage: #9aad8b;
  --sage-deep: #64775a;
  --sage-soft: #e5ecdc;
  --sage-wash: #f1f5ec;

  --clay: #cba089;
  --rose: #d39b96;
  --rose-soft: #f8ece9;
  --amber: #e3caa0;

  --line: rgba(59, 53, 46, 0.06);
  --line-strong: rgba(59, 53, 46, 0.10);

  --sq-light: #f8f4ec;
  --sq-dark: #c2cfb5;

  --shadow-sm: 0 1px 2px rgba(62, 54, 42, .035);
  --shadow-md: 0 2px 6px rgba(62, 54, 42, .03), 0 20px 44px -24px rgba(62, 54, 42, .22);
  --shadow-lg: 0 34px 80px -40px rgba(62, 54, 42, .34);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 30px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 8% -10%, #ffffff 0%, rgba(255, 255, 255, 0) 55%),
    radial-gradient(90% 80% at 100% 0%, #f6f8f0 0%, rgba(246, 248, 240, 0) 52%),
    radial-gradient(120% 100% at 50% 120%, #f7f2e9 0%, rgba(247, 242, 233, 0) 62%),
    var(--paper);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--sage-soft); color: var(--sage-deep); }

.mono { font-variant-numeric: tabular-nums; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

/* ---------------- shell ---------------- */

.shell {
  position: relative;
  z-index: 1;
  max-width: 1380px;
  margin: 0 auto;
  padding: 22px 28px 32px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------------- topbar ---------------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 2px 4px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand__mark {
  width: 38px; height: 38px;
  padding: 6px;
  border-radius: 12px;
  object-fit: contain;
  background: linear-gradient(160deg, #ffffff, #eef2e8);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255, 255, 255, .7);
}

.brand__text h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400;
  font-size: 23px;
  letter-spacing: -.015em;
  margin: 0;
  line-height: 1;
  font-variation-settings: 'opsz' 40, 'SOFT' 60;
}

.brand__text p {
  margin: 4px 0 0;
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.tabs {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink-soft);
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .22s var(--ease), background .22s var(--ease), box-shadow .22s var(--ease);
}

.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--sage-deep);
  background: #fff;
  box-shadow: 0 1px 2px rgba(48,42,34,.07), 0 6px 16px -10px rgba(48,42,34,.4);
}

.topbar__meta { display: flex; justify-content: flex-end; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-faint);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.5);
  box-shadow: inset 0 0 0 1px var(--line);
  white-space: nowrap;
}
.chip--ghost { background: transparent; box-shadow: none; }

/* ---------------- layout ---------------- */

.layout {
  display: grid;
  grid-template-columns: 304px minmax(0, 664px) 344px;
  gap: 22px;
  align-items: start;
  justify-content: center;
  flex: 1;
}

.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col--board { position: sticky; top: 18px; }

/* ---------------- panels ---------------- */

.panel {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(255, 255, 255, .55);
  backdrop-filter: blur(14px);
  animation: rise .5s var(--ease-out) both;
}

.panel--flush { padding: 0; overflow: hidden; }

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

.panel__title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-variation-settings: 'opsz' 24, 'SOFT' 50;
  font-size: 15px;
  letter-spacing: -.005em;
  margin: 0 0 4px;
  color: var(--ink);
}

.panel__hint {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.panel__hint--tiny { font-size: 11.5px; color: var(--ink-faint); margin: 10px 0 0; }

.eyebrow {
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
}

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

.board-stage { display: flex; flex-direction: column; gap: 12px; }

.board-frame {
  position: relative;
  border-radius: var(--r-lg);
  padding: 11px;
  background: linear-gradient(155deg, #ffffff, rgba(255, 255, 255, .72));
  box-shadow: var(--shadow-lg), 0 0 60px -14px rgba(154, 173, 139, .22), inset 0 0 0 1px rgba(255, 255, 255, .95);
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 17px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  outline: none;
  user-select: none;
  touch-action: manipulation;
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sq--light { background: var(--sq-light); }
.sq--dark { background: var(--sq-dark); }

.sq__coord {
  position: absolute;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  opacity: .5;
  pointer-events: none;
}
.sq__coord--file { right: 4px; bottom: 2px; }
.sq__coord--rank { left: 3px; top: 2px; }
.sq--light .sq__coord { color: #8c8677; }
.sq--dark .sq__coord { color: #6d7a5f; }

.sq.is-last::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(232, 208, 160, .40);
  box-shadow: inset 0 0 0 1.5px rgba(216, 186, 129, .30);
}

.sq.is-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(154, 173, 139, .34);
  box-shadow: inset 0 0 0 2px rgba(100, 119, 90, .38);
}

.sq.is-hint::before {
  content: '';
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(100, 119, 90, .26);
  animation: pop .22s var(--ease-out);
}
.sq.is-hint.is-capture::before {
  width: 92%;
  height: 92%;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 4px rgba(100, 119, 90, .26);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

.sq.is-check::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(211, 155, 150, .70) 0%, rgba(211, 155, 150, .20) 55%, transparent 72%);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .85; } 50% { opacity: .5; } }

.sq.is-good::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(154, 173, 139, .38);
  box-shadow: inset 0 0 0 2px rgba(100, 119, 90, .42);
}
.sq.is-bad::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(211, 155, 150, .34);
  box-shadow: inset 0 0 0 2px rgba(190, 128, 123, .38);
}
.sq.is-book::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(232, 208, 160, .42);
  box-shadow: inset 0 0 0 2px rgba(216, 186, 129, .5);
  animation: glow 1.4s ease-in-out infinite;
}
@keyframes glow { 0%,100% { opacity: .6; } 50% { opacity: 1; } }

.piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .21s var(--ease-out);
  will-change: transform;
  z-index: 2;
  pointer-events: none;
}
.piece img {
  width: 86%;
  height: 86%;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(40, 35, 28, .18));
}
.piece.is-dragging { transition: none; z-index: 5; }
.piece.is-captured { transition: opacity .16s ease, transform .16s ease; opacity: 0; }

/* coordinates drawn outside the board would be nicer, but keep it simple */

.board-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.players { display: flex; flex-direction: column; gap: 3px; }
.player { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.player__name { font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
.dot--w { background: #fffdf8; }
.dot--b { background: #3a352e; }

.board-bar__tools { display: flex; gap: 6px; }

.icon-btn {
  appearance: none;
  border: 0;
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,.6);
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: #fff; color: var(--ink); }
.icon-btn:active { transform: scale(.94); }

/* ---------------- move strip ---------------- */

.moves {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 2px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.55);
  box-shadow: inset 0 0 0 1px var(--line);
  min-height: 46px;
  align-content: flex-start;
  max-height: 132px;
  overflow-y: auto;
}

.mv {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 13px;
  padding: 3px 7px;
  border-radius: 7px;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: background .15s var(--ease);
}
.mv:hover { background: rgba(126,144,112,.14); }
.mv.is-current { background: var(--sage-soft); color: var(--sage-deep); font-weight: 600; }
.mv__num { font-size: 10.5px; color: var(--ink-faint); font-weight: 500; }
.mv.is-current .mv__num { color: var(--sage); }
.mv__empty { font-size: 12.5px; color: var(--ink-faint); padding: 4px 6px; }

/* ---------------- branch list ---------------- */

.branch-list { display: flex; flex-direction: column; gap: 4px; }

.branch {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--ink);
  transition: background .18s var(--ease), transform .18s var(--ease);
}
.branch:hover { background: rgba(255,255,255,.72); transform: translateX(2px); }
.branch.is-active { background: #fff; box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }

.branch__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.branch__san {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  font-weight: 500;
  font-variation-settings: 'opsz' 20;
  min-width: 42px;
}
.branch__name {
  font-size: 11.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.branch__pct { font-size: 11.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------------- repertoire ---------------- */

.repertoire { display: flex; flex-direction: column; gap: 7px; }

.rep-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.rep-row__num {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 13px;
  color: var(--ink-faint);
  min-width: 14px;
}
.rep-row__mv {
  font-weight: 600;
  color: var(--sage-deep);
  background: var(--sage-wash);
  padding: 2px 8px;
  border-radius: 7px;
  font-size: 12.5px;
}
.rep-row__note { color: var(--ink-faint); font-size: 11.5px; }

/* ---------------- stats ---------------- */

.wdl {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.02);
}
.wdl__w { background: #eae5da; }
.wdl__d { background: #cfd8c2; }
.wdl__b { background: #b4aea4; }

.wdl-legend {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-faint);
}
.wdl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.wdl-legend i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }

/* ---------------- study info ---------------- */

.si-head {
  padding: 20px 20px 16px;
  background: linear-gradient(170deg, rgba(255,255,255,.9), rgba(255,255,255,.45));
  border-bottom: 1px solid var(--line);
}
.si-eco {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .1em;
  font-weight: 600;
  color: var(--sage-deep);
  background: var(--sage-wash);
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.si-name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400;
  font-variation-settings: 'opsz' 40, 'SOFT' 70;
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: -.015em;
  margin: 0 0 10px;
}
.si-meta { display: flex; gap: 16px; font-size: 11.5px; color: var(--ink-faint); }
.si-meta b { display: block; font-family: 'Fraunces', Georgia, serif; font-size: 16px; color: var(--ink); font-weight: 500; }

.si-body { padding: 16px 20px 20px; }

.si-sub {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 10px;
  font-weight: 500;
}

/* move option cards */
.opts { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; }

.opt {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border-radius: 12px;
  border: 0;
  background: rgba(255,255,255,.5);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: background .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.opt:hover { background: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-strong); }
.opt.is-main { background: linear-gradient(150deg, #fff, var(--sage-wash)); box-shadow: inset 0 0 0 1px rgba(154,173,139,.24); }

.opt__san {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  font-variation-settings: 'opsz' 24;
  display: flex;
  align-items: center;
  gap: 5px;
}
.opt__star { width: 5px; height: 5px; border-radius: 50%; background: var(--sage); flex: none; }
.opt__body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.opt__meta { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-faint); }
.opt__meta b { color: var(--ink-soft); font-weight: 600; font-variant-numeric: tabular-nums; }

/* model games */
.games { display: flex; flex-direction: column; gap: 2px; }

.game-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: background .16s var(--ease);
}
.game-row:hover { background: rgba(255,255,255,.8); }
.game-row__players { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.game-row__p { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-row__p b { font-weight: 600; }
.game-row__p.is-winner { color: var(--sage-deep); }
.game-row__yr { font-size: 10.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.game-row__res {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}

.empty-note { font-size: 12px; color: var(--ink-faint); padding: 6px 2px; }

/* ---------------- form controls ---------------- */

.field { display: block; margin-bottom: 15px; }
.field__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.field__value { color: var(--sage-deep); font-weight: 600; font-size: 11.5px; }

.select {
  width: 100%;
  appearance: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: rgba(255,255,255,.75)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%236d665c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  padding: 9px 32px 9px 12px;
  border: 0;
  border-radius: 11px;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow .18s var(--ease);
}
.select:focus { outline: none; box-shadow: inset 0 0 0 1px rgba(126,144,112,.5), 0 0 0 3px rgba(126,144,112,.12); }

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sage) var(--fill, 50%), rgba(42,38,32,.09) var(--fill, 50%));
}
.range::-moz-range-track { height: 5px; border-radius: 999px; background: rgba(42,38,32,.09); }
.range::-moz-range-progress { height: 5px; border-radius: 999px; background: var(--sage); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(48,42,34,.3), inset 0 0 0 1px rgba(42,38,32,.12);
  transition: transform .15s var(--ease);
}
.range::-webkit-slider-thumb:active { transform: scale(1.15); }
.range::-moz-range-thumb {
  width: 17px; height: 17px; border: 0; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(48,42,34,.3), inset 0 0 0 1px rgba(42,38,32,.12);
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(42,38,32,.05);
}
.seg {
  flex: 1;
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.seg.is-active {
  background: #fff;
  color: var(--sage-deep);
  box-shadow: 0 1px 2px rgba(48,42,34,.08);
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  margin-bottom: 16px;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 36px; height: 21px;
  border-radius: 999px;
  background: rgba(42,38,32,.14);
  position: relative;
  transition: background .22s var(--ease);
  flex: none;
}
.switch__dot {
  position: absolute;
  top: 3px; left: 3px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .22s var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--sage); }
.switch input:checked + .switch__track .switch__dot { transform: translateX(15px); }

.btn {
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 11px;
  border: 0;
  cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn--block { width: 100%; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn--primary { flex: 1; }
.btn-row .btn--ghost { gap: 6px; padding: 9px 14px; }
.btn--primary {
  color: #fdfcf9;
  background: linear-gradient(150deg, #93a684, #71865f);
  box-shadow: 0 1px 2px rgba(62,54,42,.12), 0 12px 24px -14px rgba(113,134,95,.8);
}
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(62,54,42,.12), 0 18px 30px -16px rgba(113,134,95,.8); }
.btn--primary:active { transform: translateY(0); }
.btn--ghost {
  color: var(--ink-soft);
  background: rgba(255,255,255,.6);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  padding: 7px 13px;
}
.btn--ghost:hover { background: #fff; color: var(--ink); }
.btn--soft {
  color: var(--sage-deep);
  background: var(--sage-wash);
  font-size: 12px;
  padding: 8px 14px;
}
.btn--soft:hover { background: var(--sage-soft); }

/* ---------------- train ---------------- */

.train-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.train-line {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  margin-top: 3px;
  color: var(--ink);
  line-height: 1.35;
}

.ring { position: relative; width: 44px; height: 44px; flex: none; }
.ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring__bg { stroke: rgba(42,38,32,.08); }
.ring__fg {
  stroke: var(--sage);
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 113;
  transition: stroke-dashoffset .5s var(--ease-out);
}
.ring span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.feedback { min-height: 96px; display: flex; flex-direction: column; gap: 8px; }
.feedback__idle { font-size: 12.5px; color: var(--ink-faint); }

.fb {
  border-radius: 13px;
  padding: 12px 14px;
  animation: rise .35s var(--ease-out) both;
  font-size: 12.5px;
  line-height: 1.5;
}
.fb--good { background: var(--sage-wash); box-shadow: inset 0 0 0 1px rgba(126,144,112,.22); }
.fb--bad { background: var(--rose-soft); box-shadow: inset 0 0 0 1px rgba(201,140,135,.28); }
.fb--info { background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px var(--line); }
.fb__title { font-weight: 600; display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.fb--good .fb__title { color: var(--sage-deep); }
.fb--bad .fb__title { color: #ab7269; }
.fb__body { color: var(--ink-soft); }
.fb__san {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.fb__actions { display: flex; gap: 7px; margin-top: 9px; }

.streak-row {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.streak-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(42,38,32,.12);
  transition: background .3s var(--ease);
}
.streak-dot.is-ok { background: var(--sage); }
.streak-dot.is-bad { background: var(--rose); }

/* ---------------- play ---------------- */

.play-status__line {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  margin-top: 3px;
  line-height: 1.35;
}

.evalbar { margin-top: 16px; }
.evalbar__track {
  height: 7px;
  border-radius: 999px;
  background: #2f2b25;
  overflow: hidden;
}
.evalbar__fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #f6f3ea, #fffdf8);
  border-radius: 999px;
  transition: width .4s var(--ease-out);
}
.evalbar__label {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(38, 34, 28, .32);
  backdrop-filter: blur(6px);
  animation: fade .25s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal__card {
  position: relative;
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(170deg, #fffdfa, #faf7f1);
  border-radius: var(--r-xl);
  padding: 26px;
  box-shadow: 0 40px 80px -30px rgba(40,35,28,.5), inset 0 0 0 1px rgba(255,255,255,.8);
  animation: rise .35s var(--ease-out) both;
}
.modal__close {
  position: absolute;
  top: 16px; right: 16px;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(42,38,32,.05);
  color: var(--ink-soft);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background .16s var(--ease);
}
.modal__close:hover { background: rgba(42,38,32,.1); }

.modal__title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400;
  font-variation-settings: 'opsz' 36, 'SOFT' 60;
  font-size: 22px;
  margin: 6px 0 3px;
  letter-spacing: -.015em;
}
.modal__sub { font-size: 12px; color: var(--ink-faint); margin-bottom: 16px; }

.modal__moves {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-height: 150px;
  overflow-y: auto;
  padding: 10px;
  border-radius: var(--r-md);
  background: rgba(42,38,32,.03);
  margin-bottom: 18px;
}

.modal__foot { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; }
.mini-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 200px;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.mini-board .sq { position: relative; }
.mini-board img { width: 92%; height: 92%; display: block; margin: auto; position: absolute; inset: 4%; }
.modal__nav { display: flex; gap: 7px; align-items: center; }

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

.foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 11px;
  color: var(--ink-faint);
  padding-top: 6px;
}
.foot b { font-weight: 600; color: var(--ink-soft); }
.foot__sep { opacity: .5; }

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

@media (max-width: 1180px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr) 320px; gap: 16px; }
  .shell { padding: 18px 20px 26px; }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col--board { position: static; order: -1; }
  .col--left { order: 0; }
  .col--right { order: 1; }
  .board-stage { max-width: 560px; margin: 0 auto; width: 100%; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar__meta { display: none; }
  .tabs { justify-self: end; }
}

@media (max-width: 620px) {
  .shell { padding: 14px 14px 22px; gap: 14px; }
  .panel { padding: 16px; border-radius: var(--r-md); }
  .brand__text h1 { font-size: 20px; }
  .brand__text p { display: none; }
  .tab { padding: 7px 14px; font-size: 12.5px; }
  .board-frame { padding: 7px; }
  .sq__coord { font-size: 7.5px; }
  .modal__foot { flex-direction: column; align-items: stretch; }
  .mini-board { width: 100%; max-width: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------- train: score sheet ---------------- */

.planned {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(42, 38, 32, .028);
  display: flex;
  flex-wrap: wrap;
  gap: 3px 2px;
  min-height: 44px;
  align-content: flex-start;
  max-height: 190px;
  overflow-y: auto;
}
.planned:empty { display: none; }

.pl {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.pl__num { font-size: 9.5px; opacity: .75; }
.pl.is-past { color: var(--ink-soft); }
.pl.is-past.pl--ok { color: var(--sage-deep); }
.pl.is-past.pl--bad { color: #ab7269; background: var(--rose-soft); }
.pl.is-now {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
}
.pl.is-now::after {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--sage);
  align-self: center;
  animation: pulse 1.6s ease-in-out infinite;
}
.pl.is-black { opacity: .78; font-style: italic; }

.lifetime {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.lifetime b { color: var(--ink-soft); font-weight: 600; font-variant-numeric: tabular-nums; }
.pl--rest {
  color: var(--ink-faint);
  font-size: 10.5px;
  opacity: .8;
}

/* first-paint loading shimmer */
.loading .panel { position: relative; overflow: hidden; }
.loading .panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
