:root {
  --grass: #5c9a4a;
  --grass-dark: #3f7434;
  --ink: #fffdf5;
  --muted: #e2f0d8;
  --accent: #ffb547;
  --bad: #ff6b8b;
  --panel: rgba(255, 252, 245, .96);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #2e4a2f; color: var(--ink); overflow: hidden; }
body { font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }

#app {
  position: relative; height: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle at 20% 15%, #7fc26a 0 2px, transparent 3px) 0 0 / 38px 38px, linear-gradient(#78b860, var(--grass) 40%, var(--grass-dark));
}

.hud { display: flex; align-items: center; gap: 14px; padding: max(12px, env(safe-area-inset-top)) 12px 6px; }
.home { width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.18); color: var(--ink); text-decoration: none; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.stat small { display: block; font-size: 11px; color: var(--muted); }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.stat.combo b { color: #fff3a8; }
.stat.time { margin-left: auto; text-align: right; }
.stat.time.low b { color: #ffd0d8; animation: blink .5s infinite alternate; }
@keyframes blink { to { opacity: .5; } }
.timebar { height: 8px; margin: 2px 14px 6px; border-radius: 4px; background: rgba(0,0,0,.2); overflow: hidden; }
.timebar span { display: block; height: 100%; width: 100%; background: #fff3a8; transform-origin: left; }

.field { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); gap: 4px 10px; padding: 8px 14px max(18px, env(safe-area-inset-bottom)); touch-action: manipulation; }
.hole { position: relative; display: flex; align-items: flex-end; justify-content: center; }
.hole::before { /* the dirt mound */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: 4%; height: 30%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 35%, #3a2a1c 55%, #6b4a2b 58%, #8a6238 75%, transparent 76%);
}
.pop { position: absolute; left: 50%; bottom: 18%; width: min(112px, 88%); aspect-ratio: 1; margin-left: calc(min(112px, 88%) / -2); overflow: hidden; border-radius: 0 0 50% 50% / 0 0 30% 30%; height: auto; }
.pop .who {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%; padding: 0; background: none; transform: translateY(105%);
  transition: transform .14s ease-out; display: grid; place-items: center;
}
.pop .who img { width: 100%; height: 100%; display: block; pointer-events: none; }
.pop .who.tub { font-size: min(64px, 15vw); line-height: 1; }
.hole.up .who { transform: translateY(0); }
.hole.hit .who { transform: translateY(105%) scale(.8, 1.1); transition-duration: .22s; }
.hole::after { /* front lip of the hole, drawn over the pet */
  content: ""; position: absolute; left: 10%; right: 10%; bottom: 4%; height: 15%; border-radius: 0 0 50% 50%;
  background: #8a6238; box-shadow: inset 0 -4px 0 #6b4a2b; pointer-events: none; z-index: 2;
}

.fx { position: absolute; left: 50%; bottom: 55%; transform: translateX(-50%); font-weight: 900; font-size: 20px; pointer-events: none; z-index: 3; animation: fx .7s ease-out forwards; text-shadow: 0 2px 0 rgba(0,0,0,.25); white-space: nowrap; }
.fx.bad { color: var(--bad); }
.fx.gold { color: #fff3a8; font-size: 24px; }
@keyframes fx { from { opacity: 1; transform: translate(-50%, 0) scale(.8); } 30% { transform: translate(-50%, -14px) scale(1.15); } to { opacity: 0; transform: translate(-50%, -46px) scale(1); } }
#app.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.panel { position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); display: none; text-align: center; padding: 22px 18px; border-radius: 24px; background: var(--panel); color: #2e3a28; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 5; }
.panel.show { display: block; }
.panel h1, .panel h2 { margin: 0 0 8px; color: #d9820e; letter-spacing: 3px; }
.panel h1 { font-size: 30px; }
.panel p { margin: 6px 0; line-height: 1.6; font-size: 14px; color: #55624c; }
.panel .tub { font-size: 18px; }
.panel .big { font-size: 52px; font-weight: 900; color: #2e3a28; margin: 2px 0; font-variant-numeric: tabular-nums; }
.best { color: #d9820e !important; min-height: 1.2em; }
.primary, .ghost { display: block; width: 100%; margin-top: 10px; padding: 13px; border-radius: 999px; font-weight: 800; font-size: 17px; text-decoration: none; text-align: center; }
.primary { background: var(--accent); color: #3b1d05; box-shadow: 0 4px 0 #c47a12; }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #c47a12; }
.ghost { background: rgba(0,0,0,.06); color: #2e3a28; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; background: #2e4a2f; z-index: 6; }
.loading.hide { display: none; }
