/* Ludo. The square board in its wooden frame (drawn by app.js) sits in a square sized (--side, shared/fit.js) to the room
   .board-wrap is given; the pieces stand on it in per cent of its width. Each player's plate sits at the corner of the
   board where that player's yard is (yours is always bottom left), and the die, the dice of the turn and the turn line
   sit just above your plate. Wide screens: the plates stand beside the board's corners. Upright screens: above and
   below them, with the die under the bottom ones. .board-wrap leaves the room for them; they hang from the board's frame. */
.stage { flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 12px max(12px, var(--gk-safe-end)) max(12px, var(--gk-safe-bottom)) max(12px, var(--gk-safe-start)); }
.board-wrap { --card: 236px; --gap: 16px; --plate: 60px; width: calc(100% - 2 * (var(--card) + var(--gap))); height: 100%; max-width: 860px; min-width: 0; min-height: 0; display: grid; place-items: center; }
/* The board's own wooden frame is part of its drawing; the page only rounds its corners to match and gives it a shadow. */
.frame { --side: 360px; position: relative; width: var(--side); height: var(--side); border-radius: calc(var(--side) * .043); box-shadow: var(--gk-shadow-3); }
.board { position: relative; width: 100%; height: 100%; border-radius: calc(var(--side) * .043); direction: ltr; isolation: isolate; }
.board svg { display: block; width: 100%; height: 100%; }
.tokens { position: absolute; inset: 0; pointer-events: none; }

/* The pieces: a pawn drawing in its player's colour (app.js). One that can move hops and wears a ring of that colour. */
.token { position: absolute; width: calc(5.9% * var(--size, 1)); aspect-ratio: 40 / 52; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
  transform: translate(-50%, -74%); pointer-events: auto; transition: left .16s linear, top .16s linear, width .16s; }
.token .pawn { position: absolute; inset: 0; background: center / contain no-repeat; }
/* A little more room to press than the pawn itself, without reaching the next square's pawn. */
.token::after { content: ""; position: absolute; inset: -22% -42%; }
.token:disabled { opacity: 1; pointer-events: none; }
.token.movable { cursor: pointer; animation: token-hop .5s ease-in-out infinite alternate; }
.token.movable::before { content: ""; position: absolute; left: -22%; right: -22%; bottom: -3%; height: 38%; border-radius: 50%; border: 3px solid var(--gk-white); box-shadow: 0 0 0 3px var(--player-color), 0 0 10px 3px var(--gk-white); }
.token.movable:hover { filter: brightness(1.1); }
/* A token tapped first, waiting for its die: lifted, with a gold ring. */
.token.picked { animation: none; translate: 0 -16%; }
.token.picked::before { border-color: var(--gk-gold); box-shadow: 0 0 0 3px var(--player-color), 0 0 14px 5px var(--gk-gold); }
@keyframes token-hop { to { translate: 0 -16%; } }
/* A clear board behind New game and while a room waits for its people. */
html.gk-clear .tokens { visibility: hidden; }

/* The players' plates, at their corners: beside the board's top and bottom corners, on the left and on the right. */
.seat-corner { position: absolute; width: var(--card); }
.seat-corner:empty { display: none; }
.seat-corner.tl, .seat-corner.bl { right: calc(100% + var(--gap)); }
.seat-corner.tr, .seat-corner.br { left: calc(100% + var(--gap)); }
.seat-corner.tl, .seat-corner.tr { top: 0; }
.seat-corner.bl, .seat-corner.br { bottom: 0; }
.seat-corner .gk-seat { min-height: var(--plate); }
/* On the player's face the pawn is a small badge. */
.gk-seat i.gk-face-badge { background-size: 62%; }
.gk-seat i { flex: none; width: 24px; height: 31px; background: center / contain no-repeat; }
/* The die, the dice of the turn and the turn line stand by the plate of the player whose turn it is (data-at: tl, tr, bl,
   br, set by app.js), and move on with the turn: on wide screens beside the board, under a top plate or over a bottom one,
   the die always next to the board; on upright screens above the top plates or under the bottom ones, on that player's
   side. The places keep to the board whatever the language; each line of words takes its own direction. */
.roll { position: absolute; width: var(--card); display: flex; align-items: center; gap: 12px; direction: ltr; }
.roll[data-at="tl"], .roll[data-at="bl"] { right: calc(100% + var(--gap)); }
.roll[data-at="tr"], .roll[data-at="br"] { left: calc(100% + var(--gap)); }
.roll[data-at="tl"], .roll[data-at="tr"] { top: calc(var(--plate) + var(--gap)); }
.roll[data-at="bl"], .roll[data-at="br"] { bottom: calc(var(--plate) + var(--gap)); }
.roll .die { order: 2; }
.roll-text { flex: 1; min-width: 0; text-align: right; }
.roll-text p { unicode-bidi: plaintext; }
.roll .dice-row { justify-content: right; }
html[dir="rtl"] .roll .dice-row { direction: rtl; }
.roll:is([data-at="tr"], [data-at="br"]) .die { order: 0; }
.roll:is([data-at="tr"], [data-at="br"]) .roll-text { text-align: left; }
.roll:is([data-at="tr"], [data-at="br"]) .dice-row { justify-content: left; }
/* Arriving at the next player's plate. */
.roll.arrive { animation: roll-arrive .3s ease-out; }
@keyframes roll-arrive { from { opacity: 0; scale: .85; } }
/* The die is the game's action: it glows gold while it is yours to roll. */
.die:disabled { opacity: 1; }
.die.ready { box-shadow: 0 0 0 3px var(--gk-gold), 0 0 18px color-mix(in srgb, var(--gk-gold) 55%, transparent); }
.gk-turn.won { color: var(--gk-gold); }

/* Upright screens: the two top plates above the board's top corners, the two bottom ones under its bottom corners; the
   die with the turn line above the top plates or under the bottom ones, whoever's turn it is, so room is kept for both. */
@media (orientation: portrait) {
  .board-wrap { --gap: 8px; --plate: 54px; --roll: 92px; width: 100%; max-width: none; height: calc(100% - 2 * (var(--plate) + var(--roll) + 2 * var(--gap))); }
  .seat-corner { width: calc(50% - 4px); }
  .seat-corner.tl, .seat-corner.bl { right: auto; left: 0; }
  .seat-corner.tr, .seat-corner.br { left: auto; right: 0; }
  .seat-corner.tl, .seat-corner.tr { top: auto; bottom: calc(100% + var(--gap)); }
  .seat-corner.bl, .seat-corner.br { bottom: auto; top: calc(100% + var(--gap)); }
  .roll[data-at] { left: 0; right: 0; width: auto; }
  .roll:is([data-at="bl"], [data-at="br"]) { top: calc(100% + var(--plate) + 2 * var(--gap)); bottom: auto; }
  .roll:is([data-at="tl"], [data-at="tr"]) { bottom: calc(100% + var(--plate) + 2 * var(--gap)); top: auto; }
  .roll:is([data-at="tl"], [data-at="bl"]) .die { order: 0; }
  .roll:is([data-at="tl"], [data-at="bl"]) .roll-text { text-align: left; }
  .roll:is([data-at="tl"], [data-at="bl"]) .dice-row { justify-content: left; }
  .roll:is([data-at="tr"], [data-at="br"]) .die { order: 2; }
  .roll:is([data-at="tr"], [data-at="br"]) .roll-text { text-align: right; }
  .roll:is([data-at="tr"], [data-at="br"]) .dice-row { justify-content: right; }
}
/* A phone: smaller plates and die. */
@media (max-width: 599px) {
  .gk-seat { padding: 6px 9px; gap: 7px; }
  .gk-seat i { width: 18px; height: 23px; }
  .die { --die: 58px; }
}
@media (orientation: portrait) and (max-width: 599px) { .board-wrap { --plate: 50px; --roll: 88px; } }
/* An upright tablet: larger plates, die and turn line. */
@media (min-width: 600px) and (max-width: 1023px) and (orientation: portrait) {
  .board-wrap { --gap: 12px; --plate: 64px; --roll: 104px; }
  .die { --die: 84px; }
  .gk-turn { font-size: var(--gk-text-lg); }
}
/* A tablet on its side: narrower plates beside the board. */
@media (min-width: 600px) and (max-width: 1023px) and (orientation: landscape) { .board-wrap { --card: 206px; --gap: 12px; } }
/* A sideways phone: small plates beside the board. */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { padding-top: 6px; padding-bottom: max(6px, var(--gk-safe-bottom)); }
  .board-wrap { --card: 182px; --gap: 10px; --plate: 46px; }
  .gk-seat { padding: 5px 10px; }
  .gk-seat i { width: 18px; height: 23px; }
  .die { --die: 52px; }
}
