:root {
  --chess-ink: #243050;
  --chess-muted: #68728b;
  --chess-accent: #424c88;
  --chess-soft: #eef0fa;
  --chess-line: #e0e5ee;
  --chess-white: #fff;
  --chess-light: #f0ede6;
  --chess-dark: #8095ab;
}
* {
  box-sizing: border-box;
}
body[data-page="chess"] {
  margin: 0;
  background: #f5f7fb;
  color: var(--chess-ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: calc(16px * var(--fs, 1));
  line-height: 1.65;
}
body[data-page="chess"][data-global-theme="candy"] {
  background: #fff7fa;
  --chess-soft: #f8edf5;
  --chess-accent: #79527d;
}
body[data-page="chess"][data-global-theme="forest"] {
  background: #f5f8f3;
  --chess-soft: #eaf3ed;
  --chess-accent: #416e62;
}
body[data-page="chess"][data-global-theme="ocean"] {
  background: #f3f8fb;
  --chess-soft: #e9f2fa;
  --chess-accent: #35618b;
}
[hidden] {
  display: none !important;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
a {
  color: inherit;
  text-decoration: none;
}
button:disabled {
  cursor: default;
  opacity: 0.55;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #dd9723;
  outline-offset: 4px;
}
.chess-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  top: 0;
  left: 16px;
  z-index: 100;
  transform: translateY(-150%);
  background: white;
  padding: 10px;
}
.skip-link:focus {
  transform: none;
}
.chess-header {
  height: 88px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #ffffffde;
  border-bottom: 1px solid var(--chess-line);
}
.chess-back,
.chess-profile {
  font-size: calc(14px * var(--fs, 1));
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chess-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chess-brand > span {
  font-family: serif;
  font-size: 36px;
  background: var(--chess-soft);
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: var(--chess-accent);
}
.chess-brand b {
  font-size: calc(20px * var(--fs, 1));
}
.chess-profile {
  border: 0;
  background: transparent;
  color: inherit;
}
.chess-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}
.chess-nav {
  display: flex;
  width: max-content;
  max-width: 100%;
  gap: 5px;
  border-bottom: 1px solid var(--chess-line);
  margin-bottom: 28px;
}
.chess-nav a {
  min-height: 54px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  color: var(--chess-muted);
  font-weight: 650;
  font-size: calc(15px * var(--fs, 1));
  border-bottom: 3px solid transparent;
}
.chess-nav a[aria-current="page"] {
  border-bottom-color: var(--chess-accent);
  color: var(--chess-accent);
}
.chess-today-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 44px;
  padding: 44px;
  background: white;
  border: 1px solid var(--chess-line);
  border-radius: 28px;
  box-shadow: 0 10px 36px #273e6810;
}
.chess-today-copy {
  align-self: center;
}
.chess-eyebrow {
  display: block;
  font-size: calc(13px * var(--fs, 1));
  font-weight: 650;
  color: var(--chess-accent);
  letter-spacing: 0.04em;
}
.chess-today-copy h1 {
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin: 18px 0;
}
.chess-today-copy p {
  color: var(--chess-muted);
  margin: 0 0 20px;
}
.chess-round-label {
  display: block;
  color: var(--chess-muted);
  font-size: calc(14px * var(--fs, 1));
  margin: 18px 0;
}
.chess-primary {
  border: 0;
  border-radius: 12px;
  min-height: 54px;
  padding: 13px 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--chess-accent);
  color: white;
  font-weight: 650;
}
.chess-primary:hover {
  filter: brightness(1.1);
}
.chess-secondary-note {
  font-size: calc(13px * var(--fs, 1));
  margin: 15px 0 0 !important;
}
.chess-preview {
  max-width: 390px;
  width: 100%;
  justify-self: end;
  align-self: center;
  transform: rotate(1deg);
}
.chess-preview-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: calc(12px * var(--fs, 1));
  color: var(--chess-muted);
  margin-bottom: 10px;
}
.chess-preview-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border: 7px solid #e0e5ee;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  font-family: "DejaVu Sans", "Segoe UI Symbol", serif;
  font-size: clamp(19px, 3vw, 37px);
  line-height: 1;
}
.chess-preview-board span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  color: #172436;
}
.light {
  background: var(--chess-light);
}
.dark {
  background: var(--chess-dark);
}
.chess-preview-note {
  font-size: calc(12px * var(--fs, 1));
  display: block;
  text-align: center;
  color: var(--chess-muted);
  margin-top: 10px;
}
.chess-progress-strip {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 26px 6px;
  border-bottom: 1px solid var(--chess-line);
}
.chess-progress-strip > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
.chess-progress-strip strong {
  font-size: 28px;
  color: var(--chess-accent);
}
.chess-progress-strip span,
.chess-progress-strip p {
  font-size: calc(13px * var(--fs, 1));
  color: var(--chess-muted);
}
.chess-progress-strip p {
  margin-left: auto;
}
.chess-chapter-preview {
  margin-top: 30px;
}
.chess-chapter-preview h2 {
  font-size: calc(19px * var(--fs, 1));
  margin-bottom: 20px;
}
#chapterPreview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.chess-chapter-link {
  border: 1px solid var(--chess-line);
  border-radius: 16px;
  background: white;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: calc(14px * var(--fs, 1));
  text-align: left;
}
.chess-chapter-link > span {
  color: var(--chess-muted);
  font-size: 13px;
}
.chess-chapter-link:hover {
  border-color: var(--chess-accent);
}
.chess-view-heading {
  margin: 30px 0;
}
.chess-view-heading h1 {
  font-size: calc(29px * var(--fs, 1));
  line-height: 1.4;
  margin: 10px 0;
}
.chess-view-heading p {
  color: var(--chess-muted);
}
.chess-map-section {
  margin: 32px 0;
}
.chess-map-section h2 {
  font-size: calc(20px * var(--fs, 1));
  margin: 0;
}
.chess-map-section > p {
  margin: 6px 0 16px;
  color: var(--chess-muted);
  font-size: calc(14px * var(--fs, 1));
}
.chess-lessons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.chess-lesson {
  border: 1px solid var(--chess-line);
  border-radius: 16px;
  background: white;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  padding: 20px;
  align-items: center;
  text-align: left;
  color: inherit;
}
.chess-lesson > span:first-child {
  font-size: 15px;
  color: var(--chess-accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--chess-soft);
}
.chess-lesson b {
  display: block;
  font-size: calc(16px * var(--fs, 1));
}
.chess-lesson small {
  font-size: calc(12px * var(--fs, 1));
  color: var(--chess-muted);
}
.chess-lesson:hover {
  border-color: var(--chess-accent);
}
.chess-practice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.chess-practice-card {
  background: white;
  border: 1px solid var(--chess-line);
  border-radius: 20px;
  padding: 28px;
}
.chess-practice-card h2 {
  font-size: calc(22px * var(--fs, 1));
  margin: 8px 0;
}
.chess-practice-card p {
  color: var(--chess-muted);
  font-size: calc(14px * var(--fs, 1));
}
.chess-practice-card button {
  margin-top: 12px;
}
.chess-session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
  font-size: calc(14px * var(--fs, 1));
  color: var(--chess-muted);
}
.chess-text-button {
  border: 0;
  min-height: 48px;
  padding: 8px 10px;
  background: transparent;
  color: var(--chess-accent);
  font-size: calc(14px * var(--fs, 1));
}
.chess-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.chess-board-column {
  min-width: 0;
}
.chess-turn {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  font-size: calc(13px * var(--fs, 1));
  color: var(--chess-muted);
}
.chess-turn b {
  color: var(--chess-ink);
}
.chess-board {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border: 6px solid #d9e0ea;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 10px 28px #273e6812;
  touch-action: manipulation;
}
.chess-board [role="row"] {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  min-height: 0;
}
.chess-square {
  position: relative;
  min-height: 0 !important;
  min-width: 0 !important;
  border: 0;
  border-radius: 0;
  padding: 0 !important;
  display: grid;
  place-items: center;
  line-height: 1;
  color: #172436;
}
.chess-square .piece {
  font-family: "DejaVu Sans", "Segoe UI Symbol", serif;
  font-size: clamp(25px, 4.6vw, 53px);
  z-index: 2;
  pointer-events: none;
}
.chess-square .piece.white-piece {
  color: #fffdf6;
  -webkit-text-stroke: 1px #28364a;
  text-shadow: 0 1px 2px #0009;
}
.chess-square.selected {
  box-shadow: inset 0 0 0 4px #e8b749;
  background: #e4cd88;
}
.chess-square.last-move {
  box-shadow: inset 0 0 0 3px #e3b84a;
}
.chess-square.target:after {
  content: "";
  position: absolute;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: #172c5680;
}
.chess-square.target:has(.piece):after {
  width: 85%;
  height: 85%;
  background: transparent;
  border: 4px solid #173864a0;
}
.chess-square.hinted {
  outline: 3px dashed #e9b74c;
  outline-offset: -4px;
}
.chess-square:focus-visible {
  outline: 3px solid #d48104;
  outline-offset: -4px;
  z-index: 3;
}
.chess-coord {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font: 11px system-ui;
  color: #142841;
  opacity: 0.85;
}
.chess-board-tools {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.chess-targets,
.chess-promotions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.chess-targets button,
.chess-promotions button {
  min-width: 54px;
  min-height: 48px;
  border: 1px solid var(--chess-line);
  border-radius: 10px;
  background: white;
  color: var(--chess-ink);
}
.chess-targets p {
  font-size: 14px;
  color: var(--chess-muted);
}
.chess-instruction {
  background: white;
  border: 1px solid var(--chess-line);
  padding: 30px;
  border-radius: 22px;
  margin-top: 37px;
}
.chess-instruction h1 {
  font-size: calc(24px * var(--fs, 1));
  line-height: 1.4;
  margin: 12px 0;
}
.chess-instruction > p {
  font-size: calc(17px * var(--fs, 1));
  margin: 18px 0;
  line-height: 1.8;
}
.chess-lesson-steps {
  padding-left: 1.5em;
  color: var(--chess-muted);
  font-size: calc(15px * var(--fs, 1));
}
.chess-lesson-steps li {
  margin: 12px 0;
}
.chess-session-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}
.chess-session-actions > button {
  min-height: 50px;
}
.chess-hints {
  padding: 16px;
  background: var(--chess-soft);
  border-radius: 12px;
  font-size: calc(14px * var(--fs, 1));
  margin-top: 18px;
}
.chess-hints p {
  margin: 6px 0;
}
.chess-feedback {
  padding: 18px;
  border-radius: 14px;
  background: #fdf3df;
  border: 1px solid #eed6a1;
  margin-top: 20px;
  font-size: calc(15px * var(--fs, 1));
}
.chess-feedback[data-kind="success"] {
  background: #eaf5ef;
  border-color: #bedbcc;
  color: #285f4b;
}
.chess-feedback b {
  display: block;
  margin-bottom: 8px;
}
.chess-feedback p {
  margin: 0;
}
.chess-result {
  max-width: 680px;
  margin: 50px auto;
  background: white;
  border: 1px solid var(--chess-line);
  border-radius: 26px;
  padding: 44px;
  text-align: center;
}
.chess-result-icon {
  display: grid;
  place-items: center;
  font: 64px serif;
  width: 100px;
  height: 100px;
  background: var(--chess-soft);
  border-radius: 28px;
  margin: 0 auto 24px;
  color: var(--chess-accent);
}
.chess-result h1 {
  font-size: calc(29px * var(--fs, 1));
  line-height: 1.35;
}
.chess-result p {
  color: var(--chess-muted);
}
#resultDetails {
  margin: 24px 0;
}
.chess-text-link {
  display: block;
  margin-top: 20px;
  font-size: calc(14px * var(--fs, 1));
  color: var(--chess-muted);
}
.chess-notice {
  padding: 14px;
  border: 1px solid #ead59d;
  border-radius: 12px;
  background: #fff8e8;
  font-size: 15px;
}
.chess-mobile-nav {
  display: none;
}
.chess-playing #chessHeader,
.chess-playing .chess-mobile-nav,
.chess-playing .study-tools {
  display: none !important;
}
@media (max-width: 900px) {
  .chess-header {
    height: 72px;
    padding: 0 20px;
  }
  .chess-shell {
    padding: 20px 20px 100px;
  }
  .chess-today-card {
    gap: 28px;
    padding: 28px;
  }
  .chess-today-copy h1 {
    font-size: 30px;
  }
  .chess-progress-strip {
    gap: 20px;
    flex-wrap: wrap;
  }
  .chess-progress-strip p {
    width: 100%;
    margin: 0;
  }
  .chess-workspace {
    gap: 22px;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
  .chess-instruction {
    padding: 22px;
  }
  .chess-instruction h1 {
    font-size: 24px;
  }
  #chapterPreview {
    grid-template-columns: repeat(3, 1fr);
  }
  .chess-mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--chess-line);
    background: #ffffffed;
  }
  .chess-mobile-nav a {
    display: grid;
    place-items: center;
    min-height: 48px;
    font-size: 14px;
    color: var(--chess-muted);
  }
  .chess-mobile-nav a[aria-current] {
    background: var(--chess-soft);
    border-radius: 12px;
    color: var(--chess-accent);
  }
}
@media (max-width: 620px) {
  .chess-header {
    padding: 0 14px;
    gap: 10px;
  }
  .chess-brand {
    gap: 7px;
  }
  .chess-brand b {
    font-size: 18px;
  }
  .chess-brand > span {
    width: 38px;
    height: 38px;
    font-size: 30px;
  }
  .chess-profile {
    font-size: 14px;
  }
  .chess-back span {
    display: none;
  }
  .chess-shell {
    padding: 12px 12px 100px;
  }
  .chess-nav {
    width: 100%;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 0;
  }
  .chess-nav a {
    padding: 10px;
    justify-content: center;
    font-size: 15px;
  }
  .chess-today-card {
    grid-template-columns: 1fr;
    padding: 24px;
    gap: 24px;
    border-radius: 22px;
  }
  .chess-today-copy h1 {
    font-size: 30px;
    margin: 14px 0;
  }
  .chess-today-copy p {
    font-size: 16px;
  }
  .chess-today-copy .chess-primary {
    width: 100%;
    font-size: 17px;
  }
  .chess-preview {
    max-width: 270px;
    justify-self: center;
  }
  .chess-preview-board {
    font-size: 27px;
  }
  .chess-today-copy .chess-secondary-note {
    font-size: 14px;
  }
  .chess-eyebrow {
    font-size: 14px;
  }
  .chess-progress-strip {
    gap: 18px;
    padding: 22px 0;
  }
  .chess-progress-strip span {
    font-size: 13px;
  }
  .chess-progress-strip strong {
    font-size: 25px;
  }
  #chapterPreview {
    grid-template-columns: repeat(2, 1fr);
  }
  .chess-chapter-link {
    padding: 16px;
    font-size: 15px;
  }
  .chess-lessons,
  .chess-practice-grid {
    grid-template-columns: 1fr;
  }
  .chess-lesson {
    padding: 16px;
    gap: 12px;
  }
  .chess-session-header {
    margin-bottom: 12px;
    font-size: 13px;
  }
  .chess-session-header #sessionLabel {
    display: none;
  }
  .chess-workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .chess-instruction {
    margin: 0;
    padding: 22px;
  }
  .chess-instruction h1 {
    font-size: 25px;
  }
  .chess-instruction > p {
    font-size: 18px;
  }
  .chess-turn {
    font-size: 14px;
  }
  .chess-square .piece {
    font-size: clamp(25px, 8vw, 46px);
  }
  .chess-result {
    padding: 28px 20px;
    margin: 24px 0;
  }
  .chess-result h1 {
    font-size: 29px;
  }
  .chess-playing .chess-shell {
    padding-bottom: 30px;
  }
  .chess-preview-label {
    font-size: 13px;
  }
  .chess-lesson-steps {
    font-size: 17px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
.chess-mobile-prompt {
  display: none;
}
html[data-network="offline"] .chess-shell {
  padding-bottom: 150px;
}
@media (max-width: 620px) {
  .chess-mobile-prompt {
    display: block;
    margin: 0;
    font-size: 18px;
    line-height: 1.7;
  }
  .chess-instruction > #puzzlePrompt {
    display: none;
  }
  .chess-board {
    border-width: 4px;
  }
}
