/* Mlýn: status and announcement on top, the opponent's plate with the tray of their stones, the board, my tray
   and 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 drawn in SVG (public/games/mlyn.js): maple with a faint grain, dark lines, a walnut
   frame; the stones are ivory and ebony discs with a turned rim. After a mill the frame turns red and the
   stones that may be taken pulse. */
.mlyn{
  --mlyn-edge:#4a2c1a;--mlyn-line:#3b2414;
  --mlyn-gold:var(--medal,#ffc65c);--mlyn-red:#e8484a;
  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;
}
.mlyn-top{grid-area:top;display:grid;justify-items:center;gap:2px;padding:6px 10px 2px}
.mlyn-status{padding:.4em .9em;font-size:.93rem;transition:background-color .2s,border-color .2s}
.mlyn-status.mlyn-alert{background:var(--mlyn-red);border-color:var(--mlyn-red);color:#fff}
.mlyn-say{margin:0;min-height:1.3em;max-width:26rem;font-size:.86rem;line-height:1.3;text-align:center;color:var(--mist)}
.mlyn-say.big{color:var(--ivory);font-weight:600}
.mlyn-say.alert{color:#ff8a8a;font-weight:600}

/* ── plates and trays ────────────────────────────────────────────────── */
.mlyn-them{grid-area:them}
.mlyn-us{grid-area:us}
.mlyn-side{display:grid;justify-items:center;gap:2px;min-width:0}
.mlyn-plate{
  width:min(100% - 16px,360px);
  display:flex;align-items:center;gap:8px;min-height:44px;margin:2px 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;
}
.mlyn-plate .ava{width:34px;height:34px;font-size:1rem;flex:none}
.mlyn-who{display:grid;line-height:1.15;min-width:0;flex:1}
.mlyn-who .nm{font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mlyn-who .sub{font-size:.72rem;color:var(--mist);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mlyn-plate.turn{border-color:var(--gold);background:rgba(118,176,67,.13)}
.mlyn-plate.turn .ava{box-shadow:0 0 0 2.5px var(--gold)}
.mlyn-plate.best .mlyn-disc.tag{box-shadow:0 0 0 2.5px var(--mlyn-gold),0 2px 4px rgba(0,0,0,.45)}
.mlyn-pips{display:flex;gap:4px;margin-top:3px}
.mlyn-pips i{width:8px;height:8px;border-radius:50%;border:1.5px solid var(--mist)}
.mlyn-pips i.on{background:var(--gold);border-color:var(--gold)}

/* the tray: the stones still to place (overlapping a little, like a stack laid out), then those taken */
.mlyn-tray{
  display:flex;align-items:center;justify-content:center;gap:12px;min-height:20px;width:min(100% - 16px,360px);
}
.mlyn-tray.empty{min-height:4px}
.mlyn-hand,.mlyn-took{display:flex;align-items:center}
.mlyn-hand .mlyn-disc + .mlyn-disc{margin-left:-4px}
.mlyn-took{opacity:.75;padding-left:10px;border-left:1px solid var(--line)}
.mlyn-took .mlyn-disc + .mlyn-disc{margin-left:-5px}
.mlyn-disc{
  position:relative;display:block;flex:none;width:18px;height:18px;border-radius:50%;
}
.mlyn-disc.w{background:radial-gradient(circle at 35% 30%,#fffdf6 0 18%,#efe3c8 55%,#c9b48c 100%);box-shadow:inset 0 -2px 0 rgba(120,90,50,.35),0 1px 3px rgba(0,0,0,.5)}
.mlyn-disc.b{background:radial-gradient(circle at 35% 30%,#6b5a5e 0 12%,#2c2326 55%,#121011 100%);box-shadow:inset 0 -2px 0 rgba(0,0,0,.45),inset 0 0 0 1px rgba(255,255,255,.1),0 1px 3px rgba(0,0,0,.5)}
.mlyn-disc::before{content:"";position:absolute;inset:22%;border-radius:50%;border:1px solid rgba(120,90,50,.35)}
.mlyn-disc.b::before{border-color:rgba(255,255,255,.14)}
.mlyn-disc.mini{width:13px;height:13px}
.mlyn-disc.tag{width:28px;height:28px}
.mlyn-disc.next{box-shadow:0 0 0 2px var(--mlyn-gold),0 1px 3px rgba(0,0,0,.5);animation:mlyn-next 1.3s ease-in-out infinite}
@keyframes mlyn-next{50%{transform:translateY(-2px)}}

/* ── the board ───────────────────────────────────────────────────────── */
.mlyn-main{grid-area:main;display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden;padding:2px}
.mlyn-wrap{position:relative;display:grid;place-items:center;border-radius:12px;transition:box-shadow .25s}
.mlyn-board{display:block;width:300px;height:300px;touch-action:manipulation;user-select:none;-webkit-user-select:none;overflow:visible}
.mlyn-frame{fill:var(--mlyn-edge);filter:drop-shadow(0 .2px .3px rgba(0,0,0,.6));transition:fill .25s}
.mlyn-co{font:700 .24px/1 var(--ui);fill:#5a3a1e;fill-opacity:.6;text-anchor:middle;dominant-baseline:middle;pointer-events:none}
.mlyn-lines{fill:none;stroke:var(--mlyn-line);stroke-width:.085;stroke-linecap:square}
.mlyn-mills path{fill:none;stroke:var(--mlyn-gold);stroke-width:.2;stroke-linecap:round;opacity:.85}
.mlyn-mills.now path{animation:mlyn-mill 1s ease-in-out infinite}
@keyframes mlyn-mill{50%{opacity:.45}}

/* removing: the frame turns red and the board glows */
.mlyn-wrap.rm{box-shadow:0 0 0 3px var(--mlyn-red),0 0 22px 2px rgba(232,72,74,.55)}
.mlyn-wrap.rm .mlyn-frame,.mlyn-wrap.rm-them .mlyn-frame{fill:#8e2224}

/* a point: a hit area (never smaller than 44 px on a phone), the dot, a target mark, the stone, a ring, a cross */
.mlyn-pt{cursor:pointer;-webkit-tap-highlight-color:transparent;outline:none}
.mlyn-pt .mlyn-hit{fill:transparent}
.mlyn-pt .mlyn-dot{fill:var(--mlyn-line)}
.mlyn-pt.full .mlyn-dot{display:none}
.mlyn-pt .mlyn-tgt{fill:rgba(255,236,170,.75);stroke:rgba(255,236,170,.45);stroke-width:.06;opacity:0;transition:opacity .15s}
.mlyn-pt.tgt-on .mlyn-tgt{opacity:1}
/* where the chosen stone may go: a green dot with a light rim, clearly seen on the maple */
.mlyn-pt.go .mlyn-tgt{fill:#4f7a2e;stroke:#fff3c4;stroke-width:.06;r:.2px;animation:mlyn-go 1.2s ease-in-out infinite}
@keyframes mlyn-go{50%{opacity:.6}}
.mlyn-pt .mlyn-ring{fill:none;stroke:var(--mlyn-gold);stroke-width:.07;opacity:0;pointer-events:none}
.mlyn-pt .mlyn-x{fill:none;stroke:var(--mlyn-red);stroke-width:.11;stroke-linecap:round;opacity:0;pointer-events:none}
.mlyn-pt .mlyn-slot{pointer-events:none}

/* stones */
.mlyn-st{transform-origin:0 0;transition:transform .15s var(--ease,ease)}
.mlyn-st .mlyn-bd{stroke-width:.03;filter:url(#mlyn-sh)}
.mlyn-st.w .mlyn-bd{fill:url(#mlyn-gw);stroke:#a8936c}
.mlyn-st.b .mlyn-bd{fill:url(#mlyn-gb);stroke:#000}
.mlyn-st .mlyn-rim{fill:none;stroke-width:.035}
.mlyn-st.w .mlyn-rim{stroke:rgba(120,90,50,.4)}
.mlyn-st.b .mlyn-rim{stroke:rgba(255,255,255,.16)}
.mlyn-st.ghost{opacity:.55}
.mlyn-st.gone{animation:mlyn-gone .45s ease-in forwards}
@keyframes mlyn-gone{to{opacity:0;transform:scale(.3)}}

/* the last move: where the stone came from, and the stone */
.mlyn-pt.from .mlyn-dot{fill:var(--mlyn-gold);r:.15px}
.mlyn-pt.last .mlyn-ring{opacity:.55;stroke-dasharray:.12 .1}
/* stones that may move, the one chosen */
.mlyn-pt.can .mlyn-ring{opacity:.5}
.mlyn-pt.sel .mlyn-ring{opacity:1;stroke-width:.09}
.mlyn-pt.sel .mlyn-st{transform:translateY(-.06px) scale(1.1)}
.mlyn-pt.ghost .mlyn-tgt{opacity:0}
/* the stones that may be taken pulse red; the one tapped once is crossed */
.mlyn-pt.take .mlyn-ring{opacity:1;stroke:var(--mlyn-red);stroke-width:.09;animation:mlyn-take 1s ease-in-out infinite}
.mlyn-pt.take.armed .mlyn-x{opacity:1}
.mlyn-pt.take.armed .mlyn-st{opacity:.7}
@keyframes mlyn-take{50%{opacity:.35}}
@keyframes mlyn-shake{25%{transform:translateX(-.08px)}75%{transform:translateX(.08px)}}
.mlyn-pt.mlyn-shake .mlyn-slot{animation:mlyn-shake .3s}

/* ── a hint on the board (server/hints/mlyn.js: hint.mark) ──────────── */
.mlyn-pt.hn-from .mlyn-ring{opacity:1;stroke:var(--mlyn-gold);stroke-width:.1}
.mlyn-pt.hn-to .mlyn-tgt{opacity:1;fill:var(--mlyn-gold);animation:hn-pulse 1.4s ease-in-out infinite}
.mlyn-pt.hn-cap .mlyn-x{opacity:1;stroke:var(--mlyn-gold)}
.mlyn-pt.hn-alt .mlyn-ring{opacity:.45;stroke:rgba(255,198,92,.7);stroke-dasharray:.1 .08}

/* ── the button of the pause ─────────────────────────────────────────── */
.mlyn-bar{grid-area:bar;display:flex;justify-content:center;padding:4px 10px 10px}
.mlyn-bar[hidden]{display:none}
.mlyn-bar .btn{min-height:46px;min-width:9em;font-size:.98rem}
.mlyn-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 ────────── */
.mlyn.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;
}
.mlyn.wide .mlyn-top{padding-top:14px}
.mlyn.wide .mlyn-plate,.mlyn.wide .mlyn-tray{width:calc(100% - 12px)}
.mlyn.wide .mlyn-us{grid-auto-flow:row}
.mlyn.wide .mlyn-us .mlyn-tray{order:2}

/* a short screen: everything a little tighter */
@media (max-height:620px){
  .mlyn-top{padding-top:3px;gap:0}
  .mlyn-status{padding:.3em .8em;font-size:.86rem}
  .mlyn-say{font-size:.78rem}
  .mlyn-plate{min-height:36px;margin:1px 0}
  .mlyn-plate .ava{width:28px;height:28px;font-size:.85rem}
  .mlyn-disc.tag{width:22px;height:22px}
  .mlyn-disc{width:15px;height:15px}
  .mlyn-tray{min-height:16px}
}
@media (prefers-reduced-motion:reduce){
  .mlyn-pt.take .mlyn-ring,.mlyn-pt.go .mlyn-tgt,.mlyn-mills.now path,.mlyn-st.gone,.mlyn-disc.next,.mlyn-pt.hn-to .mlyn-tgt,.mlyn-pt.mlyn-shake .mlyn-slot{animation:none}
  .mlyn-st,.mlyn-pt .mlyn-tgt{transition:none}
}
