/* Ludo (Kızma Birader) — board, pawns, dice trays (prefix kz-).
 * Geometry: the board is a square sized ONCE from the container width and the small viewport height (svh ignores the
 * mobile URL bar); nothing inside it changes its size — die, captions and banners live in fixed boxes or overlays. */
.kz-wrap {
  --kz-c: #ff6b4a; --kz-c-d: #c9472b; --kz-c-l: #ffd8ce;
  --kz-b: #3d7bf7; --kz-b-d: #2552b8; --kz-b-l: #d3e2ff;
  --kz-wood: #f6e7cf; --kz-wood-2: #efd9b8; --kz-rim: #c9a678; --kz-ink: #1e2636; --kz-sq: #fffaf2;
  width: min(100%, 560px, max(272px, calc(100vh - var(--kz-chrome, 292px))));
  width: min(100%, 560px, max(272px, calc(100svh - var(--kz-chrome, 292px))));
  gap: 0; flex: none;
}
:root[data-theme="dark"] .kz-wrap { --kz-wood: #2b3346; --kz-wood-2: #252c3d; --kz-rim: #151a26; --kz-ink: #0b0f17; --kz-sq: #56627c; --kz-c-l: #5a3229; --kz-b-l: #253a66; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kz-wrap { --kz-wood: #2b3346; --kz-wood-2: #252c3d; --kz-rim: #151a26; --kz-ink: #0b0f17; --kz-sq: #56627c; --kz-c-l: #5a3229; --kz-b-l: #253a66; } }
@media (orientation: landscape) and (max-height: 520px) { .kz-wrap { width: min(100%, 560px, max(240px, calc(100svh - var(--kz-chrome-l, 120px)))); } }

.kz-frame { width: 100%; padding: 2.2%; border-radius: 18px; background: var(--kz-rim); box-shadow: 0 6px 0 rgba(0, 0, 0, .22), var(--shadow); box-sizing: border-box; }
.kz-board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; container-type: size;
  background: radial-gradient(circle at 50% 50%, var(--kz-wood) 0, var(--kz-wood-2) 100%); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.kz-bg { position: absolute; inset: 0; pointer-events: none; }

/* squares: circles on an 11 × 11 grid */
.kz-sq { position: absolute; width: calc(100% / 11); height: calc(100% / 11); display: grid; place-items: center; }
.kz-sq::before { content: ""; width: 78%; height: 78%; border-radius: 50%; background: var(--kz-sq); border: max(1.5px, .45cqw) solid var(--kz-ink); box-sizing: border-box;
  box-shadow: inset 0 -.5cqw 0 rgba(0, 0, 0, .08); }
.kz-sq.start.kz-c::before { background: var(--kz-c); border-color: var(--kz-c-d); }
.kz-sq.start.kz-b::before { background: var(--kz-b); border-color: var(--kz-b-d); }
.kz-sq.home.kz-c::before { background: var(--kz-c-l); border-color: var(--kz-c); }
.kz-sq.home.kz-b::before { background: var(--kz-b-l); border-color: var(--kz-b); }
.kz-sq.spot::before { width: 70%; height: 70%; background: transparent; border-style: dashed; }
.kz-sq.spot.kz-c::before { border-color: var(--kz-c); }
.kz-sq.spot.kz-b::before { border-color: var(--kz-b); }
.kz-arrow { position: absolute; width: 30%; height: 30%; border-radius: 50%; background: #fff; opacity: .85; }

.kz-yardbg { position: absolute; width: calc(350% / 11); height: calc(350% / 11); border-radius: 22%; border: max(2px, .6cqw) solid; box-sizing: border-box; }
.kz-yardbg.kz-c { background: var(--kz-c-l); border-color: var(--kz-c); }
.kz-yardbg.kz-b { background: var(--kz-b-l); border-color: var(--kz-b); }
.kz-goal { position: absolute; width: calc(200% / 11); height: calc(200% / 11); transform: rotate(45deg) scale(.6); border-radius: 18%; overflow: hidden;
  display: grid; grid-template-rows: 1fr 1fr; border: max(2px, .5cqw) solid var(--kz-ink); box-sizing: border-box; }
.kz-g1.kz-c, .kz-g2.kz-c { background: var(--kz-c); }
.kz-g1.kz-b, .kz-g2.kz-b { background: var(--kz-b); }
.kz-goal i { display: block; }

/* dice trays in the two free corners */
.kz-tray { position: absolute; width: calc(380% / 11); height: calc(380% / 11); box-sizing: border-box; border-radius: 20%; padding: 0; margin: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%; font: inherit; color: var(--kz-ink);
  background: rgba(255, 255, 255, .35); border: max(2px, .5cqw) dashed rgba(30, 38, 54, .25); transition: background .2s, border-color .2s, opacity .2s; }
:root[data-theme="dark"] .kz-tray { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .16); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kz-tray { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .16); color: var(--ink); } }
button.kz-tray { cursor: default; -webkit-appearance: none; appearance: none; }
.kz-tray.on.kz-c { border-style: solid; border-color: var(--kz-c); background: color-mix(in srgb, var(--kz-c) 14%, transparent); }
.kz-tray.on.kz-b { border-style: solid; border-color: var(--kz-b); background: color-mix(in srgb, var(--kz-b) 14%, transparent); }
.kz-tray.ready { cursor: pointer; animation: kztray 1.1s ease-in-out infinite alternate; }
.kz-tray.ready:hover .kz-die { transform: rotate(-8deg) scale(1.05); }
.kz-tray.ready:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.kz-tray:disabled { cursor: default; }
@keyframes kztray { from { box-shadow: 0 0 0 0 rgba(255, 107, 74, 0); } to { box-shadow: 0 0 0 1.2cqw rgba(255, 107, 74, .22); } }
.kz-tray.ready.kz-b { animation-name: kztrayb; }
@keyframes kztrayb { from { box-shadow: 0 0 0 0 rgba(61, 123, 247, 0); } to { box-shadow: 0 0 0 1.2cqw rgba(61, 123, 247, .25); } }
.kz-dwrap { width: 48%; aspect-ratio: 1; display: grid; place-items: center; }
.kz-die { width: 100%; height: 100%; box-sizing: border-box; padding: 14%; border-radius: 22%; background: #fff; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  box-shadow: 0 .9cqw 0 #c9cfdb, 0 1.4cqw 2cqw rgba(0, 0, 0, .25); border: max(1px, .3cqw) solid #d8dde7; transition: transform .15s; }
.kz-die i { display: block; width: 72%; height: 72%; margin: auto; border-radius: 50%; }
.kz-die i.on { background: #1e2636; box-shadow: inset 0 .3cqw 0 rgba(255, 255, 255, .25); }
.kz-die.blank { opacity: .45; }
.kz-tray.stale .kz-die { opacity: .55; }
.kz-tray.tumble .kz-die { animation: kztumble .17s linear infinite; }
.kz-tray.shaking .kz-die { animation: kzshake .2s linear infinite; }
@keyframes kztumble { 0% { transform: rotate(0) translateY(0); } 50% { transform: rotate(160deg) translateY(-12%); } 100% { transform: rotate(360deg) translateY(0); } }
@keyframes kzshake { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
.kz-cap { display: block; max-width: 92%; height: 1.3em; line-height: 1.3em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: clamp(10px, 3.3cqw, 15px); font-weight: 800; text-align: center; }
.kz-tray.ready .kz-cap { color: var(--kz-c-d); }
.kz-tray.ready.kz-b .kz-cap { color: var(--kz-b-d); }
:root[data-theme="dark"] .kz-tray.ready .kz-cap { color: #ff9a82; }
:root[data-theme="dark"] .kz-tray.ready.kz-b .kz-cap { color: #9ec0ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kz-tray.ready .kz-cap { color: #ff9a82; } :root:not([data-theme="light"]) .kz-tray.ready.kz-b .kz-cap { color: #9ec0ff; } }

/* pawns */
.kz-pawn { position: absolute; width: calc(100% / 11); height: calc(100% / 11); display: grid; place-items: center; z-index: 3; pointer-events: none; outline: none; }
.kz-pc { position: relative; width: 70%; height: 70%; border-radius: 50%; display: block; }
.kz-pawn.kz-c .kz-pc { background: radial-gradient(circle at 35% 30%, #ffc2b2 0, #ff6b4a 45%, #df4b2c 100%); box-shadow: 0 .55cqw 0 #a33a20, 0 .9cqw 1.2cqw rgba(0, 0, 0, .35); }
.kz-pawn.kz-b .kz-pc { background: radial-gradient(circle at 35% 30%, #b8d0ff 0, #3d7bf7 45%, #2a5bc4 100%); box-shadow: 0 .55cqw 0 #1d4396, 0 .9cqw 1.2cqw rgba(0, 0, 0, .35); }
.kz-pc::after { content: ""; position: absolute; inset: 27%; border-radius: 50%; background: rgba(255, 255, 255, .3); box-shadow: inset 0 .3cqw .4cqw rgba(0, 0, 0, .2); }
.kz-pawn.can { pointer-events: auto; cursor: pointer; z-index: 4; }
.kz-pawn.can::before { content: ""; position: absolute; width: 96%; height: 96%; border-radius: 50%; border: max(2.5px, .7cqw) solid #fff; box-sizing: border-box;
  box-shadow: 0 0 0 max(2px, .5cqw) var(--kz-ink); animation: kzpulse .9s ease-in-out infinite alternate; }
.kz-pawn.can.hot::before, .kz-pawn.can:focus-visible::before { border-color: #ffd257; animation: none; transform: scale(1.12); }
.kz-pawn.can:focus-visible { z-index: 7; }
@keyframes kzpulse { from { transform: scale(.88); opacity: .75; } to { transform: scale(1.1); opacity: 1; } }

/* legal destinations and the last move */
.kz-dests { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.kz-dest { position: absolute; width: calc(100% / 11); height: calc(100% / 11); display: grid; place-items: center; }
.kz-dest i { width: 40%; height: 40%; border-radius: 50%; border: max(2px, .55cqw) solid var(--kz-ink); box-sizing: border-box; animation: kzdot 1s ease-in-out infinite alternate; }
.kz-dest.kz-c i { background: rgba(255, 107, 74, .75); }
.kz-dest.kz-b i { background: rgba(61, 123, 247, .75); }
.kz-dest.cap i { width: 92%; height: 92%; background: transparent; border: max(3px, .8cqw) dashed #e8312a; }
.kz-dest.hot i { width: 62%; height: 62%; animation: none; }
.kz-dest.cap.hot i { width: 100%; height: 100%; }
@keyframes kzdot { from { transform: scale(.85); } to { transform: scale(1.1); } }
.kz-last { position: absolute; width: calc(100% / 11); height: calc(100% / 11); display: grid; place-items: center; pointer-events: none; z-index: 1; }
.kz-last::after { content: ""; width: 34%; height: 34%; border-radius: 50%; opacity: .55; }
.kz-last.kz-c::after { background: var(--kz-c); }
.kz-last.kz-b::after { background: var(--kz-b); }

.kz-board .fx-banner { font-size: clamp(18px, 6cqw, 30px); padding: 10px 18px 12px; }
.kz-board .fx-banner.blue { background: #2552b8; box-shadow: 0 5px 0 #173777; }

/* The page around the board (only while a Ludo board is on the page):
 * - the status line above the board stays ONE line in every language (it never pushes the board down);
 * - the player who plays blue gets a blue turn highlight and a blue status line instead of the brand coral. */
body:has(.kz-wrap) #status { display: block; height: 22px; min-height: 22px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:has(.kz-wrap.kz-bot-b) #status.me { color: var(--blue); }
body:has(.kz-wrap.kz-bot-b) #pBottom.pbar.turn, body:has(.kz-wrap.kz-top-b) #pTop.pbar.turn { border-color: var(--blue); background: var(--blue-soft); }
body:has(.kz-wrap.kz-bot-b) #pBottom .ptag:not(.think), body:has(.kz-wrap.kz-top-b) #pTop .ptag:not(.think) { color: var(--blue); }
body:has(.kz-wrap.kz-bot-b) #pBottom .psc.bump, body:has(.kz-wrap.kz-top-b) #pTop .psc.bump { color: var(--blue); }

/* Phones turned sideways (short landscape): the shell stacks bar / status / board / bar, which needs ~2× the screen
 * height. For Ludo the stage becomes three columns instead — status line on top, then opponent bar | board | own bar — so the whole
 * game is on one screen with no scrolling. Scoped to a stage that holds a Ludo board; drop this block once the room
 * shell has its own landscape layout (INTEGRATE.md §8). */
@media (orientation: landscape) and (max-height: 520px) {
  /* the board column has a fixed width computed from the viewport once (never from its content: no layout feedback);
   * the height left for it = top bar + page and stage padding + the status line (~128 px, measured at 640–915 × 360–412) */
  body.in-room #boardPanel:has(> #board .kz-wrap) { --kz-land: clamp(180px, calc(100vh - 128px), 560px); --kz-land: clamp(180px, calc(100svh - 128px), 560px);
    display: grid; grid-template-columns: minmax(0, 1fr) var(--kz-land) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
    align-items: start; justify-items: stretch; gap: 6px 12px; padding: 6px 12px 10px; min-height: 0; }
  body.in-room #boardPanel:has(> #board .kz-wrap) > #board .kz-wrap { width: 100%; }
  body.in-room #boardPanel:has(> #board .kz-wrap) > #pTop, body.in-room #boardPanel:has(> #board .kz-wrap) > .ptop-row { grid-column: 1; grid-row: 2; }
  body.in-room #boardPanel:has(> #board .kz-wrap) > #claimLine { grid-column: 1; grid-row: 3; }
  body.in-room #boardPanel:has(> #board .kz-wrap) > #status { grid-column: 1 / -1; grid-row: 1; justify-self: center; max-width: 100%; }
  body.in-room #boardPanel:has(> #board .kz-wrap) > #board { grid-column: 2; grid-row: 2 / span 2; }
  body.in-room #boardPanel:has(> #board .kz-wrap) > #pBottom { grid-column: 3; grid-row: 2; }
  body.in-room #boardPanel:has(> #board .kz-wrap) > #chatBar { grid-column: 3; grid-row: 3; }
  body.in-room #boardPanel:has(> #board .kz-wrap) .pbar { min-height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .kz-tray.ready, .kz-pawn.can::before, .kz-dest i, .kz-tray.tumble .kz-die, .kz-tray.shaking .kz-die { animation: none !important; }
}
