:root {
  --bg: #ffffff;
  --card: #f6f5f2;
  --ink: #17171a;
  --soft: rgba(23, 23, 26, 0.52);
  --line: rgba(23, 23, 26, 0.1);
  --accent: #4b5bf0;
  --bad: #e5484d;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 10px 12px;
}

.sd { position: relative; width: min(276px, 100%); padding: 12px; border-radius: 22px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 #ffffff, 0 22px 34px -22px rgba(23, 23, 26, 0.45); }

.sd__top { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 2px; }
.sd__title { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sd__name { display: block; height: 19px; overflow: hidden; font-size: 14.500px; line-height: 19px; font-weight: 720; font-stretch: 104%; letter-spacing: -0.006em; }
.sd__name span { display: block; white-space: nowrap; }
.sd__status { font-size: 11.500px; line-height: 15px; color: var(--soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* the clock: a pill that turns to the accent when the puzzle is solved */
.sd__time { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px 0 7px; border-radius: 13px; background: #ffffff; box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px -1px rgba(23, 23, 26, 0.2); color: var(--ink); transition: background-color 0.4s ease, color 0.4s ease, box-shadow 0.4s ease; }
.sd__time svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.500; stroke-linecap: round; stroke-linejoin: round; }
.sd__time svg circle { opacity: 0.4; }
.sd__tick { stroke-dasharray: 1; stroke-dashoffset: 1; }
.sd__time b { font-size: 12px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.sd__time[data-won] { background: var(--accent); color: #ffffff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 12px -8px var(--accent); }
.sd__time[data-won] .sd__hand { opacity: 0; }
.sd__time[data-won] svg circle { opacity: 0.55; }

/* the board: three bands of two boxes, each box three squares wide and two tall */
.sd__board { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.sd__box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.sd__cell { position: relative; display: grid; place-items: center; height: 38px; border: 0; border-radius: 9px; background: #ffffff; box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px -1px rgba(23, 23, 26, 0.2); color: var(--accent); font: inherit; cursor: pointer; outline: none; transition: background-color 0.22s ease, box-shadow 0.22s ease; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.sd__cell b { display: block; font-size: 17px; line-height: 20px; font-weight: 720; font-variant-numeric: tabular-nums; transition: font-weight 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), color 0.25s ease; }
.sd__cell[data-given] { color: var(--ink); }
.sd__cell[data-given] b { font-weight: 560; }
.sd__cell[data-peer] { background: color-mix(in srgb, var(--accent) 7%, #ffffff); }
.sd__cell[data-same] { background: color-mix(in srgb, var(--accent) 18%, #ffffff); }
.sd__cell[data-same] b { font-weight: 800; }
.sd__cell[data-sel] { background: color-mix(in srgb, var(--accent) 12%, #ffffff); }
.sd__cell[data-bad] { color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, #ffffff); }
.sd__cell[data-clash] { background: color-mix(in srgb, var(--bad) 20%, #ffffff); box-shadow: inset 0 0 0 1.500px color-mix(in srgb, var(--bad) 55%, transparent); }
.sd__cell[data-lit] { background: color-mix(in srgb, var(--accent) 22%, #ffffff); }
.sd__cell:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }
@media (hover: hover) { .sd__cell:not([data-sel]):not([data-peer]):not([data-same]):not([data-bad]):not([data-clash]):not([data-lit]):hover { background: #fbfbfa; box-shadow: inset 0 0 0 1px rgba(23, 23, 26, 0.2), 0 1px 2px -1px rgba(23, 23, 26, 0.2); } }
/* the ring of the chosen square: one element that glides from square to square */
.sd__ring { position: absolute; left: 0; top: 0; width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent), 0 6px 10px -6px color-mix(in srgb, var(--accent) 70%, #000000); opacity: 0; pointer-events: none; z-index: 2; }

/* the number pad */
.sd__pad { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.sd__key { display: grid; place-items: center; height: 36px; border: 0; border-radius: 11px; background: var(--ink); color: #ffffff; font: inherit; cursor: pointer; outline: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 12px -9px rgba(23, 23, 26, 0.7); transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.sd__key b { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sd__key--erase { background: #ffffff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px -1px rgba(23, 23, 26, 0.2); }
.sd__key--erase svg { width: 19px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.500; stroke-linecap: round; stroke-linejoin: round; }
/* a number that is all on the board steps back */
.sd__key[data-done] { background: rgba(23, 23, 26, 0.08); color: rgba(23, 23, 26, 0.34); box-shadow: none; }
.sd__key:focus-visible { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
@media (hover: hover) { .sd__key:not([data-done]):not(.sd__key--erase):hover { background: #2a2a2f; } .sd__key--erase:hover { background: #fbfbfa; } }
.sd__pad[data-won] .sd__key { opacity: 0; pointer-events: none; }
.sd__again { position: absolute; inset: 0; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--accent); color: #ffffff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; outline: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 16px -10px var(--accent); opacity: 0; visibility: hidden; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.sd__pad[data-won] .sd__again { visibility: visible; }
.sd__again:focus-visible { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }

.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ghost { position: absolute; left: 0; top: 0; width: 24px; height: 24px; margin: -3px 0 0 -5px; transform-origin: 20% 15%; pointer-events: none; opacity: 0; fill: #17171a; stroke: #ffffff; stroke-width: 1.300; stroke-linejoin: round; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); z-index: 6; }
