:root {
  --page: #f3f0e8;
  --panel: #fffdf6;
  --panel-border: #d9cda9;
  --text-main: #2d261c;
  --text-soft: #675d4d;
  --accent: #23543a;
  --accent-warm: #c89037;
  --shadow-soft: 0 18px 44px rgba(47, 40, 28, 0.12);
  --sq-light: #f0e2c4;
  --sq-dark: #8b6043;
  --sq-selected: #c8b400;
  --sq-movable: rgba(100, 180, 80, 0.62);
  --sq-capture: rgba(200, 60, 40, 0.52);
  --sq-check: rgba(220, 40, 20, 0.72);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(35, 84, 58, 0.1), transparent 34%),
    radial-gradient(circle at 82% 14%, rgba(200, 144, 55, 0.14), transparent 28%),
    var(--page);
  color: var(--text-main);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.65;
}

a { color: var(--accent); }

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.breadcrumb {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: 0.92rem;
}
.breadcrumb a {
  text-decoration: none;
  border-bottom: 1px solid rgba(102, 88, 69, 0.28);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.85fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.hero-panel,
.game-shell,
.panel,
.faq-panel,
.related-panel,
.round-panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.hero-copy {
  position: relative;
  overflow: hidden;
  padding: 34px;
  border-radius: 24px;
}

/* Decorative chess pattern in hero */
.hero-copy::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 20px;
  width: 148px;
  height: 148px;
  border-radius: 10px;
  background:
    conic-gradient(
      var(--sq-dark) 0 25%,
      var(--sq-light) 0 50%,
      var(--sq-dark) 0 75%,
      var(--sq-light) 0
    ),
    conic-gradient(
      var(--sq-light) 0 25%,
      var(--sq-dark) 0 50%,
      var(--sq-light) 0 75%,
      var(--sq-dark) 0
    );
  background-size: 37px 37px;
  background-position: 0 0, 37px 37px;
  opacity: 0.38;
  pointer-events: none;
}

.hero-panel,
.round-panel {
  padding: 28px;
  border-radius: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 { line-height: 1.15; }
h1 {
  margin: 0 0 14px;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
}
h2 { margin: 0 0 12px; font-size: clamp(1.45rem, 3vw, 2rem); }
p, ul, ol { margin-top: 0; }

.lead {
  max-width: 760px;
  color: var(--text-soft);
  font-size: 1.13rem;
}

.hero-actions,
.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button,
.game-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #fffdf6;
  color: var(--text-main);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.button.primary,
.game-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fffaf0;
}

.button:hover,
.button:focus-visible,
.game-button:hover,
.game-button:focus-visible {
  outline: 3px solid rgba(200, 144, 55, 0.28);
  outline-offset: 2px;
}

/* ===== GAME SHELL ===== */
.game-shell {
  margin-bottom: 24px;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(248, 244, 234, 0.96)),
    var(--panel);
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-item {
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(246, 240, 228, 0.7);
  text-align: center;
}

.status-label {
  display: block;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.status-item strong {
  display: block;
  min-height: 28px;
  font-size: 1.25rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(240px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  border: 1px solid rgba(35, 84, 58, 0.16);
  border-radius: 20px;
  background:
    linear-gradient(90deg, rgba(35, 84, 58, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(35, 84, 58, 0.06) 1px, transparent 1px),
    #fbf6eb;
  background-size: 28px 28px;
}

.game-status {
  width: 100%;
  min-height: 28px;
  margin: 0 0 12px;
  color: var(--text-soft);
  font-weight: 700;
  text-align: center;
  font-size: 1rem;
}

/* ===== CHESS BOARD ===== */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(100%, 480px);
  aspect-ratio: 1;
  border: 3px solid rgba(35, 84, 58, 0.3);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(47, 40, 28, 0.22);
  user-select: none;
}

.chess-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s;
}

.chess-cell.light { background: var(--sq-light); }
.chess-cell.dark  { background: var(--sq-dark); }

.chess-cell.selected {
  background: var(--sq-selected) !important;
}

.chess-cell.can-move::after {
  content: "";
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--sq-movable);
  pointer-events: none;
}

.chess-cell.can-capture {
  outline: 4px solid rgba(200, 60, 40, 0.7);
  outline-offset: -4px;
}

.chess-cell.in-check {
  background: var(--sq-check) !important;
}

.chess-piece {
  font-size: clamp(1.4rem, 4.5vw, 2.1rem);
  line-height: 1;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.w-piece {
  color: #fdf8ee;
  text-shadow:
    0 0 2px #5a3a1a,
    0 1px 3px rgba(60, 40, 10, 0.7);
  filter: drop-shadow(0 1px 2px rgba(40, 20, 0, 0.5));
}

.b-piece {
  color: #1a1008;
  text-shadow:
    0 0 1px rgba(255, 240, 200, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.3);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

/* Coordinate labels */
.coord {
  position: absolute;
  font-size: 0.55rem;
  font-weight: 700;
  font-family: sans-serif;
  line-height: 1;
  pointer-events: none;
  opacity: 0.72;
}

.chess-cell.light .coord { color: var(--sq-dark); }
.chess-cell.dark  .coord { color: var(--sq-light); }

.r-coord { top: 2px; left: 2px; }
.f-coord { bottom: 2px; right: 3px; }

/* ===== ROUND PANEL ===== */
.round-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 260px;
  box-shadow: none;
}

#round-message {
  color: var(--text-soft);
  font-size: 0.97rem;
  min-height: 3em;
}

/* ===== CONTENT GRID ===== */
.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.panel,
.faq-panel,
.related-panel {
  padding: 24px;
  border-radius: 18px;
}

.faq-list { display: grid; gap: 10px; }

details {
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.72);
}
summary { cursor: pointer; font-weight: 700; }
details p { margin: 10px 0 0; color: var(--text-soft); }

.related-panel { margin-top: 24px; }

.related-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.related-card {
  display: grid;
  gap: 6px;
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(246, 240, 228, 0.62);
  color: inherit;
  text-decoration: none;
}
.related-card span { color: var(--text-soft); font-size: 0.95rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
  .hero,
  .game-layout,
  .content-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }
  .hero-copy::after { opacity: 0.18; }
  .chess-board { width: min(100%, 400px); }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 18px;
  }
  .hero-copy,
  .hero-panel,
  .game-shell,
  .panel,
  .faq-panel,
  .related-panel,
  .round-panel {
    border-radius: 14px;
  }
  .hero-copy,
  .hero-panel,
  .game-shell,
  .panel,
  .faq-panel,
  .related-panel {
    padding: 18px;
  }
  .chess-board { width: min(100%, 340px); }
  .status-bar { gap: 6px; }
  .status-item { padding: 8px 6px; }
  .status-label { font-size: 0.63rem; }
  .board-wrap { padding: 14px; }
}
