.stroke-play { --game-play-width: 545px; }
.stroke-toolbar, .stroke-stats, .stroke-actions, .stroke-victory-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.stroke-toolbar, .stroke-stats, .stroke-status {
  color: var(--game-secondary);
  font-size: 14px;
  line-height: 1.65;
}
.stroke-toolbar select { min-width: 0; max-width: 100%; }
.stroke-stats {
  gap: 5px clamp(12px, 2.4vw, 25px);
  margin: 13px 0 10px;
  font-variant-numeric: tabular-nums;
}
.stroke-stats strong { color: var(--game-ink); white-space: nowrap; }

.stroke-board {
  --stroke-paper: #f5f7fc;
  --stroke-grid: #647b9e16;
  --stroke-frame: #bac9dc;
  --stroke-idle: #bac7d7;
  --stroke-trace: #1d6b6c;
  --stroke-hint: #ac6500;
  --stroke-dot-bg: #fff;
  --stroke-dot-edge: #496886;
  --stroke-dot-ink: #254560;
  --stroke-start: #287463;
  --stroke-finish: #89571f;
  --stroke-glow: #2e787633;
  position: relative;
  isolation: isolate;
  width: min(100%, 445px);
  aspect-ratio: 1;
  margin-inline: auto;
  border-radius: 15px;
  background:
    linear-gradient(var(--stroke-grid) 1px, transparent 1px) center / 8% 8%,
    linear-gradient(90deg, var(--stroke-grid) 1px, transparent 1px) center / 8% 8%,
    var(--stroke-paper);
  box-shadow: inset 0 0 0 1px var(--stroke-frame), 0 3px 0 #2443661a;
  touch-action: none;
  user-select: none;
}
html[data-theme=dark] .stroke-board {
  --stroke-paper: #253146;
  --stroke-grid: #92aac217;
  --stroke-frame: #526784;
  --stroke-idle: #7f95ad;
  --stroke-trace: #82d6b9;
  --stroke-hint: #ffc373;
  --stroke-dot-bg: #344760;
  --stroke-dot-edge: #a1b9d0;
  --stroke-dot-ink: #f5f6ff;
  --stroke-start: #9de6d2;
  --stroke-finish: #ffc995;
  --stroke-glow: #83d7bf35;
}
.stroke-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.stroke-edge {
  stroke: var(--stroke-idle);
  stroke-width: 3.5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.stroke-edge[data-used] {
  stroke: var(--stroke-trace);
  stroke-width: 4.5;
}
.stroke-edge[data-hinted] {
  stroke: var(--stroke-hint);
  stroke-width: 4.5;
  stroke-dasharray: .09 .06;
}
.stroke-dot {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  z-index: 1;
  padding: 0;
  border: 0;
  border-radius: 100%;
  background: transparent;
  color: var(--stroke-dot-ink);
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transform: translate(-50%, -50%);
}
.stroke-dot > span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: 2px solid var(--stroke-dot-edge);
  border-radius: 50%;
  background: var(--stroke-dot-bg);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  transition: box-shadow 150ms, background-color 150ms;
  pointer-events: none;
}
.stroke-dot:is([data-start], [data-end]) > span { width: 23px; height: 23px; }
.stroke-dot[data-start] > span { border-color: var(--stroke-start); color: var(--stroke-start); }
.stroke-dot[data-end]:not([data-start]) > span { border-color: var(--stroke-finish); color: var(--stroke-finish); }
.stroke-dot[data-visited]:not([data-current]) > span { border-color: var(--stroke-trace); }
.stroke-dot[data-current] { z-index: 2; }
.stroke-dot[data-current] > span {
  border-color: var(--stroke-trace);
  background: var(--stroke-trace);
  color: var(--stroke-paper);
  box-shadow: 0 0 0 5px var(--stroke-glow);
}
.stroke-dot[data-hinted] > span { box-shadow: 0 0 0 3px var(--stroke-hint); }
.stroke-dot:focus-visible { outline: 2px solid var(--stroke-dot-edge); outline-offset: 1px; }
.stroke-dot:disabled { cursor: default; }
@media (hover: hover) {
  .stroke-dot:hover:not(:disabled):not([data-current]) > span {
    box-shadow: 0 0 0 4px var(--stroke-glow);
  }
}
@media (max-width: 510px) {
  .stroke-dot { width: 29px; height: 29px; }
  .stroke-dot > span { width: 15px; height: 15px; }
  .stroke-dot:is([data-start], [data-end]) > span { width: 20px; height: 20px; }
  body[data-fourhao-game=one-stroke] .stroke-actions .game-page-button { padding-inline: 12px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .stroke-dot > span { transition: none; }
}

.stroke-actions { margin-top: 15px; }
.stroke-status { min-height: 1.65em; margin: 8px 0 0; text-align: center; }
.stroke-status[data-error] { color: #a14239; }
html[data-theme=dark] .stroke-status[data-error] { color: #ffb8ad; }
#show-victory[hidden], #next-level[hidden] { display: none; }

.stroke-victory {
  box-sizing: border-box;
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--game-line);
  border-radius: 14px;
  background: var(--game-surface);
  color: var(--game-secondary);
  box-shadow: 0 18px 54px #14243840;
  overscroll-behavior: contain;
}
.stroke-victory::backdrop { background: #1326348c; }
.stroke-victory-body { padding: 24px clamp(18px, 6vw, 32px); text-align: center; }
.stroke-victory h2 { margin: 0; color: var(--game-accent); font-size: 22px; line-height: 1.45; }
.stroke-victory p { margin: 9px 0 16px; line-height: 1.65; }

@media (prefers-reduced-motion: no-preference) {
  .stroke-victory[open] { animation: stroke-result-in 220ms ease-out; }
  @keyframes stroke-result-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
