/* games/dots — Dots & Boxes: pen strokes on graph paper */
.dots{flex:1;display:flex;flex-direction:column;justify-content:center;min-height:0;gap:6px}

/* score: initial + handwritten tally */
.dots-score{display:flex;justify-content:space-between;align-items:center;padding:0 10px;min-height:38px}
.dots-side{display:flex;align-items:center;gap:10px;color:var(--ink)}
.dots-side.p1{color:var(--red);flex-direction:row-reverse}
.dots-side .init{--rot:-5deg;font-family:var(--font-title);font-size:34px;line-height:1;display:inline-block;transform:rotate(var(--rot))}
.dots-side.p1 .init{--rot:4deg}
.dots-side .init.bump{animation:dots-bump 340ms var(--ease-pop)}
.tally{height:26px;overflow:visible;display:block}
.tally path{stroke:currentColor;stroke-width:2.6;fill:none;stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:0}
.tally path.new{animation:dots-draw 160ms var(--ease-pen) both;animation-delay:calc(var(--i,0)*70ms)}

/* board */
.dots-board{width:100%;height:auto;flex:0 1 auto;min-height:0;max-height:calc(100% - 84px);touch-action:none;overflow:visible;display:block}
.dots-hint{font-size:14px;margin-bottom:2px}
.dot{fill:var(--ink);pointer-events:none;transform-box:fill-box;transform-origin:center;animation:dots-pop 360ms var(--ease-pop) both;animation-delay:calc(var(--i,0)*16ms)}

/* edges: hit target, pencil ghost, ink stroke, fading halo for the last move */
.edge{color:var(--ink)}.edge.p1{color:var(--red)}
.edge .hit{stroke:transparent;stroke-width:30;cursor:pointer;pointer-events:stroke}
.edge.on .hit{cursor:default}
.edge .ghost{stroke:var(--pencil-2);stroke-width:3;fill:none;stroke-linecap:round;opacity:0;pointer-events:none;transition:opacity 70ms}
.edge.press .ghost{opacity:.65}
@media (hover:hover){.edge:not(.on):hover .ghost{opacity:.4}}
.edge .stroke{stroke:currentColor;stroke-width:4.2;fill:none;stroke-linecap:round;pointer-events:none;visibility:hidden;stroke-dasharray:1;stroke-dashoffset:0}
.edge.on .stroke{visibility:visible;animation:dots-draw 180ms linear both}
.edge.on.static .stroke{animation:none}
.edge .halo{stroke:currentColor;stroke-width:11;fill:none;stroke-linecap:round;opacity:0;pointer-events:none}
.edge.last .halo{animation:dots-halo 2.4s linear 160ms both}

/* boxes: hatch scribble + handwritten initial */
.box{color:var(--ink)}.box.p1{color:var(--red)}
.box .fill{fill:currentColor;opacity:0;pointer-events:none}
.box .hatch path{stroke:currentColor;stroke-width:2.4;fill:none;stroke-linecap:round;opacity:.36;stroke-dasharray:1;stroke-dashoffset:0;visibility:hidden}
.box.on .hatch path{visibility:visible;animation:dots-draw 110ms var(--ease-pen) both;animation-delay:calc(var(--d,0ms) + var(--i,0)*28ms)}
.box.on.static .hatch path{animation:none}
.box .init{--rot:0deg;font-family:var(--font-title);font-weight:700;font-size:30px;fill:currentColor;opacity:0;pointer-events:none;transform-box:fill-box;transform-origin:center;transform:rotate(var(--rot))}
.box.on .init{opacity:1;animation:dots-pop 280ms var(--ease-pop) both;animation-delay:calc(var(--d,0ms) + 200ms)}
.box.on.static .init{animation:none}
.box .scribble{stroke:var(--pencil);stroke-width:2.2;fill:none;stroke-linecap:round;stroke-linejoin:round;opacity:0;stroke-dasharray:1;stroke-dashoffset:0;pointer-events:none}

/* end of game: winner's boxes flash in a diagonal sweep, loser's get pencilled out */
.box.win .fill{animation:dots-flash 300ms var(--ease-pen) both;animation-delay:var(--w,0ms)}
.box.win .init{animation:dots-bump 300ms var(--ease-pop) both;animation-delay:var(--w,0ms)}
.box.lose .scribble{opacity:.55;animation:dots-draw 320ms var(--ease-pen) both;animation-delay:var(--w,0ms)}
.box.lose .hatch path{opacity:.18;transition:opacity 300ms}
.box.lose .init{opacity:.45;transition:opacity 300ms}

@keyframes dots-draw{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}
@keyframes dots-pop{from{transform:scale(0) rotate(var(--rot,0deg));opacity:0}60%{transform:scale(1.25) rotate(var(--rot,0deg));opacity:1}to{transform:scale(1) rotate(var(--rot,0deg));opacity:1}}
@keyframes dots-bump{0%{transform:scale(1) rotate(var(--rot,0deg))}45%{transform:scale(1.3) rotate(calc(var(--rot,0deg) - 8deg))}100%{transform:scale(1) rotate(var(--rot,0deg))}}
@keyframes dots-halo{from{opacity:.32;stroke-width:13}to{opacity:0;stroke-width:6}}
@keyframes dots-flash{0%{opacity:0}45%{opacity:.26}100%{opacity:.1}}
