/* Stone Pits — Playnesta (MIT). Warm stone shell, sand ink for the stores. */

:root {
  --bg: #12100e;
  --panel: #1b1815;
  --panel-2: #241f1a;
  --line: #3a322a;
  --ink: #f0e9e0;
  --muted: #a89b8c;
  --sand: #e0a45f;
  --sand-soft: #3b2c16;
  --good: #6fd18a;
  --bad: #e8776a;
  --gap: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 900px;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.title small {
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.spacer {
  flex: 1 1 auto;
}

.hud {
  display: flex;
  gap: 6px;
  align-items: baseline;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}

.hud b {
  color: var(--ink);
  font-weight: 600;
}

.hud .sep {
  opacity: 0.5;
}

/* ── controls ────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.btn,
.chip {
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  min-height: 34px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:hover,
.chip:hover {
  border-color: var(--sand);
}

.btn.primary {
  background: var(--sand);
  border-color: var(--sand);
  color: #201505;
  font-weight: 700;
}

.chip.on {
  border-color: var(--sand);
  color: var(--sand);
  background: var(--sand-soft);
}

.btn:focus-visible,
.chip:focus-visible,
.pit:focus-visible {
  outline: 2px solid var(--sand);
  outline-offset: 2px;
}

/* ── status ──────────────────────────────────────────────────────────── */
#status {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
  line-height: 1.35;
}

#status[data-tone="good"] {
  color: var(--good);
}

#status[data-tone="warn"] {
  color: var(--bad);
}

#status[data-tone="hint"] {
  color: var(--sand);
}

/* ── board ───────────────────────────────────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: minmax(44px, 0.9fr) repeat(6, minmax(0, 1fr)) minmax(44px, 0.9fr);
  grid-template-rows: repeat(2, minmax(34px, auto));
  gap: var(--gap);
  padding: 8px;
  background: linear-gradient(180deg, #2a2119 0%, #1d1813 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.pit {
  position: relative;
  font: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 4px 2px;
  border-radius: 50% / 42%;
  border: 1px solid #4a3d30;
  background: radial-gradient(circle at 50% 30%, #322820, #1f1913 78%);
  cursor: default;
  touch-action: manipulation;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.pit.mine {
  border-color: #5a4a37;
}

.pit.playable {
  cursor: pointer;
  border-color: var(--sand);
  box-shadow: 0 0 0 1px rgba(224, 164, 95, 0.18), 0 0 12px rgba(224, 164, 95, 0.12);
}

.pit.playable:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(224, 164, 95, 0.3), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.pit.dim {
  opacity: 0.82;
}

.pit.empty {
  background: radial-gradient(circle at 50% 30%, #241d17, #171310 80%);
}

.pit .count {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pit .tag {
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
  min-height: 9px;
}

.pit .seeds {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 2px;
  max-width: 100%;
  min-height: 0;
}

.pit.empty .seeds {
  display: none;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6d9ac, var(--sand) 70%);
  box-shadow: 0 0 2px rgba(224, 164, 95, 0.5);
  flex: 0 0 auto;
}

.pit .seeds .dot:nth-child(3n) {
  background: radial-gradient(circle at 35% 30%, #efe4d4, #b9a892 70%);
  box-shadow: 0 0 2px rgba(240, 233, 224, 0.35);
}

.store {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #262019, #17130f);
  min-height: 44px;
}

.store.mine {
  border-color: #6a5334;
  background: linear-gradient(180deg, #33281a, #1a1510);
}

.store .label {
  font-size: 9px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.store .count {
  font-size: 20px;
  font-weight: 700;
  color: var(--sand);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.store .seeds {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  padding: 0 3px;
}

.store.lead .count {
  color: var(--good);
}

/* ── move feedback ───────────────────────────────────────────────────── */
.pit.land {
  animation: land 0.65s ease-out;
}

@keyframes land {
  0% {
    box-shadow: 0 0 0 0 rgba(224, 164, 95, 0.8);
    transform: scale(1.08);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(224, 164, 95, 0);
    transform: scale(1);
  }
}

.pit.taken {
  animation: taken 0.7s ease-out;
}

@keyframes taken {
  0% {
    border-color: var(--bad);
    box-shadow: 0 0 0 0 rgba(232, 119, 106, 0.75);
  }
  100% {
    border-color: #4a3d30;
    box-shadow: 0 0 0 12px rgba(232, 119, 106, 0);
  }
}

.pit.hint {
  animation: hint 1.5s ease-in-out;
}

@keyframes hint {
  0%,
  100% {
    border-color: #4a3d30;
  }
  25%,
  75% {
    border-color: var(--good);
    box-shadow: 0 0 0 2px rgba(111, 209, 138, 0.35);
  }
}

/* ── legend ──────────────────────────────────────────────────────────── */
.legend {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── win dialog ──────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.overlay[hidden] {
  display: none;
}

.card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.card .crest {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.card h2 {
  margin: 4px 0 6px;
  font-size: 20px;
}

.card .score {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  color: var(--sand);
  font-variant-numeric: tabular-nums;
}

.card .detail,
.card .series {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.card-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

/* ── toast ───────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 12px);
  background: var(--sand);
  color: #201505;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── compact stages (the production iframe is small) ─────────────────── */
@media (max-height: 430px) {
  #app {
    gap: 6px;
    padding: 8px 10px 8px;
  }

  .title small,
  .legend {
    display: none;
  }

  .hud {
    font-size: 10px;
  }

  #board {
    gap: 5px;
    padding: 5px;
    grid-template-columns: minmax(38px, 0.85fr) repeat(6, minmax(0, 1fr)) minmax(38px, 0.85fr);
    grid-template-rows: repeat(2, minmax(34px, auto));
  }

  .pit {
    min-height: 34px;
    padding: 2px 1px;
  }

  .pit .count {
    font-size: 13px;
  }

  .btn,
  .chip {
    min-height: 34px;
    padding: 5px 9px;
    font-size: 11px;
  }

  #status {
    font-size: 11px;
  }
}

@media (max-width: 380px) {
  #app {
    padding: 10px 10px 12px;
  }

  .title {
    font-size: 15px;
  }

  .hud {
    font-size: 10px;
  }
}
