* { box-sizing: border-box; }

:root {
  --grid-size: 12;
  --cell: 42px;
  --border: #222;
  --inactive: #f0f0f0;
  --active: #fff;
  --selected: #fff2a8;
  --word: #dceeff;
  --good: #dff4df;
  --bad: #ffd8d8;
  --text: #1f1f1f;
  --muted: #666;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fafafa;
  color: var(--text);
}

.app { max-width: 1000px; margin: 0 auto; padding: 24px; }
.hero h1 { margin: 0 0 6px; }
.hero p { margin: 0; color: var(--muted); }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 22px 0;
  padding: 16px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
}

label { display: grid; gap: 4px; font-size: .9rem; color: #444; }
select, button { font: inherit; padding: 9px 10px; border: 1px solid #aaa; border-radius: 8px; }
button { cursor: pointer; background: #1f1f1f; color: #fff; border-color: #1f1f1f; }

.meta, .status { min-height: 24px; margin-bottom: 10px; color: var(--muted); }
.board-section { width: 100%; overflow-x: auto; margin: 12px 0 24px; }

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), var(--cell));
  grid-template-rows: repeat(var(--grid-size), var(--cell));
  width: calc(var(--grid-size) * var(--cell) + 13px);
  border: 2px solid var(--border);
  background: var(--border);
  gap: 1px;
}

.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--active);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  user-select: none;
  cursor: pointer;
}

.cell.inactive { background: var(--inactive); cursor: default; }
.cell.selected { background: var(--selected); }
.cell.word { background: var(--word); }
.cell.correct { background: var(--good); }
.cell.incorrect { background: var(--bad); }
.cell:focus { outline: 2px solid #111; outline-offset: -2px; }

.number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #333;
}

.letter { z-index: 1; }

.clues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 16px;
}

.clues section, .notes {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 16px;
}

.clues h2, .notes h2 { margin: 0 0 10px; font-size: 1.1rem; }
.clues ol { margin: 0; padding: 0; list-style: none; }
.clues li { padding: 8px; border-radius: 8px; cursor: pointer; }
.clues li:hover, .clues li.active { background: #eef5ff; }
.clue-number { font-weight: 800; margin-right: 6px; }
.notes { margin-top: 22px; }
.note { border-top: 1px solid #eee; padding: 10px 0; }
.note:first-child { border-top: 0; }
.note strong { letter-spacing: .03em; }

@media (max-width: 720px) {
  :root { --cell: 32px; }
  .app { padding: 14px; }
  .clues { grid-template-columns: 1fr; }
  .cell { font-size: 18px; }
}
.cell.inactive {
  background: #111 !important;
}

.cell.inactive .letter,
.cell.inactive .number {
  display: none;
}

input {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid #aaa;
  border-radius: 8px;
  min-width: 320px;
}

.metrics {
  margin: 8px 0 14px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  color: #444;
  font-size: 0.95rem;
}

.reveal-study-answer {
  margin-top: 10px;
}

.study-hidden-answer {
  margin-top: 10px;
  font-weight: 700;
}