/* Catch the Wolf — UI layer. The world is drawn on #stage; everything with
   text or a button lives in #ui on top. Colours echo the art palette. */

:root {
  --ink: #262a3b;
  --cream: #fff7e4;
  --cream-2: #f3e3bd;
  --red: #ee5b3f;
  --red-dark: #b8381f;
  --gold: #f7c548;
  --gold-dark: #c98f17;
  --green: #6cc644;
  --green-dark: #3f8a22;
  --sky: #69b7e6;
  --sky-dark: #2f7fb3;
  --grey: #c9ccd6;
  --grey-dark: #8e93a3;
  --title: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #5fa630; }
body { font-family: var(--body); color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }

#stage { position: fixed; inset: 0; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui * { pointer-events: auto; }
#ui .passthrough, #ui .passthrough * { pointer-events: none; }
#ui .passthrough button { pointer-events: auto; }

#boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  font: 900 20px var(--body); color: #fff; background: #5fa630;
}

/* ---------- buttons ---------- */
.btn {
  --c: var(--cream); --d: var(--cream-2); --t: var(--ink);
  font: 400 22px/1 var(--title); letter-spacing: 0.5px; color: var(--t);
  background: var(--c);
  border: 3.5px solid var(--ink);
  border-radius: 18px;
  padding: 13px 26px 15px;
  box-shadow: inset 0 -6px 0 var(--d), 0 5px 0 var(--ink);
  cursor: pointer;
  transform: translateY(0);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  text-shadow: 0 2px 0 rgba(0,0,0,0.12);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: inset 0 -3px 0 var(--d), 0 1px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.btn[disabled] { filter: grayscale(0.7) brightness(0.92); cursor: default; }
.btn.red   { --c: var(--red);   --d: var(--red-dark);   --t: #fff; }
.btn.gold  { --c: var(--gold);  --d: var(--gold-dark); }
.btn.green { --c: var(--green); --d: var(--green-dark); --t: #fff; }
.btn.sky   { --c: var(--sky);   --d: var(--sky-dark);   --t: #fff; }
.btn.red, .btn.green, .btn.sky { text-shadow: 0 2px 0 rgba(0,0,0,0.25); }
.btn.big { font-size: 30px; padding: 16px 44px 19px; border-radius: 22px; }
.btn.small { font-size: 17px; padding: 8px 14px 10px; border-radius: 14px; box-shadow: inset 0 -4px 0 var(--d), 0 4px 0 var(--ink); }
.btn.icon { width: 50px; height: 50px; padding: 0; border-radius: 16px; font-size: 24px; }
.btn img { height: 1.15em; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(10px + var(--safe-top)) 12px 0;
  display: flex; align-items: center; gap: 10px;
}
.hud .spacer { flex: 1; }
.chip {
  font: 400 20px/1 var(--title); color: var(--ink);
  background: var(--cream); border: 3px solid var(--ink); border-radius: 999px;
  padding: 5px 14px 6px 6px; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 0 var(--ink);
}
.chip img { width: 40px; height: 40px; margin: -8px 0 -8px -2px; }
.chip.pop { animation: pop 0.35s; }
.chip .label { font: 800 11px/1 var(--body); text-transform: uppercase; opacity: 0.6; display: block; letter-spacing: 0.5px; }
.chip.streak { padding-left: 12px; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

.bottombar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 12px calc(12px + var(--safe-bottom));
  display: flex; align-items: flex-end; gap: 10px;
}
.bottombar .spacer { flex: 1; }

/* Toast / banner in the middle of the play field */
.banner {
  position: absolute; left: 50%; top: calc(92px + var(--safe-top)); transform: translate(-50%, 0);
  background: rgba(38, 42, 59, 0.62); border-radius: 22px; padding: 12px 22px 14px;
  font: 400 30px/1.05 var(--title); color: #fff; text-align: center;
  -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
  white-space: nowrap; pointer-events: none !important;
  animation: banner 1.6s ease-out forwards;
}
.banner small { display: block; font-size: 19px; margin-top: 6px; -webkit-text-stroke-width: 5px; }
.banner.low { top: auto; bottom: calc(110px + var(--safe-bottom)); }
.banner.good { color: #fff4a8; }
.banner.bad { color: #ffb4a6; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 18px) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  25% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(1); }
}

/* ---------- panels / dialogs ---------- */
.scrim {
  position: absolute; inset: 0; background: rgba(30, 40, 30, 0.45);
  display: grid; place-items: center; padding: 18px;
  animation: fade 0.2s;
}
@keyframes fade { from { opacity: 0; } }
.panel {
  background: var(--cream); border: 4px solid var(--ink); border-radius: 26px;
  box-shadow: inset 0 -8px 0 var(--cream-2), 0 8px 0 var(--ink);
  padding: 22px 22px 26px; width: min(420px, 100%); text-align: center;
  animation: rise 0.28s cubic-bezier(.2,1.4,.4,1);
  max-height: calc(100% - 20px); overflow: auto;
}
@keyframes rise { from { transform: translateY(30px) scale(0.92); opacity: 0; } }
.panel h2 { font: 400 32px/1 var(--title); margin: 0 0 10px; }
.panel p { font: 700 17px/1.4 var(--body); margin: 8px 0 16px; }
.panel .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.panel .art { display: block; margin: 0 auto 6px; }
.panel .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 16px; }
.panel .stat { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px; }
.panel .stat b { display: block; font: 400 26px/1 var(--title); }
.panel .stat span { font: 800 12px/1 var(--body); text-transform: uppercase; opacity: 0.65; }

.toggle { display: flex; align-items: center; justify-content: space-between; font: 800 18px var(--body); padding: 10px 4px; border-bottom: 2px dashed var(--cream-2); }
.toggle input { width: 52px; height: 30px; appearance: none; background: var(--grey); border: 3px solid var(--ink); border-radius: 999px; position: relative; cursor: pointer; transition: background 0.15s; }
.toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: left 0.15s; }
.toggle input:checked { background: var(--green); }
.toggle input:checked::after { left: 24px; }

/* ---------- title ---------- */
.title-wrap {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(max(6vh, 72px) + var(--safe-top)) 16px calc(5vh + var(--safe-bottom));
}
.logo {
  font: 400 clamp(52px, 15vw, 96px)/0.86 var(--title); color: #fff; text-align: center;
  -webkit-text-stroke: 12px var(--ink); paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--ink);
  margin: 0; transform: rotate(-3deg);
  animation: bob 3.5s ease-in-out infinite;
}
.logo .the { display: block; font-size: 0.45em; color: var(--gold); margin: 6px 0; }
.logo .wolf { color: #b9c6dc; }
@keyframes bob { 50% { transform: rotate(-3deg) translateY(-6px); } }
.tagline { font: 900 17px var(--body); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.35); margin-top: 18px; text-align: center; }
.menu { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.menu .pair { display: flex; gap: 14px; }
.corner { position: absolute; top: calc(12px + var(--safe-top)); right: 12px; }

/* ---------- shop ---------- */
.shop-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.shop-head { padding: calc(10px + var(--safe-top)) 12px 6px; display: flex; align-items: center; gap: 10px; }
.shop-head h1 { flex: 1; text-align: center; font: 400 34px/1 var(--title); color: #fff; margin: 0; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.shop-sub { text-align: center; font: 900 15px var(--body); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.35); margin: 2px 0 8px; }
.shop-grid {
  flex: 1; overflow-y: auto; padding: 8px 14px calc(24px + var(--safe-bottom));
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
  align-content: start; max-width: 760px; width: 100%; margin: 0 auto;
  touch-action: pan-y;
}
.card {
  background: var(--cream); border: 3.5px solid var(--ink); border-radius: 20px;
  box-shadow: inset 0 -6px 0 var(--cream-2), 0 5px 0 var(--ink);
  padding: 8px 10px 12px; text-align: center; position: relative;
}
.card img.sheep { width: 100%; max-width: 120px; aspect-ratio: 1 / 1.15; display: block; margin: 0 auto -4px; }
.card h3 { font: 400 19px/1.05 var(--title); margin: 2px 0 8px; min-height: 2.1em; display: grid; place-items: center; }
.card .owned { position: absolute; top: 8px; right: 8px; font: 900 13px var(--body); background: var(--green); color: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 2px 8px; }
.card .btn { width: 100%; }
.card.locked img.sheep { filter: brightness(0) opacity(0.25); }

/* ---------- farm ---------- */
.nameplate {
  position: absolute; transform: translate(-50%, -100%);
  font: 400 17px/1 var(--title); color: var(--ink); background: var(--cream);
  border: 3px solid var(--ink); border-radius: 12px; padding: 5px 10px 6px;
  box-shadow: 0 3px 0 var(--ink); pointer-events: none !important; white-space: nowrap;
  animation: rise 0.25s cubic-bezier(.2,1.4,.4,1);
}
.empty-farm { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); width: min(340px, 90%); }

@media (max-height: 640px) {
  .btn.big { font-size: 26px; padding: 12px 36px 15px; }
  .logo { font-size: clamp(44px, 12vw, 80px); }
}

.btn.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }

@media (prefers-reduced-motion: reduce) {
  .logo, .btn.pulse { animation: none; }
  .banner { animation-duration: 2.2s; }
  .panel, .scrim, .nameplate, .chip.pop { animation: none; }
}

/* Press your luck: pelts you hold are at risk until spent. */
.chip.at-risk { position: relative; }
.chip.at-risk::after {
  content: 'at risk'; position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%);
  font: 900 10px/1 var(--body); text-transform: uppercase; letter-spacing: 0.5px;
  color: #fff; background: var(--red); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 6px;
  white-space: nowrap;
}

.shop-section { grid-column: 1 / -1; margin: 8px 0 -2px; font: 400 24px/1 var(--title); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.card h3 small { display: block; font: 800 11px/1.2 var(--body); opacity: 0.6; margin-top: 3px; }
.card.goodie img.sheep { aspect-ratio: 1 / 1; max-width: 96px; }

/* Farm pantry tray: food waiting to be put out */
.tray { position: absolute; left: 0; right: 0; bottom: calc(76px + var(--safe-bottom)); display: flex; justify-content: center; gap: 8px; padding: 0 12px; flex-wrap: wrap; }
.tray .btn img { height: 30px; margin: -6px -2px; }
.tray .btn.armed { --c: var(--green); --d: var(--green-dark); --t: #fff; animation: pulse 1s ease-in-out infinite; }

.tabs { display: flex; justify-content: center; gap: 10px; margin: 0 0 6px; }

.panel img.tellcard { display: block; width: 100%; max-width: 340px; margin: 4px auto 0; background: #8fcf5a; border: 3px solid var(--ink); border-radius: 16px; }

/* Wolf Stampede countdown (the bonus round is the one place a timer shows) */
.stampede-bar { position: absolute; left: 50%; top: calc(70px + var(--safe-top)); transform: translateX(-50%); width: min(420px, 80%); height: 16px; background: var(--cream); border: 3px solid var(--ink); border-radius: 999px; overflow: hidden; box-shadow: 0 3px 0 var(--ink); }
.stampede-bar > div { height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width 0.1s linear; }
