/* Halma: status and the last move on top, the players' plates, the square board in the room that is left,
   the buttons of a jump chain (and the zoom of the big board) at the foot. On a wide screen the board stands
   on the left and everything else beside it.
   The board is pale maple with a faint checker; the camps are tinted in the colour of the player who starts
   there (red, blue, green, yellow by seat, as in Člověče); the pieces are glossy glass marbles. */
.halma{
  --halma-c0:#d8433b;--halma-c1:#2f6fd6;--halma-c2:#2e9b52;--halma-c3:#f0c419;
  --halma-t0:#f2c2bb;--halma-t1:#c3d3f2;--halma-t2:#bfe0c8;--halma-t3:#f5e3a0;
  --halma-wood:#efe2c6;--halma-wood2:#e6d6b5;--halma-edge:#5a3a22;
  --halma-gold:var(--medal,#ffc65c);
  position:absolute;inset:0;
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) auto;
  grid-template-areas:"top" "plates" "main" "bar";
  overflow:hidden;
}
.halma .k0{--pc:var(--halma-c0);--pt:var(--halma-t0)}
.halma .k1{--pc:var(--halma-c1);--pt:var(--halma-t1)}
.halma .k2{--pc:var(--halma-c2);--pt:var(--halma-t2)}
.halma .k3{--pc:var(--halma-c3);--pt:var(--halma-t3)}

.halma-top{grid-area:top;display:grid;justify-items:center;gap:2px;padding:6px 10px 0}
.halma-status{padding:.4em .9em;font-size:.93rem}
.halma-say{
  margin:0;min-height:1.3em;max-width:28rem;font-size:.86rem;line-height:1.3;text-align:center;color:var(--mist);
}
.halma-say.big{color:var(--ivory);font-weight:600}

/* ── plates ──────────────────────────────────────────────────────────── */
.halma-plates{
  grid-area:plates;
  display:grid;grid-template-columns:repeat(var(--halma-n,2),minmax(0,1fr));gap:5px;
  padding:5px 8px;max-width:34rem;width:100%;justify-self:center;box-sizing:border-box;
}
.halma-plate{
  display:flex;align-items:center;gap:5px;min-width:0;min-height:44px;padding:3px 6px 3px 3px;
  border:1.5px solid var(--line);border-left:5px solid var(--pc);border-radius:12px;
  background:rgba(0,0,0,.22);box-sizing:border-box;
  transition:border-color .2s,background-color .2s;
}
.halma-plate .ava{width:30px;height:30px;font-size:.9rem;flex:none}
.halma-who{display:grid;line-height:1.15;min-width:0;flex:1}
.halma-who .nm{font-weight:600;font-size:.82rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.halma-who .sub{font-size:.68rem;color:var(--mist);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.halma-plate.turn{border-color:var(--pc);background:rgba(255,255,255,.1);box-shadow:0 0 0 1px var(--pc)}
.halma-plate.turn .ava{box-shadow:0 0 0 2.5px var(--pc)}
.halma-plate.best{border-color:var(--gold)}
/* how much of the way is done */
.halma-bar-p{display:block;height:4px;margin-top:3px;border-radius:2px;background:rgba(255,255,255,.14);overflow:hidden}
.halma-bar-p i{display:block;height:100%;background:var(--pc);border-radius:2px;transition:width .4s}

/* ── the board ───────────────────────────────────────────────────────── */
.halma-main{grid-area:main;min-width:0;min-height:0;overflow:hidden;padding:3px;display:flex}
.halma-scroll{flex:1;min-width:0;min-height:0;display:flex;overflow:hidden}
.halma-scroll.zoomed{overflow:auto;touch-action:pan-x pan-y;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  border-radius:8px;box-shadow:inset 0 0 0 1.5px var(--line)}
.halma-board{
  --cell:32px;--n:10;
  position:relative;isolation:isolate;margin:auto;flex:none;
  display:grid;grid-template-columns:repeat(var(--n),var(--cell));grid-template-rows:repeat(var(--n),var(--cell));
  border:max(3px,calc(var(--cell)*.12)) solid var(--halma-edge);border-radius:8px;
  box-shadow:0 14px 28px -14px rgba(0,0,0,.9),inset 0 0 0 1px rgba(255,255,255,.1);
  background:var(--halma-wood);
}
.halma-sq{
  position:relative;min-width:0;min-height:0;padding:0;border:0;border-radius:0;font:inherit;
  background:var(--halma-wood);box-shadow:inset 0 0 0 .5px rgba(90,58,34,.22);
  cursor:pointer;-webkit-tap-highlight-color:transparent;
}
.halma-sq.alt{background:var(--halma-wood2)}
.halma-sq:focus-visible{outline:2px solid var(--halma-edge);outline-offset:-3px}
/* the camps: the starting player's colour; a camp nobody starts in (three players) only striped */
.halma-sq.camp{background:var(--pt)}
.halma-sq.camp.alt{background:linear-gradient(rgba(0,0,0,.05),rgba(0,0,0,.05)),var(--pt)}
.halma-sq.camp.goal{background:repeating-linear-gradient(135deg,var(--pt) 0 4px,var(--halma-wood) 4px 8px)}
/* my target camp: a dashed ring inside every square */
.halma-sq.mygoal::before{
  content:"";position:absolute;inset:12%;border-radius:50%;border:1.5px dashed rgba(90,58,34,.45);pointer-events:none;
}
.halma-slot{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none}

/* the last move, the move being built, the piece chosen and where it may go */
.halma-sq.last{box-shadow:inset 0 0 0 calc(var(--cell)*.07) rgba(90,58,34,.28)}
.halma-sq.trail{background:#d9c79e}
.halma-sq.sel{box-shadow:inset 0 0 0 3px var(--halma-gold)}
/* where the piece being moved started: a ghost of it */
.halma-sq.origin::after{
  content:"";position:absolute;left:50%;top:50%;width:62%;height:62%;transform:translate(-50%,-50%);
  border-radius:50%;border:2px dashed rgba(90,58,34,.6);box-sizing:border-box;pointer-events:none;
}
.halma-sq.tgt::after{
  content:"";position:absolute;left:50%;top:50%;width:46%;height:46%;transform:translate(-50%,-50%);
  border-radius:50%;border:2.5px solid rgba(50,110,60,.85);box-sizing:border-box;pointer-events:none;z-index:3;
}
.halma-sq.tgt.jump::after{width:38%;height:38%;border:0;background:#3c9a4e;box-shadow:0 0 0 2.5px rgba(255,255,255,.75),0 1px 3px rgba(0,0,0,.35)}
.halma-sq.can .halma-pc{cursor:pointer}
.halma.mine .halma-sq.can .halma-pc{box-shadow:0 0 0 2px rgba(255,255,255,.75),0 2px 4px rgba(0,0,0,.45)}
.halma-sq.sel .halma-pc{transform:translateY(-6%) scale(1.08);box-shadow:0 0 0 3px var(--halma-gold),0 7px 10px rgba(0,0,0,.45)}
.halma-sq.shake{animation:shake .3s}

/* lines over the squares and the pieces (a jump's line runs through the pieces jumped over) */
.halma-lines{position:absolute;inset:0;width:100%;height:100%;z-index:4;pointer-events:none;overflow:visible}
.halma-lines polyline{fill:none;stroke-linecap:round;stroke-linejoin:round;vector-effect:non-scaling-stroke}
.halma-lines .ln-last{stroke:var(--pc);stroke-width:2.5;stroke-opacity:.6;filter:drop-shadow(0 0 1px rgba(255,255,255,.8))}
.halma-lines .ln-way{stroke:#fff;stroke-width:3.5;stroke-opacity:.9;filter:drop-shadow(0 0 1.5px rgba(0,0,0,.6))}
.halma-lines .ln-hint{stroke:var(--halma-gold);stroke-width:4;stroke-dasharray:6 5;filter:drop-shadow(0 0 1.5px rgba(0,0,0,.7))}

/* ── the marbles ─────────────────────────────────────────────────────── */
.halma-pc{
  position:relative;z-index:2;display:block;width:80%;aspect-ratio:1;border-radius:50%;
  background:
    radial-gradient(circle at 34% 28%,rgba(255,255,255,.95) 0 9%,rgba(255,255,255,.35) 16%,rgba(255,255,255,0) 34%),
    radial-gradient(circle at 60% 78%,rgba(255,255,255,.28) 0 10%,rgba(255,255,255,0) 30%),
    radial-gradient(circle at 50% 50%,var(--pc) 0 52%,color-mix(in srgb,var(--pc) 62%,#000) 100%);
  background-color:var(--pc);
  box-shadow:0 2px 4px rgba(0,0,0,.42),inset 0 -2px 3px rgba(0,0,0,.25);
  transition:transform .15s var(--ease,ease);
}
.halma-fly{position:absolute;z-index:6;display:grid;place-items:center;pointer-events:none}
.halma-fly .halma-pc{filter:drop-shadow(0 5px 6px rgba(0,0,0,.35))}

/* ── a hint on the board (server/hints/halma.js: hint.mark) ──────────── */
.halma .halma-sq.hn-from .halma-pc,.halma.mine .halma-sq.hn-from .halma-pc{box-shadow:0 0 0 3px var(--halma-gold),0 3px 6px rgba(0,0,0,.5)}
.halma-sq.hn-to::after{
  content:"";position:absolute;left:50%;top:50%;width:42%;height:42%;transform:translate(-50%,-50%);z-index:3;
  border-radius:50%;background:var(--halma-gold);opacity:.9;pointer-events:none;animation:hn-pulse 1.4s ease-in-out infinite;
}
.halma-sq.hn-alt{box-shadow:inset 0 0 0 2px rgba(214,150,30,.55)}

/* ── the buttons ─────────────────────────────────────────────────────── */
.halma-bar{grid-area:bar;display:flex;justify-content:center;gap:8px;padding:4px 10px 10px}
.halma-bar[hidden]{display:none}
.halma-bar .btn{flex:0 1 9em;min-width:0;min-height:44px;padding-inline:.7em;font-size:.95rem;white-space:nowrap}
.halma-bar .btn[hidden]{display:none}
.halma-bar.off .halma-back,.halma-bar.off .halma-done{visibility:hidden}
.halma-done.go{animation:halma-go 1.3s ease-in-out infinite}
@keyframes halma-go{50%{box-shadow:0 0 0 4px rgba(255,198,92,.45)}}
.halma-sum{margin:.2em 0 .6em;font-size:.9rem;opacity:.75;text-align:center}

/* ── a wide screen: the board on the left, the rest beside it ────────── */
.halma.wide{
  grid-template-columns:minmax(0,760px) clamp(220px,30%,320px);
  grid-template-rows:auto auto minmax(0,1fr) auto;
  grid-template-areas:"main top" "main plates" "main ." "main bar";
  justify-content:center;column-gap:8px;
}
.halma.wide .halma-top{padding-top:14px}
.halma.wide .halma-plates{grid-template-columns:minmax(0,1fr)}

/* a short screen: everything a little tighter */
@media (max-height:640px){
  .halma-top{padding-top:3px;gap:0}
  .halma-status{padding:.3em .8em;font-size:.86rem}
  .halma-say{font-size:.78rem}
  .halma-plates{padding:3px 8px;gap:4px}
  .halma-plate{min-height:38px}
  .halma-plate .ava{width:26px;height:26px;font-size:.8rem}
  .halma-bar{padding:2px 10px 6px}
}
@media (prefers-reduced-motion:reduce){
  .halma-sq.hn-to::after,.halma-done.go{animation:none}
  .halma-pc,.halma-bar-p i{transition:none}
}
