:root {
  --green: #2FA86A;
  --green-d: #1f7d4e;
  --ink: #21331f;
  --paper: #F3FBEF;
  --gold: #F2C53D;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: Nunito, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: #BDE6C6;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,0.55) 0%, transparent 45%),
    radial-gradient(circle at 85% 88%, rgba(47,168,106,0.25) 0%, transparent 55%),
    linear-gradient(180deg, #CFEFD4 0%, #A9DDB6 100%);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ───────── Top bar ───────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.title {
  font-family: Chewy, Nunito, sans-serif;
  font-size: clamp(26px, 7vw, 40px);
  color: var(--green-d);
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(31,125,78,0.25);
  margin: 0;
  letter-spacing: 0.5px;
}
.stats { display: flex; gap: 8px; }
.stat {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 12px;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 2px 3px 0 rgba(33,51,31,0.25);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.stat .ic { font-size: 18px; }

/* ───────── Stage (the wild) ───────── */
.stage {
  position: relative;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,0.6), transparent 60%),
    linear-gradient(180deg, #DDF3E1, #BCE6C6);
  border: 4px solid var(--ink);
  border-radius: 26px;
  box-shadow: 4px 6px 0 rgba(33,51,31,0.22);
  min-height: 340px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  overflow: hidden;
}
.grass {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 46px;
  background:
    radial-gradient(circle at 10% 0, var(--green) 14px, transparent 15px) 0 0/40px 46px repeat-x,
    var(--green-d);
  opacity: 0.85;
}

/* the moving critter you tap to catch — a countdown ring wraps it */
.critter {
  position: absolute;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff, #eef7ef 70%);
  border: 3px solid var(--ink);
  cursor: pointer;
  box-shadow: inset 0 -6px 12px rgba(33,51,31,0.12), 2px 4px 0 rgba(33,51,31,0.18);
  z-index: 3;
  will-change: left, top;
  touch-action: none;
}
.critter:active { filter: brightness(0.94); }
.critter .ring { position: absolute; inset: 0; transform: rotate(-90deg); pointer-events: none; }
.ring-bg { fill: none; stroke: rgba(33,51,31,0.15); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--gold); stroke-width: 8; stroke-linecap: round; }
.critter .pic-holder {
  position: absolute; inset: 13px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.critter .pic { width: 100%; height: 100%; }
.critter .pic img { width: 100%; height: 100%; object-fit: contain; }
.critter .pic .emoji { font-size: 72px; line-height: 1; }

.stage-hint {
  position: absolute; top: 10px; left: 0; right: 0;
  text-align: center; z-index: 1;
  font-family: Chewy, sans-serif; font-size: 18px;
  color: rgba(31,125,78,0.85);
  pointer-events: none;
}

.stage-msg {
  font-family: Chewy, sans-serif;
  font-size: clamp(22px, 6vw, 34px);
  text-align: center;
  z-index: 2;
}
.stage-msg.good { color: var(--green-d); }
.stage-msg.miss { color: #c0492f; }
.stage-msg .sub { display: block; font-family: Nunito; font-weight: 800; font-size: 16px; color: var(--ink); margin-top: 6px; }

/* float-up coin / reveal */
.pop {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-family: Chewy, sans-serif;
  font-size: 30px;
  color: var(--gold);
  text-shadow: 1px 1px 0 var(--ink);
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
  z-index: 5;
}
@keyframes floatUp { from { opacity: 1; } to { opacity: 0; transform: translate(-50%, -60px); } }

/* ───────── Buy-in ───────── */
.buyin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  border: 3px dashed var(--ink);
  border-radius: 18px;
  padding: 10px 16px;
  font-weight: 800;
}
.buyin button {
  font-family: Nunito; font-weight: 900; font-size: 15px;
  background: var(--gold);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b88f1e;
}
.buyin button:active { transform: translateY(3px); box-shadow: 0 1px 0 #b88f1e; }
.buyin button:disabled { opacity: 0.45; cursor: default; }

/* ───────── Encyclopedia ───────── */
.book h2 {
  font-family: Chewy, sans-serif;
  color: var(--green-d);
  font-size: 24px;
  margin: 6px 0 2px;
}
.set { margin-bottom: 14px; }
.set-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Chewy, sans-serif;
  font-size: 18px;
  margin: 8px 0 6px;
}
.set-head .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.set-head .lock { font-size: 14px; font-family: Nunito; font-weight: 800; opacity: 0.7; }
.set-head .done { color: var(--green-d); font-family: Nunito; font-weight: 900; font-size: 14px; }

.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 8px 6px;
  text-align: center;
  position: relative;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.slot .num {
  position: absolute; top: 4px; left: 8px;
  font-family: Chewy, sans-serif; font-size: 14px; color: var(--green-d);
}
.slot .star { position: absolute; top: 4px; right: 8px; font-size: 13px; }
.slot .pic { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; }
.slot .pic img { width: 100%; height: 100%; object-fit: contain; }
.slot .pic .emoji { font-size: 44px; line-height: 1; }
.slot .nm { font-weight: 900; font-size: 13px; }

.slot.locked { background: #e6efe4; }
.slot.locked .pic, .slot.locked .nm { filter: grayscale(1); opacity: 0.35; }
.slot.uncaught .pic { filter: brightness(0) opacity(0.35); }
.slot.uncaught .nm { color: rgba(33,51,31,0.4); }
.slot.just-caught { animation: pulse 0.6s ease; }
@keyframes pulse { 0% { transform: scale(1); } 40% { transform: scale(1.14); box-shadow: 0 0 0 6px rgba(242,197,61,0.5); } 100% { transform: scale(1); } }

.footer { text-align: center; margin-top: 6px; }
.footer button {
  font-family: Nunito; font-weight: 800; font-size: 13px;
  background: transparent; border: 2px solid rgba(33,51,31,0.4);
  border-radius: 10px; padding: 6px 14px; color: rgba(33,51,31,0.7); cursor: pointer;
}
.home {
  display: inline-block; font-family: Chewy, sans-serif; text-decoration: none;
  color: var(--green-d); font-size: 16px;
}
