.chess-training { max-width: 1420px; padding: clamp(24px, 4vw, 52px); margin-inline: auto; }
.chess-header { margin-bottom: 28px; }
.chess-header h1 { font-size: clamp(2rem, 4.2vw, 3.4rem); font-weight: 750; letter-spacing: -.045em; line-height: 1.12; margin: 14px 0; }
.chess-header > p:last-child { color: var(--ink-dim); font-size: 1rem; line-height: 1.7; }
.chess-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 28px; width: fit-content; max-width: 100%; }
.chess-tabs button { border: 0; border-radius: 9px; background: transparent; color: var(--ink-dim); font: inherit; font-weight: 600; font-size: .88rem; padding: 12px 17px; min-height: 44px; cursor: pointer; }
.chess-tabs [aria-selected="true"] { background: var(--ink); color: var(--bg); }
.chess-tab-symbol { margin-right: 8px; font-size: 1.1em; }
.chess-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(275px, 330px); gap: clamp(22px, 3vw, 40px); align-items: start; }
.chess-board-panel { min-width: 0; }
.chess-mobile-prompt { display: none; }
.chess-board-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; font-size: .85rem; font-weight: 600; margin-bottom: 14px; }
.chess-badge { color: var(--ink-dim); font-size: .75rem; font-weight: 500; border: 1px solid var(--line); padding: 4px 9px; border-radius: 20px; }
.chess-board { --square-light: #e6e8df; --square-dark: #74958b; position: relative; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); width: 100%; aspect-ratio: 1; border: 3px solid #425a53; border-radius: 4px; overflow: hidden; isolation: isolate; }
.chess-square { display: grid; place-items: center; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 0; background: var(--square-light); cursor: pointer; touch-action: manipulation; position: relative; }
.chess-square.dark { background: var(--square-dark); }
.chess-square.last { background: #d3d991; }
.chess-square.dark.last { background: #9cac62; }
.chess-square.selected::after, .chess-square.wrong::after, .chess-square.in-check::after { content: ''; position: absolute; inset: 2px; border: 3px solid #205bbb; border-radius: 2px; pointer-events: none; }
.chess-square.wrong::after, .chess-square.in-check::after { border-color: #ab2f28; background: #c7352820; }
.chess-square:focus-visible { outline: 3px solid #184ca0; outline-offset: -4px; z-index: 2; }
.chess-square:disabled { cursor: default; opacity: 1; }
.chess-piece { width: 89%; height: 89%; display: block; pointer-events: none; filter: drop-shadow(0 1px 1px #0002); }
.chess-piece.white { --piece-fill: #fffaf0; --piece-stroke: #28332f; --piece-detail: #28332f; }
.chess-piece.black { --piece-fill: #26322e; --piece-stroke: #f0f2e5; --piece-detail: #f0f2e5; }
.chess-piece g { fill: var(--piece-fill); stroke: var(--piece-stroke); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.chess-piece .piece-detail { fill: none; stroke: var(--piece-detail); }
.chess-moving { position: absolute; display: grid; place-items: center; z-index: 4; pointer-events: none; }
.chess-result-flash { position: absolute; inset: 0; z-index: 5; pointer-events: none; border-radius: inherit; }
.chess-result-flash.correct { background: #16a34a40; box-shadow: inset 0 0 0 4px #15803d; }
.chess-result-flash.wrong { background: #dc262640; box-shadow: inset 0 0 0 4px #dc2626; }
#chess-answer[data-result="correct"] { outline: 3px solid #15803d; outline-offset: 2px; }
#chess-answer[data-result="wrong"] { outline: 3px solid #dc2626; outline-offset: 2px; }
.chess-board-note { font-size: .8rem; color: var(--ink-dim); line-height: 1.65; margin-top: 12px; }
.chess-exercise { min-width: 0; border: 1px solid var(--line); background: var(--bg-raised); border-radius: 18px; padding: clamp(20px, 2.2vw, 28px); }
.chess-eyebrow { color: var(--vermillion); font-size: .67rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 9px; }
.chess-exercise h2 { font-size: 1.35rem; line-height: 1.3; letter-spacing: -.025em; margin-bottom: 10px; }
#chess-instruction { font-size: .88rem; color: var(--ink-dim); line-height: 1.7; }
.chess-prompt { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: clamp(2.4rem, 5vw, 3.7rem); font-weight: 700; color: var(--ink); line-height: 1.25; margin: 22px 0; overflow-wrap: anywhere; }
.chess-prompt.observation { font-family: inherit; font-size: 1rem; color: var(--ink-dim); font-weight: 500; }
#chess-answer-form label { display: block; font-size: .85rem; font-weight: 650; margin: 16px 0 7px; }
#chess-answer { display: block; width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); color: var(--ink); padding: 11px 12px; font: 1.1rem ui-monospace, Consolas, monospace; }
.chess-small { font-size: .75rem; color: var(--ink-dim); line-height: 1.7; }
#chess-answer-hint { margin: 8px 0 14px; }
.chess-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; width: 100%; padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); color: var(--ink); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; }
.chess-button:hover:not(:disabled) { border-color: var(--vermillion); }
.chess-button.chess-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.chess-button:disabled { opacity: .6; cursor: default; }
.chess-text-button { min-height: 44px; padding: 8px 0; border: 0; background: none; color: var(--ink-dim); font: inherit; font-size: .78rem; cursor: pointer; text-underline-offset: 3px; }
.chess-text-button:hover:not(:disabled) { color: var(--vermillion); text-decoration: underline; }
.chess-text-button:disabled { opacity: .5; cursor: default; }
#chess-replay { margin-top: 12px; }
.chess-feedback { min-height: 72px; padding-block: 16px; font-size: .85rem; line-height: 1.65; overflow-wrap: anywhere; }
.chess-feedback[data-state="correct"] { color: var(--verdigris); }
.chess-feedback[data-state="wrong"] { color: var(--ink); }
.chess-actions { display: grid; gap: 5px; }
.chess-score { display: flex; gap: 10px; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); margin: 15px 0 8px; padding-top: 15px; }
.chess-score strong { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.chess-score span { display: block; color: var(--ink-dim); font-size: .72rem; }
.chess-score button { max-width: 105px; text-align: right; line-height: 1.5; }
.chess-help { margin-top: 32px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-raised); }
.chess-help summary { padding: 18px 22px; cursor: pointer; font-size: .95rem; font-weight: 650; }
.chess-help summary span { margin-left: 12px; font-size: .8rem; color: var(--ink-dim); font-weight: 400; }
.chess-help-content { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 25px; padding: 0 22px 22px; font-size: .85rem; }
.chess-help-content h2 { font-size: .95rem; margin-bottom: 12px; }
.chess-help-content p { color: var(--ink-dim); margin-top: 12px; }
.chess-legend { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 14px; }
.chess-legend dt { font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.chess-legend dd { margin: 0; color: var(--ink-dim); }
.chess-purpose { margin-top: 18px; }
.chess-promotion { border: 1px solid var(--line-strong); border-radius: 16px; background: var(--bg); color: var(--ink); padding: 26px; width: min(400px, calc(100% - 32px)); }
.chess-promotion::backdrop { background: #0008; }
.chess-promotion h2 { margin-bottom: 12px; }
.chess-promotion-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-block: 20px; }
.chess-promotion-options button { padding: 14px; min-height: 48px; border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--ink); border-radius: 8px; cursor: pointer; }
.chess-training button:focus-visible, .chess-training input:focus-visible, .chess-help summary:focus-visible, .chess-promotion button:focus-visible { outline: 3px solid var(--vermillion); outline-offset: 3px; }
.chess-training .chess-square:focus-visible { outline-offset: -4px; }
.chess-training [hidden], .chess-training [hidden].chess-button { display: none !important; }
@container (max-width: 800px) {
  .chess-workspace { grid-template-columns: 1fr; }
  .chess-board-panel { width: 100%; max-width: 620px; margin-inline: auto; }
  .chess-mobile-prompt { display: block; font-size: 1.3rem; font-weight: 700; margin-bottom: 12px; }
  .chess-exercise > .chess-eyebrow, .chess-exercise > h2, .chess-exercise > #chess-instruction, .chess-exercise > .chess-prompt { display: none; }
  .chess-exercise { display: grid; grid-template-columns: 1fr; }
  .chess-help-content { grid-template-columns: 1fr; }
  .chess-feedback { min-height: 0; }
}
@media (max-width: 520px) {
  .chess-training { padding: 24px 16px; }
  .chess-header { margin-bottom: 22px; }
  .chess-tabs { width: 100%; gap: 3px; padding: 4px; }
  .chess-tabs button { flex: 1; padding: 10px 5px; font-size: .73rem; }
  .chess-tab-symbol { display: none; }
  .chess-help summary span { display: block; margin: 4px 0 0 17px; }
}
