:root {
  --bg: #f4f2ea;
  --card: #fffdf8;
  --fg: #1f2a1f;
  --muted: #5d6b5d;
  --line: #8a9a8a;
  --border: #d9ddd2;
  --accent: #2f6b3a;
  --accent-soft: #e3efe2;
  --ok: #2f8a45;
  --bad: #a9aca3;
  --chip: #e6ecdf;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121512;
    --card: #1a1f1a;
    --fg: #e6ece3;
    --muted: #9aa79a;
    --line: #6a786a;
    --border: #323b32;
    --accent: #7cc48a;
    --accent-soft: #233225;
    --ok: #5cc26f;
    --bad: #4c544c;
    --chip: #263026;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 480px; margin: 0 auto; padding: 12px 16px 32px; }

.top { display: flex; align-items: center; justify-content: space-between; }
h1 { margin: 0; font-size: 1.5rem; }
h1 span { color: var(--muted); font-weight: 400; font-size: 1rem; }
h2 { margin: 0 0 8px; font-size: 1.2rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

.status {
  min-height: 3em;
  margin: 8px 0 10px;
  font-weight: 600;
}
.status .sp { color: var(--accent); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
svg .edge { stroke: var(--line); stroke-width: 2; fill: none; }
svg .node { fill: var(--card); stroke: var(--line); stroke-width: 2; }
svg .node.ok { fill: var(--ok); stroke: var(--ok); }
svg .node.bad { fill: var(--bad); stroke: var(--bad); }
svg .slot { cursor: grab; outline: none; touch-action: none; }
svg .slot { transition: transform 120ms ease-out; }
svg .slot.dragging { transition: none; }
svg .slot rect { fill: var(--chip); stroke: var(--border); stroke-width: 1.5; }
svg .slot text { fill: var(--fg); font-size: 15px; dominant-baseline: middle; pointer-events: none; }
svg .slot .grip { fill: var(--muted); font-size: 18px; letter-spacing: -2px; }
svg .slot:hover rect { stroke: var(--accent); }
svg .slot.picked rect { fill: var(--accent); stroke: var(--accent); }
svg .slot.picked text { fill: var(--card); font-weight: 600; }
svg .slot.target rect { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 5 4; fill: var(--accent-soft); }
svg .slot.dragging { cursor: grabbing; }
svg .slot.dragging rect { fill: var(--accent); stroke: var(--accent); filter: drop-shadow(0 4px 6px rgb(0 0 0 / 0.25)); }
svg .slot.dragging text { fill: var(--card); font-weight: 600; }
svg .slot:focus-visible rect { stroke: var(--fg); stroke-width: 2.5; }
svg .slot.hint-a { animation: hintA 1.6s ease-in-out 0.6s 2; }
svg .slot.hint-b { animation: hintB 1.6s ease-in-out 0.6s 2; }
@keyframes hintA { 0%, 100% { transform: translateY(0); } 40%, 60% { transform: translateY(52px); } }
@keyframes hintB { 0%, 100% { transform: translateY(0); } 40%, 60% { transform: translateY(-52px); } }
@media (prefers-reduced-motion: reduce) { svg .slot.hint-a, svg .slot.hint-b { animation: none; } }
.locked svg .slot { cursor: default; }
.locked .actions, .locked .tries, .locked .grip { display: none; }

.axis { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); padding: 2px 4px 0; }
.legend { display: flex; gap: 16px; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.ok-text { color: var(--ok); font-weight: 600; }
.bad-text { color: var(--muted); font-weight: 600; }

button { font: inherit; cursor: pointer; border-radius: 999px; padding: 10px 16px; border: 1.5px solid transparent; }
button:disabled { cursor: default; opacity: 0.45; }
.primary { background: var(--accent); color: var(--card); font-weight: 600; }
.icon { width: 36px; height: 36px; padding: 0; background: var(--chip); color: var(--fg); font-weight: 700; }
.wide { width: 100%; }

.actions { display: flex; gap: 10px; }
.actions .primary { flex: 1; }
.tries { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 8px 0 12px; letter-spacing: 0.02em; }

.result pre { background: var(--chip); padding: 10px; border-radius: 8px; white-space: pre-wrap; font-size: 0.95rem; }

dialog {
  border: none;
  border-radius: 16px;
  padding: 20px;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--card);
  color: var(--fg);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.steps { padding-left: 1.2em; }
.steps li { margin-bottom: 10px; }
