/* Chess Corner — warm, beginner-friendly teaching UI */

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/nunito-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}


:root {
  --linen: #f5efe4;
  --linen-deep: #ebe3d4;
  --surface: #fffbf4;
  --surface-ink: #fffdf9;
  --ink: #3a3832;
  --ink-muted: #6a655a;
  --ink-faint: #8a8478;
  --sage: #8a9a78;
  --sage-deep: #6b7b5c;
  --sage-soft: #d5deca;
  --sage-mist: #e7efd9;
  --terracotta: #c4896a;
  --gold: #d4a054;
  --gold-soft: #f0d5a0;
  --gold-wash: rgba(228, 186, 90, 0.48);
  --teal: #2a9d8f;
  --sky: #5b9bd5;
  --coral: #d0756a;
  --lavender: #9b8ec4;
  --board-light: #efe3c4;
  --board-dark: #a8b592;
  --board-border: #c9bea6;
  --selected: #e09a6a;
  --move-dot: rgba(62, 72, 58, 0.38);
  --capture-ring: rgba(196, 110, 80, 0.88);
  --shadow: 0 10px 40px rgba(80, 60, 40, 0.08);
  --shadow-tight: 0 4px 16px rgba(80, 60, 40, 0.08);
  --radius: 18px;
  --radius-sm: 10px;
  --font: "Nunito", "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --tap: 40px;
  --text: 1rem;
  --headline: 1.45rem;
}

.tier-6yo {
  --tap: 44px;
  --text: 1.06rem;
  --headline: 1.52rem;
}

.tier-8yo {
  --tap: 46px;
  --text: 1.02rem;
  --headline: 1.48rem;
}

.tier-16yo {
  --tap: 42px;
  --text: 0.98rem;
  --headline: 1.32rem;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse at top, #fbf6ec 0%, #f3ebdc 55%, #ede4d4 100%);
  line-height: 1.5;
}

button,
input,
select {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:focus-visible,
.tier-btn:focus-visible,
.scaffold-btn:focus-visible,
.ctrl-btn:focus-visible {
  outline: 2.5px solid var(--teal);
  outline-offset: 2px;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px 16px;
}

/* ——— Top bar ——— */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7f1e4, #e6d7b8);
  box-shadow: var(--shadow-tight);
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 1px rgba(50, 40, 30, 0.25));
}

.brand-title {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3ebd2;
  color: #7a5c28;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 10px;
}

.topbar-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
  align-items: center;
}

.tier-switch {
  display: inline-flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-tight);
  gap: 2px;
}

.tier-btn {
  min-height: var(--tap);
  min-width: 86px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--ink-muted);
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  line-height: 1.1;
  gap: 1px;
}

.tier-btn .level-num {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
}

.tier-btn .level-name {
  font-size: 0.82rem;
  font-weight: 800;
}

.tier-btn.is-active {
  background: var(--sage);
  color: #fff;
  box-shadow: 0 2px 6px rgba(90, 110, 70, 0.28);
}

.scaffold-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface);
  border-radius: 16px;
  padding: 4px;
  box-shadow: var(--shadow-tight);
}

.scaffold-btn {
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.scaffold-btn.is-on {
  background: var(--sage-mist);
  color: var(--sage-deep);
}

.scaffold-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c8c0b0;
}

.scaffold-btn.is-on .dot {
  background: var(--sage-deep);
}

/* ——— Layout ——— */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 24px;
  align-items: start;
}

.board-col {
  min-width: 0;
}

.board-root {
  width: 100%;
  max-width: min(520px, 64vh);
}

.board-root,
.board-frame,
.board-stack {
  width: 100%;
  min-width: 0;
}

.board-frame {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 6px;
  align-items: stretch;
}

.board-frame[data-coords="off"] {
  display: block;
  grid-template-columns: 1fr;
  gap: 0;
}

.board-frame[data-coords="off"] .rank-labels,
.board-frame[data-coords="off"] .file-labels {
  display: none;
}

.rank-labels,
.file-labels {
  display: grid;
  color: var(--ink-faint);
  font-weight: 700;
  font-size: 0.78rem;
  user-select: none;
}

.rank-labels {
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
  padding-bottom: 22px;
}

.file-labels {
  grid-template-columns: repeat(8, 1fr);
  height: 22px;
  align-items: start;
  justify-items: center;
}

.board-stack {
  min-width: 0;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px #e4d8c0,
    0 12px 36px rgba(80, 60, 40, 0.12);
  touch-action: none;
  user-select: none;
  background: var(--board-border);
}

.squares {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.square {
  position: relative;
}

.square.light {
  background: var(--board-light);
}

.square.dark {
  background: var(--board-dark);
}

.square.last-move {
  background-image: linear-gradient(var(--gold-wash), var(--gold-wash));
}

.square.selected::after {
  content: "";
  position: absolute;
  inset: 6%;
  border: 2.5px solid var(--selected);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  pointer-events: none;
  z-index: 2;
}

.square.legal::before,
.square.ann-legal::before {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--move-dot);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}

.square.capture::before,
.square.ann-capture::before {
  content: "";
  position: absolute;
  inset: 8%;
  border: 3px solid var(--capture-ring);
  border-radius: 50%;
  background: transparent;
  pointer-events: none;
  z-index: 2;
}

.square.ann-target {
  background-image: linear-gradient(rgba(42, 157, 143, 0.38), rgba(42, 157, 143, 0.38));
}

.square.ann-origin {
  background-image: linear-gradient(rgba(212, 160, 84, 0.42), rgba(212, 160, 84, 0.42));
}

.square.ann-safe {
  background-image: linear-gradient(rgba(106, 160, 90, 0.4), rgba(106, 160, 90, 0.4));
}

.square.ann-danger,
.square.refutation.ann-danger {
  background-image: linear-gradient(rgba(208, 117, 106, 0.42), rgba(208, 117, 106, 0.42));
}

.square.ann-focus {
  background-image: linear-gradient(rgba(155, 142, 196, 0.36), rgba(155, 142, 196, 0.36));
}

.square.ann-check {
  background-image: linear-gradient(rgba(212, 120, 96, 0.4), rgba(212, 120, 96, 0.4));
  box-shadow: inset 0 0 0 3px rgba(200, 100, 80, 0.35);
}

.square.check {
  animation: check-pulse 1.4s ease-in-out infinite;
}

@keyframes check-pulse {
  0%,
  100% {
    background-image: linear-gradient(rgba(212, 120, 96, 0.28), rgba(212, 120, 96, 0.28));
    box-shadow: inset 0 0 0 3px rgba(200, 100, 80, 0.35);
  }
  50% {
    background-image: linear-gradient(rgba(212, 120, 96, 0.48), rgba(212, 120, 96, 0.48));
    box-shadow: inset 0 0 0 4px rgba(200, 100, 80, 0.6);
  }
}

.sq-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(40, 30, 20, 0.3));
}

.sq-badge-icon {
  width: 100%;
  height: 100%;
  display: block;
}

.badge-shield {
  color: #3d8b7a;
}

.badge-warning {
  color: #d0756a;
}

.badge-star {
  color: #d4a054;
}

.arrows-layer,
.pieces-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.arrows-layer {
  z-index: 3;
  overflow: visible;
}

.arrow-label {
  fill: var(--ink);
  font-family: var(--font);
  font-weight: 800;
}

.labels-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.arrow-label-pill {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 0.45em;
  background: rgba(255, 251, 244, 0.95);
  border: 1px solid rgba(80, 70, 50, 0.12);
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(50, 40, 30, 0.18);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.arrow-label-pill[data-crowded="true"] {
  outline: none;
}

.pieces-layer {
  z-index: 4;
}

.piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  will-change: transform;
  cursor: inherit;
  touch-action: none;
}

.board-root.is-interactive .square {
  cursor: pointer;
}

.piece.is-dragging,
.piece.is-dragging {
  cursor: grabbing;
  filter: drop-shadow(0 8px 10px rgba(50, 40, 30, 0.25));
}

.piece svg {
  width: 90%;
  height: 90%;
  overflow: visible;
  filter: drop-shadow(0 1.25px 1.25px rgba(50, 40, 30, 0.28));
}

.piece-w .sil,
.piece-w .pearl {
  fill: #fbf6eb;
  stroke: #6f6250;
}

.piece-b .sil,
.piece-b .pearl {
  fill: #4a534c;
  stroke: #2c322e;
}

.piece-w .accent {
  fill: #6f6250;
  stroke: #6f6250;
}

.piece-b .accent {
  fill: #d8d3c8;
  stroke: #d8d3c8;
}

.piece .shine {
  fill: rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.piece-b .shine {
  fill: rgba(255, 255, 255, 0.1);
}

/* ——— Playback ——— */
.playback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ctrl-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-tight);
  font-weight: 800;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ctrl-btn:hover {
  background: var(--surface-ink);
}

.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.ctrl-btn.is-primary {
  background: var(--sage);
  color: #fff;
  min-width: 92px;
}

.ctrl-btn.is-primary:hover {
  background: var(--sage-deep);
}

.ctrl-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.notation-strip {
  margin-top: 8px;
  background: var(--surface);
  border-radius: 10px;
  padding: 5px 12px;
  font-weight: 700;
  color: var(--ink-muted);
  font-size: 0.88rem;
  box-shadow: var(--shadow-tight);
  font-variant-numeric: tabular-nums;
}

.notation-strip[hidden] {
  display: none !important;
}

.board-options {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ——— Panel ——— */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  min-width: 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.lesson-badge {
  background: var(--sage-soft);
  color: var(--sage-deep);
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}

.step-count {
  margin-left: auto;
  font-weight: 800;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.step-headline {
  margin: 0 0 8px;
  font-size: var(--headline);
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.step-explanation {
  margin: 0 0 14px;
  font-size: var(--text);
  color: var(--ink);
  line-height: 1.55;
}

.go-deeper {
  background: #efe8fb;
  border-left: 3px solid var(--lavender);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.go-deeper-label {
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #6d6294;
  margin-bottom: 4px;
}

.go-deeper-body {
  margin: 0;
  color: #4d4664;
  font-size: var(--text);
}

.hint-card,
.prompt,
.feedback-bubble {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.hint-card {
  background: #f3ebd2;
  border-left: 3px solid var(--gold);
}

.hint-label {
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8a6a30;
  margin-bottom: 4px;
}

.hint-card p,
.prompt p,
.feedback-bubble p {
  margin: 0;
}

.prompt {
  background: var(--sage-mist);
  border: 1.5px dashed #7d8f68;
  animation: prompt-glow 2.2s ease-in-out infinite;
  font-weight: 700;
}

@keyframes prompt-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(138, 154, 120, 0.15);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(138, 154, 120, 0.12);
  }
}

.feedback-bubble {
  background: #fbe8e4;
  border-left: 3px solid var(--coral);
}

.feedback-bubble.is-praise {
  background: var(--sage-mist);
  border-left-color: var(--teal);
}

.feedback-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.hint-row,
.audio-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.rungs {
  display: inline-flex;
  gap: 6px;
}

.rung {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--gold-soft);
  color: var(--ink-faint);
  font-size: 0.7rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.rung.is-on {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

.branches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.branch-pill {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 999px;
  background: #e8f3fb;
  color: #2d5f86;
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: var(--shadow-tight);
}

.branch-pill.is-active {
  background: var(--sky);
  color: #fff;
}

.progress-block {
  margin: 16px 0 12px;
}

.progress-bar {
  height: 8px;
  background: var(--linen-deep);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--sage), var(--teal));
  border-radius: 999px;
  transition: width 280ms ease;
}

.step-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.step-dot {
  min-width: 32px;
  min-height: 32px;
  border-radius: 999px;
  background: var(--linen-deep);
  color: var(--ink-muted);
  font-weight: 800;
  font-size: 0.78rem;
}

.tier-6yo .step-dot {
  min-width: 34px;
  min-height: 34px;
}

.step-dot.is-current {
  background: var(--sage);
  color: #fff;
}

.step-dot.is-done {
  background: var(--gold-soft);
  color: #6a5420;
}

.lessons-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  min-height: 0;
}

.lesson-group-label {
  margin: 6px 0 0;
  padding: 2px 2px 0;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.lesson-group-label:first-child {
  margin-top: 0;
}

.lesson-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--linen);
  text-align: left;
  font-weight: 700;
}

.lesson-pill.is-active {
  background: var(--sage-mist);
  box-shadow: inset 0 0 0 1.5px var(--sage);
}

.lesson-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--sage);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: transparent;
  flex-shrink: 0;
}

.lesson-pill.is-complete .lesson-check {
  background: var(--sage);
  color: #fff;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.reset-progress {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 36px;
}

.reset-progress:hover {
  color: var(--ink-muted);
}

.hidden,
[hidden] {
  display: none !important;
}

@media (min-width: 841px) {
  .panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 112px);
    min-height: 0;
    overflow-y: auto;
  }
  .lessons-nav,
  .games-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 7.5rem;
    max-height: none;
  }
}

/* ——— Mobile ——— */
@media (max-width: 840px) {
  .app {
    padding: 8px 12px 24px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .board-root {
    max-width: 100%;
  }

  .topbar {
    margin-bottom: 8px;
    gap: 8px;
  }

  .brand-sub {
    display: none;
  }

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

  .topbar-cluster {
    margin-left: 0;
    width: 100%;
  }

  .tier-switch {
    width: 100%;
    justify-content: space-between;
  }

  .tier-btn {
    flex: 1;
    min-height: 42px;
  }

  .scaffold-toggles {
    width: 100%;
    padding: 3px;
    gap: 4px;
  }

  .scaffold-btn {
    min-height: 32px;
    padding: 0 8px;
    font-size: 0.7rem;
  }

  .playback {
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 10px;
  }

  .playback .ctrl-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 0 8px;
  }

  .playback .ctrl-btn.is-primary {
    min-width: 64px;
  }

  .board-options {
    display: none;
  }

  .notation-strip {
    margin-top: 8px;
    padding: 4px 10px;
  }

  .panel {
    padding: 14px 14px 12px;
  }

  .step-count {
    margin-left: 0;
  }
}


body:not(.level-6yo) .audio-row,
body:not(.level-6yo) [data-scaffold="autoAudio"] {
  display: none;
}

.level-up-card {
  margin: 8px 0 4px;
  padding: 6px 10px;
  background: var(--sage-mist);
  border: 1px solid var(--sage-soft);
  border-radius: 10px;
  box-shadow: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}

.level-up-card[hidden] {
  display: none;
}

.level-up-text {
  margin: 0;
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.3;
  color: var(--ink);
  flex: 1 1 10rem;
}

.level-up-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.level-up-actions .ctrl-btn {
  min-height: 32px;
  min-width: 0;
  padding: 0 10px;
  font-size: 0.8rem;
  border-radius: 10px;
}

.site-footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2px 20px 12px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.site-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--sage-soft);
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--ink);
}

.credits-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 20px 40px;
}

.credits-back {
  margin-left: auto;
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px solid var(--sage-soft);
}

.credits-article h1 {
  font-size: 1.6rem;
  margin: 8px 0 12px;
}

.credits-article h2 {
  font-size: 1.15rem;
  margin: 24px 0 8px;
}

.credits-article p,
.credits-note {
  color: var(--ink-muted);
  line-height: 1.55;
}

.license-block {
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--sage-soft);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
  overflow-x: auto;
}


.library-tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 4px;
  background: var(--linen-deep);
  border-radius: 12px;
  padding: 3px;
}

.library-tab {
  flex: 1;
  min-height: 36px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.library-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-tight);
}

body.mode-lesson .game-only {
  display: none !important;
}

body.mode-game .lesson-only {
  display: none !important;
}

.game-chrome {
  margin: 10px 0 8px;
  padding: 10px 0 0;
  background: transparent;
  border-top: 1px solid var(--linen-deep);
  border-radius: 0;
  box-shadow: none;
}

.game-header {
  margin-bottom: 8px;
}

.game-players {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.3;
}

.game-vs {
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 0.8rem;
}

.game-event,
.game-result {
  color: var(--ink-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.game-result {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.move-list {
  max-height: min(11.5rem, 28vh);
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
  position: relative;
}

.move-row {
  display: grid;
  grid-template-columns: 2rem 1fr 1fr;
  align-items: center;
  gap: 2px;
}

.move-num {
  color: var(--ink-faint);
  font-weight: 700;
  font-size: 0.78rem;
}

.move-san {
  text-align: left;
  min-height: 26px;
  min-width: 0;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
}

.move-san.is-current,
.move-san.is-guess {
  background: var(--sage-mist);
  color: var(--ink);
}

.move-san.is-guess {
  box-shadow: inset 0 0 0 1px var(--gold);
}

.other-side {
  margin: 8px 0 12px;
  padding: 10px 12px;
  background: var(--sage-mist);
  border-radius: 12px;
}

.other-side-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sage-deep);
  margin-bottom: 4px;
}

.move-note {
  margin: 0 0 12px;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

@media (max-width: 840px) {
  .move-list {
    max-height: min(7.5rem, 22vh);
  }

  .game-chrome {
    margin-top: 8px;
    padding-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .piece,
  .progress-fill,
  .square.check,
  .prompt {
    animation: none !important;
    transition: none !important;
  }
}


/* ----- Free play / coaching ----- */

body.mode-play .lesson-only,
body.mode-play .game-only {
  display: none !important;
}

body.mode-lesson .play-only,
body.mode-game .play-only {
  display: none !important;
}

body.mode-play .play-only {
  display: block !important;
}

body.mode-play.mode-lesson .lesson-only,
body.mode-play.mode-game .game-only {
  display: none !important;
}

body.mode-play .hint-row,
body.mode-play .rungs,
body.mode-play .branches,
body.mode-play .progress-block,
body.mode-play [data-slot="meta"],
body.mode-play [data-action="play"],
body.mode-play [data-action="next"],
body.mode-play [data-action="speed"],
body.mode-play [data-slot="step-dots"] {
  display: none !important;
}

.play-setup {
  margin: 0 0 12px;
}

.play-color,
.play-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.coaching-card {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #efe8fb;
  border-left: 3px solid var(--lavender, #8b7ec8);
}

.coaching-card.is-info {
  background: #efe8fb;
  border-left-color: var(--lavender, #8b7ec8);
}

.coaching-card.is-warn {
  background: #f3ebd2;
  border-left-color: var(--gold, #c9a227);
}

.coaching-card.is-blunder {
  background: #fbe8e4;
  border-left-color: var(--coral, #d97868);
}

.coaching-card.is-praise {
  background: var(--sage-mist, #e4efe6);
  border-left-color: var(--teal, #3d8a7a);
}

.coaching-label {
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #6d6294;
  margin-bottom: 4px;
}

.coaching-card.is-warn .coaching-label { color: #8a6a30; }
.coaching-card.is-blunder .coaching-label { color: #a0564a; }
.coaching-card.is-praise .coaching-label { color: #2f6d5f; }

.coaching-text {
  margin: 0;
  color: var(--ink, #3a3228);
  font-size: var(--text, 1rem);
  line-height: 1.45;
}

.coaching-deeper {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #d4cce8;
}

.coaching-deeper-label {
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6d6294;
}

.coaching-deeper p {
  margin: 4px 0 0;
  color: #4d4664;
  font-size: 0.92rem;
}

.play-move-list {
  max-height: 140px;
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.4;
  margin-bottom: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--linen-deep, #e6dcc8);
}

.play-move-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr 1fr;
  gap: 6px;
  padding: 1px 0;
}

.play-move-num {
  color: var(--ink-muted, #7a7164);
  font-weight: 700;
}

.library-tabs {
  flex-wrap: wrap;
}

@media (max-width: 840px) {
  body.mode-play .layout {
    display: flex;
    flex-direction: column;
  }
  body.mode-play .panel {
    display: contents;
  }
  body.mode-play .board-col,
  body.mode-play .board-root {
    order: 1;
    width: 100%;
    max-width: 100%;
  }
  body.mode-play .panel > * {
    order: 4;
  }
  body.mode-play [data-slot="coaching"] {
    order: 2;
    margin-top: 8px;
  }
  body.mode-play [data-slot="play-setup"] {
    order: 3;
    margin-top: 4px;
  }
  body.mode-play .play-move-list {
    max-height: 90px;
  }
  body.mode-play .library-tabs,
  body.mode-play .progress-block,
  body.mode-play [data-slot="meta"],
  body.mode-play [data-action="reset-progress"] {
    /* keep reachable but after the coach card so the message fits at 390x844 */
  }
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: center;
}

.footer-audio-btn {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid var(--sage-soft);
}

.footer-audio-btn:hover,
.footer-audio-btn:focus-visible {
  color: var(--ink);
}

.footer-audio-btn:disabled {
  cursor: default;
  border-bottom-color: transparent;
  color: var(--ink-faint);
}

body.tier-6yo .footer-audio-btn,
body.level-6yo .footer-audio-btn {
  display: inline;
}

.pwa-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  border: 1px solid var(--sage-soft);
}

.pwa-toast-text {
  margin: 0 0 10px;
  font-weight: 700;
}

.pwa-toast-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .pwa-toast {
    right: 12px;
    left: 12px;
    bottom: 12px;
    max-width: none;
  }
}
