:root {
  --sky: #74c7ff;
  --sky2: #d8f1ff;
  --sun: #ffe27a;
  --grass: #7ac85b;
  --grass2: #4fa344;
  --panel: rgba(255, 255, 255, 0.92);
  --text: #20401c;
  --muted: #4d6a42;
  --line: rgba(40, 80, 30, 0.12);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", ui-rounded, system-ui, sans-serif;
}

button, input {
  font: inherit;
  color: inherit;
}

.app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 86% 12%, var(--sun) 0 30px, rgba(255, 226, 122, 0.42) 31px, transparent 78px),
    linear-gradient(180deg, var(--sky) 0 40%, var(--sky2) 50%, #b6e27a 50%, var(--grass) 68%, var(--grass2) 100%);
}

.app.sad-sky {
  background:
    radial-gradient(circle at 86% 12%, #c9b48a 0 30px, transparent 78px),
    linear-gradient(180deg, #6a7f99 0 40%, #9aa9b8 50%, #5d7a48 50%, #4e6d3e 100%);
}

.app.rotated {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 100dvh;
  height: 100dvw;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}

.cloud {
  position: absolute;
  background: #fff;
  border-radius: 40px;
  opacity: 0.92;
  pointer-events: none;
  animation: drift 28s linear infinite;
}

.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.cloud.a { top: 8%; left: 8%; width: 90px; height: 28px; }
.cloud.a::before { width: 38px; height: 38px; top: -18px; left: 14px; }
.cloud.a::after { width: 28px; height: 28px; top: -12px; left: 44px; }
.cloud.b { top: 16%; left: 48%; width: 70px; height: 22px; animation-duration: 36s; }
.cloud.b::before { width: 30px; height: 30px; top: -14px; left: 10px; }
.cloud.b::after { width: 22px; height: 22px; top: -10px; left: 34px; }
.cloud.c { top: 6%; left: 72%; width: 80px; height: 24px; animation-duration: 32s; animation-delay: -8s; }
.cloud.c::before { width: 34px; height: 34px; top: -16px; left: 12px; }
.cloud.c::after { width: 24px; height: 24px; top: -10px; left: 42px; }

@keyframes drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(40px); }
}

.hill {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 18%;
  height: 28%;
  border-radius: 50% 50% 0 0;
  background: #8ed36a;
  pointer-events: none;
}

.hill.back {
  bottom: 26%;
  height: 22%;
  background: #a6e07d;
}

.tuft, .flower {
  position: absolute;
  pointer-events: none;
}

.tuft {
  width: 18px;
  height: 14px;
  border-radius: 40% 40% 0 0;
  background: #3f9a3a;
}

.tuft::before, .tuft::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 16px;
  border-radius: 40% 40% 0 0;
  background: #5cb24a;
}

.tuft::before { left: -6px; transform: rotate(-18deg); }
.tuft::after { right: -6px; transform: rotate(18deg); background: #2f7d32; }
.t1 { left: 12%; bottom: 12%; }
.t2 { left: 48%; bottom: 8%; }
.t3 { left: 78%; bottom: 14%; }

.flower {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffd36a;
  box-shadow: 8px 0 0 #ff8aa0, -8px 0 0 #ff8aa0, 0 8px 0 #fff, 0 -8px 0 #fff;
}

.f1 { left: 22%; bottom: 18%; }
.f2 { left: 63%; bottom: 10%; }
.f3 { left: 86%; bottom: 22%; }

.screen {
  position: relative;
  z-index: 1;
  height: 100%;
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
}

.home {
  display: grid;
  grid-template-columns: 1.05fr 0.9fr;
  gap: 16px;
  align-items: stretch;
}

.brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 8px 8px 6px;
}

.eyebrow {
  display: inline-block;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  color: #2f6b28;
  font-size: 11px;
  letter-spacing: 0.16em;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(26px, 5.4vw, 42px);
  line-height: 1.1;
}

.lead, .hint, .rules {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.panel {
  margin: auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(40, 80, 20, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.label { font-size: 13px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 8px; }

.circle-btn, .primary, .ghost, .icon-btn, .ghost-btn {
  border: 0;
  cursor: pointer;
}

.circle-btn, .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e8f6d8;
  font-size: 18px;
}

.count {
  min-width: 42px;
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  color: #d88912;
}

.primary, .ghost {
  min-height: 42px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
}

.primary {
  background: linear-gradient(180deg, #ffd56a, #f0b030);
  color: #4a2d00;
}

.ghost {
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--line);
}

.ghost.light {
  color: #fff8ee;
  border-color: rgba(255,255,255,0.35);
}

.ghost-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.78);
  font-size: 12px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  z-index: 3;
}

.pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.78);
  font-size: 12px;
  font-weight: 700;
}

.spacer { flex: 1; }

.pasture {
  position: relative;
  flex: 1;
  min-height: 0;
}

.sheep {
  position: absolute;
  width: 15%;
  max-width: 150px;
  min-width: 72px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transform: scale(var(--size, 1));
  transform-origin: center bottom;
}

.sheep.flip { transform: scale(var(--size, 1)) scaleX(-1); }
.sheep.flip .badge { transform: translate(-50%, -10%) scaleX(-1); }

.sheep img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 6px 4px rgba(40, 80, 20, 0.18));
}

.grazing img {
  animation: nibble 2.8s ease-in-out infinite;
  transform-origin: 70% 80%;
}

.grazing {
  animation: wander var(--walk, 6s) ease-in-out infinite;
}

.badge {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translate(-50%, -10%);
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff6c8;
  border: 2px solid #e2b23a;
  color: #5b3b00;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  z-index: 2;
}

.bubble {
  position: absolute;
  top: 8%;
  right: 8%;
  padding: 2px 7px;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  z-index: 2;
}

.sheep.leaving {
  animation: walk-off 0.95s ease forwards;
  pointer-events: none;
  z-index: 4;
}

.sheep.gone {
  visibility: hidden;
  pointer-events: none;
}

.sheep.wolf-hit { animation: shock 0.55s ease; }
.sheep.disabled { pointer-events: none; }

@keyframes nibble {
  0%, 28%, 100% { transform: rotate(0); }
  40%, 62% { transform: rotate(10deg) translate(2px, 6px); }
}

@keyframes wander {
  0%, 100% { transform: translate(0, 0) scale(var(--size, 1)); }
  25% { transform: translate(10px, 5px) scale(var(--size, 1)); }
  50% { transform: translate(-6px, 8px) scale(var(--size, 1)); }
  75% { transform: translate(8px, -4px) scale(var(--size, 1)); }
}

@keyframes walk-off {
  0% { transform: translate(0, 0) scale(var(--size, 1)); }
  20% { transform: translate(8%, -8%) rotate(-8deg) scale(var(--size, 1)); }
  55% { transform: translate(42%, 4%) rotate(8deg) scale(var(--size, 1)); }
  100% { transform: translate(130%, 10%) rotate(10deg) scale(var(--size, 1)); opacity: 0; }
}

@keyframes shock {
  0%, 100% { transform: translateX(0) scale(var(--size, 1)); }
  20% { transform: translateX(-8px) rotate(-6deg) scale(var(--size, 1)); }
  40% { transform: translateX(8px) rotate(6deg) scale(var(--size, 1)); }
  60% { transform: translateX(-6px) scale(var(--size, 1)); }
  80% { transform: translateX(6px) scale(var(--size, 1)); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(90, 160, 70, 0.28);
  backdrop-filter: blur(6px);
  text-align: center;
  padding: 16px;
}

.overlay.dark {
  background: rgba(40, 28, 28, 0.45);
  color: #fff8ee;
}

.overlay.dim {
  background: rgba(20, 28, 18, 0.46);
}

.popup {
  width: min(360px, 86%);
  padding: 18px 18px 16px;
  border-radius: 22px;
  background: #fffdf7;
  box-shadow: 0 18px 40px rgba(30, 40, 20, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: pop-in 0.28s ease;
}

.wolf-popup {
  border: 3px solid #e25b4a;
}

.popup-sheep {
  width: 120px;
  height: auto;
  margin-top: -8px;
}

.popup-tag {
  padding: 6px 16px;
  border-radius: 999px;
  background: #e25b4a;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

@keyframes pop-in {
  0% { transform: scale(0.82); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.overlay h2 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
}

.overlay .primary, .overlay .ghost { width: min(280px, 70%); }

.rules { text-align: left; }
.rules b { color: var(--text); }
