/* Page colors are tokens, swapped for dark mode. The grid's own cell colors are the puzzle's
   and stay the same in both. */
:root {
  --bg: #f7f3ee;
  --panel: #ffffff;
  --ink: #3b2f33;
  --muted: #7a6b70;
  --line: #e4dbd3;
  --accent: #b85c38;
  --accent-ink: #ffffff;
  --focus: #2f6fd6;
  --wrong: #d0342c;
  --new: #f5b800;
  --mark: rgba(45, 35, 40, 0.55);
  --unpainted: #fbfaf8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a1c;
    --panel: #2a2629;
    --ink: #f1e9e4;
    --muted: #b3a6a9;
    --line: #463f43;
    --accent: #e08a62;
    --accent-ink: #1d1a1c;
    --focus: #7fb0ff;
    --unpainted: #3a3437;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1a1c;
  --panel: #2a2629;
  --ink: #f1e9e4;
  --muted: #b3a6a9;
  --line: #463f43;
  --accent: #e08a62;
  --accent-ink: #1d1a1c;
  --focus: #7fb0ff;
  --unpainted: #3a3437;
}

* { box-sizing: border-box; }
/* `hidden` must win over any display set below (the foot bar is display: flex). */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.top, main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 20px; }
h1 { margin: 0 0 4px; font-size: 1.5rem; }
.lede { margin: 0 0 16px; color: var(--muted); }

button, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}
button:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
button.quiet { background: transparent; color: var(--muted); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.mode[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.tools { margin-bottom: 12px; }
.tool-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.size select { margin-left: 6px; min-height: 44px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.help { margin: 6px 0; color: var(--muted); font-size: 0.92rem; }

.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 8px 0; }
.swatch {
  min-height: 44px;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 10px;
  background: var(--c);
  position: relative;
}
.swatch[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg) inset; }
.swatch .used {
  position: absolute; right: 4px; bottom: 2px;
  font-size: 0.7rem; color: rgba(30, 25, 28, 0.75);
}

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actions button { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: 8px 6px; }

.message {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  border-left: 4px solid var(--accent);
}
.message.warn { border-left-color: var(--wrong); }

.board {
  display: grid;
  /* Rows fixed equal: sized by content, rows without a mark collapsed on a phone. */
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  gap: 3px;
  padding: 6px;
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  aspect-ratio: 1;
  user-select: none;
  -webkit-user-select: none;
}
.board.painting { touch-action: none; }
.cell {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--c, var(--unpainted));
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
}
.cell.unpainted { outline: 1px dashed var(--line); outline-offset: -1px; }
/* Out of the flow, so a mark can never change a cell's size. */
.cell svg { position: absolute; inset: 11%; width: 78%; height: 78%; pointer-events: none; }
.cell .x line { stroke: var(--mark); stroke-width: 5; stroke-linecap: round; }
/* A cat the site placed (hint, reveal, answer) gets a gold ring; the visitor's own has none. */
.cell.site-cat::after {
  content: ""; position: absolute; inset: 2px;
  border: 2px solid var(--new); border-radius: 5px; pointer-events: none;
}
.cell.focus { box-shadow: 0 0 0 3px var(--focus) inset; }
.cell.new { animation: pop 0.6s ease-out; }
.cell.wrong { box-shadow: 0 0 0 3px var(--wrong) inset; }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .cell.new { animation: none; } }

.foot { display: flex; justify-content: flex-end; margin-top: 8px; }

.shot-in { margin-bottom: 16px; }
button.primary {
  width: 100%;
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-weight: 600; font-size: 1.05rem;
}
.drop-zone {
  display: none;
  margin-top: 8px;
  padding: 14px 12px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.drop-zone p { margin: 0 0 4px; }
.drop-zone strong { color: var(--ink); }
.drop-zone button { min-height: 36px; margin-top: 4px; }
kbd {
  font: inherit; font-size: 0.85em;
  padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--panel); color: var(--ink);
}
@media (hover: hover) and (pointer: fine) {
  .drop-zone { display: block; }
}
body.dropping .drop-zone { border-color: var(--accent); background: var(--panel); color: var(--ink); }
button.link {
  min-height: 0; padding: 0; margin-left: 4px; border: 0; background: none;
  color: var(--accent); font-weight: 600; text-decoration: underline;
}
.shot { margin-top: 12px; }
.shot summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.shot img { display: block; width: 100%; height: auto; border-radius: 14px; }

.more { margin: 20px 0 32px; }
.more summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
textarea {
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.15em;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
