:root {
  --bg: #f5ede6;
  --card: #fffdfb;
  --ink: #6b4c46;
  --accent: #e0745f;
  --line: #e8dcd2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header { text-align: center; padding: 24px 16px 8px; }
h1 { margin: 0; font-size: 1.8rem; }
.subtitle { margin: 6px 0 0; font-size: 0.85rem; opacity: 0.75; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 40px; }
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  margin: 16px 0;
  box-shadow: 0 2px 10px rgba(107, 76, 70, 0.08);
}
h2 { margin: 0 0 12px; font-size: 1.1rem; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

button {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
  background: #efe4da;
  color: var(--ink);
}
button:hover { filter: brightness(0.96); }
button.primary { background: var(--accent); color: #fff; font-weight: bold; }
button.ghost { background: transparent; border: 1px solid var(--line); }
select, input[type="range"] { font: inherit; }
select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: #fff; color: var(--ink); }

/* dropzone */
#dropzone {
  flex: 1 1 260px;
  min-height: 90px;
  border: 2px dashed #d8c4b6;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
#dropzone.drag { background: #fdf1e7; border-color: var(--accent); }
.cv-options { display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; }
#cv-canvas { max-width: 100%; border-radius: 10px; margin-top: 12px; display: block; }
#cv-info { font-size: 0.85rem; margin-top: 8px; }
#cv-info .warn { color: #b06a00; }
#cv-info .ok-msg { color: #2a8c53; font-weight: bold; }

/* board */
.board {
  display: grid;
  gap: 2px;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  margin: 14px auto;
  width: fit-content;
  max-width: 100%;
  touch-action: none;
  user-select: none;
}
.cell {
  width: var(--cell, 44px);
  height: var(--cell, 44px);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell, 44px) * 0.58);
  position: relative;
  background: #eee6de;
  cursor: pointer;
}
.cell.empty-label { background: repeating-linear-gradient(45deg, #f3ece5, #f3ece5 6px, #eae0d7 6px, #eae0d7 12px); }
.cell .mark { pointer-events: none; line-height: 1; }
.cell .elim {
  color: rgba(255, 255, 255, 0.9);
  font-weight: bold;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.25);
  font-size: calc(var(--cell, 44px) * 0.45);
}
.cell.hl { outline: 3px solid #ff5722; outline-offset: -3px; z-index: 1; }
.cell.hl-cause { outline: 3px dashed #ff9800; outline-offset: -3px; }

.toolbar { margin-bottom: 4px; }
#palette { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.active { border-color: var(--ink); transform: scale(1.12); }
.swatch.eraser { background: #fff; font-size: 14px; }

.info { font-size: 0.85rem; margin-top: 6px; min-height: 1.2em; }
.info .err { color: #c0392b; }

/* viewer */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}
.controls button { padding: 8px 12px; }
#step-slider { flex: 1 1 160px; }
#step-desc {
  background: #fdf4ec;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  min-height: 2.4em;
}
#step-list {
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.8rem;
  padding-left: 2em;
  margin: 10px 0 0;
  border-top: 1px solid var(--line);
}
#step-list li { padding: 3px 6px; border-radius: 6px; cursor: pointer; }
#step-list li:hover { background: #f6ece3; }
#step-list li.current { background: #fbe3d8; font-weight: bold; }
#step-list li.t-assume { color: #8e44ad; }
#step-list li.t-backtrack { color: #c0392b; }
#step-list li.t-place { color: #2a8c53; }
#step-list li.t-solved { color: var(--accent); font-weight: bold; }

footer { text-align: center; font-size: 0.75rem; opacity: 0.6; padding: 12px; }

@media (max-width: 520px) {
  .cell { --cell: 32px; }
}
