/* Warcaby in the AleGry look: paper background, ink outlines, hard shadows; a sand and green board. */
:root {
  --paper: #FFF7EA;
  --ink: #1D1533;
  --muted: #574D6E;
  --primary: #D93D22;
  --lemon: #FFD23F;
  --lemon-light: #FFF3C4;
  --mint: #20B69A;
  --sand-light: #F6E7CF;
  --plum-dark: #2E2450;
  --tomato-light: #FFE1D9;
  --line: 3px solid var(--ink);
  --radius: 18px;
  --radius-sm: 10px;
  --font-heading: 'Fredoka', 'Trebuchet MS', 'Segoe UI', sans-serif;
  --font-body: 'Nunito', 'Segoe UI', Verdana, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--paper); color: var(--ink); }
body { margin: 0; padding: 4px 8px 12px 4px; font: 16px/1.5 var(--font-body); }
h2 { font-family: var(--font-heading); line-height: 1.15; }
:focus-visible { outline: 3px solid #7A5CFA; outline-offset: 2px; }
.notice { margin: 1rem; padding: .75rem 1rem; border: 2px solid var(--ink); border-radius: var(--radius-sm); background: var(--lemon-light); }

.button { font: 700 1rem var(--font-heading); padding: .6rem 1.1rem; border: var(--line); border-radius: 999px; background: var(--primary); color: #fff; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button--ghost { background: #fff; color: var(--ink); }

.board { background: #fff; border: var(--line); border-radius: var(--radius); box-shadow: 5px 5px 0 var(--ink); overflow: hidden; }
.board__bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: var(--sand-light); border-bottom: var(--line); }
.board__counters { margin: 0; display: flex; gap: 1rem; font-weight: 700; font-size: .9rem; }
.board__counters strong { font: 700 1.15rem var(--font-heading); }
.segmented { display: inline-flex; flex-wrap: wrap; border: var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.segmented button { font: 600 .95rem var(--font-heading); border: 0; background: transparent; color: var(--ink); padding: .45rem .85rem; cursor: pointer; }
.segmented button + button { border-left: 2px solid var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.play { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; justify-content: center; padding: 1rem 1.25rem 1.25rem; }
.side { width: min(100%, 12rem); }
.turn { margin: 0 0 .6rem; padding: .5rem .8rem; border: var(--line); border-radius: var(--radius-sm); font: 700 1rem var(--font-heading); min-height: 2.9rem; }
.turn:empty { visibility: hidden; }
.turn--white { background: #fff; }
.turn--black { background: var(--plum-dark); color: #fff; }
.score { display: flex; align-items: center; gap: .4rem; margin: 0 0 .8rem; font: 700 1.3rem var(--font-heading); }
.score__vs { color: var(--muted); }
.piece-icon { display: inline-block; width: 1.3rem; height: 1.3rem; border: 2px solid var(--ink); border-radius: 50%; }
.piece-icon--white { background: #FFFDF6; }
.piece-icon--black { background: #2E2450; }
.side__actions { display: grid; gap: .45rem; margin: 0 0 .8rem; }
.tool { padding: .45rem .8rem; border: var(--line); border-radius: 999px; background: #fff; color: var(--ink); box-shadow: 2px 2px 0 var(--ink); font: 700 .95rem var(--font-heading); cursor: pointer; }
.tool:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.tool:disabled { opacity: .45; cursor: default; }
.tip { margin: 0; font-size: .82rem; color: var(--muted); }

.checkers { display: grid; grid-template-columns: repeat(8, 1fr); width: min(100%, 28rem); border: var(--line); border-radius: 8px; overflow: hidden; box-shadow: 4px 4px 0 var(--ink); }
.square { aspect-ratio: 1; background: var(--sand-light); }
.square--dark { display: grid; place-items: center; padding: 0; border: 0; background: #2E8C77; cursor: pointer; }
.square--dark.is-last { background: #5BB8A2; }
.square--dark.is-selected { background: var(--lemon); }
.square--dark.is-target { background: #2E8C77; }
.square--dark.is-target::after { content: ''; width: 30%; height: 30%; border: 2px solid var(--ink); border-radius: 50%; background: var(--lemon); }
.square--dark:focus-visible { outline: 3px solid var(--lemon); outline-offset: -4px; }
.piece { position: relative; width: 78%; height: 78%; border: 3px solid var(--ink); border-radius: 50%; box-shadow: 0 3px 0 var(--ink); }
.piece::before { content: ''; position: absolute; inset: 16%; border: 2px solid rgba(29, 21, 51, .25); border-radius: 50%; }
.piece--white { background: #FFFDF6; }
.piece--black { background: #2E2450; }
.piece--black::before { border-color: rgba(255, 255, 255, .35); }
.piece--king::after { content: '♛'; position: absolute; inset: 0; display: grid; place-items: center; font: 700 clamp(.9rem, 4vw, 1.5rem)/1 var(--font-heading); color: var(--ink); }
.piece--black.piece--king::after { color: var(--lemon); }
.is-movable .piece { box-shadow: 0 3px 0 var(--ink), 0 0 0 3px var(--lemon); }
.is-selected .piece { transform: translateY(-3px); box-shadow: 0 6px 0 var(--ink); }

.result { display: none; margin: 0 1.25rem 1.25rem; padding: 1rem 1.25rem; border: var(--line); border-radius: var(--radius); background: var(--lemon); }
.result.is-visible { display: block; }
.result.is-lost { background: var(--tomato-light); }
.result h2 { margin: 0 0 .25rem; font-size: 1.4rem; }
.result p { margin: 0; }
.result__actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem !important; }

.mg-toast { position: fixed; left: 50%; top: 1rem; z-index: 50; max-width: calc(100% - 2rem); transform: translate(-50%, -6rem); visibility: hidden; padding: .6rem 1.1rem; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 800; text-align: center; transition: transform .25s ease, visibility .25s; }
.mg-toast.is-visible { transform: translate(-50%, 0); visibility: visible; }

@media (max-width: 640px) {
  .board__bar { padding: .6rem .75rem; }
  .segmented button { padding: .4rem .6rem; font-size: .85rem; }
  .play { flex-direction: column-reverse; align-items: stretch; padding: .75rem .6rem 1rem; gap: .8rem; }
  .checkers { align-self: center; }
  .side { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 0 .75rem; align-items: center; }
  .turn { grid-column: 1 / -1; }
  .score { margin: 0; font-size: 1.1rem; }
  .side__actions { grid-auto-flow: column; margin: 0; }
  .tool { font-size: .85rem; padding: .4rem .6rem; }
  .tip { grid-column: 1 / -1; margin-top: .6rem; }
  .piece { border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
  .result { margin: 0 .75rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
