/* =====================================================================
   Sowing: a carved mahogany mancala board laid on a woven cloth of bold
   stripes (ochre, deep green, red, black). The seeds are glossy beans of
   many colours; the cards are the cloth itself, an ochre weave with a
   striped border.
   ===================================================================== */

:root {
  --ochre: #d9a03b;
  --ochre-deep: #a8731f;
  --green: #2f6b45;
  --red: #b5402f;
  --black: #1e1a17;
  --wood: #6b3420;
  --wood-deep: #3f1c10;
  --wood-hi: #8d4a2c;
  --cream: #f6ead2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: "Work Sans", system-ui, sans-serif;
  color: var(--cream);
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 6px),
    linear-gradient(180deg,
      var(--black) 0 6%, var(--ochre) 6% 18%, var(--green) 18% 24%, var(--ochre) 24% 30%, var(--red) 30% 34%,
      var(--ochre) 34% 66%, var(--red) 66% 70%, var(--ochre) 70% 76%, var(--green) 76% 82%, var(--ochre) 82% 94%, var(--black) 94% 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

.nav-back-games {
  position: fixed; top: 16px; left: 18px; z-index: 50;
  font-family: inherit; font-size: 15px; font-weight: 700;
  color: var(--cream); text-decoration: none;
  background: linear-gradient(175deg, var(--wood-hi), var(--wood) 60%, var(--wood-deep));
  border: 2px solid var(--black); border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  padding: 6px 14px;
}
.nav-back-games:hover { filter: brightness(1.12); }

.cloth { max-width: 820px; margin: 0 auto; padding: 62px 16px 26px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.title { font-family: "Fraunces", serif; font-weight: 800; font-size: 40px; color: var(--black); letter-spacing: 1px; text-shadow: 0 2px 0 rgba(255, 240, 200, 0.5); }
.tally { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(760px, 100%); }
.side { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 10px; background: var(--black); color: var(--cream); }
.side b { font-family: "Fraunces", serif; font-size: 22px; font-weight: 800; color: var(--ochre); min-width: 1.5em; text-align: center; }
.side small { font-size: 13px; }
.turn { font-weight: 700; color: var(--black); text-align: center; flex: 1; font-size: 15px; }

/* the board: two rows of six pits between the stores, carved from one log */
.board {
  width: min(760px, 100%);
  display: grid; grid-template-columns: 1.15fr repeat(6, 1fr) 1.15fr; grid-template-rows: 1fr 1fr; gap: 10px;
  padding: 16px; border-radius: 60px;
  background:
    repeating-linear-gradient(100deg, rgba(0, 0, 0, 0.12) 0 3px, transparent 3px 11px),
    radial-gradient(ellipse at 50% 20%, var(--wood-hi), var(--wood) 55%, var(--wood-deep));
  border: 3px solid var(--black);
  box-shadow: inset 0 3px 0 rgba(255, 210, 170, 0.25), 0 14px 30px rgba(0, 0, 0, 0.45);
}
.pit, .store {
  position: relative; border: 0; padding: 0; font: inherit; color: var(--cream);
  border-radius: 50%; aspect-ratio: 1;
  background: radial-gradient(ellipse at 50% 35%, #2a120a, #3d1a0e 60%, #5a2a17);
  box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 210, 170, 0.25);
}
.store { aspect-ratio: auto; border-radius: 40px; }
.pit { cursor: default; }
.pit.can { cursor: pointer; box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.65), 0 0 0 3px var(--ochre); }
.pit.can:hover { box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.65), 0 0 0 3px #f6c35f; }
.pit.cursor { box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.65), 0 0 0 3px var(--cream), 0 0 0 6px var(--red); }
.pit.hint { box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.65), 0 0 0 4px var(--green), 0 0 0 7px var(--cream); }
.pit:focus { outline: none; }
.seeds { position: absolute; inset: 10%; pointer-events: none; }
.seeds i {
  position: absolute; width: 27%; height: 19%; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.store .seeds i { width: 22%; height: 8%; }
.n {
  position: absolute; left: 50%; bottom: -2px; transform: translate(-50%, 50%);
  font-family: "Fraunces", serif; font-weight: 800; font-size: 14px; line-height: 1;
  background: var(--black); color: var(--ochre); border-radius: 999px; padding: 3px 7px; min-width: 24px; text-align: center;
}
.store .n { font-size: 18px; bottom: 6px; }
/* the far row's counts sit above it, the near row's below */
.pit.far .n { bottom: auto; top: -2px; transform: translate(-50%, -50%); }
/* a seed dropping in: the pit's seeds give a little hop (Visual FX on) */
html.fx-on .pit.drop .seeds, html.fx-on .store.drop .seeds { animation: sw-drop 0.16s ease-out; }
@keyframes sw-drop { 40% { transform: translateY(-3px) scale(1.04); } }
/* a row's keys, 1 to 6, sit on its pits (a keyboard only), centred, on the
   side away from the count: the near row's at the top, the far row's at the foot */
.pit[data-gs-key]::after { position: absolute; top: 6%; left: 50%; transform: translateX(-50%); margin: 0; }
.pit.far[data-gs-key]::after { top: auto; bottom: 6%; }

.tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
/* The words and the keycap side by side, each in the middle top to bottom
   (in one line the keycap stood on the words' baseline, low); the red foot
   is drawn inside the padding, so 3px more below than above keeps both in
   the middle of the black face over it. */
.tools button {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; color: var(--cream);
  background: var(--black); border: 2px solid var(--black); border-radius: 10px; padding: 4.5px 12px 7.5px;
  box-shadow: inset 0 -3px 0 var(--red);
}
.tools button:disabled { opacity: 0.45; cursor: default; }
.tools button:not(:disabled):hover { background: #322b25; }
.keys, .record { font-size: 14px; color: var(--black); font-weight: 500; text-align: center; }
.record { min-height: 18px; }
kbd { font-family: inherit; font-size: 12px; font-weight: 700; color: var(--ochre); background: var(--black); border-radius: 4px; padding: 0 5px; }

/* ---- the cards: the cloth's own weave ------------------------------------------ */
.panel {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 26px 16px; overflow-y: auto; background: rgba(30, 26, 23, 0.45);
}
.panel[hidden] { display: none; }
.panel > .card { margin: auto; }
.card {
  width: min(470px, 100%); color: var(--black);
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0 2px, transparent 2px 6px), #e8b54e;
  border: 8px solid transparent; border-radius: 12px;
  border-image: repeating-linear-gradient(90deg, var(--black) 0 10px, var(--red) 10px 20px, var(--green) 20px 30px) 8;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  padding: 20px 22px 18px;
}
.card h2 { font-family: "Fraunces", serif; font-weight: 800; font-size: 34px; }
.card .tag { font-weight: 700; color: var(--red); margin: 2px 0 10px; }
.card .how { font-size: 15px; line-height: 1.5; margin-bottom: 12px; }
.card .how b { color: var(--wood-deep); }
.seg { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.seg button {
  font-family: inherit; font-size: 16px; text-align: left; cursor: pointer; color: var(--black);
  background: rgba(255, 245, 220, 0.55); border: 2px solid var(--black); border-radius: 8px; padding: 7px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.seg button b { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.seg button small { font-size: 13px; color: #5a4320; }
.seg button.on { background: var(--green); color: var(--cream); }
.seg button.on small { color: #d8ead9; }
.playbtn, .card .row button:first-child {
  font-family: "Fraunces", serif; font-weight: 800; cursor: pointer; color: var(--cream);
  background: linear-gradient(175deg, var(--wood-hi), var(--wood) 60%, var(--wood-deep)); border: 2px solid var(--black); border-radius: 10px;
  box-shadow: 0 3px 0 var(--black);
}
.playbtn { width: 100%; font-size: 22px; padding: 9px 12px; }
.playbtn:active, .card .row button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--black); }
.card.end { text-align: center; }
.card .big { font-family: "Fraunces", serif; font-weight: 800; font-size: 40px; margin: 4px 0; }
.card .stats { font-size: 15px; margin: 2px 0 16px; white-space: pre-line; color: #4a3518; }
.card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.card .row button { font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer; color: var(--black);
  background: rgba(255, 245, 220, 0.6); border: 2px solid var(--black); border-radius: 10px; padding: 8px 16px; }
.card .row button:first-child { font-size: 17px; }

@media (max-width: 640px) {
  .cloth { padding-top: 58px; gap: 10px; }
  .title { font-size: 32px; }
  .board { gap: 6px; padding: 10px; border-radius: 34px; grid-template-columns: 1fr repeat(6, 1fr) 1fr; }
  .n { font-size: 12px; padding: 2px 5px; min-width: 20px; }
  .store .n { font-size: 14px; }
  .side { padding: 4px 8px; }
  .side b { font-size: 19px; }
  .turn { font-size: 13px; }
  .panel { padding-top: 62px; }
  .card h2 { font-size: 28px; }
}

.gs-pause { background: rgba(30, 26, 23, 0.5); }
