/* Dáma: status and announcement on top, the opponent's plate, the board, my plate, a button in the pause.
   On a wide screen the board stands on the left and everything else beside it.
   The board is a wooden one: light maple and dark walnut squares; the pieces are ivory and ebony discs
   with a turned rim, the kings with a gold crown. */
.dama{
  --dama-lt:#e8d5b0;--dama-dk:#8a5a3b;--dama-edge:#4a2c1a;
  --dama-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 auto;
  grid-template-areas:"top" "them" "main" "us" "bar";
  overflow:hidden;
}
.dama-top{grid-area:top;display:grid;justify-items:center;gap:2px;padding:6px 10px 2px}
.dama-status{padding:.4em .9em;font-size:.93rem}
.dama-say{margin:0;min-height:1.3em;max-width:26rem;font-size:.86rem;line-height:1.3;text-align:center;color:var(--mist)}
.dama-say.big{color:var(--ivory);font-weight:600}

/* ── plates ──────────────────────────────────────────────────────────── */
.dama-them{grid-area:them}
.dama-us{grid-area:us}
.dama-plate{
  justify-self:center;width:min(100% - 16px,360px);
  display:flex;align-items:center;gap:8px;min-height:44px;margin:3px 0;padding:3px 10px 3px 4px;
  border:1.5px solid var(--line);border-radius:999px;background:rgba(13,18,10,.3);
  transition:border-color .2s,background-color .2s;
}
.dama-plate .ava{width:34px;height:34px;font-size:1rem;flex:none}
.dama-who{display:grid;line-height:1.15;min-width:0;flex:1}
.dama-who .nm{font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dama-who .sub{font-size:.72rem;color:var(--mist);white-space:nowrap}
.dama-plate.turn{border-color:var(--gold);background:rgba(118,176,67,.13)}
.dama-plate.turn .ava{box-shadow:0 0 0 2.5px var(--gold)}
.dama-plate.best .dama-pc.tag{box-shadow:0 0 0 2.5px var(--dama-gold),0 2px 4px rgba(0,0,0,.45)}
.dama-took{display:flex;align-items:center;gap:3px;font:600 .85rem/1 var(--ui);color:var(--mist);white-space:nowrap}
.dama-pips{display:flex;gap:4px;margin-top:3px}
.dama-pips i{width:8px;height:8px;border-radius:50%;border:1.5px solid var(--mist)}
.dama-pips i.on{background:var(--gold);border-color:var(--gold)}

/* ── the board ───────────────────────────────────────────────────────── */
.dama-main{grid-area:main;display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden;padding:2px}
.dama-board{
  --cell:40px;
  display:grid;grid-template-columns:repeat(8,var(--cell));grid-template-rows:repeat(8,var(--cell));
  border:max(3px,calc(var(--cell)*.09)) solid var(--dama-edge);border-radius:6px;
  box-shadow:0 14px 28px -14px rgba(0,0,0,.9),inset 0 0 0 1px rgba(255,255,255,.08);
  background:var(--dama-edge);
}
.dama-sq{position:relative;min-width:0;min-height:0;padding:0;border:0;border-radius:0;font:inherit}
.dama-sq.lt{background:var(--dama-lt)}
.dama-sq.dk{
  background:var(--dama-dk) linear-gradient(135deg,rgba(255,255,255,.06),rgba(0,0,0,.08));
  cursor:pointer;-webkit-tap-highlight-color:transparent;
}
.dama-sq.dk:focus-visible{outline:2px solid var(--ivory);outline-offset:-3px}
/* coordinates in the corners of the edge squares */
.dama-co{position:absolute;font:700 max(8px,calc(var(--cell)*.2))/1 var(--ui);pointer-events:none;opacity:.7}
.dama-co.r{left:2px;top:2px}
.dama-co.f{right:3px;bottom:2px}
.dama-sq.lt .dama-co{color:var(--dama-dk)}
.dama-sq.dk .dama-co{color:var(--dama-lt)}
.dama-slot{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none}
.dama-slot > .dama-pc{grid-area:1/1}

/* the last move, a jump under way, the piece chosen and where it may go */
.dama-sq.last{background-color:#a7783a}
.dama-sq.trail{background-color:#9c6d33}
.dama-sq.sel{background-color:#5f7f3a;box-shadow:inset 0 0 0 3px var(--dama-gold)}
.dama-sq.tgt::after{
  content:"";position:absolute;left:50%;top:50%;width:34%;height:34%;transform:translate(-50%,-50%);
  border-radius:50%;background:rgba(255,236,170,.55);box-shadow:0 0 0 2px rgba(255,236,170,.35);pointer-events:none;
}
.dama-sq.tgt.jump::after{background:rgba(230,70,70,.6);box-shadow:0 0 0 2px rgba(255,200,200,.45)}
.dama-sq.can .dama-pc{cursor:pointer}
.dama-sq.must .dama-pc:not(.gone){box-shadow:0 0 0 3px var(--dama-gold),0 3px 6px rgba(0,0,0,.5);animation:dama-must 1.3s ease-in-out infinite}
.dama-sq.sel .dama-pc{transform:translateY(-6%) scale(1.06);box-shadow:0 0 0 3px var(--dama-gold),0 8px 12px rgba(0,0,0,.5)}
@keyframes dama-must{50%{box-shadow:0 0 0 1.5px var(--dama-gold),0 3px 6px rgba(0,0,0,.5)}}
.dama-sq.taken .dama-pc{opacity:.38;filter:grayscale(.6)}
.dama-sq.taken .dama-slot::after{content:"✕";grid-area:1/1;position:relative;z-index:2;font:800 calc(var(--cell)*.42)/1 var(--ui);color:#e84a4a;text-shadow:0 1px 2px rgba(0,0,0,.6)}
.dama-sq.shake{animation:shake .3s}

/* ── pieces ──────────────────────────────────────────────────────────── */
.dama-pc{
  position:relative;display:block;width:78%;aspect-ratio:1;border-radius:50%;
  transition:transform .15s var(--ease,ease);
}
.dama-pc.w{
  background:radial-gradient(circle at 35% 30%,#fffdf6 0 18%,#efe3c8 55%,#cdbb96 100%);
  box-shadow:inset 0 -3px 0 rgba(120,90,50,.35),inset 0 0 0 2px rgba(150,120,80,.25),0 3px 5px rgba(0,0,0,.45);
}
.dama-pc.b{
  background:radial-gradient(circle at 35% 30%,#6b5a5e 0 12%,#2c2326 55%,#141012 100%);
  box-shadow:inset 0 -3px 0 rgba(0,0,0,.45),inset 0 0 0 2px rgba(255,255,255,.08),0 3px 5px rgba(0,0,0,.55);
}
/* the turned rim */
.dama-pc::before{content:"";position:absolute;inset:17%;border-radius:50%;border:1.5px solid rgba(120,90,50,.35)}
.dama-pc.b::before{border-color:rgba(255,255,255,.14)}
/* the crown of a king */
.dama-pc.k::after{
  content:"";position:absolute;inset:22%;
  background:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18l-1-11 5.5 4.5L12 4l4.5 7.5L22 7l-1 11z' fill='%23ffc65c' stroke='%237a4f0a' stroke-width='1.3' stroke-linejoin='round'/%3E%3Crect x='3' y='18.5' width='18' height='2.5' rx='1' fill='%23ffc65c' stroke='%237a4f0a' stroke-width='1'/%3E%3C/svg%3E");
  filter:drop-shadow(0 1px 1px rgba(0,0,0,.4));
}
.dama-pc.gone{animation:dama-gone .4s ease-in forwards}
@keyframes dama-gone{to{opacity:0;transform:scale(.4)}}
/* small pieces on the plates */
.dama-pc.tag{flex:none;width:28px}
.dama-pc.mini{width:14px}
.dama-pc.mini::before,.dama-pc.tag::before{inset:20%;border-width:1px}

/* ── a hint on the board (server/hints/dama.js: hint.mark) ──────────── */
.dama-sq.hn-path{box-shadow:inset 0 0 0 3px var(--dama-gold)}
.dama-sq.hn-from .dama-pc{box-shadow:0 0 0 3px var(--dama-gold),0 3px 6px rgba(0,0,0,.5)}
.dama-sq.hn-to::after{
  content:"";position:absolute;left:50%;top:50%;width:40%;height:40%;transform:translate(-50%,-50%);
  border-radius:50%;background:var(--dama-gold);opacity:.85;pointer-events:none;animation:hn-pulse 1.4s ease-in-out infinite;
}
.dama-sq.hn-cap .dama-slot::after{content:"✕";grid-area:1/1;position:relative;z-index:2;font:800 calc(var(--cell)*.42)/1 var(--ui);color:var(--dama-gold);text-shadow:0 1px 2px rgba(0,0,0,.8)}
.dama-sq.hn-alt{box-shadow:inset 0 0 0 2px rgba(255,198,92,.45)}

/* ── the button of the pause ─────────────────────────────────────────── */
.dama-bar{grid-area:bar;display:flex;justify-content:center;padding:4px 10px 10px}
.dama-bar[hidden]{display:none}
.dama-bar .btn{min-height:46px;min-width:9em;font-size:.98rem}
.dama-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 ────────── */
.dama.wide{
  grid-template-columns:minmax(0,720px) clamp(200px,30%,300px);
  grid-template-rows:auto auto auto minmax(0,1fr) auto;
  grid-template-areas:"main top" "main them" "main us" "main ." "main bar";
  justify-content:center;column-gap:8px;
}
.dama.wide .dama-top{padding-top:14px}
.dama.wide .dama-plate{width:calc(100% - 12px)}

/* a short screen: everything a little tighter */
@media (max-height:620px){
  .dama-top{padding-top:3px;gap:0}
  .dama-status{padding:.3em .8em;font-size:.86rem}
  .dama-say{font-size:.78rem}
  .dama-plate{min-height:36px;margin:2px 0}
  .dama-plate .ava{width:28px;height:28px;font-size:.85rem}
  .dama-pc.tag{width:22px}
}
@media (prefers-reduced-motion:reduce){
  .dama-sq.must .dama-pc,.dama-pc.gone,.dama-sq.hn-to::after{animation:none}
  .dama-pc{transition:none}
}
