:root {
  --ink: #080b10;
  --paper: #f5fff6;
  --grid: rgba(168, 255, 220, 0.16);
  --cyan: #5cf6ff;
  --acid: #dfff54;
  --pink: #ff5fa8;
  --shadow: rgba(0, 0, 0, 0.44);
  --sky-top: #6ec1ee;
  --sky-low: #d3edff;
  --grass: #7cc44a;
  --grass-dark: #4f9b2c;
  --wood: #b1733f;
  --wood-dark: #6e4022;
  --barn: #c63a2b;
  --barn-dark: #93271d;
  --cream: #fcefce;
  --tone-0: #dfff54;
  --tone-1: #5cf6ff;
  --tone-2: #ffb84c;
  --tone-3: #fff27a;
  --tone-4: #71ff8c;
  --tone-5: #ff5fa8;
  --tone-6: #73e2ff;
  --tone-7: #cfa5ff;
  --tone-8: #ffcf5e;
  --tone-9: #74a9ff;
  --tone-10: #ff8f70;
  --tone-11: #cfff4a;
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top), #a9ddf6 55%, var(--sky-low)) fixed;
  overflow-x: hidden;
  touch-action: manipulation;
}

button { font: inherit; }

.stage {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(0.75rem, 1.8vw, 1.2rem);
  padding: clamp(0.8rem, 2vw, 1.6rem);
}

.topbar,
.deck,
.credit {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
}

.topbar h1 { grid-column: 2; }

h1 {
  margin: 0;
  color: #fffdf4;
  font-size: clamp(2.5rem, 8vw, 7.4rem);
  line-height: 0.82;
  letter-spacing: 0;
  -webkit-text-stroke: clamp(2px, 0.55vw, 4px) var(--wood-dark);
  paint-order: stroke fill;
  text-shadow: 0 0.14em 0 var(--wood-dark);
}

.deck {
  position: relative;
  min-height: 0;
  display: grid;
  align-items: center;
  padding: clamp(0.8rem, 1.8vw, 1.1rem);
  border: 3px solid var(--wood-dark);
  border-radius: 14px;
  background: linear-gradient(180deg,
    var(--sky-top) 0%, #9fd9f4 30%, var(--sky-low) 52%,
    var(--grass) 52%, var(--grass-dark) 100%);
  box-shadow: 0 1.2rem 2.6rem var(--shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.18);
  overflow: hidden;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.deck.is-overdrive {
  border-color: #ffcf5e;
  box-shadow: 0 1.2rem 2.6rem var(--shadow), inset 0 0 5rem rgba(255, 207, 94, 0.28), 0 0 2.4rem rgba(255, 207, 94, 0.45);
}

/* --------------------- farm scenery ---------------------------- */
.scene,
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene { z-index: 0; overflow: hidden; }
.fx-layer { z-index: 8; overflow: hidden; }

.scene .sun {
  position: absolute;
  top: 5%;
  right: 7%;
  width: clamp(3rem, 8vw, 6rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff6b0 0 40%, #ffd23f 72%, #ffb300 100%);
  box-shadow: 0 0 2.2rem rgba(255, 210, 80, 0.7), 0 0 5rem rgba(255, 210, 80, 0.45);
}

.scene .cloud {
  position: absolute;
  height: clamp(1.3rem, 3vw, 2.3rem);
  width: clamp(4rem, 11vw, 8rem);
  background: #ffffff;
  border-radius: 999px;
  box-shadow: 0 0.25rem 0 rgba(120, 150, 170, 0.12);
}

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

.scene .cloud::before { width: 54%; height: 175%; left: 10%; }
.scene .cloud::after { width: 44%; height: 140%; right: 12%; }
.scene .c1 { top: 11%; left: 7%; }
.scene .c2 { top: 24%; left: 52%; transform: scale(0.78); opacity: 0.92; }

.scene .hill {
  position: absolute;
  border-radius: 50%;
}

.scene .h1 { left: -8%; bottom: 45%; width: 60%; height: 16%; background: #6bb33f; }
.scene .h2 { right: -10%; bottom: 45%; width: 66%; height: 19%; background: #5ca636; }

.scene .barn {
  position: absolute;
  left: 14%;
  bottom: 45%;
  width: clamp(4.4rem, 13vw, 9rem);
  height: clamp(2.8rem, 7.5vw, 5.2rem);
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0 0.7rem, transparent 0.7rem 1.4rem),
    var(--barn);
  border: 0.18rem solid var(--barn-dark);
  border-bottom: none;
}

.scene .barn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -68%);
  border-left: clamp(2.7rem, 8vw, 5.4rem) solid transparent;
  border-right: clamp(2.7rem, 8vw, 5.4rem) solid transparent;
  border-bottom: clamp(1.7rem, 5vw, 3.3rem) solid var(--barn-dark);
}

.scene .barn::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 42%;
  height: 64%;
  background: #6f3326;
  border: 0.16rem solid var(--cream);
  border-bottom: none;
}

.scene .fence {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 41%;
  height: clamp(1.5rem, 3.6vw, 2.4rem);
  background:
    repeating-linear-gradient(90deg, var(--cream) 0 0.42rem, transparent 0.42rem 2.4rem),
    linear-gradient(var(--cream), var(--cream)) 0 28% / 100% 0.28rem no-repeat,
    linear-gradient(var(--cream), var(--cream)) 0 74% / 100% 0.28rem no-repeat;
  filter: drop-shadow(0 0.1rem 0.1rem rgba(80, 45, 20, 0.4));
  opacity: 0.96;
}

/* --------------------- farmyard life --------------------------- */
.critters {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

.critter {
  position: absolute;
  line-height: 1;
  font-size: var(--size, 1.9rem);
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.28));
  user-select: none;
  will-change: transform, left, top;
}

.critter.walk {
  left: -14%;
  top: var(--top, 82%);
  animation: cr-cross var(--dur, 16s) linear var(--delay, 0s) infinite,
             cr-bob var(--bob, 0.5s) ease-in-out infinite;
}

.critter.fly,
.critter.flyby {
  left: -16%;
  top: var(--top, 28%);
  animation: cr-cross var(--dur, 13s) linear var(--delay, 0s) infinite,
             cr-flit var(--bob, 1.1s) ease-in-out infinite;
}

.critter.flyby { animation-iteration-count: 1, infinite; animation-fill-mode: forwards, none; }

.critter.dash {
  left: -16%;
  top: var(--top, 88%);
  animation: cr-cross var(--dur, 6s) linear forwards,
             cr-bob var(--bob, 0.4s) ease-in-out infinite;
}

.critter.float {
  left: var(--x, 30%);
  top: 112%;
  animation: cr-float var(--dur, 9s) ease-in forwards;
}

.critter.sway {
  left: var(--x, 10%);
  top: var(--top, 82%);
  transform-origin: 50% 100%;
  animation: cr-sway var(--dur, 3.4s) ease-in-out var(--delay, 0s) infinite alternate;
}

@keyframes cr-cross { from { left: -16%; } to { left: 116%; } }

@keyframes cr-bob {
  0%, 100% { transform: translateY(0) scaleX(var(--face, 1)) scale(var(--scale, 1)); }
  50% { transform: translateY(var(--hop, -0.3rem)) scaleX(var(--face, 1)) scale(var(--scale, 1)); }
}

@keyframes cr-flit {
  0%, 100% { transform: translateY(0) scaleX(var(--face, 1)) scale(var(--scale, 1)) rotate(0deg); }
  25% { transform: translateY(-0.9rem) scaleX(var(--face, 1)) scale(var(--scale, 1)) rotate(7deg); }
  75% { transform: translateY(0.9rem) scaleX(var(--face, 1)) scale(var(--scale, 1)) rotate(-7deg); }
}

@keyframes cr-float {
  from { top: 112%; transform: translateX(0) rotate(-5deg); }
  to { top: -22%; transform: translateX(var(--drift, 6vw)) rotate(5deg); }
}

@keyframes cr-sway {
  from { transform: rotate(-7deg) scale(var(--scale, 1)); }
  to { transform: rotate(7deg) scale(var(--scale, 1)); }
}

/* mooing cow pop-up */
.cow-skit {
  position: absolute;
  bottom: 0;
  left: var(--x, 50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, 120%);
  animation: cow-rise 2.6s cubic-bezier(0.2, 1.25, 0.25, 1) forwards;
}

.cow-skit .cow {
  font-size: clamp(2.6rem, 10vw, 4.4rem);
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.35));
}

.cow-skit .moo {
  margin-bottom: 0.2rem;
  background: #fff;
  color: var(--barn-dark);
  border: 2.5px solid var(--wood-dark);
  border-radius: 999px;
  padding: 0.12rem 0.7rem;
  font-weight: 900;
  font-size: clamp(0.9rem, 3.4vw, 1.4rem);
  white-space: nowrap;
  box-shadow: 0 0.2rem 0 rgba(80, 45, 20, 0.4);
}

@keyframes cow-rise {
  0% { transform: translate(-50%, 120%); }
  16% { transform: translate(-50%, 4%); }
  26% { transform: translate(-50%, -9%); }
  38% { transform: translate(-50%, 2%); }
  50%, 76% { transform: translate(-50%, 2%); }
  100% { transform: translate(-50%, 120%); }
}

/* praise word + star pops */
.critter.praise {
  left: var(--x, 50%);
  top: var(--y, 40%);
  transform: translate(-50%, -50%);
  font-weight: 900;
  color: #fffdf4;
  -webkit-text-stroke: 2px var(--wood-dark);
  paint-order: stroke fill;
  font-size: clamp(1.5rem, 6vw, 3rem);
  white-space: nowrap;
  animation: praise-pop 1.15s ease-out forwards;
}

@keyframes praise-pop {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.5) rotate(-6deg); }
  22% { opacity: 1; transform: translate(-50%, -55%) scale(1.12) rotate(3deg); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1) rotate(-2deg); }
}

.critter.starpop {
  left: var(--x, 50%);
  top: var(--y, 40%);
  font-size: clamp(0.95rem, 3vw, 1.6rem);
  animation: starpop 0.75s ease-out forwards;
}

@keyframes starpop {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1.1) rotate(40deg); }
}

.pocket {
  position: relative;
  z-index: 5;
  display: grid;
  gap: 0.42rem;
  width: min(36rem, 88%);
  margin: 0 auto 0.55rem;
}

.announcer {
  color: var(--acid);
  font-size: clamp(0.9rem, 2.1vw, 1.35rem);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0 1rem rgba(223, 255, 84, 0.52);
}

.groove-meter {
  height: 0.48rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.groove-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--acid), var(--pink));
  box-shadow: 0 0 1rem rgba(223, 255, 84, 0.58);
  transition: width 160ms ease;
}

.arena {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(clamp(11.25rem, 19vw, 15.75rem), 1fr);
  gap: clamp(0.55rem, 1.35vw, 1rem);
}

.donkey {
  --body: #9b7650;
  --body-dark: #5f412d;
  --snout: #d8b186;
  --accent: #5cf6ff;
  --barrel-bottom: -1.15rem;
  --barrel-w: min(56%, 6.3rem);
  --barrel-h: clamp(3.2rem, 5.4vw, 4.6rem);
  --skin-w: min(64%, 7rem);
  --skin-h: clamp(1.35rem, 2.5vw, 1.95rem);
  --head-sink: 1.6rem;
  position: relative;
  min-width: 0;
  min-height: clamp(11.25rem, 19vw, 15.75rem);
  border: 2px solid rgba(110, 64, 34, 0.55);
  border-radius: 16px 16px 10px 10px;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 250, 230, 0.36), rgba(150, 100, 55, 0.16));
  box-shadow: 0 0.5rem 0 rgba(80, 45, 20, 0.28), 0 0.9rem 1.6rem var(--shadow), inset 0 0 1.2rem rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transform: translateY(0);
  transition: transform 90ms ease, box-shadow 90ms ease, filter 120ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: hidden;
}

.donkey::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: var(--barrel-bottom);
  width: var(--barrel-w);
  height: var(--barrel-h);
  border-radius: 16% 16% 32% 32% / 14% 14% 22% 22%;
  background:
    linear-gradient(180deg, rgba(228, 230, 238, 0.6) 0 0.16rem, rgba(0, 0, 0, 0.32) 0.16rem 0.36rem, transparent 0.36rem),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0 0.42rem, rgba(255, 255, 255, 0.07) 0.42rem 0.84rem),
    linear-gradient(90deg, #36200f, #9c6537 26%, #bd864f 50%, #7c4a28 74%, #2f1c0d);
  border: 0.16rem solid #36200f;
  box-shadow:
    inset 0 -0.55rem 0.7rem rgba(0, 0, 0, 0.42),
    inset 0 0.4rem 0.5rem rgba(255, 255, 255, 0.1),
    0 0.45rem 0.8rem rgba(0, 0, 0, 0.42);
  transform: translateX(-50%);
  z-index: 4;
}

.donkey::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(var(--barrel-bottom) + var(--barrel-h) - var(--skin-h) * 0.62);
  width: var(--skin-w);
  height: var(--skin-h);
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 32%, #fff1d2 0 34%, #eccd98 58%, #cda063 82%, #ad7c42 100%);
  border: 0.2rem solid #4e2b1b;
  box-shadow: 0 0.18rem 0.4rem rgba(0, 0, 0, 0.4), inset 0 -0.22rem 0.4rem rgba(0, 0, 0, 0.26);
  transform: translateX(-50%);
  z-index: 5;
}

.donkey:hover { filter: saturate(1.12) brightness(1.05); }

.donkey:focus-visible {
  outline: 4px solid var(--acid);
  outline-offset: 4px;
}

.donkey.is-playing {
  transform: translateY(0.46rem) scale(1.025);
  box-shadow: 0 0.24rem 0 rgba(80, 45, 20, 0.3), 0 0.5rem 1rem var(--shadow), 0 0 2rem var(--accent);
}

.donkey.is-playing::after {
  animation: drum-squash 230ms ease-out both;
}

.hit-ring {
  position: absolute;
  left: 50%;
  top: 60%;
  z-index: 1;
  width: 3rem;
  aspect-ratio: 1;
  border: 0.16rem solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
}

.donkey.is-playing .hit-ring { animation: ring-pop 310ms ease-out; }


.hoof {
  position: absolute;
  bottom: calc(var(--barrel-bottom) + var(--barrel-h) - var(--head-sink));
  z-index: 6;
  width: min(18%, 1.9rem);
  height: 1.18rem;
  border: 2px solid rgba(5, 8, 13, 0.38);
  border-radius: 44% 44% 58% 58%;
  background: linear-gradient(180deg, var(--body), var(--body-dark));
  opacity: 0;
  transform-origin: 50% 100%;
}

.hoof.left {
  left: calc(50% + var(--hoof-left, -14%));
  transform: translate(-50%, -1.45rem) rotate(-18deg);
}

.hoof.right {
  left: calc(50% + var(--hoof-right, 14%));
  transform: translate(-50%, -1.45rem) rotate(18deg);
}

.donkey.is-playing .hoof.left { animation: hoof-bang-left 230ms ease-out both; }
.donkey.is-playing .hoof.right { animation: hoof-bang-right 230ms ease-out 32ms both; }
.donkey-head {
  position: absolute;
  left: 50%;
  bottom: calc(var(--barrel-bottom) + var(--barrel-h) - var(--head-sink));
  z-index: 3;
  width: min(68%, 7.4rem);
  --rest-y: 14%;
  aspect-ratio: 0.86;
  transform-origin: 50% 100%;
  border: 3px solid rgba(5, 8, 13, 0.32);
  border-radius: 42% 42% 50% 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,0.35) 0 0.25rem, transparent 0.28rem),
    linear-gradient(160deg, color-mix(in srgb, var(--body) 82%, #ffffff), var(--body-dark));
  transform: translate(calc(-50% + var(--pop-x, 0%)), var(--rest-y, 22%)) rotate(var(--eye-tilt));
  transition: transform 120ms ease;
}

.donkey.is-playing .donkey-head {
  animation: donkey-pop 330ms cubic-bezier(0.2, 1.4, 0.22, 1) both;
}

.ear {
  position: absolute;
  top: -42%;
  width: 28%;
  height: 58%;
  border: 3px solid rgba(5, 8, 13, 0.28);
  border-radius: 70% 70% 32% 32%;
  background: linear-gradient(90deg, var(--body-dark), var(--body));
  transform-origin: 50% 100%;
  animation: ear-wobble var(--ear-speed) ease-in-out infinite alternate;
  animation-delay: var(--ear-delay);
}

.ear::after {
  content: "";
  position: absolute;
  inset: 16% 26% 18%;
  border-radius: inherit;
  background: #d7a7a0;
}

.ear.left { left: 8%; transform: rotate(calc(-18deg + var(--ear-tilt))); }
.ear.right { right: 8%; transform: rotate(calc(18deg - var(--ear-tilt))); animation-direction: alternate-reverse; }

.forelock {
  position: absolute;
  left: 50%;
  top: -7%;
  width: 34%;
  height: 24%;
  border-radius: 60% 40% 60% 40%;
  background: #2d2019;
  transform: translateX(-50%) rotate(-7deg);
}

.eye {
  position: absolute;
  top: 29%;
  width: 17%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fffdf4;
  border: 2px solid rgba(5, 8, 13, 0.72);
  overflow: hidden;
  transform: rotate(calc(var(--eye-tilt) * -0.4));
}

.eye::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 43%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: inset 0.08rem 0.06rem 0 #fff;
  transform: translate(-50%, -50%);
  animation: eye-dart var(--dart-speed) steps(1, end) infinite;
  animation-delay: var(--dart-delay);
}

.eye.left { left: 25%; }
.eye.right { right: 25%; }

.donkey.is-playing .eye::after {
  width: 58%;
  animation: none;
  transform: translate(-50%, -50%);
}

.snout {
  position: absolute;
  left: 50%;
  bottom: 11%;
  width: 58%;
  height: 39%;
  border-radius: 48% 48% var(--grin) var(--grin);
  background: var(--snout);
  transform: translateX(-50%);
}

.nostril {
  position: absolute;
  bottom: 25%;
  width: 8%;
  height: 6%;
  border-radius: 50%;
  background: #3a241c;
  z-index: 2;
}

.nostril.left { left: 39%; }
.nostril.right { right: 39%; }

.mouth {
  position: absolute;
  left: 50%;
  bottom: 15%;
  z-index: 2;
  width: 42%;
  height: 15%;
  border-bottom: 0.35rem solid #5a1d23;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.teeth {
  position: absolute;
  left: 50%;
  bottom: 10%;
  z-index: 2;
  width: 18%;
  height: 11%;
  border-radius: 0 0 0.2rem 0.2rem;
  background: #fffdf4;
  box-shadow: -0.22rem 0 0 #fffdf4, 0.22rem 0 0 #fffdf4;
  transform: translateX(-50%);
}

.bongo { display: none; }

.spark {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  color: var(--spark, var(--acid));
  background: currentColor;
  box-shadow: 0 0 0.8rem currentColor;
  animation: spark-fly 520ms ease-out forwards;
}

.tone-0 { --body: #b88a58; --body-dark: #68442d; --snout: #e6bc8e; --accent: #dfff54; }
.tone-1 { --body: #8c7b68; --body-dark: #514235; --snout: #d8b186; --accent: #5cf6ff; }
.tone-2 { --body: #c99263; --body-dark: #76452f; --snout: #f0c092; --accent: #ffb84c; }
.tone-3 { --body: #7f685a; --body-dark: #47372f; --snout: #d5ad87; --accent: #fff27a; }
.tone-4 { --body: #ae8560; --body-dark: #5e3e2c; --snout: #e3b98a; --accent: #71ff8c; }
.tone-5 { --body: #9e7356; --body-dark: #513626; --snout: #e1b086; --accent: #ff5fa8; }
.tone-6 { --body: #c08654; --body-dark: #694028; --snout: #edbd88; --accent: #73e2ff; }
.tone-7 { --body: #75685e; --body-dark: #403832; --snout: #cfaa8a; --accent: #cfa5ff; }
.tone-8 { --body: #b67b4d; --body-dark: #5d3724; --snout: #eabb86; --accent: #ffcf5e; }
.tone-9 { --body: #8f7660; --body-dark: #4e3a2b; --snout: #d8b08a; --accent: #74a9ff; }
.tone-10 { --body: #ca9366; --body-dark: #71472f; --snout: #f1c59a; --accent: #ff8f70; }
.tone-11 { --body: #947157; --body-dark: #4c382b; --snout: #dcb48d; --accent: #cfff4a; }

.credit {
  display: flex;
  justify-content: center;
}

.credit a,
.credit-link {
  color: var(--wood-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.credit-link {
  background: none;
  border: none;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
}

.credit-link:hover { color: var(--barn); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(2, 5, 9, 0.78);
}

.modal.is-open { display: flex; }

.modal-card {
  position: relative;
  width: min(26rem, 100%);
  padding: 1.6rem 1.5rem 1.4rem;
  border: 3px solid var(--wood-dark);
  border-radius: 16px;
  background: linear-gradient(160deg, #fff8e6, var(--cream));
  box-shadow: 0 1.4rem 4rem rgba(0, 0, 0, 0.5);
  color: var(--wood-dark);
  animation: banner-pop 200ms ease-out;
}

.modal-card h2 {
  margin: 0 0 0.6rem;
  font-size: 1.5rem;
  color: var(--barn);
}

.modal-card p { margin: 0 0 0.7rem; font-size: 0.92rem; line-height: 1.45; }

.modal-list {
  margin: 0 0 0.9rem;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.modal-links a {
  color: var(--barn);
  font-weight: 900;
  font-size: 0.85rem;
  text-decoration: underline;
  text-transform: uppercase;
}

.modal-links a:hover { color: var(--barn-dark); }

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--wood-dark);
  border-radius: 50%;
  background: rgba(110, 64, 34, 0.12);
  color: var(--wood-dark);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { background: var(--barn); color: #fff; }

.modal-ok {
  margin-top: 1.1rem;
  width: 100%;
  padding: 0.8rem;
  border: 2px solid var(--barn-dark);
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd23f, var(--barn));
  color: #fff;
  font-weight: 900;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.modal-ok:hover { filter: brightness(1.08); }


@keyframes donkey-pop {
  0% { transform: translate(calc(-50% + var(--pop-x, 0%)), var(--rest-y, 22%)) rotate(calc(var(--pop-angle, 0deg) * -0.45)) scale(0.94); }
  58% { transform: translate(calc(-50% + var(--pop-x, 0%)), calc(var(--pop-rise, 44%) * -1)) rotate(var(--pop-angle, 0deg)) scale(1.1); }
  100% { transform: translate(calc(-50% + var(--pop-x, 0%)), -4%) rotate(calc(var(--pop-angle, 0deg) * 0.45)) scale(1.04); }
}

@keyframes hoof-bang-left {
  0% { opacity: 0; transform: translate(-50%, -1.9rem) rotate(-34deg) scale(0.8); }
  40% { opacity: 1; transform: translate(-50%, -0.34rem) rotate(-8deg) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -0.08rem) rotate(8deg) scale(0.92); }
}

@keyframes hoof-bang-right {
  0% { opacity: 0; transform: translate(-50%, -1.9rem) rotate(34deg) scale(0.8); }
  40% { opacity: 1; transform: translate(-50%, -0.34rem) rotate(8deg) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -0.08rem) rotate(-8deg) scale(0.92); }
}
@keyframes eye-dart {
  0%, 14% { transform: translate(-50%, -50%); }
  15%, 34% { transform: translate(calc(-50% - var(--dart-range)), -50%); }
  35%, 54% { transform: translate(calc(-50% + var(--dart-range)), -50%); }
  55%, 72% { transform: translate(-50%, calc(-50% - 14%)); }
  73%, 88% { transform: translate(-24%, calc(-50% + 14%)); }
  89%, 100% { transform: translate(-50%, -50%); }
}

@keyframes ear-wobble {
  from { rotate: -7deg; }
  to { rotate: 9deg; }
}

@keyframes drum-squash {
  0% { transform: translateX(-50%) scaleY(1) scaleX(1); }
  42% { transform: translateX(-50%) scaleY(0.76) scaleX(1.12); }
  100% { transform: translateX(-50%) scaleY(1) scaleX(1); }
}

@keyframes ring-pop {
  0% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.25); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.8); }
}

@keyframes spark-fly {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2); }
}

@keyframes scan {
  from { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.08); }
  to { transform: rotate(360deg) scale(1); }
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-low) 64%, #b6e596 64%, var(--grass-dark));
  opacity: 1;
  transition: opacity 480ms ease;
}

.loader.is-done { opacity: 0; pointer-events: none; }

.loader-inner { width: min(28rem, 86%); text-align: center; }

.loader-title {
  margin: 0 0 1.1rem;
  font-size: clamp(2rem, 9vw, 4.4rem);
  line-height: 0.9;
  color: var(--paper);
  animation: loader-throb 1.1s ease-in-out infinite;
}

.loader-bar {
  height: 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  overflow: hidden;
  box-shadow: inset 0 0 0 2px var(--wood-dark);
}

.loader-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd23f, #ff9f43, var(--barn));
  transition: width 180ms ease;
}

.loader-note {
  margin: 0.8rem 0 0;
  color: var(--wood-dark);
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@keyframes loader-throb {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.04); opacity: 1; }
}

/* ------------------------- mode chrome ------------------------- */

.menu-btn {
  grid-column: 1;
  justify-self: start;
  padding: 0.4rem 0.85rem;
  border: 2px solid var(--wood-dark);
  border-radius: 999px;
  background: var(--cream);
  color: var(--wood-dark);
  font-weight: 900;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 0.2rem 0 rgba(80, 45, 20, 0.4);
}

.menu-btn:hover { background: #fff7e0; }

.hud {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 0.85rem;
  font-size: clamp(0.72rem, 2.4vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--wood-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.menu-btn, .hud { display: none; }
body.mode-hero .hud, body.mode-simon .hud { display: flex; }
body:not(.mode-menu) .menu-btn { display: inline-flex; }

body.mode-hero #app-title,
body.mode-simon #app-title { font-size: clamp(1.3rem, 4vw, 2.4rem); }

/* arena / pocket only show in the right modes (arena stays visible in menu so the donkeys are still playable) */
body.mode-hero .arena { display: none; }
body:not(.mode-free) .pocket { display: none; }

/* --------------------------- menu ----------------------------- */

.menu {
  position: absolute;
  inset: 0;
  z-index: 16;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.2rem;
  background: none;
  pointer-events: none;
}

body.mode-menu .menu { display: flex; }

.menu-kicker {
  margin: 0;
  color: var(--cream);
  font-weight: 900;
  font-size: clamp(0.85rem, 2.4vw, 1.1rem);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  -webkit-text-stroke: 1px var(--wood-dark);
  paint-order: stroke fill;
  text-shadow: 0 0.12rem 0.4rem rgba(80, 45, 20, 0.8);
}

.menu-cards {
  display: grid;
  gap: 0.9rem;
  width: min(46rem, 94%);
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  padding: 1rem;
  border-radius: 16px;
  border: 3px solid var(--wood-dark);
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0 1.1rem, transparent 1.1rem 2.2rem),
    linear-gradient(180deg, var(--wood), var(--wood-dark));
  box-shadow: 0 1rem 2.8rem rgba(0, 0, 0, 0.45), inset 0 0 0 3px rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.menu-card {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.15rem 1.3rem;
  border: 2px solid var(--wood-dark);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff8e6, var(--cream));
  color: var(--wood-dark);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 0.3rem 0 rgba(80, 45, 20, 0.35);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.menu-card:hover {
  transform: translateY(-3px);
  border-color: var(--barn);
  box-shadow: 0 0.7rem 1.2rem rgba(0, 0, 0, 0.3);
}

.menu-name { font-size: clamp(1.3rem, 4vw, 1.7rem); font-weight: 900; letter-spacing: 0.03em; }
.menu-sub { font-size: 0.8rem; color: rgba(110, 64, 34, 0.78); text-transform: uppercase; letter-spacing: 0.03em; }

/* ----------------------- Donkey Hero --------------------------- */

.hero {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.4rem;
}

body.mode-hero .hero { display: flex; }

.health {
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.health span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--acid), var(--cyan));
  box-shadow: 0 0 0.8rem rgba(92, 246, 255, 0.5);
  transition: width 180ms ease;
}

.health span.is-low { background: linear-gradient(90deg, var(--pink), #ff8f70); }

.lanes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.45rem;
}

.lane {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 2px solid rgba(110, 64, 34, 0.4);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(150, 210, 255, 0.16));
}

.lane .track { position: absolute; inset: 0; }

.hitline {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 22%;
  height: 3px;
  border-radius: 999px;
  background: var(--barn);
  box-shadow: 0 0 0.8rem rgba(198, 58, 43, 0.7);
  opacity: 0.85;
}

.lane .donkey {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 42%;
  min-height: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
  cursor: pointer;
}

.lane .key-badge {
  position: absolute;
  left: 50%;
  bottom: 0.4rem;
  transform: translateX(-50%);
  z-index: 7;
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  background: var(--cream);
  border: 2px solid var(--wood-dark);
  color: var(--wood-dark);
  font-size: 0.7rem;
  font-weight: 900;
  pointer-events: none;
}

.note {
  position: absolute;
  left: 50%;
  top: 0;
  width: 58%;
  max-width: 4.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffffff 0 18%, var(--note, var(--acid)) 62%, rgba(0, 0, 0, 0.3));
  box-shadow: 0 0 1rem var(--note, var(--acid)), inset 0 -0.2rem 0.4rem rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -120%);
  will-change: transform;
}

.note.is-hit { animation: note-hit 140ms ease-out forwards; }
.note.is-miss { animation: note-miss 160ms ease-in forwards; }

@keyframes note-hit {
  to { opacity: 0; transform: translate(-50%, var(--y, 0)) scale(1.7); }
}

@keyframes note-miss {
  to { opacity: 0; transform: translate(-50%, 120%) scale(0.7); }
}

/* (Coarse pointer: hide per-lane key hints on touch devices) */
@media (pointer: coarse) {
  .lane .key-badge { display: none; }
}

/* ----------------------- Donkey Says --------------------------- */

body.mode-simon .donkey.is-dim {
  opacity: 0.16;
  filter: saturate(0.35) brightness(0.7);
  pointer-events: none;
}

body.simon-watch .arena { pointer-events: none; }

.donkey.simon-lit {
  filter: saturate(1.3) brightness(1.18);
  box-shadow: 0 0.7rem 0 rgba(0, 0, 0, 0.35), 0 0 2.4rem var(--accent);
}

.donkey.simon-wrong {
  animation: simon-shake 0.45s ease;
  box-shadow: 0 0 2.4rem var(--pink);
}

@keyframes simon-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------------------------- banner --------------------------- */

.banner {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 22;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.banner.is-on { opacity: 1; }

.banner .big {
  font-size: clamp(2.6rem, 15vw, 7rem);
  font-weight: 900;
  line-height: 0.9;
  color: #fffdf4;
  -webkit-text-stroke: 3px var(--wood-dark);
  paint-order: stroke fill;
  text-shadow: 0 0.1em 0 var(--wood-dark);
  animation: banner-pop 240ms ease-out;
}

.banner .small {
  margin-top: 0.4rem;
  font-size: clamp(0.85rem, 3.6vw, 1.4rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cream);
  text-shadow: 0 1px 3px rgba(80, 45, 20, 0.85);
}

@keyframes banner-pop {
  from { transform: scale(0.7); opacity: 0.2; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 600px) {
  .hud { gap: 0.55rem; }
  .lanes { gap: 0.3rem; }
  .hitline { bottom: 20%; }
  .lane .donkey { height: 38%; }
}

@media (max-width: 860px) {
  .arena { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(10rem, 1fr); }
  .donkey { min-height: 10rem; }
}

/* Portrait phones: fit all 12 pads on one screen, no scrolling */
@media (max-width: 600px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  .stage {
    height: 100dvh;
    min-height: 0;
    gap: 0.4rem;
    padding: 0.45rem;
    overflow: hidden;
  }
  h1 { font-size: clamp(1.55rem, 8.5vw, 2.6rem); line-height: 0.9; }
  .deck {
    display: grid;
    grid-template-rows: 1fr;
    align-items: stretch;
    padding: 0.5rem;
  }
  .pocket { width: 96%; margin: 0 auto 0.3rem; gap: 0.24rem; }
  .announcer { font-size: 0.82rem; }
  .groove-meter { height: 0.34rem; }
  .arena {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
    grid-auto-rows: auto;
    gap: 0.36rem;
    height: 100%;
    min-height: 0;
  }
  .donkey {
    min-height: 0;
    border-radius: 10px;
    --barrel-bottom: -0.8rem;
    --barrel-w: min(64%, 4.4rem);
    --barrel-h: clamp(1.9rem, 9vw, 3rem);
    --skin-w: min(72%, 5rem);
    --skin-h: clamp(0.95rem, 4.2vw, 1.35rem);
    --head-sink: 1.05rem;
  }
  .donkey-head { width: min(82%, 5.6rem); --rest-y: 20%; }
  .ear { border-width: 2px; }
  .hoof { height: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
