/* Mancala (Turkish Mangala rules) — board, pits, stores, sowing animation. Theme tokens only (light + dark). */
.mg-wrap { width: min(100%, 680px); gap: 8px; }
.mg-frame { width: 100%; padding: 10px; border-radius: 22px; background: var(--surface-2); border: 2px solid var(--line); box-shadow: 0 5px 0 var(--line-2), var(--shadow); }
.mg-board { --peb: 11px; position: relative; display: grid; grid-template-columns: .82fr repeat(6, 1fr) .82fr; grid-template-rows: auto auto; gap: 7px; container-type: inline-size; }
@supports (width: 1cqw) { .mg-board { --peb: clamp(6px, 2.15cqw, 14px); } }

.pc-brand { --pc: var(--brand); --pcs: var(--brand-soft); }
.pc-blue { --pc: var(--blue); --pcs: var(--blue-soft); }

.mg-pit, .mg-store { position: relative; min-width: 0; margin: 0; padding: 0; font: inherit; color: inherit; border: 0; background: none; display: block; -webkit-tap-highlight-color: transparent; }
.mg-pit { aspect-ratio: 1; }
.mg-cup { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 50% 38%, var(--surface-3), var(--surface) 140%);
  box-shadow: inset 0 4px 0 color-mix(in srgb, var(--ink) 9%, transparent), inset 0 0 0 2px color-mix(in srgb, var(--pc) 28%, transparent); transition: box-shadow .2s, transform .18s var(--spring); }
.mg-store .mg-cup { border-radius: 999px; }
.mg-pit.top .mg-cup { box-shadow: inset 0 4px 0 color-mix(in srgb, var(--ink) 9%, transparent), inset 0 0 0 2px color-mix(in srgb, var(--pc) 28%, transparent); }
.mg-store .mg-cup { background: linear-gradient(180deg, var(--pcs), transparent 60%), radial-gradient(circle at 50% 40%, var(--surface-3), var(--surface) 150%);
  box-shadow: inset 0 4px 0 color-mix(in srgb, var(--ink) 9%, transparent), inset 0 0 0 2.5px color-mix(in srgb, var(--pc) 55%, transparent); }

/* pebbles */
.mg-peb { position: absolute; width: var(--peb); height: var(--peb); border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle at 34% 30%, #fff 0 12%, var(--g) 46%, color-mix(in srgb, var(--g) 62%, #000) 100%);
  box-shadow: 0 1.5px 0 rgba(0, 0, 0, .28), 0 2px 4px rgba(0, 0, 0, .18); pointer-events: none; }

/* counts */
.mg-cnt { position: absolute; z-index: 3; min-width: 22px; height: 20px; padding: 0 5px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; font-size: 12px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1.5px var(--line-2), 0 2px 0 var(--line-2); pointer-events: none; }
.mg-pit.bot .mg-cnt { right: -4px; bottom: -6px; }
.mg-pit.top .mg-cnt { right: -4px; top: -6px; }
.mg-store .mg-cnt { left: 0; right: 0; margin-inline: auto; width: max-content; bottom: 6px; min-width: 30px; height: 26px; font-size: 15px; border-radius: 13px; color: #fff; background: var(--pc); box-shadow: 0 2px 0 color-mix(in srgb, var(--pc) 60%, #000); }
.mg-pit.empty .mg-cnt { color: var(--ink-3); opacity: .7; }

/* your pits */
.mg-pit.can { cursor: pointer; }
.mg-pit.can .mg-cup { box-shadow: inset 0 4px 0 color-mix(in srgb, var(--ink) 9%, transparent), 0 0 0 3px var(--pc), 0 4px 0 color-mix(in srgb, var(--pc) 55%, #000); transform: translateY(-2px); }
.mg-pit.can:focus-visible { outline: none; }
.mg-pit.can:focus-visible .mg-cup { box-shadow: 0 0 0 3px var(--pc), 0 0 0 6px var(--pcs); }
@media (hover: hover) { .mg-pit.can:hover .mg-cup { transform: translateY(-4px) scale(1.04); } }
.mg-pit.can:active .mg-cup { transform: translateY(0) scale(.97); }
.mg-board.live .mg-pit.bot:not(.can) .mg-cup { opacity: .62; }

/* move preview (mouse hover) */
.mg-pit.land .mg-cup, .mg-store.land .mg-cup { box-shadow: inset 0 0 0 3px var(--good), 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent); }
.mg-pit.land::after, .mg-store.land::after { content: ""; position: absolute; left: 50%; top: 50%; width: 26%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); background: var(--good); opacity: .75; animation: mg-dot .25s var(--spring); z-index: 2; }
.mg-pit.capt .mg-cup { box-shadow: inset 0 0 0 3px var(--bad), 0 0 0 4px color-mix(in srgb, var(--bad) 25%, transparent); animation: mg-pulse .8s ease-in-out infinite alternate; }

/* last move */
.mg-pit.from .mg-cup { box-shadow: inset 0 4px 0 color-mix(in srgb, var(--ink) 9%, transparent), inset 0 0 0 2px color-mix(in srgb, var(--pc) 28%, transparent), 0 0 0 2px color-mix(in srgb, var(--ink) 30%, transparent); }
.mg-pit.to::before, .mg-store.to::before { content: ""; position: absolute; z-index: 3; left: 50%; width: 8px; height: 8px; border-radius: 50%; background: #ffc531; box-shadow: 0 0 0 2px var(--surface-2); transform: translateX(-50%); }
.mg-pit.bot.to::before { top: -5px; }
.mg-pit.top.to::before { bottom: -5px; }
.mg-store.to::before { top: 4px; }
.mg-pit.robbed .mg-cup, .mg-pit.swept .mg-cup { animation: mg-flash .5s ease-out; }

/* sowing hand, flying captures, skip */
.mg-hand { position: absolute; left: 0; top: 0; z-index: 20; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; pointer-events: none;
  background: var(--pc); color: #fff; font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 color-mix(in srgb, var(--pc) 60%, #000), 0 6px 14px rgba(0, 0, 0, .25);
  transition: transform .13s cubic-bezier(.3, .7, .3, 1), opacity .2s; }
.mg-hand::after { content: ""; position: absolute; left: 50%; bottom: -5px; border: 6px solid transparent; border-top-color: var(--pc); border-bottom: 0; transform: translateX(-50%); }
.mg-hand.notrans { transition: none; }
.mg-hand.gone { opacity: 0; }
.mg-fly { position: absolute; left: 0; top: 0; z-index: 21; padding: 3px 9px; border-radius: 999px; font-weight: 800; font-size: 14px; color: #3b2a00; background: #ffc531; box-shadow: 0 3px 0 #b8860b, 0 6px 14px rgba(0, 0, 0, .25); pointer-events: none; white-space: nowrap; }
.mg-fly.sweep { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 2px var(--line-2), 0 3px 0 var(--line-2); }
.mg-bar { height: 30px; display: flex; align-items: center; justify-content: center; }
.mg-skip { height: 30px; padding: 0 14px; border-radius: 15px; border: 0; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink-2); background: var(--surface-2); box-shadow: 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); animation: mg-in .25s ease-out; }
.mg-skip:active { transform: translateY(2px); box-shadow: 0 0 0 1.5px var(--line-2), 0 1px 0 var(--line-2); }

@keyframes mg-dot { from { transform: translate(-50%, -50%) scale(0); } }
@keyframes mg-pulse { to { box-shadow: inset 0 0 0 3px var(--bad), 0 0 0 7px color-mix(in srgb, var(--bad) 12%, transparent); } }
@keyframes mg-flash { 0% { background: color-mix(in srgb, #ffc531 55%, var(--surface)); } }
@keyframes mg-in { from { opacity: 0; transform: translateY(4px); } }

@media (max-width: 560px) {
  .mg-wrap { width: calc(100% + 12px); margin-inline: -6px; }   /* uses most of the stage padding (8px) but stays inside the card border */
  .mg-frame { padding: 5px; border-radius: 16px; border-width: 1.5px; }
  .mg-board { gap: 3px; grid-template-columns: .6fr repeat(6, 1fr) .6fr; --peb: clamp(6px, 2.3cqw, 12px); }
  .mg-cnt { min-width: 18px; height: 17px; font-size: 11px; padding: 0 4px; }
  .mg-pit.bot .mg-cnt { right: -3px; bottom: -4px; }
  .mg-pit.top .mg-cnt { right: -3px; top: -4px; }
  .mg-store .mg-cnt { min-width: 24px; height: 22px; font-size: 13px; bottom: 4px; }
  .mg-hand { width: 26px; height: 26px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-cup, .mg-hand { transition: none; }
  .mg-pit.capt .mg-cup, .mg-pit.land::after, .mg-skip { animation: none; }
}

/* player bars beside a Mancala board (this file only loads with the game): the name, the store label and the
   connection state shrink and clip on phones instead of pushing the bar, and with it the page, wider than the screen */
body:has(.mg-wrap) .pbar .pn > b, body:has(.mg-wrap) .pbar .pn > small { contain: inline-size; }   /* no min-content push */
body:has(.mg-wrap) .pbar .pn small { min-width: 0; overflow: hidden; }
body:has(.mg-wrap) .pbar .pn small > span:not(.chip) { min-width: 0; flex-shrink: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:has(.mg-wrap) .pbar .pn small > span.chip + span, body:has(.mg-wrap) .pbar .pn small > span.chip + span + span { flex-shrink: 0; }
body:has(.mg-wrap) .pbar .pn small > span.conn { flex-shrink: 100; min-width: 6px; }   /* clips down to its status dot first */
body:has(.mg-wrap) .pbar .pn small > span.conn::before { flex-shrink: 0; }
/* the extra-turn notice wraps inside the board instead of running past a phone screen (long German / Turkish lines) */
.mg-wrap .fx-banner { width: max-content; max-width: calc(100% - 24px); box-sizing: border-box; white-space: normal; text-wrap: balance; font-size: clamp(20px, 5.2vw, 34px); }
