:root {
  --bg: #f6f4ee;
  --panel: #fffdf8;
  --ink: #2b2721;
  --muted: #6f6752;
  --line: #ddd6c6;
  --accent: #2f6f4e;
  --bad: #a3352b;
  --warn: #8a6d1f;
  --good: #2f6f4e;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1b17;
    --panel: #26231e;
    --ink: #ece7dc;
    --muted: #a49b86;
    --line: #3b362d;
    --accent: #7fc39b;
    --bad: #e08b80;
    --warn: #d8bd6a;
    --good: #7fc39b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 20px 48px;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  max-width: 1000px;
  margin-inline: auto;
}

h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -0.01em; }
.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { flex: 1 1 380px; }
.field label { font-size: 12px; color: var(--muted); }
.field.check { justify-content: end; }
.field.check label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }

input[type="text"], input:not([type]) {
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  min-width: 0;
}
#stip { width: 110px; }

.buttons { flex-direction: row; gap: 8px; }

button {
  font: inherit;
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.55; cursor: default; }
#solve { background: var(--accent); border-color: var(--accent); color: #fff; }
#solve:disabled { background: var(--muted); border-color: var(--muted); }

#status { margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.note {
  margin: 0;
  padding: 9px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--muted);
  background: var(--panel);
  font-size: 13.5px;
}
.note.bad { border-left-color: var(--bad); color: var(--bad); }
.note.warn { border-left-color: var(--warn); color: var(--warn); }
.note.good { border-left-color: var(--good); color: var(--good); }

main {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 18px;
  align-items: start;
}
.left { flex: 0 0 auto; }
.right { flex: 1 1 320px; min-width: 280px; }

.board { width: min(392px, 92vw); }
.board svg { width: 100%; height: auto; display: block; }

.nav { display: flex; gap: 6px; margin-top: 10px; }
.nav button { padding: 6px 12px; font-family: ui-monospace, monospace; font-size: 13px; }
.nav #edit { font-family: inherit; margin-left: 8px; }

.nav #edit.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.board.editing svg { cursor: crosshair; }

.editor {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  width: min(392px, 92vw);
}
.palette { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.swatch {
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background: var(--bg);
}
.swatch svg { display: block; width: 100%; height: auto; }
.swatch.eraser { font-size: 17px; line-height: 1; }
.swatch.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.editor-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }

.strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.ply {
  padding: 3px 8px;
  font: 12.5px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  border-radius: 5px;
}
.ply.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.solution {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: auto;
  max-height: 520px;
}
.solution:empty { display: none; }

.move {
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  padding: 3px 8px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}
.move:hover { background: rgba(127, 127, 127, 0.14); }
.move.key { font-weight: 700; }
.move.try { color: var(--muted); font-style: italic; }
.move.threat { color: var(--warn); }
.move.on { background: rgba(47, 111, 78, 0.14); }
.move.tip { background: var(--accent); color: #fff; }

details {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px 14px;
}
summary { cursor: pointer; font-size: 13px; color: var(--muted); }
pre {
  margin: 10px 0 0;
  overflow: auto;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 420px;
}

footer { margin-top: 30px; font-size: 12px; color: var(--muted); }
footer a { color: inherit; }
