:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  background: #edf1e7;
  color: #182e27;
  --green: #175641;
  --border: #d6dfd1;
}
* { box-sizing: border-box; }
body { margin: 0; }
.layout {
  width: min(1050px, calc(100% - 48px));
  margin: clamp(28px, 8vh, 90px) auto;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 620px);
  align-items: start;
  gap: clamp(24px, 5vw, 66px);
}
.intro { padding-top: 12px; }
.label { font-size: .82rem; font-weight: 750; letter-spacing: .12em; color: var(--green); }
h1 { font-size: clamp(2.45rem, 5.2vw, 4.1rem); letter-spacing: -.075em; margin: 10px 0; line-height: 1.1; }
.subtitle { line-height: 1.65; color: #415950; }
details { border-top: 1px solid #c9d5c7; margin-top: 34px; padding-top: 16px; }
summary { cursor: pointer; font-weight: 750; }
ol { padding-left: 1.25rem; color: #415950; line-height: 1.65; }
li + li { margin-top: 8px; }
.game { background: #fffefa; border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 16px 45px #263b2810; overflow: hidden; }
.toolbar, footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px; }
.toolbar { border-bottom: 1px solid var(--border); }
footer { border-top: 1px solid var(--border); justify-content: space-between; }
button { font: inherit; font-size: .87rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.toolbar button, .actions button { color: var(--green); background: white; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.modes { display: flex; gap: 4px; margin-right: auto; }
.toolbar button[aria-pressed="true"] { background: #e1efe5; border-color: #97bda5; }
.toolbar button:disabled { opacity: .48; cursor: default; }
#check { background: var(--green); color: white; border-color: var(--green); }
#status { flex: 1 1 185px; font-size: .88rem; margin: 0; line-height: 1.5; }
#status[data-result="error"] { color: #96372d; }
#status[data-result="success"] { color: var(--green); font-weight: 750; }
.board-wrap { padding: clamp(15px, 4vw, 32px); }
.board { position: relative; width: 100%; aspect-ratio: 1; }
.board > * { position: absolute; transform: translate(-50%, -50%); }
.dot { width: clamp(4px, 1vw, 7px); aspect-ratio: 1; border-radius: 50%; background: #374b40; pointer-events: none; z-index: 1; }
.clue { font-size: clamp(.91rem, 3vw, 1.4rem); font-weight: 680; pointer-events: none; font-variant-numeric: tabular-nums; }
.edge { display: grid; place-items: center; border: 0; background: none; color: #905137; padding: 0; border-radius: 6px; }
.edge.horizontal { width: 6.8%; height: 4.6%; }
.edge.vertical { width: 4.6%; height: 6.8%; }
.edge::after { content: ""; display: block; border-radius: 10px; pointer-events: none; background: #dfe6dc; }
.edge.horizontal::after { width: 147%; height: 1px; }
.edge.vertical::after { height: 147%; width: 1px; }
.edge[data-state="line"]::after { background: #19734f; }
.edge.horizontal[data-state="line"]::after { height: 4px; }
.edge.vertical[data-state="line"]::after { width: 4px; }
.edge[data-state="mark"]::after { content: "×"; background: none; width: auto; height: auto; font-size: 1rem; line-height: 1; }
.edge:focus-visible { outline: 2px solid #9a5838; outline-offset: 1px; z-index: 2; }
@media (hover: hover) { .edge:hover { background: #e1efe5; } }
@media (max-width: 730px) {
  .layout { display: block; width: min(620px, calc(100% - 28px)); }
  details { margin: 18px 0; }
}
@media (max-width: 390px) {
  .toolbar { gap: 5px; padding: 9px; }
  .toolbar button { padding-inline: 8px; }
}
.game { position: relative; }
.fireworks { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.firework-ring, .spark { position: absolute; }
.firework-ring {
  width: var(--diameter);
  aspect-ratio: 1;
  border: 3px solid currentColor;
  border-radius: 50%;
  box-shadow: 0 0 20px currentColor, inset 0 0 14px currentColor;
  animation: firework-ring 740ms ease-out both;
}
.spark {
  width: clamp(16px, 4vw, 34px);
  height: clamp(5px, 1vw, 8px);
  border-radius: 100%;
  background: linear-gradient(90deg, transparent, currentColor 48%, #fff 90%);
  box-shadow: 0 0 10px currentColor, 0 0 18px currentColor;
  animation: firework-burst 1.25s cubic-bezier(.14, .65, .29, 1) both;
}
@keyframes firework-ring {
  0% { opacity: .95; transform: translate(-50%, -50%) scale(.06); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
@keyframes firework-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--angle)) scale(.3); }
  12%, 43% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 18px)) rotate(var(--angle)) scale(.42); }
}
@media (prefers-reduced-motion: reduce) {
  .fireworks { visibility: hidden; }
  #status[data-result="success"] { background: #e1efe5; padding: 8px; border-radius: 8px; }
}
