/* Ganzenbord: home tile, menu extras, the board (stepping stones over a landscape), the geese and the die. The menu is built from
   the shell's components (css/style.css); the HUD and turn chips reuse Vier op een rij's classes. */

/* ---------- home tile ---------- */
#tile-ganzen .tile-art { display: flex; align-items: center; justify-content: center; }
#tile-ganzen .tile-art > svg { width: 84px; height: 84px; display: block; border-radius: 18px; box-shadow: 0 0 0 3px #5aa95e, 0 4px 0 3px rgba(43, 35, 112, 0.25); }

/* ---------- menu: the shell's option cards and player slots (css/style.css) ---------- */
.ganzen-boardopt .mini-ganzen { width: 56px; height: 56px; border-radius: 12px; box-shadow: 0 0 0 2px rgba(43, 35, 112, 0.25); }
.ganzen-count-art .big-num { font-size: var(--bz-text-l); font-weight: var(--bz-weight-brand); color: var(--bz-ink); letter-spacing: 1px; white-space: nowrap; }
.ganzen-count-art svg { width: 48px; height: 48px; }

/* ---------- the board ---------- */
#ganzen-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;
}
#ganzen-stage.side { flex-direction: row; gap: 12px; }
.ganzen-board {
  --step: 40px; /* from one stone to the next (set by ganzen.js from board.js) */
  --stone: 30px; /* a stone's diameter */
  --hit: 44px; /* the button round each stone: never under 44 px */
  --frame: #5aa95e;
  position: relative;
  flex: none;
  border: 4px solid var(--frame);
  border-radius: 22px;
  background: var(--board-bg);
  box-shadow: 0 7px 0 rgba(43, 35, 112, 0.18), 0 14px 30px rgba(59, 47, 168, 0.18);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
/* the landscape: grass, snow or sand, the trail and the pond (scene.js) */
.ganzen-land { position: absolute; inset: 0; pointer-events: none; border-radius: 18px; overflow: hidden; } /* only the picture is clipped: geese and counts may stand over the edge */
.ganzen-land svg { display: block; width: 100%; height: 100%; }
.ganzen-stones { position: absolute; inset: 0; }
/* a stone's button is a clear square of --hit round the stone; the stone is drawn inside it */
.gsq {
  font: inherit;
  position: absolute;
  left: 0;
  top: 0;
  width: var(--hit);
  height: var(--hit);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%; /* a round tap area: it never covers the middle of the next stone */
  background: none;
  color: var(--board-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.gsq .stone {
  --d: var(--stone);
  position: relative;
  flex: none;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: var(--tile-a);
  border: max(1.5px, calc(var(--d) * 0.06)) solid rgba(43, 35, 112, 0.55);
  box-shadow: 0 calc(var(--d) * 0.1) 0 rgba(43, 35, 112, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gsq.odd .stone { background: var(--tile-b); }
.gsq.special .stone { --d: calc(var(--stone) * 1.12); background: var(--tile-special); }
.gsq.k-goose .stone { background: var(--tile-a); }
.gsq.k-start .stone { --d: calc(var(--stone) * 1.1); background: var(--tile-end); }
.gsq.k-end .stone { --d: calc(var(--stone) * 1.3); background: var(--tile-end); border-color: #c98a00; }
.gsq .num { position: relative; z-index: 1; font-weight: 900; font-size: max(11px, calc(var(--d) * 0.5)); line-height: 1; letter-spacing: -0.02em; }
/* on a special stone the picture fills it; the number sits in a little white tag at the bottom */
.gsq.special .num {
  position: absolute;
  left: 50%;
  bottom: calc(var(--d) * -0.2);
  transform: translateX(-50%);
  font-size: max(10px, calc(var(--stone) * 0.36));
  padding: 0.08em 0.28em;
  border-radius: 0.5em;
  background: #fff;
  box-shadow: 0 0 0 1.5px rgba(43, 35, 112, 0.45);
}
.gsq .num:empty { display: none; } /* the start has no number */
.gsq .sq-icon { position: absolute; inset: 8%; width: 84%; height: 84%; display: block; }
.gsq.k-goose .sq-icon { inset: 8% 4% 12% 8%; opacity: 0.6; }
.gsq.k-start .sq-icon { inset: 12%; width: 76%; height: 76%; }
.gsq:focus-visible { outline: none; z-index: 2; }
.gsq:focus-visible .stone { outline: 4px solid var(--bz-focus); outline-offset: 2px; }

/* count yourself: the stone to tap glows; a wrong tap makes it wiggle */
.gsq.next { cursor: pointer; z-index: 1; }
.gsq.next .stone::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px #ffc531, 0 0 calc(var(--step) * 0.4) 4px rgba(255, 197, 49, 0.95);
  pointer-events: none;
  animation: ganzen-next 1.1s ease-in-out infinite; /* opacity and scale only: cheap to draw */
}
.gsq.wiggle .stone { animation: ganzen-wiggle 0.45s ease; }

/* the geese stand on a layer over the stones */
.ganzen-pawns { position: absolute; inset: 0; pointer-events: none; }
.gpawn { position: absolute; left: 0; top: 0; transition: transform 0.22s ease, width 0.2s ease, height 0.2s ease; z-index: 2; }
.gpawn svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 2px rgba(43, 35, 112, 0.3)); }
.gpawn.turn { z-index: 3; }
.gpawn.turn svg { filter: drop-shadow(0 0 4px #fff) drop-shadow(0 3px 2px rgba(43, 35, 112, 0.35)); }
.gpawn.hop svg { animation: ganzen-hop 0.26s ease; }
.gpawn.slide { transition: transform 0.7s ease-in-out, width 0.2s ease, height 0.2s ease; }
.gpawn.won svg { animation: ganzen-hop 0.5s ease 4; }
.count-pop {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transform: translate(-50%, -88%);
  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);
  pointer-events: none;
  animation: ganzen-pop 1.1s ease-out forwards;
}
.count-pop.below { transform: translate(-50%, 0); animation-name: ganzen-pop-below; }

/* ---------- the die and whose turn ---------- */
.ganzen-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#ganzen-stage.side .ganzen-side { width: 220px; flex: none; }
.ganzen-die {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 8px 22px 8px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  font-size: 1.35rem;
  box-shadow: 0 5px 0 var(--primary-dark);
  cursor: pointer;
  touch-action: manipulation;
}
.ganzen-die .faces { display: flex; gap: 6px; }
.ganzen-die .face { display: block; width: 52px; height: 52px; }
.ganzen-die .face svg { width: 100%; height: 100%; display: block; }
.ganzen-die:disabled { background: #b9b1f0; box-shadow: 0 5px 0 #9a90e6; cursor: default; }
.ganzen-die.ready { animation: ganzen-ready 1.4s ease-in-out infinite; }
.ganzen-die.tumble .face { animation: ganzen-tumble 0.18s linear infinite; }
.ganzen-die:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 3px; }
.ganzen-turn { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#ganzen-stage.side .ganzen-turn { flex-direction: column; align-self: stretch; flex-wrap: nowrap; }
.ganzen-chip .goose { width: 40px; height: 40px; flex: none; }
.ganzen-chip .robot-badge { width: 22px; height: 22px; flex: none; }
.ganzen-chip.waiting { filter: grayscale(0.6); }
#ganzen-stage.side .ganzen-chip { box-sizing: border-box; width: 100%; }
#ganzen-stage.side .ganzen-chip.on, #ganzen-stage.side .ganzen-chip.winner { transform: none; }
.ganzen-status { margin: 0; min-height: 2.6em; max-width: 26em; font-weight: 800; color: var(--primary-dark); text-align: center; }
.ganzen-ov { display: inline-flex; align-items: center; gap: 4px; }
.ov-art .ganzen-ov svg { width: 92px; height: 92px; }

/* short sideways phones: the HUD becomes a column on the left */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-ganzen { flex-direction: row; }
  .ganzen-hud { flex: none; width: 116px; flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; }
  .ganzen-hud .hud-mid { flex: 0; min-width: 0; text-align: center; }
  .ganzen-hud .hud-level { font-size: 0.8rem; white-space: normal; }
  .ganzen-hud .dogu-title { font-size: 1rem; line-height: 1.15; white-space: normal; }
  .ganzen-hud .btn.icon { width: 54px; height: 54px; }
  #ganzen-stage.side .ganzen-side { width: 168px; }
  .ganzen-die { min-height: 60px; padding: 6px 16px 6px 8px; font-size: 1.1rem; }
  .ganzen-die .face { width: 38px; height: 38px; }
  .ganzen-chip { gap: 5px; padding: 3px 8px 3px 3px; font-size: 0.85rem; }
  .ganzen-chip .goose { width: 30px; height: 30px; }
  .ganzen-chip .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  #ganzen-stage.side .ganzen-turn { gap: 4px; }
  .ganzen-status { font-size: 0.82rem; min-height: 3.6em; }
}
/* narrow phones: the chips get smaller so four fit on two rows */
@media (max-width: 420px) {
  .ganzen-chip { gap: 5px; padding: 3px 10px 3px 3px; font-size: 0.9rem; }
  .ganzen-chip .goose { width: 32px; height: 32px; }
  .ganzen-chip.on, .ganzen-chip.winner { transform: none; }
  .ganzen-chip.on .arrow { display: none; }
  .ganzen-die { min-height: 64px; }
  .ganzen-die .face { width: 46px; height: 46px; }
  .ganzen-turn.many { gap: 6px; flex-wrap: nowrap; }
  .ganzen-turn.many .name { display: none; }
  .ganzen-turn.many .ganzen-chip { padding: 3px 6px 3px 3px; gap: 3px; }
  .ganzen-status { min-height: 2.4em; font-size: 0.95rem; }
}
@media (max-height: 600px) {
  .ov-art .ganzen-ov svg { width: 64px; height: 64px; }
}

@keyframes ganzen-hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-28%); } }
@keyframes ganzen-pop { 0% { opacity: 0; transform: translate(-50%, -60%) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, -88%) scale(1.12); } 35%, 75% { opacity: 1; transform: translate(-50%, -88%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -110%) scale(0.95); } }
@keyframes ganzen-pop-below { 0% { opacity: 0; transform: translate(-50%, -40%) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.12); } 35%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, 20%) scale(0.95); } }
@keyframes ganzen-next { 0%, 100% { opacity: 0.6; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.08); } }
@keyframes ganzen-wiggle { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10%); } 75% { transform: translateX(10%); } }
@keyframes ganzen-ready { 0%, 100% { box-shadow: 0 5px 0 var(--primary-dark), 0 0 0 0 rgba(255, 197, 49, 0.9); } 50% { box-shadow: 0 5px 0 var(--primary-dark), 0 0 0 7px rgba(255, 197, 49, 0.55); } }
@keyframes ganzen-tumble { 0% { transform: rotate(0); } 50% { transform: rotate(14deg) scale(0.92); } 100% { transform: rotate(0); } }

@media (prefers-reduced-motion: reduce) {
  .gsq.next .stone::before, .gsq.wiggle .stone, .gpawn.hop svg, .gpawn.won svg, .count-pop, .ganzen-die.ready, .ganzen-die.tumble .face { animation: none !important; }
  .count-pop { opacity: 0.95; }
  .gpawn, .gpawn.slide { transition: none; }
}
