:root {
  --bg: #f4f1ea;
  --ink: #2b2b2b;
  --accent: #2e7d32;
  --accent-dark: #1b5e20;
  --gold: #f9a825;
  --card: #ffffff;
  --line: #d8d2c4;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  text-align: center;
  padding: 1.25rem 1rem 0.75rem;
}
.site-header h1 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--accent-dark);
  letter-spacing: 0.04em;
}
.tagline {
  margin: 0.25rem 0 0;
  color: #555;
  font-size: 0.95rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
}
.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#difficulty {
  padding: 0.4rem 0.5rem;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
}
#newGameBtn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
#newGameBtn:hover { background: var(--accent-dark); }
.timer-group {
  background: var(--card);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.timer-label, .best-label { color: #555; font-size: 0.8rem; }
.timer { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-dark); }
.best { font-variant-numeric: tabular-nums; color: #444; }

.play-area {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
  flex: 1;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 2px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  max-width: 90vw;
  width: min(560px, 92vw);
}
.cell {
  aspect-ratio: 1 / 1;
  background: var(--card);
  border: none;
  font-family: "Courier New", monospace;
  font-size: clamp(0.6rem, 2vw, 1rem);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}
.cell:hover { background: #fbf7ec; }
.cell.selected {
  background: var(--gold);
  color: #000;
}
.cell.found-cell {
  background: var(--accent);
  color: white;
}

.sidebar {
  min-width: 180px;
  max-width: 240px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
}
.sidebar h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--accent-dark);
}
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 1rem;
}
.checklist li {
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  padding: 0.15rem 0;
  break-inside: avoid;
  color: #333;
}
.checklist li.found {
  text-decoration: line-through;
  color: #999;
}

.banner {
  text-align: center;
  margin: 0.5rem auto;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 700;
  color: var(--ink);
  width: fit-content;
  box-shadow: var(--shadow);
}
.banner.win {
  background: var(--gold);
  border-color: var(--gold);
  color: #000;
}
.hidden { display: none; }

.site-footer {
  text-align: center;
  padding: 1rem;
  color: #777;
  font-size: 0.85rem;
}

@media (max-width: 540px) {
  .checklist { columns: 1; }
  .sidebar { max-width: none; width: 100%; }
}