:root {
  --board-dark: #4a2c14;
  --board-light: #e8c99b;
  --cell-dark: #977356;
  --cell-light: #efdab4;
  --accent: #b5451b;
  --text: #2b2b2b;
  --bg: #faf6ef;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

header {
  background: var(--board-dark);
  color: var(--board-light);
  padding: 2.5rem 1.5rem;
  text-align: center;
}

header h1 {
  margin: 0 0 0.4rem;
  font-size: 2.4rem;
  letter-spacing: 0.05em;
}

header h1 a,
header h1 a:link,
header h1 a:visited,
header h1 a:hover,
header h1 a:active,
header h1 a:focus {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

header p {
  margin: 0;
  opacity: 0.85;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

section {
  margin-bottom: 2.2rem;
  text-align: center;
}

h2 {
  color: var(--accent);
  border-bottom: 2px solid var(--board-light);
  padding-bottom: 0.3rem;
  text-align: center;
}

h2 a,
h2 a:link,
h2 a:visited,
h2 a:hover,
h2 a:active,
h2 a:focus {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.board-preview {
  display: block;
  width: 320px;
  max-width: 100%;
  aspect-ratio: 1;
  margin: 1.5rem auto;
  border: 4px solid var(--board-dark);
  object-fit: cover;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
}

.app-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--board-dark);
  font-family: Calibri, Candara, 'Segoe UI', Optima, sans-serif;
  font-size: 0.9rem;
  padding: 0.6rem;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.app-card:hover {
  background: rgba(74, 44, 20, 0.08);
}

.app-card img {
  width: 96px;
  height: 96px;
  border-radius: 16px;
  object-fit: cover;
  margin-bottom: 0.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.puzzle-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 400px;
  margin: 0 auto 1.5rem;
}

.save-row {
  margin-top: 2rem;
}

.puzzle-form label {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  gap: 0.25rem;
  font-family: Calibri, Candara, 'Segoe UI', Optima, sans-serif;
  font-size: 0.9rem;
}

.puzzle-form label.inline {
  flex-direction: row;
  align-items: center;
}

.puzzle-form label.inline input {
  width: auto;
  padding: 0;
}

.puzzle-form input,
.puzzle-form select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--board-light);
  border-radius: 6px;
  font-family: Calibri, Candara, 'Segoe UI', Optima, sans-serif;
  background: #fff;
}

.puzzle-form select {
  text-align: center;
}

.rules-content {
  max-width: 600px;
  margin: 0 auto;
  text-align: left;
}

.rules-content h3 {
  text-align: center;
}

.rules-content ul {
  padding-left: 1.2rem;
}

.rules-content li {
  margin-bottom: 0.6rem;
}

#variant-board .draughts-board,
.section-board .draughts-board {
  width: 256px;
}

.board-caption {
  text-align: center;
  font-size: 0.8rem;
  color: #888;
  margin-top: -1.3rem;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  font-family: Calibri, Candara, 'Segoe UI', Optima, sans-serif;
  font-size: 0.8rem;
}

.rules-table th,
.rules-table td {
  padding: 0.1rem 0.75rem;
  border-bottom: 1px solid var(--board-light);
}

.rules-table th {
  text-align: left;
  font-weight: normal;
  color: var(--text);
}

.rules-table td {
  text-align: right;
  font-weight: bold;
  color: var(--board-dark);
}

.rules-table tr.no-row th,
.rules-table tr.no-row td {
  color: #888;
}

.rules-table tr.no-row td {
  font-weight: normal;
}

.rules-table-gap td {
  border-bottom: none;
  padding: 0.7rem 0.75rem 0.1rem;
}

.puzzle-form button {
  padding: 0.5rem 1.5rem;
  background: var(--board-dark);
  color: var(--board-light);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: Calibri, Candara, 'Segoe UI', Optima, sans-serif;
}

.puzzle-form button:hover {
  opacity: 0.9;
}

.draughts-board {
  width: 320px;
  max-width: 100%;
  aspect-ratio: 1;
  margin: 1.5rem auto;
  border: 8px solid var(--board-dark);
  padding: 0.5px;
  background: var(--cell-dark);
}

.draughts-grid {
  display: grid;
  width: 100%;
  height: 100%;
  position: relative;
}

.draughts-grid .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 2px rgba(151, 115, 86, 0.35);
}

.draughts-grid .cell.light { background: var(--cell-light); }
.draughts-grid .cell.dark { background: var(--cell-dark); }

.draughts-grid .cell.highlight {
  box-shadow: inset 0 0 2px rgba(151, 115, 86, 0.35), inset 0 0 0 999px rgba(110, 30, 20, 0.4);
}

.draughts-grid .piece {
  width: 82%;
  height: 82%;
  object-fit: contain;
  pointer-events: none;
}

.draughts-grid .cell.clickable {
  cursor: pointer;
}

.tool-bar {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.5rem auto 0;
}

.tool-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0.3rem;
  cursor: pointer;
  line-height: 0;
}

.tool-btn img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.tool-btn.active {
  border-color: var(--accent);
  background: rgba(181, 69, 27, 0.12);
}

.tool-swatch {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--board-dark);
  background: var(--cell-light);
  box-shadow: inset 0 0 0 999px rgba(74, 44, 20, 0.3);
}

.move-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: #888;
  font-size: 0.9rem;
}

.text-link,
.text-link:link,
.text-link:visited,
.text-link:hover,
.text-link:active,
.text-link:focus {
  color: var(--accent);
  text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
}

footer a,
footer a:link,
footer a:visited,
footer a:hover,
footer a:active,
footer a:focus {
  color: var(--accent);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
