/* Piškvorky: status and announcement on top, the two players' plates, the
   board in the room that is left, the buttons at the bottom. On a wide
   screen the board stands on the left and everything else beside it.
   The board is a sheet of squared paper on the plum cloth: ivory, thin blue
   lines, cherry crosses and ink-blue circles. */
.pisk{
  --pisk-x:#c92a2a;--pisk-o:#1d4f91;
  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;
}
.pisk-top{grid-area:top;display:grid;justify-items:center;gap:2px;padding:6px 10px 2px}
.pisk-status{padding:.4em .9em;font-size:.93rem}
.pisk-say{
  margin:0;min-height:1.3em;max-width:24rem;
  font-size:.88rem;line-height:1.3;text-align:center;color:var(--mist);
}
.pisk-say.big{color:var(--ivory);font-weight:600}

/* ── plates ──────────────────────────────────────────────────────────── */
.pisk-plates{grid-area:plates;display:flex;justify-content:center;gap:8px;padding:4px 8px}
.pisk-plate{
  display:flex;align-items:center;gap:8px;
  flex:0 1 220px;min-width:0;min-height:46px;padding:4px 8px 4px 5px;
  border:1.5px solid var(--line);border-radius:999px;
  background:rgba(13,18,10,.3);
  transition:border-color .2s,background-color .2s;
}
.pisk-plate .ava{width:34px;height:34px;font-size:1rem;flex:none}
.pisk-who{display:grid;line-height:1.15;min-width:0;flex:1}
.pisk-who .nm{font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pisk-who .sub{font-size:.72rem;color:var(--mist);white-space:nowrap}
.pisk-plate.turn{border-color:var(--gold);background:rgba(118,176,67,.13)}
.pisk-plate.turn .ava{box-shadow:0 0 0 2.5px var(--gold)}
.pisk-plate.best .pisk-mark{box-shadow:0 0 0 2.5px var(--gold)}
/* the mark the player draws: a scrap of the paper */
.pisk-mark{
  flex:none;width:30px;height:30px;border-radius:8px;
  background:var(--ivory) center/86% no-repeat;
  box-shadow:inset 0 -2px 0 rgba(23,23,15,.16);
}
/* games won: one dot for every game the match needs */
.pisk-pips{display:flex;gap:4px;margin-top:3px}
.pisk-pips i{width:8px;height:8px;border-radius:50%;border:1.5px solid var(--mist)}
.pisk-pips i.on{background:var(--gold);border-color:var(--gold)}

/* ── the board ───────────────────────────────────────────────────────── */
.pisk-main{grid-area:main;display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden}
.pisk-view{
  position:relative;overflow:hidden;
  border-radius:5px;
  box-shadow:0 0 0 1px rgba(23,23,15,.5),0 12px 26px -14px rgba(0,0,0,.85);
  background:var(--ivory);
}
.pisk-view.zoomed{
  overflow:auto;touch-action:pan-x pan-y;overscroll-behavior:contain;
  scrollbar-width:thin;scrollbar-color:rgba(23,23,15,.35) transparent;cursor:grab;
}
.pisk-view.panning{cursor:grabbing}
.pisk-board{
  --n:15;--cell:22px;
  position:relative;
  display:grid;grid-template-columns:repeat(var(--n),var(--cell));grid-template-rows:repeat(var(--n),var(--cell));
  width:calc(var(--n)*var(--cell));height:calc(var(--n)*var(--cell));
  background-color:var(--ivory);
  background-image:
    linear-gradient(to right,rgba(40,90,150,.3) 1px,transparent 1px),
    linear-gradient(to bottom,rgba(40,90,150,.3) 1px,transparent 1px);
  background-size:var(--cell) var(--cell);
  box-shadow:inset -1px -1px 0 rgba(40,90,150,.3);
}
.pisk-cell{
  position:relative;min-width:0;min-height:0;
  padding:0;border:0;border-radius:0;background:none center/100% no-repeat;
  -webkit-tap-highlight-color:transparent;cursor:inherit;
}
.pisk-view:not(.zoomed) .pisk-cell{cursor:pointer}
.pisk-cell:focus-visible{outline:2px solid var(--ink);outline-offset:-2px}
.pisk-cell.x,.pisk-mark.x,.pisk-cell.gx::after{
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 6.5l11 11M17.5 6.5l-11 11' fill='none' stroke='%23d42a4c' stroke-width='3.1' stroke-linecap='round'/%3E%3C/svg%3E");
}
.pisk-cell.o,.pisk-mark.o,.pisk-cell.go::after{
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='6.3' fill='none' stroke='%231d4f91' stroke-width='2.9'/%3E%3C/svg%3E");
}
/* the last mark: a gold square under it */
.pisk-cell.last{background-color:rgba(118,176,67,.55);box-shadow:inset 0 0 0 1px rgba(196,130,20,.55)}
.pisk-cell.win{background-color:rgba(118,176,67,.8)}
.pisk-cell.new{animation:pisk-put .28s var(--ease)}
@keyframes pisk-put{from{background-size:30%;opacity:.2}}
/* the cell chosen for my mark: a ring and the mark, pale */
.pisk-cell.sel{box-shadow:inset 0 0 0 2px var(--ink);background-color:rgba(118,176,67,.4);animation:pisk-sel 1.2s ease-in-out infinite}
.pisk-cell.sel::after{content:"";position:absolute;inset:0;background-position:center;background-size:100%;background-repeat:no-repeat;opacity:.5}
@keyframes pisk-sel{50%{box-shadow:inset 0 0 0 1.5px rgba(23,23,15,.62)}}
.pisk-cell.shake{animation:shake .3s}

/* the line through the winning row */
.pisk-strike{
  position:absolute;z-index:3;pointer-events:none;
  left:calc(var(--c)*var(--cell));top:calc(var(--r)*var(--cell));
  width:calc(var(--len)*var(--cell));height:max(3px,calc(var(--cell)*.14));
  margin-top:calc(max(3px,var(--cell)*.14)/-2);
  border-radius:999px;background:var(--ink);opacity:.82;
  transform-origin:0 50%;transform:rotate(var(--turn)) scaleX(1.06);
}
.pisk-strike.draw{animation:pisk-strike .5s var(--ease) both}
@keyframes pisk-strike{from{transform:rotate(var(--turn)) scaleX(0)}}

/* ── buttons ─────────────────────────────────────────────────────────── */
.pisk-bar{grid-area:bar;display:flex;justify-content:center;align-items:center;gap:8px;padding:6px 10px 10px;min-height:62px}
.pisk-bar .btn{min-height:46px;padding:.4em 1.1em;font-size:.98rem;white-space:nowrap}
.pisk-put,.pisk-next{min-width:8em}
.pisk-zoom[aria-pressed=true]{background:rgba(244,240,232,.2);border-color:var(--ivory)}

.pisk-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 ────────── */
.pisk.wide{
  grid-template-columns:minmax(0,720px) clamp(190px,30%,280px);
  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;
}
.pisk.wide .pisk-top{padding-top:14px}
.pisk.wide .pisk-plates{flex-direction:column;align-items:stretch;padding:8px}
.pisk.wide .pisk-plate{flex:none}
.pisk.wide .pisk-bar{flex-direction:column-reverse;align-items:stretch;padding:8px 8px 14px}

/* a short screen: everything a little tighter */
@media (max-height:600px){
  .pisk-top{padding-top:3px;gap:0}
  .pisk-status{padding:.3em .8em;font-size:.86rem}
  .pisk-say{font-size:.8rem}
  .pisk-plates{padding:2px 6px;gap:6px}
  .pisk-plate{min-height:38px;padding:2px 6px 2px 3px}
  .pisk-plate .ava{width:28px;height:28px;font-size:.85rem}
  .pisk-mark{width:24px;height:24px;border-radius:6px}
  .pisk-bar{min-height:52px;padding:4px 8px 6px}
  .pisk-bar .btn{min-height:44px;font-size:.92rem}
  .pisk.wide .pisk-top{padding-top:6px}
  .pisk.wide .pisk-plates{padding:4px 6px}
  .pisk.wide .pisk-bar{flex-direction:row;flex-wrap:wrap;padding:4px 6px 6px}
  .pisk.wide .pisk-bar .btn{flex:1 1 auto;padding:.4em .7em}
}
@media (prefers-reduced-motion:reduce){
  .pisk-cell.sel,.pisk-cell.new,.pisk-strike.draw{animation:none}
}
