/* ===== Variables ===== */
:root {
  color-scheme: dark;
  --lacquer: #b83232;
  --lacquer-deep: #8b1f1f;
  --lacquer-glow: rgba(184, 50, 50, 0.35);
  --gold: #c9a227;
  --gold-light: #e8c84a;
  --ink: #1a1410;
  --ink-soft: #2d2520;
  --paper: #f3ece0;
  --paper-dark: #e8dfd0;
  --board: #c9a66b;
  --board-line: #5c3d1e;
  --board-river: rgba(70, 110, 140, 0.15);
  --red-piece: #c62828;
  --red-piece-bg: #fff5f0;
  --black-piece: #1a1410;
  --black-piece-bg: #f0ebe3;
  --bg: #14100e;
  --bg-alt: #1c1714;
  --bg-card: #241e1a;
  --text: #f0e8dc;
  --text-muted: #a89888;
  --border: #3d342c;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font-display: 'Ma Shan Zheng', cursive;
  --font-body: 'Noto Serif SC', 'Songti SC', serif;
  --header-bg: rgba(20, 16, 14, 0.9);
  --highlight-dot: rgba(201, 162, 39, 0.55);
  --move-dot: rgba(76, 175, 80, 0.5);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5efe6;
  --bg-alt: #ebe3d6;
  --bg-card: #fffdf9;
  --text: #1a1410;
  --text-muted: #6b5d50;
  --border: #d4c8b8;
  --shadow: 0 12px 40px rgba(60, 40, 20, 0.1);
  --header-bg: rgba(245, 239, 230, 0.92);
  --lacquer-glow: rgba(184, 50, 50, 0.15);
  --board-river: rgba(70, 110, 140, 0.08);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

.container {
  width: min(1140px, 92vw);
  margin: 0 auto;
}

/* ===== Background ===== */
.paper-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.ink-wash {
  position: fixed;
  top: -20%;
  right: -15%;
  width: 70vw;
  height: 70vw;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at center, var(--lacquer-glow) 0%, transparent 65%);
  opacity: 0.6;
}

main, header, footer { position: relative; z-index: 1; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--lacquer);
}

.logo-piece {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red-piece-bg);
  color: var(--red-piece);
  border: 2px solid var(--lacquer);
  font-family: var(--font-display);
  font-size: 1.2rem;
  box-shadow: 0 2px 8px var(--lacquer-glow);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
}

.nav-links a {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.nav-links a:hover {
  color: var(--lacquer);
  background: var(--lacquer-glow);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover { color: var(--gold); border-color: var(--gold); }
.theme-toggle svg { width: 18px; height: 18px; fill: currentColor; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]) .icon-moon { display: none; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--lacquer), var(--lacquer-deep));
  color: #fff;
  box-shadow: 0 4px 16px var(--lacquer-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--lacquer-glow);
}

.btn-outline {
  border: 1.5px solid var(--gold);
  color: var(--gold);
}

.btn-outline:hover {
  background: rgba(201, 162, 39, 0.1);
  transform: translateY(-2px);
}

/* ===== Hero ===== */
.hero {
  padding: 4rem 0 5rem;
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.hero-tag {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1.25;
  font-weight: 400;
  margin-bottom: 1.25rem;
}

.hero .highlight {
  color: var(--lacquer);
  display: inline-block;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  max-width: 520px;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

.hero-stats {
  display: flex;
  gap: 2.5rem;
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--gold);
  line-height: 1.2;
}

.stat span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hero-board-wrap {
  display: flex;
  justify-content: center;
}

.board-frame {
  position: relative;
  padding: 1.25rem;
  background: linear-gradient(145deg, var(--ink-soft), var(--ink));
  border-radius: 16px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.06);
  border: 2px solid var(--border);
}

.board-label {
  text-align: center;
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold);
  letter-spacing: 0.3em;
}

/* ===== Chess Board ===== */
.chess-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(10, 1fr);
  width: min(360px, 80vw);
  aspect-ratio: 9 / 10;
  background: var(--board);
  border: 3px solid var(--board-line);
  position: relative;
  border-radius: 4px;
}

.chess-board::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 44.5%;
  height: 11%;
  background: var(--board-river);
  pointer-events: none;
  z-index: 0;
}

.board-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.board-cell::before,
.board-cell::after {
  content: '';
  position: absolute;
  background: var(--board-line);
  pointer-events: none;
}

.board-cell::before {
  width: 100%;
  height: 1px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.board-cell::after {
  width: 1px;
  height: 100%;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.board-cell.edge-top::before { height: 2px; top: 0; transform: none; }
.board-cell.edge-bottom::before { height: 2px; top: auto; bottom: 0; transform: none; }
.board-cell.edge-left::after { width: 2px; left: 0; transform: none; }
.board-cell.edge-right::after { width: 2px; left: auto; right: 0; transform: none; }

.board-cell.river-top::before,
.board-cell.river-bottom::before { display: none; }

.palace-line {
  position: absolute;
  width: 1px;
  height: 141%;
  background: var(--board-line);
  top: -20%;
  z-index: 2;
  pointer-events: none;
}

.palace-line.diag-1 { transform: rotate(45deg); }
.palace-line.diag-2 { transform: rotate(-45deg); }

.river-text {
  position: absolute;
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  color: var(--board-line);
  opacity: 0.7;
  z-index: 2;
  pointer-events: none;
  letter-spacing: 0.2em;
}

.river-text.chu { left: 18%; top: 46%; }
.river-text.han { right: 18%; top: 46%; }

.piece {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 2.8vw, 1.15rem);
  border: 2px solid;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  position: relative;
  z-index: 3;
  transition: transform 0.2s;
}

.piece.red {
  background: var(--red-piece-bg);
  color: var(--red-piece);
  border-color: var(--red-piece);
}

.piece.black {
  background: var(--black-piece-bg);
  color: var(--black-piece);
  border-color: var(--black-piece);
}

.piece.highlight {
  box-shadow: 0 0 0 3px var(--gold), 0 2px 8px rgba(0,0,0,0.3);
  transform: scale(1.08);
}

.cell-marker {
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  z-index: 2;
}

.cell-marker.move {
  background: var(--move-dot);
  border: 1px solid rgba(76, 175, 80, 0.8);
}

.cell-marker.target {
  background: var(--highlight-dot);
  border: 1px solid var(--gold);
}

/* ===== Sections ===== */
.section {
  padding: 5rem 0;
}

.section-alt {
  background: var(--bg-alt);
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 400;
  margin-bottom: 0.75rem;
}

.section-header p {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
}

/* ===== About ===== */
.about-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  transition: transform 0.25s, border-color 0.25s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--lacquer);
}

.card-icon {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--lacquer);
  margin-bottom: 0.75rem;
}

.card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.card p { color: var(--text-muted); font-size: 0.95rem; }
.card strong { color: var(--text); }

.notation-box {
  background: linear-gradient(135deg, rgba(184,50,50,0.08), rgba(201,162,39,0.06));
  border: 1px solid var(--border);
  border-left: 4px solid var(--lacquer);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
}

.notation-box h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--lacquer);
  margin-bottom: 0.5rem;
}

.notation-box p { color: var(--text-muted); }

/* ===== Pieces Section ===== */
.pieces-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  align-items: start;
}

.piece-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.piece-card {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.piece-card:hover,
.piece-card.active {
  border-color: var(--lacquer);
  background: rgba(184, 50, 50, 0.06);
}

.piece-char {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  border: 1.5px solid;
}

.piece-char.red {
  background: var(--red-piece-bg);
  color: var(--red-piece);
  border-color: var(--red-piece);
}

.piece-char.black {
  background: var(--black-piece-bg);
  color: var(--black-piece);
  border-color: var(--black-piece);
}

.piece-card strong { font-size: 0.95rem; }
.piece-value { font-size: 0.75rem; color: var(--text-muted); }

.piece-detail {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  align-items: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.piece-info h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--lacquer);
  margin-bottom: 0.75rem;
}

.piece-info p { color: var(--text-muted); margin-bottom: 1rem; }

.piece-tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.piece-tips li {
  padding-left: 1rem;
  position: relative;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.piece-tips li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--gold);
  font-weight: bold;
}

/* ===== Rules ===== */
.rules-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 2.5rem;
}

.rule-step {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.rule-step:last-child { border-bottom: none; }

.step-num {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--gold);
  opacity: 0.7;
}

.step-body h3 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.step-body p { color: var(--text-muted); font-size: 0.95rem; }
.step-body strong { color: var(--lacquer); }

.value-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  overflow-x: auto;
}

.value-table-wrap h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--gold);
}

.value-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.value-table th,
.value-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.value-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.value-table td:first-child {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--lacquer);
}

/* ===== Tactics ===== */
.tactics-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
}

.tactic-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tactic-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.tactic-btn:hover,
.tactic-btn.active {
  border-color: var(--lacquer);
  background: rgba(184, 50, 50, 0.08);
}

.tactic-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.tactic-level {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: rgba(201, 162, 39, 0.15);
  color: var(--gold);
}

.tactic-detail {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.tactic-content h3 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--lacquer);
  margin-bottom: 0.75rem;
}

.tactic-content > p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.tactic-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.step-item {
  display: flex;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.step-item span {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--lacquer);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.tactic-tip {
  padding: 1rem 1.25rem;
  background: rgba(201, 162, 39, 0.08);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.tactic-tip strong { color: var(--gold); }

/* ===== Opening ===== */
.opening-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.opening-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
}

.opening-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: var(--lacquer-glow);
  border-radius: 0 0 0 100%;
}

.opening-num {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--gold);
  opacity: 0.5;
  margin-bottom: 0.5rem;
}

.opening-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
}

.opening-card p { color: var(--text-muted); font-size: 0.9rem; }
.opening-card strong { color: var(--lacquer); }

.opening-common {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
}

.opening-common h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.opening-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tag {
  padding: 0.35rem 0.85rem;
  background: rgba(184, 50, 50, 0.1);
  border: 1px solid rgba(184, 50, 50, 0.25);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--lacquer);
}

.opening-note { color: var(--text-muted); font-size: 0.9rem; }

/* ===== Endgame ===== */
.endgame-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.endgame-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  border-top: 3px solid var(--gold);
}

.endgame-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--gold);
}

.endgame-card p { color: var(--text-muted); font-size: 0.9rem; }

.practice-box {
  background: linear-gradient(135deg, rgba(201,162,39,0.08), rgba(184,50,50,0.06));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
}

.practice-box h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--lacquer);
  margin-bottom: 1rem;
}

.practice-box ol {
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.practice-box li {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.practice-box strong { color: var(--text); }

/* ===== Puzzles ===== */
.puzzle-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
}

.puzzle-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.puzzle-item-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.puzzle-item-btn:hover,
.puzzle-item-btn.active {
  border-color: var(--lacquer);
  background: rgba(184, 50, 50, 0.08);
}

.puzzle-item-btn.solved {
  border-color: rgba(76, 175, 80, 0.5);
}

.puzzle-item-btn.solved::after {
  content: '✓';
  position: absolute;
  right: 0.75rem;
  color: #4caf50;
  font-weight: bold;
}

.puzzle-item-btn {
  position: relative;
}

.puzzle-item-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.puzzle-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.puzzle-workspace {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  align-items: start;
}

.puzzle-board-wrap {
  display: flex;
  justify-content: center;
}

.puzzle-meta {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.puzzle-difficulty,
.puzzle-mate {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.puzzle-difficulty {
  background: rgba(201, 162, 39, 0.15);
  color: var(--gold);
}

.puzzle-mate {
  background: rgba(184, 50, 50, 0.12);
  color: var(--lacquer);
}

.puzzle-panel h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--lacquer);
  margin-bottom: 0.5rem;
}

.puzzle-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.puzzle-status {
  padding: 0.85rem 1rem;
  background: var(--surface-muted, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.puzzle-status.success {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.4);
  color: #81c784;
}

.puzzle-status.error {
  background: rgba(184, 50, 50, 0.1);
  border-color: rgba(184, 50, 50, 0.35);
  color: #e57373;
}

.puzzle-status.hint {
  background: rgba(201, 162, 39, 0.1);
  border-color: rgba(201, 162, 39, 0.35);
  color: var(--gold);
}

.puzzle-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
}

.puzzle-progress {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--lacquer), var(--gold));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ===== Play vs AI ===== */
.play-layout {
  max-width: 960px;
  margin: 0 auto;
}

.play-workspace {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  align-items: start;
}

.play-board-wrap {
  display: flex;
  justify-content: center;
}

.play-panel h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.play-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.play-difficulty-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.play-difficulty-select {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.play-sound-toggle {
  margin-left: auto;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.play-sound-toggle:hover {
  color: var(--text);
  border-color: var(--gold);
}

.play-sound-toggle[aria-pressed="true"] {
  color: var(--gold);
  border-color: rgba(201, 162, 39, 0.45);
}

.play-sound-toggle[aria-pressed="false"] {
  opacity: 0.75;
}

.play-status {
  padding: 0.85rem 1rem;
  background: var(--surface-muted, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.play-status.check {
  background: rgba(184, 50, 50, 0.1);
  border-color: rgba(184, 50, 50, 0.35);
  color: #e57373;
}

.play-status.thinking {
  background: rgba(201, 162, 39, 0.1);
  border-color: rgba(201, 162, 39, 0.35);
  color: var(--gold);
}

.play-status.success {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.4);
  color: #81c784;
}

.play-status.fail {
  background: rgba(184, 50, 50, 0.1);
  border-color: rgba(184, 50, 50, 0.35);
  color: #e57373;
}

.play-winrate {
  padding: 1rem;
  background: var(--surface-muted, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.play-winrate-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.winrate-label {
  color: var(--gold);
  font-weight: 600;
}

.winrate-row {
  display: grid;
  grid-template-columns: 1.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.winrate-side {
  font-size: 0.8rem;
  font-weight: 700;
}

.winrate-side.red { color: var(--lacquer); }
.winrate-side.black { color: var(--text); }

.winrate-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.winrate-bar-red {
  height: 100%;
  background: linear-gradient(90deg, var(--lacquer), #e05555);
  border-radius: 4px;
  transition: width 0.5s ease;
  max-width: 100%;
}

.winrate-bar-black {
  height: 100%;
  background: linear-gradient(90deg, #555, #333);
  border-radius: 4px;
  transition: width 0.5s ease;
  max-width: 100%;
}

.winrate-pct {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.winrate-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.play-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.play-move-history {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.play-move-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 160px;
  overflow-y: auto;
}

.play-move-item {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.play-review-panel {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.25rem;
}

.play-review-progress-wrap {
  margin-bottom: 1rem;
}

.play-review-progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.play-review-summary {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.play-review-step-info {
  padding: 0.75rem 1rem;
  background: var(--surface-muted, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}

.play-review-step-info p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.play-review-eval,
.play-review-best {
  font-size: 0.82rem;
}

.play-review-quality {
  margin-top: 0.5rem !important;
}

.play-review-moves-wrap {
  margin-bottom: 1rem;
}

.play-review-moves-wrap h4 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.play-review-move-list {
  max-height: 180px;
  overflow-y: auto;
}

.play-review-exit {
  width: 100%;
}

.play-review-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.review-tag-good {
  color: #81c784;
  font-weight: 600;
}

.review-tag-inaccuracy {
  color: var(--gold);
  font-weight: 600;
}

.review-tag-blunder {
  color: #e57373;
  font-weight: 600;
}

.cell-marker.legal-move {
  background: var(--move-dot);
  border: 1px solid rgba(76, 175, 80, 0.8);
}

/* Interactive board */
.chess-board-interactive .board-cell {
  cursor: pointer;
}

.chess-board-interactive .board-cell:hover {
  background: rgba(201, 162, 39, 0.08);
}

.board-cell.selected {
  background: rgba(201, 162, 39, 0.2) !important;
}

.board-cell.last-move-from,
.board-cell.last-move-to {
  background: rgba(76, 175, 80, 0.15) !important;
}

.board-cell.last-move-to::after {
  content: '';
  position: absolute;
  inset: 15%;
  border: 2px solid rgba(76, 175, 80, 0.6);
  border-radius: 50%;
  pointer-events: none;
}

.piece.moving {
  transition: transform 0.35s ease;
  z-index: 10;
}

/* ===== Replay ===== */
.replay-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  align-items: start;
}

.replay-board-wrap {
  position: sticky;
  top: 88px;
}

.replay-move-badge {
  text-align: center;
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold);
  min-height: 1.8rem;
  transition: opacity 0.3s;
}

.replay-move-badge.animate-in {
  animation: notationPop 0.4s ease;
}

@keyframes notationPop {
  0% { opacity: 0; transform: scale(0.9) translateY(6px); }
  60% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.replay-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.replay-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.replay-select-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all 0.2s;
}

.replay-select-btn:hover,
.replay-select-btn.active {
  border-color: var(--lacquer);
  color: var(--lacquer);
  background: rgba(184, 50, 50, 0.08);
}

.replay-info h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--lacquer);
  margin-bottom: 0.4rem;
}

.replay-info p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.replay-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.ctrl-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s;
}

.ctrl-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201, 162, 39, 0.1);
}

.ctrl-btn-play {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--lacquer), var(--lacquer-deep));
  border-color: transparent;
  color: #fff;
}

.ctrl-btn-play:hover {
  background: linear-gradient(135deg, var(--lacquer-deep), var(--lacquer));
  color: #fff;
  transform: scale(1.05);
}

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

.ctrl-btn-play svg { width: 22px; height: 22px; }
.ctrl-btn-play .icon-pause { display: none; }
.ctrl-btn-play.playing .icon-play { display: none; }
.ctrl-btn-play.playing .icon-pause { display: block; }

.replay-speed {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.replay-speed input[type="range"] {
  flex: 1;
  accent-color: var(--lacquer);
}

.notation-list-wrap h4 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.notation-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.4rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.notation-list li {
  padding: 0.5rem 0.75rem;
  background: var(--surface-muted, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.notation-list li:hover {
  border-color: var(--gold);
}

.notation-list li.active {
  background: rgba(184, 50, 50, 0.12);
  border-color: var(--lacquer);
  color: var(--lacquer);
  font-weight: 600;
}

.notation-list li .move-num {
  color: var(--text-muted);
  margin-right: 0.35rem;
  font-size: 0.75rem;
}

.notation-list li.red-move { border-left: 3px solid var(--red-piece); }
.notation-list li.black-move { border-left: 3px solid var(--black-piece); }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  margin-top: 2rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer-brand strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--lacquer);
}

.footer-brand p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Animations ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-text > * {
  animation: fadeUp 0.7s ease backwards;
}

.hero-text > *:nth-child(1) { animation-delay: 0.1s; }
.hero-text > *:nth-child(2) { animation-delay: 0.2s; }
.hero-text > *:nth-child(3) { animation-delay: 0.3s; }
.hero-text > *:nth-child(4) { animation-delay: 0.4s; }
.hero-text > *:nth-child(5) { animation-delay: 0.5s; }

.board-frame {
  animation: fadeUp 0.8s ease 0.3s backwards;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .hero-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .hero-desc { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
  .hero-stats { justify-content: center; }

  .about-grid,
  .endgame-grid { grid-template-columns: 1fr; }

  .pieces-layout,
  .tactics-layout {
    grid-template-columns: 1fr;
  }

  .piece-detail,
  .tactic-detail {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .opening-grid { grid-template-columns: 1fr; }

  .puzzle-layout,
  .replay-layout {
    grid-template-columns: 1fr;
  }

  .puzzle-workspace,
  .play-workspace {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .replay-board-wrap { position: static; }
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    backdrop-filter: blur(12px);
  }

  .nav-links.open { display: flex; }
  .nav-toggle { display: flex; }

  .piece-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .tactic-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .puzzle-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}
