/* Ludo and Pachisi (one game, two modes): home tile, menu extras, the boards, the pawns, the die,
   the shells and the hints. The menu is built from the shell's components (css/style.css); the
   HUD and turn chips reuse Vier op een rij's classes (games/vier/vier.css). */

/* ---------- home tile ---------- */
#tile-pachisi .tile-art { display: flex; align-items: center; justify-content: center; }
#tile-pachisi .tile-art > svg { width: 84px; height: 84px; display: block; border-radius: 16px; filter: drop-shadow(0 3px 0 rgba(43, 35, 112, 0.25)); }

/* ---------- menu: the shell's option cards, player slots and segments (css/style.css) ---------- */
.pachisi-intro { display: flex; align-items: center; gap: 12px; margin: 4px; color: var(--bz-ink-soft); font-weight: var(--bz-weight-text); }
.pachisi-intro p { margin: 0; font-size: var(--bz-text-m); line-height: 1.35; }
.pachisi-intro-art { flex: none; width: 64px; height: 64px; }
.pachisi-intro-art svg { width: 100%; height: 100%; display: block; }
.pachisi-levels { flex-wrap: wrap; }
.pachisi-level { flex: 1 1 140px; }
.pachisi-level .lv-wins { color: var(--bz-ink-soft); }
.pachisi-pawnrow { display: flex; align-items: flex-end; justify-content: center; width: 56px; }
.pachisi-pawnrow svg { width: 26px; height: 26px; margin: 0 -5px; flex: none; }
.pachisi-pawnrow.n2 svg { width: 34px; height: 34px; margin: 0 -3px; }
.pachisi-countart { display: flex; align-items: center; justify-content: center; width: 56px; gap: 1px; }
.pachisi-countart svg { width: 18px; height: 24px; flex: none; }
.pachisi-countart b { font-size: 1.9rem; font-weight: 900; color: var(--bz-ink); }
.pachisi-modeart { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; }
.pachisi-modeart svg { width: 54px; height: 54px; display: block; border-radius: 12px; }
.pachisi-intro-art .die-svg, .pachisi-intro-art .shell-svg { width: 52px; height: 52px; }
.pachisi-countart .die-svg { width: 40px; height: 40px; }

/* ---------- HUD ---------- */
#pachisi-undo:disabled { opacity: 0.45; }
#pachisi-undo svg { width: 30px; height: 30px; }

/* ---------- the stage ---------- */
#pachisi-stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 6px 6px;
}
#pachisi-stage.side { flex-direction: row; gap: 12px; }

/* ---------- the cloth ---------- */
.pachisi-board {
  --cell: 16px;
  position: relative;
  flex: none;
  border-radius: calc(var(--cell) * 0.7);
  box-shadow: 0 7px 0 rgba(127, 42, 60, 0.35), 0 14px 30px rgba(59, 47, 168, 0.2);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.pachisi-board.ludo { border-radius: calc(var(--cell) * 1.2); box-shadow: 0 7px 0 rgba(43, 35, 112, 0.18), 0 14px 30px rgba(59, 47, 168, 0.18); }
.pachisi-board > svg.pachisi-cloth { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: inherit; }
.pachisi-marks, .pachisi-pawns, .pachisi-hits { position: absolute; inset: 0; }
.pachisi-marks, .pachisi-pawns { pointer-events: none; }
.pachisi-marks { z-index: 1; }
.pachisi-pawns { z-index: 2; }
.pachisi-hits { z-index: 3; }

/* the pawns stand on a layer over the cloth */
.ppawn { position: absolute; left: 0; top: 0; transition: transform 0.2s ease, width 0.2s ease, height 0.2s ease; }
.ppawn svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ppawn.hop svg { animation: pachisi-hop 0.24s ease; }
.ppawn.can svg { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px #ffc531); animation: pachisi-can 1.1s ease-in-out infinite; }
.ppawn.sel svg { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 6px #ffc531); transform: translateY(-12%) scale(1.12); }
.ppawn.home svg { filter: drop-shadow(0 0 3px #ffd27a); }
.ppawn.won svg { animation: pachisi-hop 0.5s ease 4; }

/* the square the chosen pawn would reach glows; small dots mark the way there */
.pp-target {
  position: absolute;
  width: max(26px, calc(var(--cell) * 1.45));
  height: max(26px, calc(var(--cell) * 1.45));
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 3px #ffc531, 0 0 calc(var(--cell) * 0.6) 4px rgba(255, 197, 49, 0.95), inset 0 0 0 2px #fff;
  animation: pachisi-glow 1.1s ease-in-out infinite;
}
.pp-target.home { width: calc(var(--cell) * 2.6); height: calc(var(--cell) * 2.6); }
.pp-dot { position: absolute; width: max(5px, calc(var(--cell) * 0.3)); height: max(5px, calc(var(--cell) * 0.3)); transform: translate(-50%, -50%); border-radius: 50%; background: #ffc531; box-shadow: 0 0 0 1.5px rgba(43, 35, 112, 0.55); }
/* the tap areas: invisible, 44 px or more (pachisi.js picks the nearest) */
.pp-hit { position: absolute; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pp-hit:focus-visible { outline: 4px solid var(--gold); outline-offset: -4px; }
.pp-pop {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transform: translate(-50%, -100%);
  border-radius: 50%;
  border: 3px solid var(--primary-dark);
  background: #fff;
  color: var(--primary-dark);
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(43, 35, 112, 0.3);
  animation: pachisi-pop 1s ease-out forwards;
}
.pp-pop.below { transform: translate(-50%, 0); animation-name: pachisi-pop-below; }

/* ---------- the side: whose turn, the shells, the line ---------- */
.pachisi-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#pachisi-stage.side .pachisi-side { width: 230px; flex: none; }
.pachisi-turn { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#pachisi-stage.side .pachisi-turn { flex-direction: column; align-self: stretch; flex-wrap: nowrap; }
#pachisi-stage.side .pachisi-chip { box-sizing: border-box; width: 100%; }
#pachisi-stage.side .pachisi-chip.on, #pachisi-stage.side .pachisi-chip.winner { transform: none; }
.pachisi-chip .ppawn-svg { width: 36px; height: 36px; flex: none; }
.pachisi-chip .robot-badge { width: 20px; height: 20px; flex: none; }
.pachisi-chip .home-dots { display: inline-flex; gap: 2px; }
.pachisi-chip .home-dots i { width: 8px; height: 8px; border-radius: 50%; background: #e3def8; box-shadow: inset 0 0 0 1.5px #b8b0e8; }
.pachisi-chip .home-dots i.on { background: var(--gold); box-shadow: inset 0 0 0 1.5px #c98a00; }
.pachisi-chip.thinking .ppawn-svg { animation: vier-think 1s ease-in-out infinite; }

.pachisi-line { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; }
.pachisi-tray {
  font: inherit;
  display: grid;
  grid-template-columns: repeat(6, 44px);
  gap: 4px;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: #fbe7c6;
  box-shadow: inset 0 -4px 0 rgba(127, 42, 60, 0.18), 0 4px 0 #e6c693;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pachisi-tray[aria-disabled="true"] { cursor: default; }
.pachisi-tray:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 3px; }
.pachisi-tray.ready { animation: pachisi-ready 1.4s ease-in-out infinite; }
.pshell { position: relative; display: flex; align-items: center; justify-content: center; width: 44px; height: 52px; border-radius: 14px; }
.pshell-face { display: block; width: 34px; height: 46px; }
.pshell-face svg { width: 100%; height: 100%; display: block; }
.pachisi-tray.tumble .pshell-face { animation: pachisi-tumble 0.18s linear infinite; }
.pshell.can { box-shadow: 0 0 0 3px #ffc531; background: rgba(255, 255, 255, 0.6); }
.pshell.counted { background: #fff; box-shadow: 0 0 0 3px var(--primary); }
.pshell.wiggle .pshell-face { animation: pachisi-wiggle 0.45s ease; }
.pshell-n { position: absolute; top: -9px; right: -5px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--primary); color: #fff; font-weight: 900; font-size: 0.85rem; line-height: 22px; text-align: center; }
.pshell-n:empty { display: none; }

/* Ludo's die: one big face; every pip can be tapped and counted (a tap anywhere on the die counts the nearest pip not counted yet) */
.pachisi-tray.die { grid-template-columns: auto; padding: 6px 14px; border-radius: 26px; background: #e4f1ff; box-shadow: inset 0 -4px 0 rgba(43, 35, 112, 0.12), 0 4px 0 #bcd9f7; }
#pachisi-stage.side .pachisi-tray.die { grid-template-columns: auto; }
.pdie { position: relative; display: block; width: 76px; height: 76px; border-radius: 20px; background: #fff; box-shadow: inset 0 0 0 4px var(--ink, #2b2370), 0 3px 0 rgba(43, 35, 112, 0.3); }
.pdie-face { position: absolute; inset: 0; }
.pdie-pip { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: #2b2370; color: #fff; font-weight: 900; font-size: 0.72rem; line-height: 18px; text-align: center; }
.pdie.resting .pdie-pip { opacity: 0.25; }
.pdie-pip.can { box-shadow: 0 0 0 3px #ffc531; }
.pdie-pip.counted { background: var(--primary); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary); width: 22px; height: 22px; margin: -11px 0 0 -11px; line-height: 22px; }
.pachisi-tray.tumble .pdie { animation: pachisi-tumble 0.18s linear infinite; }
.pachisi-result { flex: none; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #fff; color: var(--primary-dark); font-size: 1.6rem; font-weight: 900; box-shadow: 0 0 0 4px var(--primary), 0 4px 0 4px var(--primary-dark); }
.pachisi-result.grace { box-shadow: 0 0 0 4px var(--gold), 0 4px 0 4px #c98a00; }
.pachisi-result[hidden] { display: none; }
.pachisi-status { margin: 0; min-height: 2.6em; max-width: 26em; display: flex; align-items: center; font-weight: 800; color: var(--primary-dark); text-align: center; }
.pachisi-ov { display: inline-flex; align-items: center; }
.ov-art .pachisi-ov svg { width: 92px; height: 92px; }
.ov-art .pachisi-ov.won svg { animation: pachisi-hop 0.6s ease 0.1s 2; }

/* the result beside the tray when there is room; above it on narrow phones */
@media (max-width: 420px) {
  .pachisi-result { width: 42px; height: 42px; font-size: 1.3rem; }
  .pachisi-line { min-height: 46px; }
  .pachisi-chip { gap: 5px; padding: 3px 10px 3px 3px; font-size: 0.9rem; }
  .pachisi-chip .ppawn-svg { width: 30px; height: 30px; }
  .pachisi-chip.on, .pachisi-chip.winner { transform: none; }
  .pachisi-chip.on .arrow { display: none; }
  .pachisi-turn.many { gap: 5px; flex-wrap: nowrap; }
  .pachisi-turn.many .name { display: none; }
  .pachisi-turn.many .pachisi-chip { padding: 3px 6px 3px 3px; gap: 3px; }
  .pachisi-turn.many .ppawn-svg { width: 28px; height: 28px; }
  .pachisi-turn.many .robot-badge { width: 16px; height: 16px; }
  .pachisi-turn.many .home-dots { gap: 1px; }
  .pachisi-turn.many .home-dots i { width: 6px; height: 6px; }
  .pachisi-status { min-height: 2.4em; font-size: 0.92rem; }
  .pachisi-tray { padding: 4px 6px; gap: 3px; }
  .pachisi-tray.die { padding: 4px 10px; }
}
/* sideways: the shells in two rows of three, the result beside them */
#pachisi-stage.side .pachisi-tray { grid-template-columns: repeat(3, 44px); border-radius: 24px; }
/* short sideways phones: the HUD becomes a column on the left */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-pachisi { flex-direction: row; }
  .pachisi-hud { flex: none; width: 116px; flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; }
  .pachisi-hud .hud-mid { flex: 0; min-width: 0; text-align: center; }
  .pachisi-hud .hud-level { font-size: 0.75rem; line-height: 1.15; white-space: normal; }
  .pachisi-hud .dogu-title { font-size: 0.95rem; line-height: 1.15; white-space: normal; }
  .pachisi-hud .btn.icon { width: 54px; height: 54px; }
  #pachisi-stage { padding: 4px 6px; }
  #pachisi-stage.side .pachisi-side { width: 164px; gap: 5px; }
  .pachisi-chip { gap: 4px; padding: 2px 8px 2px 2px; font-size: 0.82rem; }
  .pachisi-chip .ppawn-svg { width: 26px; height: 26px; }
  .pachisi-chip .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  .pachisi-chip.on .arrow { display: none; }
  #pachisi-stage.side .pachisi-turn { gap: 3px; }
  .pshell { height: 46px; }
  .pshell-face { width: 30px; height: 40px; }
  .pachisi-tray { padding: 4px 8px; }
  .pdie { width: 64px; height: 64px; border-radius: 17px; }
  .pachisi-result { width: 44px; height: 44px; font-size: 1.3rem; }
  .pachisi-status { font-size: 0.8rem; min-height: 3.6em; }
}
@media (max-height: 600px) {
  .ov-art .pachisi-ov svg { width: 64px; height: 64px; }
}

@keyframes pachisi-hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-26%); } }
@keyframes pachisi-can { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7%); } }
@keyframes pachisi-glow { 0%, 100% { opacity: 0.65; transform: translate(-50%, -50%) scale(0.95); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } }
@keyframes pachisi-pop { 0% { opacity: 0; transform: translate(-50%, -70%) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, -100%) scale(1.1); } 35%, 75% { opacity: 1; transform: translate(-50%, -100%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -120%) scale(0.95); } }
@keyframes pachisi-pop-below { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 35%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, 20%) scale(0.95); } }
@keyframes pachisi-ready { 0%, 100% { box-shadow: inset 0 -4px 0 rgba(127, 42, 60, 0.18), 0 4px 0 #e6c693, 0 0 0 0 rgba(255, 197, 49, 0.9); } 50% { box-shadow: inset 0 -4px 0 rgba(127, 42, 60, 0.18), 0 4px 0 #e6c693, 0 0 0 7px rgba(255, 197, 49, 0.55); } }
@keyframes pachisi-tumble { 0% { transform: rotate(0); } 50% { transform: rotate(160deg) scale(0.9); } 100% { transform: rotate(360deg); } }
@keyframes pachisi-wiggle { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-12%); } 75% { transform: translateX(12%); } }

@media (prefers-reduced-motion: reduce) {
  .ppawn.hop svg, .ppawn.can svg, .ppawn.won svg, .pp-target, .pp-pop, .pachisi-tray.ready, .pachisi-tray.tumble .pshell-face, .pachisi-tray.tumble .pdie, .pshell.wiggle .pshell-face, .pachisi-chip.thinking .ppawn-svg, .ov-art .pachisi-ov.won svg { animation: none !important; }
  .pp-target { transform: translate(-50%, -50%); }
  .pp-pop { opacity: 0.95; }
  .ppawn { transition: none; }
}
