:root {
  --bg: #f4efe6;
  --text: #2b2118;
  --muted: #6f5f50;
  --wood: #9a6434;
  --wood-dark: #6e4322;
  --pit: #5a3519;
  --pit-hover: #734623;
  --accent: #e0a33a;
  --capture: #d9534f;
  --panel: #fffaf2;
  --border: #d8cbb8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1916;
    --text: #efe6da;
    --muted: #b3a593;
    --wood: #7a4d27;
    --wood-dark: #4f3018;
    --pit: #3c2210;
    --pit-hover: #553219;
    --panel: #2a241f;
    --border: #4a3f35;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

h1 { margin: 0; font-size: 28px; letter-spacing: 0.5px; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.controls label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }

select, button {
  font: inherit;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
button { cursor: pointer; background: var(--accent); border-color: var(--accent); color: #2b1a08; font-weight: 600; }
button:hover { filter: brightness(1.05); }

.side-label { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); text-align: center; margin: 6px 0; }

.board {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 6fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  padding: 16px;
  border-radius: 999px / 120px;
  background: linear-gradient(180deg, var(--wood), var(--wood-dark));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.15);
}

.store { grid-row: 1 / span 2; border-radius: 999px; }
#slot-13 { grid-column: 1; }
#slot-6 { grid-column: 3; }
.row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; grid-column: 2; }
.row.top { grid-row: 1; }
.row.bottom { grid-row: 2; }

.pit, .store {
  position: relative;
  background: radial-gradient(circle at 50% 40%, var(--pit-hover), var(--pit));
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.5);
  min-height: 0;
}

.pit { aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; transition: border-color 120ms, transform 120ms; }
.pit.playable { cursor: pointer; }
.pit.playable:hover, .pit.playable:focus-visible { border-color: var(--accent); outline: none; transform: translateY(-2px); }
.pit.last, .store.last { border-color: rgba(224, 163, 58, 0.55); }
.store { border: 3px solid transparent; }
.pit.capture, .store.capture { border-color: var(--capture); }
.pit.sowing, .store.sowing { border-color: #fff3; }

.pit.chosen { border-color: var(--accent); animation: pulse 0.45s ease-in-out infinite alternate; }
.pit.target, .store.target { border-color: rgba(255, 255, 255, 0.45); }

@keyframes pulse {
  from { box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(224, 163, 58, 0.7); }
  to { box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.5), 0 0 0 8px rgba(224, 163, 58, 0); }
}

/* Animation overlay: the floating hand and seeds in flight. */
.anim-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.anim-layer .seed.flying { left: 0; top: 0; z-index: 2; }

.hand {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 200, 0.35), rgba(224, 163, 58, 0.18) 60%, transparent 72%);
  border: 2px solid rgba(255, 220, 160, 0.85);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}
.hand-seeds { position: absolute; inset: 0; }
.hand-seeds .seed { width: 26%; }
.hand-count {
  position: absolute;
  top: -10px;
  right: -10px;
  min-width: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #2b1a08;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.count {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translate(-50%, 50%);
  min-width: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  z-index: 2;
}
.row.top .count { top: -2px; bottom: auto; transform: translate(-50%, -50%); }
.store .count { font-size: 16px; padding: 2px 10px; bottom: 50%; transform: translate(-50%, 50%); }

.seed {
  position: absolute;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset -1px -2px 2px rgba(0, 0, 0, 0.35), inset 1px 1px 1px rgba(255, 255, 255, 0.5);
}
.store .seed { width: 22%; }

.status { text-align: center; font-size: 18px; font-weight: 600; margin: 22px 0 4px; min-height: 27px; }
.score { text-align: center; color: var(--muted); margin: 0 0 20px; }

.rules {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
}
.rules summary { cursor: pointer; font-weight: 600; }
.rules li { margin: 4px 0; }
kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 13px; }

@media (max-width: 600px) {
  .board { gap: 6px; padding: 10px; border-radius: 28px; }
  .row { gap: 6px; }
  .count { font-size: 11px; min-width: 20px; }
}
