:root {
  --bg: #f6f8fb;
  --surface: rgba(255,255,255,.9);
  --surface-solid: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --line: #dfe5ee;
  --green: #20b26b;
  --green-dark: #128653;
  --green-soft: rgba(32,178,107,.14);
  --cell-a: #fbfcfe;
  --cell-b: #eef2f7;
  --visited-a: #d7eadf;
  --visited-b: #c7e2d2;
  --visited-text: #0f5132;
  --shadow: 0 18px 42px rgba(19, 32, 55, .10);
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(32,178,107,.12), transparent 28%),
    radial-gradient(circle at 92% 0%, rgba(71, 95, 255, .07), transparent 24%),
    var(--bg);
}

button { font: inherit; }
h1, h2, p { margin-top: 0; }

.app {
  width: min(1360px, calc(100vw - 28px));
  height: 100vh;
  margin: 0 auto;
  padding: 14px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 54px; height: 54px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 16px;
  color: white; font-size: 32px; line-height: 1;
  background: linear-gradient(145deg, #25c77a, #118052);
  box-shadow: 0 12px 26px rgba(32,178,107,.23);
}
h1 { margin-bottom: 2px; font-size: clamp(28px, 3.2vw, 40px); line-height: 1; letter-spacing: -.04em; }
.brand p { margin-bottom: 0; color: var(--muted); font-size: 15px; max-width: 620px; line-height: 1.35; }

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(430px, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
}
.card, .board-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.board-card {
  width: 100%;
  max-width: calc(100vh - 126px);
  aspect-ratio: 1 / 1;
  min-height: 0;
  justify-self: center;
  align-self: center;
  display: grid;
  place-items: center;
  padding: 22px;
}

.board-wrap {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 24px;
  grid-template-rows: 24px minmax(0, 1fr) 24px;
}
.corner { width: 24px; height: 24px; }
.board {
  min-width: 0; min-height: 0;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-solid);
}
.rank-labels, .file-labels { color: #3a455e; font-weight: 650; font-size: 13px; }
.rank-labels { display: grid; grid-template-rows: repeat(8, 1fr); align-items: center; justify-items: center; }
.file-labels { display: grid; grid-template-columns: repeat(8, 1fr); align-items: center; justify-items: center; }
.right-ranks { grid-column: 3; grid-row: 2; }
.top-files { grid-column: 2; grid-row: 1; }

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
  overflow: hidden;
  border: 0;
  padding: 0;
  color: #34405a;
  background: var(--cell-a);
  cursor: default;
  user-select: none;
  font-size: clamp(13px, 1.9vmin, 21px);
  line-height: 1;
  appearance: none;
  transition: background .16s ease, box-shadow .16s ease, transform .16s ease;
}
.cell.dark { background: var(--cell-b); }
.cell.visited {
  background: linear-gradient(145deg, var(--visited-a), var(--visited-b));
  color: var(--visited-text);
  font-weight: 780;
  box-shadow: inset 0 0 0 1px rgba(18, 134, 83, .20);
}
.cell.current {
  box-shadow: inset 0 0 0 2px var(--green), inset 0 0 0 999px var(--green-soft);
}
.cell.available { cursor: pointer; }
.cell.available::after {
  content: "";
  width: 12%; height: 12%;
  min-width: 7px; min-height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px var(--green-soft);
}
.cell.available:hover { z-index: 3; box-shadow: inset 0 0 0 2px var(--green), 0 10px 22px rgba(32,178,107,.16); }
.cell.available:hover::before {
  content: attr(data-next);
  position: absolute;
  inset: 22%;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--green-dark);
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(32,178,107,.45);
  font-weight: 820;
}
.cell.blocked:hover { box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .10); }
.knight {
  position: absolute;
  width: 54%;
  height: 54%;
  inset: auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #111827;
  background: linear-gradient(145deg, #ffffff, #edf2f8);
  border: 1px solid rgba(15, 23, 42, .12);
  font-size: clamp(18px, 3.3vmin, 33px);
  line-height: 1;
  box-shadow: 0 8px 16px rgba(31, 41, 55, .14);
  animation: knightIn .18s ease both;
  pointer-events: none;
}

.left-panel, .right-panel { min-height: 0; display: grid; gap: 14px; align-content: start; }
.left-panel { grid-template-rows: auto auto auto; }
.right-panel { grid-template-rows: auto auto auto; }
.card { padding: 16px; }
.action-card { padding: 14px; }
.btn {
  width: 100%; min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(17, 24, 39, .08); }
.btn.primary { border-color: transparent; color: #fff; background: linear-gradient(135deg, #22c775, #128653); box-shadow: 0 14px 28px rgba(32,178,107,.22); }
.stats { display: grid; gap: 12px; }
.stats h2, .next-card h2, .info h2 { font-size: 18px; margin-bottom: 6px; }
.stats div { display: flex; justify-content: space-between; gap: 16px; }
.stats span, .next-card p, .info li, .tip-card p { color: var(--muted); }
.stats strong { font-size: 17px; }
.next-card p { font-size: 14px; line-height: 1.45; margin-bottom: 0; }
.mini-route { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.mini-route span, .mini-route b { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 23px; line-height: 1; }
.mini-route b { color: var(--green-dark); font-size: 16px; border-color: rgba(32,178,107,.45); background: var(--green-soft); }
.mini-route i { flex: 1; height: 2px; background: var(--green); position: relative; }
.mini-route i::after { content: ""; position: absolute; right: -1px; top: -4px; width: 10px; height: 10px; border-top: 2px solid var(--green); border-right: 2px solid var(--green); transform: rotate(45deg); }

.info { min-height: 0; }
.info ul { margin: 0; padding-left: 18px; }
.info li { margin: 6px 0; font-size: 14px; line-height: 1.34; }
.tip-card p { margin: 0; font-size: 14px; line-height: 1.45; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; padding: 12px 16px; border-radius: 999px; color: #fff; background: #111827; box-shadow: 0 18px 40px rgba(17,24,39,.22); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal { width: min(420px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 24px; padding: 30px; text-align: center; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(15, 23, 42, .35); backdrop-filter: blur(4px); }
.modal-close { position: absolute; top: 14px; right: 14px; border: 0; background: transparent; font-size: 28px; cursor: pointer; color: var(--muted); }
.modal-icon { width: 64px; height: 64px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 34px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
@keyframes knightIn { from { transform: scale(.94); opacity: .4; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 1120px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .board-card { max-width: min(100%, calc(100vh - 130px)); }
  .left-panel, .right-panel { grid-template-columns: 1fr; grid-template-rows: none; }
}
@media (max-width: 720px) {
  .app { width: min(100% - 18px, 1180px); padding: 10px 0; }
  .topbar { align-items: flex-start; }
  .brand-mark { width: 46px; height: 46px; font-size: 28px; }
  .brand p { display: none; }
  .board-card { padding: 8px; }
  .board-wrap { grid-template-columns: 20px 1fr 20px; grid-template-rows: 20px 1fr 20px; }
  .left-panel, .right-panel { grid-template-columns: 1fr; }
}

/* v5 targeted refinements */
.app {
  grid-template-rows: minmax(96px, auto) minmax(0, 1fr);
  padding-top: 12px;
  padding-bottom: 36px;
}
.topbar {
  min-height: 96px;
  padding: 20px 4px 18px;
}
.brand-mark {
  border-radius: 16px;
  overflow: hidden;
}
.horse-svg {
  width: 72%;
  height: 72%;
  display: block;
  fill: currentColor;
}
.brand-mark .horse-svg {
  color: #fff;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.08));
}
.layout {
  height: 100%;
  align-items: stretch;
}
.left-panel,
.right-panel,
.board-card {
  align-self: stretch;
}
.left-panel,
.right-panel {
  height: 100%;
}
.board-card {
  height: 100%;
  max-height: calc(100vh - 152px);
  max-width: calc(100vh - 152px);
}
.board {
  border-radius: 0 !important;
}
.cell:first-child,
.cell:nth-child(8),
.cell:nth-child(57),
.cell:nth-child(64) {
  border-radius: 0 !important;
}
.knight {
  width: 48%;
  height: 48%;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #24c777, #128653);
  border-color: rgba(255,255,255,.35);
  box-shadow: 0 10px 20px rgba(18, 134, 83, .24);
}
.knight .horse-svg {
  width: 72%;
  height: 72%;
}
.section-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  margin-right: 10px;
  border-radius: 9px;
  color: var(--green-dark);
  background: var(--green-soft);
  border: 1px solid rgba(32,178,107,.22);
  font-size: 15px;
  font-weight: 850;
  vertical-align: middle;
}
.stats h2,
.next-card h2,
.info h2 {
  display: flex;
  align-items: center;
}
.mini-route span.mini-knight {
  color: #fff;
  background: linear-gradient(145deg, #24c777, #128653);
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(18, 134, 83, .18);
}
.next-card::after {
  content: "";
  display: block;
  width: min(150px, 100%);
  height: 104px;
  margin: 18px auto 0;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 18% 22%, var(--green) 0 6px, transparent 7px),
    radial-gradient(circle at 82% 22%, var(--green) 0 6px, transparent 7px),
    radial-gradient(circle at 18% 78%, var(--green) 0 6px, transparent 7px),
    radial-gradient(circle at 82% 78%, var(--green) 0 6px, transparent 7px),
    linear-gradient(90deg, transparent 49%, rgba(32,178,107,.22) 49% 51%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(32,178,107,.22) 49% 51%, transparent 51%),
    repeating-conic-gradient(from 0deg, #f8fafc 0% 25%, #edf2f7 0% 50%) 0 / 52px 52px;
}
.info:nth-child(1)::after,
.info:nth-child(2)::after,
.tip-card::after {
  content: "";
  display: block;
  margin-top: 14px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(32,178,107,.12), rgba(32,178,107,.03));
  border: 1px solid rgba(32,178,107,.14);
}
.info:nth-child(1)::after {
  background:
    linear-gradient(135deg, rgba(32,178,107,.12), rgba(32,178,107,.03)),
    repeating-linear-gradient(90deg, transparent 0 16px, rgba(18,134,83,.10) 16px 17px);
}
.info:nth-child(2)::after {
  background:
    radial-gradient(circle at 18% 50%, var(--green) 0 5px, transparent 6px),
    radial-gradient(circle at 50% 50%, var(--green) 0 5px, transparent 6px),
    radial-gradient(circle at 82% 50%, var(--green) 0 5px, transparent 6px),
    linear-gradient(135deg, rgba(32,178,107,.12), rgba(32,178,107,.03));
}
.tip-card::after {
  background:
    linear-gradient(90deg, rgba(32,178,107,.45) 0 22%, transparent 22% 28%, rgba(32,178,107,.25) 28% 50%, transparent 50% 56%, rgba(32,178,107,.16) 56% 100%);
}
.footer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  display: grid;
  place-items: center;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(14px);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  z-index: 20;
}
.toast {
  bottom: 42px;
}

@media (max-width: 1120px) {
  .app { padding-bottom: 42px; }
  .board-card {
    height: auto;
    max-height: none;
    max-width: min(100%, calc(100vh - 150px));
  }
  .left-panel,
  .right-panel { height: auto; }
}

/* v6 targeted refinements */
.brand-mark,
.knight,
.mini-route span.mini-knight {
  background: linear-gradient(145deg, #23c477, #0f8b57);
  color: #fff;
}
.brand-mark .horse-svg,
.knight .horse-svg,
.mini-route .horse-svg,
.tip-horse .horse-svg {
  width: 78%;
  height: 78%;
  fill: currentColor;
}
.knight {
  width: 52%;
  height: 52%;
  border-color: rgba(255,255,255,.35);
}
.stats h2,
.next-card h2 {
  padding-left: 0;
}
.stat-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.row-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green-dark);
  background: var(--green-soft);
  border: 1px solid rgba(32,178,107,.24);
  font-size: 13px;
  font-weight: 850;
}
.section-icon.book-icon {
  position: relative;
  font-size: 0;
}
.section-icon.book-icon::before,
.section-icon.book-icon::after {
  content: "";
  width: 9px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 2px 1px 1px 2px;
  background: rgba(255,255,255,.58);
}
.section-icon.book-icon::before { transform: skewY(-5deg); border-right-width: 1px; }
.section-icon.book-icon::after { transform: skewY(5deg); border-left-width: 1px; }
.section-icon.info-icon {
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 800;
}
.info:nth-child(2)::after,
.tip-card::after {
  display: none;
  content: none;
}
.tip-card h2 {
  gap: 10px;
  margin-bottom: 14px;
}
.tip-spark {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  color: #7c3aed;
  font-size: 30px;
  line-height: 1;
}
.tip-card p {
  color: #34405a;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 720;
  margin-bottom: 18px;
}
.tip-board {
  width: 168px;
  height: 168px;
  margin: 0 auto;
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}
.tip-board span {
  background: #f8fafc;
  display: grid;
  place-items: center;
}
.tip-board span:nth-child(even) { background: #e9edf3; }
.tip-board .tip-horse {
  color: #273245;
  background: transparent;
  filter: drop-shadow(0 4px 5px rgba(17, 24, 39, .18));
}
.tip-board i {
  position: absolute;
  width: 38px;
  height: 38px;
  border: 3px solid var(--green);
  border-radius: 7px;
  background: rgba(255,255,255,.16);
}
.tip-board .corner-a { top: 0; left: 0; }
.tip-board .corner-b { top: 0; right: 0; }
.tip-board .corner-c { bottom: 0; left: 0; }
.tip-board .corner-d { bottom: 0; right: 0; }
.footer-bar {
  height: 38px;
  font-size: 13px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 -10px 24px rgba(17, 24, 39, .05);
}
.footer-bar a {
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 800;
}
.footer-bar a:hover { text-decoration: underline; }
.toast { bottom: 54px; }
.app { padding-bottom: 48px; }
.board-card { max-height: calc(100vh - 164px); max-width: calc(100vh - 164px); }
@media (max-width: 1120px) {
  .app { padding-bottom: 54px; }
}

/* v7 icon pass: SVG-based graphics matched to the approved mockup */
.brand-mark {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  background: linear-gradient(145deg, #12b66d, #0a8b53);
  box-shadow: 0 14px 30px rgba(18, 134, 83, .22);
}
.brand-mark .horse-svg {
  width: 64%;
  height: 64%;
  color: #fff;
  fill: currentColor;
  transform: translateY(1px);
  filter: none;
}
.knight,
.mini-route span.mini-knight {
  border-radius: 8px;
  background: linear-gradient(145deg, #18ba70, #0a8b53);
  color: #fff;
  border: 1px solid rgba(255,255,255,.42);
  box-shadow: 0 10px 20px rgba(18, 134, 83, .20);
}
.knight {
  width: 58%;
  height: 58%;
}
.knight .horse-svg,
.mini-route .horse-svg,
.tip-horse .horse-svg {
  width: 64%;
  height: 64%;
  fill: currentColor;
}
.mini-route span.mini-knight {
  width: 48px;
  height: 48px;
}
.row-icon svg,
.section-icon svg,
.external-icon svg {
  width: 1em;
  height: 1em;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.row-icon {
  font-size: 18px;
}
.section-icon {
  background: transparent;
  border: 0;
  color: #425171;
  font-size: 30px;
  margin-right: 12px;
  border-radius: 0;
}
.section-icon::before,
.section-icon::after {
  display: none !important;
  content: none !important;
}
.section-icon.tip-icon {
  color: #425171;
  font-size: 30px;
}
.info h2,
.tip-card h2 {
  color: var(--text);
  gap: 0;
}
.tip-card {
  background:
    radial-gradient(circle at 0% 0%, rgba(32,178,107,.08), transparent 34%),
    rgba(255,255,255,.92);
}
.tip-card p {
  color: #233049;
  font-size: 16px;
  font-weight: 520;
  line-height: 1.55;
}
.tip-board .tip-horse {
  color: #0a8b53;
  filter: drop-shadow(0 5px 7px rgba(17, 24, 39, .18));
}
.footer-bar {
  height: 44px;
  justify-content: start;
  place-items: center start;
  padding-left: max(22px, calc((100vw - min(1360px, calc(100vw - 28px))) / 2 + 4px));
  gap: 9px;
  font-size: 14px;
}
.footer-bar a {
  display: inline-flex;
  align-items: center;
  color: var(--green-dark);
}
.external-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 5px;
  color: #425171;
  vertical-align: -3px;
}
.toast { bottom: 60px; }
.app { padding-bottom: 56px; }
.board-card { max-height: calc(100vh - 172px); max-width: calc(100vh - 172px); }

@media (max-width: 720px) {
  .brand-mark { width: 52px; height: 52px; }
  .footer-bar { padding-left: 12px; font-size: 12px; }
}

/* v8: uploaded knight silhouette applied as real image asset */
.brand-mark,
.knight,
.mini-route span.mini-knight,
.tip-board .tip-horse {
  overflow: hidden;
}
.horse-img {
  display: block;
  width: 72%;
  height: 72%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
}
.brand-mark .horse-img {
  width: 67%;
  height: 67%;
  transform: translateY(1px);
}
.knight .horse-img {
  width: 68%;
  height: 68%;
  transform: translateY(1px);
}
.mini-route .horse-img,
.tip-horse .horse-img {
  width: 68%;
  height: 68%;
}

/* v9: SVG knight asset, centered inside every green mark */
.brand-mark,
.knight,
.mini-route span.mini-knight,
.tip-board .tip-horse {
  display: grid;
  place-items: center;
}

.horse-img {
  width: 68%;
  height: 68%;
  object-fit: contain;
  object-position: 50% 50%;
  transform: none !important;
  margin: auto;
}

.brand-mark .horse-img {
  width: 62%;
  height: 62%;
}

.knight .horse-img {
  width: 64%;
  height: 64%;
}

.mini-route .horse-img,
.tip-horse .horse-img {
  width: 62%;
  height: 62%;
}

/* v10 targeted refinements */
.footer-bar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  place-items: unset;
  padding-left: 0;
  padding-right: 0;
  gap: 6px;
  text-align: center;
  font-size: 14px;
}
.footer-bar a {
  display: inline;
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 800;
}
.footer-bar a:hover { text-decoration: underline; }
.footer-bar .external-icon {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin-left: 2px;
  color: #425171;
  flex: 0 0 auto;
}
.footer-bar .external-icon svg {
  width: 17px;
  height: 17px;
}

/* remove the stray decorative strip under the Interface card */
.right-panel .info:nth-of-type(2)::after {
  display: none !important;
  content: none !important;
}

.tip-card p {
  font-size: 14px;
  line-height: 1.45;
  font-weight: 400;
  color: var(--muted);
  margin: 0;
}
.tip-board { display: none !important; }

.row-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
}
.row-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  margin: 0;
}
.stat-row > span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app { padding-bottom: 64px; }
.board-card { max-height: calc(100vh - 180px); max-width: calc(100vh - 180px); }
.toast { bottom: 68px; }

@media (max-width: 720px) {
  .footer-bar {
    height: 50px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 12px;
  }
}

/* v11 targeted refinements */
.footer-bar {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  padding: 0 !important;
  line-height: 1 !important;
}
.footer-bar > span:first-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.footer-bar a {
  display: inline-flex !important;
  align-items: center;
  line-height: 1;
}
.footer-bar .external-icon {
  align-self: center;
}

/* Remove decorative segmented strip below Rules and compact the card */
.right-panel .info:nth-of-type(1)::after {
  display: none !important;
  content: none !important;
}
.right-panel .info:nth-of-type(1) ul,
.right-panel .info:nth-of-type(2) ul {
  margin-top: 0;
}
.right-panel .info:nth-of-type(1) li:first-child,
.right-panel .info:nth-of-type(2) li:first-child {
  margin-top: 0;
}

/* Center/raise the SVG knight inside green marks */
.knight {
  display: grid !important;
  place-items: center !important;
}
.knight .horse-img {
  width: 62% !important;
  height: 62% !important;
  object-fit: contain !important;
  object-position: center center !important;
  transform: translateY(-3%) !important;
  margin: auto !important;
}
.brand-mark .horse-img {
  width: 62% !important;
  height: 62% !important;
  object-fit: contain !important;
  object-position: center center !important;
  transform: translateY(-8%) !important;
  margin: auto !important;
}
.mini-route span.mini-knight {
  display: grid !important;
  place-items: center !important;
}
.mini-route .horse-img {
  width: 62% !important;
  height: 62% !important;
  object-fit: contain !important;
  object-position: center center !important;
  transform: translateY(-8%) !important;
  margin: auto !important;
}


/* v13: align statistic values and show dead-end/loss state */
.stat-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
}
.stat-row > span,
.stat-row > strong {
  display: inline-flex !important;
  align-items: center !important;
  min-height: 30px;
  line-height: 1 !important;
}
.stat-row > strong {
  justify-content: flex-end;
  text-align: right;
  white-space: nowrap;
}
.stat-row .row-icon {
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 30px;
}

.cell.current.lost {
  box-shadow: inset 0 0 0 2px #f97316, inset 0 0 0 999px rgba(249, 115, 22, .13) !important;
}
.cell.current.lost .knight {
  background: linear-gradient(145deg, #fb923c, #ea580c) !important;
  border-color: rgba(255, 255, 255, .45) !important;
  box-shadow: 0 10px 22px rgba(234, 88, 12, .28) !important;
}

/* v15: responsive layout refinements */
:root {
  --page-max: 1360px;
  --footer-h: 52px;
}

html, body {
  min-width: 320px;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

.app {
  width: min(var(--page-max), calc(100vw - 28px));
  max-width: var(--page-max);
  min-height: 100vh;
  height: auto;
  margin-inline: auto;
  padding-bottom: calc(var(--footer-h) + 12px);
}

.layout {
  width: 100%;
  max-width: var(--page-max);
  height: auto;
  min-height: 0;
  grid-template-columns: 280px minmax(0, 620px) 320px;
  justify-content: center;
  align-items: stretch;
}

.board-card {
  width: min(100%, calc(100vh - 180px), 620px);
  max-width: 620px;
  max-height: 620px;
  height: auto;
  aspect-ratio: 1 / 1;
  align-self: center;
  justify-self: center;
}

.left-panel,
.right-panel {
  height: auto;
  align-self: stretch;
}

.left-panel > .card,
.right-panel > .card {
  min-width: 0;
}

@media (min-width: 1380px) {
  .app,
  .layout {
    max-width: var(--page-max);
  }
}

/* First step: move the side information below before three columns become cramped. */
@media (max-width: 1280px) {
  .app {
    width: min(1040px, calc(100vw - 28px));
  }

  .layout {
    grid-template-columns: 280px minmax(0, 620px);
    justify-content: center;
    align-items: stretch;
  }

  .board-card {
    width: min(100%, calc(100vh - 180px), 620px);
  }

  .right-panel {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }

  .right-panel .card {
    height: 100%;
  }
}

/* Second step: switch to one column before Safari compresses the board frame. */
@media (max-width: 950px) {
  .app {
    width: min(720px, calc(100vw - 20px));
    gap: 12px;
    padding-top: 10px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .left-panel {
    width: 100%;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(180px, .75fr) minmax(280px, 1.25fr);
    grid-template-areas:
      "action stats"
      "next next";
    gap: 12px;
    align-items: stretch;
  }

  .action-card { grid-area: action; }
  .stats { grid-area: stats; }
  .next-card { grid-area: next; }

  .action-card,
  .stats {
    height: 100%;
  }

  .action-card {
    display: grid;
    align-items: stretch;
  }

  .board-card {
    grid-row: 2;
    width: min(calc(100vw - 20px), calc(100vh - 300px), 620px);
    min-width: 0;
    justify-self: center;
  }

  .right-panel {
    width: 100%;
    grid-row: 3;
    grid-column: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: auto;
    padding: 12px 0 8px;
  }

  .brand {
    align-items: center;
  }

  h1 {
    font-size: clamp(26px, 8vw, 34px);
  }

  .left-panel {
    grid-template-columns: 1fr;
    grid-template-areas:
      "action"
      "stats"
      "next";
  }

  .stats {
    gap: 10px;
  }

  .board-card {
    width: min(calc(100vw - 20px), calc(100vh - 260px), 560px);
    padding: 8px;
  }

  .right-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app {
    width: calc(100vw - 14px);
    padding-bottom: calc(var(--footer-h) + 10px);
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .card {
    padding: 14px;
  }

  .board-card {
    width: min(calc(100vw - 14px), 480px);
    padding: 6px;
  }

  .board-wrap {
    grid-template-columns: 18px minmax(0, 1fr) 18px;
    grid-template-rows: 18px minmax(0, 1fr) 18px;
  }

  .corner {
    width: 18px;
    height: 18px;
  }

  .rank-labels,
  .file-labels {
    font-size: 11px;
  }

  .footer-bar {
    height: 48px;
    font-size: 11px;
    padding: 0 8px !important;
  }
}

@media (max-height: 760px) and (min-width: 951px) {
  .topbar {
    min-height: 78px;
    padding-top: 12px;
    padding-bottom: 10px;
  }

  .brand-mark {
    width: 58px;
    height: 58px;
  }

  h1 {
    font-size: clamp(28px, 2.8vw, 36px);
  }

  .brand p {
    font-size: 14px;
  }

  .board-card {
    width: min(100%, calc(100vh - 150px), 600px);
  }
}

/* v16: compact mobile layout refinements */
@media (max-width: 660px) {
  .app {
    width: calc(100vw - 14px);
    gap: 10px;
  }

  .topbar {
    padding-top: 10px;
    padding-bottom: 8px;
  }

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

  .brand p {
    display: block;
    max-width: none;
    font-size: 12.5px;
    line-height: 1.28;
  }

  h1 {
    margin-bottom: 3px;
  }

  .layout {
    display: grid;
    grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr);
    gap: 10px;
    justify-items: stretch;
    align-items: stretch;
  }

  .left-panel {
    display: contents;
  }

  .action-card {
    grid-column: 1;
    grid-row: 1;
    padding: 10px;
    min-width: 0;
  }

  .btn {
    min-height: 42px;
    border-radius: 12px;
    font-size: 14px;
  }

  .stats {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding: 10px;
    gap: 6px;
    align-content: center;
  }

  .stats h2 {
    display: none;
  }

  .stats .stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 25px;
  }

  .stats .stat-row > span {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .stats strong {
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
  }

  .row-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
  }

  .row-icon svg {
    width: 14px;
    height: 14px;
  }

  .board-card {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    width: min(calc(100vw - 14px), 560px);
  }

  .right-panel {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .next-card {
    grid-column: 1 / -1;
    grid-row: 4;
    width: 100%;
  }
}

@media (max-width: 400px) {
  .app {
    width: calc(100vw - 10px);
    gap: 8px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 13px;
  }

  h1 {
    font-size: 25px;
  }

  .brand p {
    display: block;
    font-size: 11.5px;
    line-height: 1.22;
  }

  .layout {
    grid-template-columns: minmax(118px, .78fr) minmax(0, 1.22fr);
    gap: 8px;
  }

  .action-card,
  .stats {
    padding: 8px;
  }

  .btn {
    min-height: 38px;
    font-size: 12.5px;
    border-radius: 11px;
  }

  .stats {
    gap: 4px;
  }

  .stats .stat-row {
    min-height: 22px;
    gap: 6px;
  }

  .stats .stat-row > span {
    font-size: 0;
    gap: 5px;
  }

  .stats .stat-row:first-of-type > span::after {
    content: var(--moves-short-label, "Ходы");
    font-size: 11px;
  }

  .stats .stat-row:last-of-type > span::after {
    content: var(--time-short-label, "Время");
    font-size: 11px;
  }

  .stats strong {
    font-size: 11.5px;
  }

  .row-icon {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
  }

  .row-icon svg {
    width: 12px;
    height: 12px;
  }

  .board-card {
    width: min(calc(100vw - 10px), 390px);
  }
}


/* v17: dark graphite accent palette replacing the previous green theme */
:root {
  --green: #2f343a;
  --green-dark: #1f2328;
  --green-soft: rgba(47, 52, 58, .13);
  --visited-a: #e4e7eb;
  --visited-b: #d4d8de;
  --visited-text: #242a31;
}

body {
  background:
    radial-gradient(circle at 12% 0%, rgba(47, 52, 58, .10), transparent 28%),
    radial-gradient(circle at 92% 0%, rgba(31, 35, 40, .06), transparent 24%),
    var(--bg);
}

.brand-mark,
.knight,
.mini-route span.mini-knight {
  background: linear-gradient(145deg, #3b4148, #1f2328) !important;
  color: #fff !important;
  box-shadow: 0 14px 30px rgba(31, 35, 40, .22) !important;
}

.knight {
  border-color: rgba(255,255,255,.42) !important;
  box-shadow: 0 10px 20px rgba(31, 35, 40, .22) !important;
}

.btn.primary,
.modal-icon {
  background: linear-gradient(135deg, #3b4148, #1f2328) !important;
  color: #fff !important;
  box-shadow: 0 14px 28px rgba(31, 35, 40, .18) !important;
}

.cell.visited {
  background: linear-gradient(145deg, var(--visited-a), var(--visited-b)) !important;
  color: var(--visited-text) !important;
  box-shadow: inset 0 0 0 1px rgba(31, 35, 40, .18) !important;
}

.cell.current {
  box-shadow: inset 0 0 0 2px var(--green), inset 0 0 0 999px var(--green-soft) !important;
}

.cell.available::after {
  background: var(--green) !important;
  box-shadow: 0 0 0 6px var(--green-soft) !important;
}

.cell.available:hover {
  box-shadow: inset 0 0 0 2px var(--green), 0 10px 22px rgba(31, 35, 40, .16) !important;
}

.cell.available:hover::before {
  color: var(--green-dark) !important;
  border-color: rgba(47, 52, 58, .42) !important;
}

.row-icon,
.section-icon,
.mini-route b {
  color: var(--green-dark) !important;
  background: var(--green-soft) !important;
  border-color: rgba(47, 52, 58, .22) !important;
}

.section-icon {
  background: transparent !important;
  border-color: transparent !important;
  color: #425171 !important;
}

.mini-route i {
  background: var(--green) !important;
}

.mini-route i::after {
  border-top-color: var(--green) !important;
  border-right-color: var(--green) !important;
}

.footer-bar a {
  color: var(--green-dark) !important;
}

.tip-card {
  background:
    radial-gradient(circle at 0% 0%, rgba(47, 52, 58, .08), transparent 34%),
    rgba(255,255,255,.92) !important;
}

.tip-board i {
  border-color: var(--green) !important;
}

.tip-board .tip-horse {
  color: var(--green-dark) !important;
}

.next-card::after,
.info:nth-child(1)::after,
.info:nth-child(2)::after,
.tip-card::after {
  border-color: rgba(47, 52, 58, .14) !important;
}

/* Keep the dead-end/loss state distinct from the graphite accent. */
.cell.current.lost {
  box-shadow: inset 0 0 0 2px #dc2626, inset 0 0 0 999px rgba(220, 38, 38, .11) !important;
}
.cell.current.lost .knight {
  background: linear-gradient(145deg, #ef4444, #991b1b) !important;
  border-color: rgba(255,255,255,.45) !important;
  box-shadow: 0 10px 22px rgba(153, 27, 27, .26) !important;
}

/* v18: header alignment, language switch, footer accent, and compact mobile controls */
.topbar {
  width: 100%;
  justify-content: space-between;
  align-items: center;
}

.brand {
  margin-left: 0;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(31, 35, 40, .12);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 10px 24px rgba(19, 32, 55, .06);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: .04em;
  color: #8a94a3;
}

.language-switch a {
  color: #8a94a3;
  text-decoration: none;
  transition: color .18s ease;
}

.language-switch a:hover,
.language-switch a.is-active {
  color: var(--green-dark);
}

.footer-bar a {
  color: #b24a43 !important;
}

.footer-bar a:hover {
  color: #943b35 !important;
}

@media (max-width: 660px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
  }

  .language-switch {
    align-self: start;
    padding: 7px 9px;
    gap: 6px;
    font-size: 12px;
  }

  .layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .action-card {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .action-card .btn {
    width: 100%;
    min-height: 40px;
    border-radius: 13px;
  }

  .stats {
    grid-column: 1;
    grid-row: 2;
  }

  .next-card {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    padding: 10px;
    gap: 6px;
    align-content: center;
  }

  .next-card::after {
    display: none !important;
  }

  .next-card h2 {
    display: none;
  }

  .next-card p {
    display: none;
  }

  .mini-route {
    margin-top: 0;
    height: 100%;
    min-height: 54px;
    justify-content: center;
    gap: 8px;
  }

  .mini-route span.mini-knight {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .mini-route i {
    width: min(42px, 12vw);
  }

  .mini-route b {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .board-card {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .right-panel {
    grid-column: 1 / -1;
    grid-row: 4;
  }
}

@media (max-width: 400px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .language-switch {
    padding: 6px 8px;
    gap: 5px;
    font-size: 11px;
  }

  .action-card .btn {
    min-height: 36px;
    font-size: 12.5px;
  }

  .stats,
  .next-card {
    padding: 8px;
    min-height: 58px;
  }

  .mini-route {
    min-height: 42px;
    gap: 5px;
  }

  .mini-route span.mini-knight,
  .mini-route b {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .mini-route i {
    width: 26px;
  }
}

/* v19: footer width, language switch, dark-green action accents, and mobile compact header/cards */
:root {
  --action-green: #4f6f5a;
  --action-green-dark: #3c5645;
  --action-green-soft: rgba(79, 111, 90, .15);
  --action-green-line: rgba(79, 111, 90, .38);
  --footer-link-red: #b65750;
  --footer-link-red-hover: #984640;
}

.topbar {
  max-width: var(--page-max);
  margin-inline: auto;
  align-items: flex-start;
}

.brand {
  align-items: flex-start;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  height: 38px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid rgba(31, 35, 40, .12);
  border-radius: 14px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 10px 24px rgba(19, 32, 55, .06);
  flex: 0 0 auto;
}
.language-switch button {
  height: 30px;
  min-width: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #7b8492;
  font-size: 12px;
  font-weight: 800;
  line-height: 30px;
  letter-spacing: .04em;
  cursor: pointer;
}
.language-switch button.is-active {
  background: #2f343a;
  color: #fff;
  box-shadow: 0 8px 16px rgba(31, 35, 40, .14);
}
.language-switch span {
  width: 1px;
  height: 16px;
  background: rgba(31, 35, 40, .12);
}
.language-switch button.is-active + span { display: none; }
.language-switch button:focus-visible {
  outline: 2px solid var(--action-green-line);
  outline-offset: 2px;
}

.footer-bar {
  left: 50% !important;
  right: auto !important;
  bottom: 0;
  width: min(var(--page-max), calc(100vw - 28px)) !important;
  max-width: var(--page-max);
  transform: translateX(-50%);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
}
.footer-bar a {
  color: var(--footer-link-red) !important;
}
.footer-bar a:hover {
  color: var(--footer-link-red-hover) !important;
}

.btn.primary,
.modal-icon {
  background: linear-gradient(135deg, #587862, var(--action-green-dark)) !important;
  color: #fff !important;
  box-shadow: 0 14px 28px rgba(60, 86, 69, .19) !important;
}
.btn.primary:hover {
  box-shadow: 0 16px 30px rgba(60, 86, 69, .24) !important;
}
.cell.current {
  box-shadow: inset 0 0 0 2px var(--action-green), inset 0 0 0 999px var(--action-green-soft) !important;
}
.cell.available::after {
  background: var(--action-green) !important;
  box-shadow: 0 0 0 6px var(--action-green-soft) !important;
}
.cell.available:hover {
  box-shadow: inset 0 0 0 2px var(--action-green), 0 10px 22px rgba(60, 86, 69, .16) !important;
}
.cell.available:hover::before {
  color: var(--action-green-dark) !important;
  border-color: var(--action-green-line) !important;
}

@media (max-width: 660px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start !important;
  }
  .brand {
    align-items: flex-start !important;
  }
  .brand > div:last-child {
    padding-top: 0;
  }
  .language-switch {
    align-self: start !important;
    height: 34px;
    padding: 2px;
    border-radius: 12px;
  }
  .language-switch button {
    height: 28px;
    min-width: 34px;
    padding: 0 8px;
    border-radius: 9px;
    font-size: 11px;
    line-height: 28px;
  }

  .next-card p {
    display: block !important;
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.25;
  }
  .next-card .mini-route {
    min-height: 34px;
    height: auto;
    margin-bottom: 2px;
  }
  .next-card .mini-route::before,
  .next-card::after {
    display: none !important;
    content: none !important;
  }
}

@media (max-width: 400px) {
  .topbar {
    align-items: start !important;
  }
  .language-switch {
    height: 32px;
  }
  .language-switch button {
    height: 26px;
    min-width: 31px;
    padding: 0 6px;
    font-size: 10.5px;
    line-height: 26px;
  }
  .next-card p {
    font-size: 10.5px;
    line-height: 1.2;
  }
}


/* v20: SEO metadata support, unified action accent, desktop header width, hover states, mobile footer strip */
:root {
  --action-gradient: linear-gradient(135deg, #587862, var(--action-green-dark));
  --action-gradient-hover: linear-gradient(135deg, #63876e, #334c3c);
  --action-shadow: 0 14px 28px rgba(60, 86, 69, .19);
  --action-shadow-hover: 0 16px 32px rgba(60, 86, 69, .24);
}

@media (min-width: 1281px) {
  .topbar {
    width: min(100%, 1256px);
    max-width: 1256px;
  }
}

.btn.primary,
.modal-icon,
.brand-mark,
.knight,
.mini-route span.mini-knight,
.language-switch button.is-active {
  background: var(--action-gradient) !important;
  color: #fff !important;
  box-shadow: var(--action-shadow) !important;
}

.btn.primary {
  transition: background .18s ease, box-shadow .18s ease, border-color .18s ease, color .18s ease;
}

.btn.primary:hover {
  transform: none !important;
  background: var(--action-gradient-hover) !important;
  box-shadow: var(--action-shadow-hover) !important;
}

.cell.visited {
  background: var(--action-gradient) !important;
  color: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24) !important;
}

.cell.current {
  box-shadow: inset 0 0 0 2px var(--action-green), inset 0 0 0 999px var(--action-green-soft) !important;
}

.footer-bar a,
.footer-bar a:hover {
  color: var(--action-green-dark) !important;
}

.brand-mark,
.mini-route span.mini-knight {
  border-color: transparent !important;
}

.section-icon {
  color: var(--action-green-dark) !important;
  background: transparent !important;
  border-color: transparent !important;
}

.row-icon {
  color: var(--action-green-dark) !important;
  background: var(--action-green-soft) !important;
  border-color: var(--action-green-line) !important;
}

.language-switch button {
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.language-switch button:hover:not(.is-active) {
  color: var(--action-green-dark) !important;
  background: var(--action-green-soft) !important;
}

.language-switch button.is-active:hover {
  background: var(--action-gradient-hover) !important;
}

@media (max-width: 660px) {
  .footer-bar {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    transform: none !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-radius: 0 !important;
    background: rgba(255,255,255,.98) !important;
    box-shadow: 0 -12px 28px rgba(17, 24, 39, .08) !important;
  }
}


/* v21: header games link and footer attribution update */
.header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.games-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(31, 35, 40, .12);
  border-radius: 14px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 10px 24px rgba(19, 32, 55, .06);
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.games-link:hover {
  color: var(--action-green-dark);
  background: var(--action-green-soft);
  border-color: var(--action-green-line);
}

@media (max-width: 660px) {
  .header-actions {
    align-self: start;
    gap: 8px;
  }

  .games-link {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 12px;
  }
}

@media (max-width: 400px) {
  .header-actions {
    gap: 6px;
  }

  .games-link {
    min-height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }
}

/* v22: archive folder version, clearer games link, and mobile second-line placement */
.games-link {
  border-color: var(--action-green-line);
  background: rgba(79, 111, 90, .09);
  color: var(--action-green-dark);
  font-weight: 820;
  box-shadow: 0 10px 24px rgba(60, 86, 69, .08);
}

.games-link:hover {
  background: var(--action-green-soft);
  box-shadow: 0 12px 26px rgba(60, 86, 69, .12);
}

@media (max-width: 660px) {
  .header-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .header-actions .language-switch {
    order: 1;
  }

  .header-actions .games-link {
    order: 2;
  }

  .games-link {
    min-height: 30px;
    padding: 0 9px;
    font-size: 11.5px;
  }
}

@media (max-width: 400px) {
  .header-actions {
    gap: 5px;
  }

  .games-link {
    min-height: 28px;
    padding: 0 8px;
    font-size: 10.5px;
  }
}

/* v23: mobile toast width and centered multiline text */
@media (max-width: 660px) {
  .toast {
    box-sizing: border-box;
    width: max-content;
    max-width: calc(100vw - 20px);
    text-align: center;
    white-space: normal;
    line-height: 1.35;
  }
}

/* v24: smaller mobile text in statistics and next move cards */
@media (max-width: 660px) {
  .stats .stat-row > span {
    font-size: 11px;
    line-height: 1.05;
  }

  .stats strong {
    font-size: 12px;
  }

  .next-card p {
    font-size: 10.5px !important;
    line-height: 1.18 !important;
  }
}

@media (max-width: 400px) {
  .stats .stat-row > span {
    font-size: 10.5px;
  }

  .stats strong {
    font-size: 11.5px;
  }

  .next-card p {
    font-size: 10px !important;
    line-height: 1.16 !important;
  }
}


/* v25: mobile statistic values move to second line */
@media (max-width: 660px) {
  .stats .stat-row {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    min-height: 36px;
  }

  .stats .stat-row > strong {
    padding-left: 30px;
  }
}

@media (max-width: 400px) {
  .stats .stat-row {
    min-height: 34px;
  }

  .stats .stat-row > strong {
    padding-left: 25px;
  }
}

/* v26: compact and aligned mobile statistics without duplicated labels */
@media (max-width: 660px) {
  .stats {
    gap: 6px;
  }

  .stats .stat-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-content: start;
    column-gap: 6px;
    row-gap: 1px;
    min-height: 0;
    line-height: 1.05;
  }

  .stats .stat-row > span {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.05;
  }

  .stats .stat-row > strong {
    grid-column: 2;
    padding-left: 0;
    line-height: 1.05;
  }
}

@media (max-width: 400px) {
  .stats {
    gap: 5px;
  }

  .stats .stat-row {
    column-gap: 5px;
    row-gap: 0;
  }

  .stats .stat-row > span {
    font-size: 0;
    line-height: 1;
  }

  .stats .stat-row:first-of-type > span::after,
  .stats .stat-row:last-of-type > span::after {
    font-size: 10.5px;
    line-height: 1;
  }

  .stats .stat-row > strong {
    padding-left: 0;
  }
}

/* v27: short mobile statistic labels and single-line values */
@media (max-width: 660px) {
  .stats .stat-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 24px;
    line-height: 1.05;
  }

  .stats .stat-row > span {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 0;
    line-height: 1.05;
    white-space: nowrap;
  }

  .stats .stat-row:first-of-type > span::after {
    content: var(--moves-short-label, "Ходы");
    font-size: 11px;
    line-height: 1.05;
  }

  .stats .stat-row:last-of-type > span::after {
    content: var(--time-short-label, "Время");
    font-size: 11px;
    line-height: 1.05;
  }

  .stats .stat-row > strong {
    padding-left: 0;
    font-size: 12px;
    line-height: 1.05;
    white-space: nowrap;
  }
}

@media (max-width: 400px) {
  .stats .stat-row {
    gap: 6px;
    min-height: 22px;
  }

  .stats .stat-row:first-of-type > span::after,
  .stats .stat-row:last-of-type > span::after {
    font-size: 10.5px;
  }

  .stats .stat-row > strong {
    font-size: 11.5px;
  }
}


/* v29: mobile statistic labels and graphic-only next move card */
@media (max-width: 660px) {
  .stats .stat-row:first-of-type > span::after {
    content: var(--moves-compact-label, "Ходов:");
  }

  .stats .stat-row:last-of-type > span::after {
    content: var(--time-compact-label, "Время:");
  }

  .next-card p {
    display: none !important;
  }
}

@media (max-width: 400px) {
  .stats .stat-row:first-of-type > span::after {
    content: var(--moves-compact-label, "Ходов:");
  }

  .stats .stat-row:last-of-type > span::after {
    content: var(--time-compact-label, "Время:");
  }

  .next-card p {
    display: none !important;
  }
}


/* v31: restore active cell style and knight icon from v20 */
.cell.current {
  box-shadow: inset 0 0 0 2px var(--action-green), inset 0 0 0 999px var(--action-green-soft) !important;
}

.cell.current .knight {
  position: absolute;
  width: 54%;
  height: 54%;
  inset: auto;
  display: grid !important;
  place-items: center !important;
  border-radius: 11px;
  background: var(--action-gradient) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.42) !important;
  box-shadow: var(--action-shadow) !important;
  animation: knightIn .18s ease both;
  pointer-events: none;
  overflow: hidden;
}

.cell.current .knight .horse-img {
  display: block !important;
  width: 62% !important;
  height: 62% !important;
  object-fit: contain !important;
  object-position: center center !important;
  transform: translateY(-3%) !important;
  margin: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
}


/* v32: footer spelling, unavailable EN language state, mobile header alignment, and next move title */
.language-switch button.is-disabled {
  cursor: default !important;
  color: #a5adb8 !important;
}

.language-switch button.is-disabled:hover {
  color: #a5adb8 !important;
  background: transparent !important;
  box-shadow: none !important;
}

@media (max-width: 660px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .header-actions {
    justify-self: end;
    align-items: flex-end;
  }

  .header-actions .language-switch {
    align-self: flex-end !important;
  }

  .next-card h2 {
    display: block !important;
    margin-bottom: 2px;
    font-size: 11px;
    line-height: 1.05;
    text-align: center;
  }

  .next-card {
    align-content: center;
  }
}

@media (max-width: 400px) {
  .next-card h2 {
    font-size: 10.5px;
  }
}

/* Phone landscape: preserve block order and size the board by available width. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app {
    width: min(720px, calc(100vw - 20px));
    height: auto;
    min-height: 100vh;
    padding: 10px 0 var(--landscape-bottom-space, 0px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 12px;
    align-content: start;
  }

  .topbar {
    grid-column: 1;
    grid-row: 1;
  }

  .layout {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    justify-items: center;
  }

  .left-panel {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    grid-template-areas:
      "action stats"
      "next next";
    gap: 12px;
  }

  .action-card {
    grid-area: action;
  }

  .stats {
    grid-area: stats;
  }

  .next-card {
    grid-area: next;
  }

  .board-card {
    grid-column: 1;
    grid-row: 2;
    width: min(100%, 620px);
    max-width: 620px;
    max-height: none;
    min-width: 0;
    align-self: start;
    justify-self: center;
  }

  .right-panel {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    display: grid;
  }
}

/* Desktop alignment and final-result details. */
@media (min-width: 1281px) {
  .board-card {
    align-self: start;
  }
}

.result-summary {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font-weight: 750;
}

.result-actions {
  margin-top: 16px;
}

.app { --landscape-bottom-space: calc(var(--footer-h) + 12px); }

/* About menu and responsive long-form modal. */
.site-menu {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.about-link,
.share-link {
  cursor: pointer;
}

.share-link {
  position: relative;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-color: rgba(60, 86, 69, .18);
  border-radius: 50%;
  background: transparent;
  color: var(--action-green-dark);
  box-shadow: none;
}

.share-symbol {
  position: relative;
  width: 18px;
  height: 13px;
  margin-top: 5px;
  display: block;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 3px 3px;
}

.share-symbol::before {
  content: "↑";
  position: absolute;
  left: 50%;
  bottom: 1px;
  transform: translateX(-50%);
  font-size: 20px;
  font-weight: 560;
  line-height: 1;
}

.share-link:hover {
  border-color: var(--action-green-line);
  background: var(--action-green-soft);
  box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
  .share-link::after {
    content: attr(data-tooltip);
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    left: 50%;
    padding: 7px 9px;
    border-radius: 8px;
    transform: translate(-50%, -3px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    color: #fff;
    background: #172033;
    box-shadow: 0 8px 20px rgba(23, 32, 51, .18);
    font-size: 12px;
    font-weight: 650;
    line-height: 1;
    white-space: nowrap;
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
  }

  .share-link:hover::after,
  .share-link:focus-visible::after {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
  }
}

.about-modal {
  width: min(760px, calc(100% - 32px));
  max-height: min(82vh, 760px);
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.about-modal .modal-close {
  z-index: 10;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  touch-action: manipulation;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.about-modal-scroll {
  max-height: min(82vh, 760px);
  padding: 32px 40px 36px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.about-modal h2 {
  margin: 0 36px 20px 0;
  font-size: 26px;
}

.about-modal h2:focus {
  outline: none;
}

.about-copy p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.about-copy p:last-child {
  margin-bottom: 0;
  color: var(--text);
}

.about-copy strong {
  color: var(--text);
}

.about-copy a {
  color: var(--action-green-dark);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.about-copy a:hover {
  color: var(--action-green);
}

.about-collection {
  margin: 4px 0 24px;
  padding: 15px 18px;
  border: 1px solid var(--action-green-line);
  border-left: 4px solid var(--action-green);
  border-radius: 14px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(79, 111, 90, .13), rgba(79, 111, 90, .04));
  font-size: 15px;
  line-height: 1.55;
}

.about-copy h3 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.25;
}

.about-conclusion {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid rgba(31, 35, 40, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .7);
  box-shadow: inset 4px 0 0 var(--action-green), 0 12px 30px rgba(31, 35, 40, .06);
}

.about-conclusion p {
  color: var(--text);
}

.about-conclusion p:last-child {
  margin-bottom: 0;
  font-weight: 750;
}

.footer-copy {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: .32em;
}

.footer-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.footer-line .external-icon {
  margin-left: 5px;
}

@media (max-width: 660px) {
  .header-actions .language-switch {
    order: 1;
  }

  .header-actions .site-menu {
    order: 2;
  }

  .site-menu {
    gap: 5px;
  }

  .site-menu .games-link {
    min-height: 28px;
    padding: 0 8px;
    font-size: 10.5px;
  }

  .site-menu .share-link {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border-radius: 50%;
  }

  .about-modal {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
  }

  .about-modal .modal-close {
    top: 8px;
    right: 8px;
  }

  .about-modal-scroll {
    max-height: calc(100dvh - 16px);
    padding: 24px 20px 28px;
  }

  .about-modal h2 {
    margin-bottom: 16px;
    font-size: 22px;
  }

  .about-copy p {
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.55;
  }

  .about-collection {
    margin-bottom: 20px;
    padding: 13px 14px;
    font-size: 14px;
  }

  .about-copy h3 {
    margin-bottom: 12px;
    font-size: 18px;
  }

  .about-conclusion {
    margin-top: 20px;
    padding: 15px 16px;
  }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  .about-modal {
    width: min(760px, calc(100% - 12px));
    max-height: calc(100dvh - 12px);
    border-radius: 16px;
  }

  .about-modal-scroll {
    max-height: calc(100dvh - 12px);
    padding: 18px 32px 22px;
  }

  .about-modal h2 {
    margin-bottom: 12px;
    font-size: 20px;
  }

  .about-copy p {
    margin-bottom: 12px;
    font-size: 13.5px;
    line-height: 1.45;
  }

  .about-collection {
    margin-bottom: 16px;
    padding: 11px 14px;
    font-size: 13.5px;
  }

  .about-copy h3 {
    margin-bottom: 10px;
    font-size: 17px;
  }

  .about-conclusion {
    margin-top: 16px;
    padding: 13px 15px;
  }
}

@media (max-width: 660px), (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  .footer-copy {
    flex-direction: column;
    gap: 3px;
    line-height: 1.15;
  }

  .footer-line {
    line-height: 1.15;
  }
}

/* web-header-drawer:start */
body.menu-open {
  overflow: hidden;
}

.header-actions {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
}

.header-actions > .share-link {
  flex: 0 0 auto;
  order: initial;
}

.menu-toggle,
.menu-close {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border: 1px solid rgba(60, 86, 69, .18);
  border-radius: 12px;
  color: var(--action-green-dark);
  background: rgba(255, 255, 255, .82);
  cursor: pointer;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.menu-toggle {
  display: grid;
  place-items: center;
  order: initial;
}

.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.menu-toggle span {
  position: relative;
}

.menu-toggle span::before,
.menu-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-toggle span::before { top: -6px; }
.menu-toggle span::after { top: 6px; }

.menu-toggle:hover,
.menu-close:hover {
  border-color: var(--action-green-line);
  background: var(--action-green-soft);
}

.menu-layer[hidden] {
  display: none !important;
}

.menu-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(360px, calc(100% - 20px));
  align-items: start;
}

.menu-backdrop {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(15, 23, 42, .34);
  backdrop-filter: blur(3px);
  cursor: default;
}

.menu-drawer {
  position: relative;
  z-index: 1;
  grid-column: 2;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text);
  background: var(--surface-solid);
  box-shadow: -18px 0 48px rgba(15, 23, 42, .16);
}

.menu-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
}

.menu-drawer-head strong {
  font-size: 20px;
}

.menu-close {
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
}

.menu-drawer .site-menu {
  width: 100%;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  order: initial;
}

.menu-drawer .games-link {
  width: 100%;
  min-height: 38px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  border: 1px solid var(--action-green-line);
  border-radius: 14px;
  color: var(--action-green-dark);
  background: rgba(79, 111, 90, .09);
  box-shadow: 0 10px 24px rgba(60, 86, 69, .08);
  font-size: 13px;
  font-weight: 820;
  text-align: left;
}

.menu-drawer .games-link:hover {
  color: var(--action-green-dark);
  border-color: var(--action-green-line);
  background: var(--action-green-soft);
  box-shadow: 0 12px 26px rgba(60, 86, 69, .12);
}

.menu-external-icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 16px;
}

.menu-external-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-drawer .language-switch {
  align-self: flex-start;
  flex: 0 0 auto;
  order: initial;
}

@media (max-width: 660px) {
  .header-actions {
    display: inline-flex !important;
    width: auto !important;
    grid-template-columns: none !important;
  }

  .header-actions > .share-link,
  .menu-toggle {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
  }

  .menu-drawer .site-menu {
    display: flex;
    gap: 8px;
  }

  .header-actions > .share-link { order: 1; }
  .header-actions > .menu-toggle { order: 2; }

}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  .menu-drawer {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    gap: 10px;
  }

  .menu-drawer-head strong { font-size: 18px; }
  .header-actions > .share-link { order: 1; }
  .header-actions > .menu-toggle { order: 2; }
}

/* Desktop keeps the original open header; the drawer exists only on mobile. */
@media (min-width: 661px) and (min-height: 601px), (min-width: 1001px) {
  .menu-toggle,
  .menu-backdrop,
  .menu-drawer-head {
    display: none !important;
  }

  .menu-layer,
  .menu-layer[hidden],
  .menu-drawer {
    display: contents !important;
  }

  .menu-drawer .site-menu {
    width: auto;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .menu-drawer .games-link {
    width: auto;
    min-height: 38px;
    padding: 0 14px;
    display: inline-flex;
    justify-content: center;
    border-radius: 14px;
    font-size: 13px;
    text-align: center;
  }

  .menu-drawer .language-switch {
    align-self: auto;
  }
}
/* web-header-drawer:end */
