/* =====================================================================
   Boar Rush (Perion) — the run. Shared by both themes; the town skin
   (buttons, panels) lives in each theme's stylesheet.

   Side view: the Fire Boar stays at --bx on the ground line --gy while
   Perion scrolls past (canyon backdrop slow, scenery behind the road
   faster, the road fastest). Nothing is drawn in front of the boar.
   Set by boar.js from the stage size: --gy, --bx, --px (sprite scale),
   --k (scenery scale).
   ===================================================================== */

.stage-boar .stage-inner { padding: 0; }
/* the result note sits low, over the rock floor, so the big multiplier stays readable */
.stage-boar .result.dock { top: auto; bottom: 12px; }
.seg.seg-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seg.seg-5 button { padding-left: 2px; padding-right: 2px; }

.rush {
  --gy: 380px; --bx: 200px; --px: 1.8; --k: 1;
  position: relative; align-self: stretch; flex: 1; width: 100%; min-height: 0; overflow: hidden;
  user-select: none; -webkit-user-select: none; background: #d9cdb8;
}
.rush-layer { position: absolute; inset: 0; pointer-events: none; }

/* the canyon: Perion's real backdrop, as a strip that repeats seamlessly */
.rush-sky {
  position: absolute; left: 0; right: 0; top: 0; height: calc(var(--gy) + 20px); z-index: 0;
  background: url("/static/img/maple-perion-wide.jpg") 0 70% / auto 125% repeat-x;
}
.rush-far { z-index: 1; }
.rush-far .rush-prop { bottom: calc(100% - var(--gy) + 4px); width: calc(var(--w) * var(--k) * 0.62px); filter: saturate(0.75) brightness(0.95) drop-shadow(0 3px 2px rgba(60, 40, 20, 0.25)); }

/* the road: Perion's rock floor tile under a grassy edge */
.rush-ground {
  position: absolute; left: 0; right: 0; top: calc(var(--gy) - 12px); bottom: 0; z-index: 2;
  background:
    url("/static/img/boar/perion/ground-top.png") 0 0 / auto calc(var(--k) * 24px) repeat-x,
    url("/static/img/boar/perion/ground.png") 0 calc(var(--k) * 18px) / auto calc(var(--k) * 78px) repeat;
  box-shadow: inset 0 14px 16px -10px rgba(40, 20, 8, 0.4);
}
.rush-signs { z-index: 3; }
.rush-prop { position: absolute; left: 0; height: auto; image-rendering: auto; will-change: transform; }

/* mile markers: wooden signs at 1.5x, 2x, 3x, 5x, 10x… the boar passes each one right on time */
.rush-sign { position: absolute; left: 0; bottom: calc(100% - var(--gy) + 6px); width: 0; height: 0; will-change: transform; }
.rush-sign::before {
  content: ""; position: absolute; left: -3px; bottom: 0; width: 6px; height: calc(var(--k) * 62px);
  background: linear-gradient(90deg, #7a4f2a, #4a2c14); border-radius: 2px; box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.3);
}
.rush-sign span {
  position: absolute; left: 0; bottom: calc(var(--k) * 44px); transform: translateX(-50%) rotate(-3deg);
  padding: 4px 10px 3px; border-radius: 4px; white-space: nowrap;
  background: linear-gradient(#c08a52, #8f5b2c); border: 2px solid #4a2c14;
  font: 400 calc(var(--k) * 19px) / 1 "Bungee", "Lilita One", system-ui, sans-serif; color: #fff4dc;
  text-shadow: 0 2px 0 #4a2c14; box-shadow: 0 3px 0 rgba(40, 20, 8, 0.35);
}
.rush-sign.big span { background: linear-gradient(#ffd23f, #d98a00); border-color: #7a4b00; color: #3a1d00; text-shadow: none; }
.rush-sign.passed span { filter: saturate(0.6) brightness(0.9); }
.rush-sign.gone { opacity: 0; transition: opacity 0.35s; } /* past the crash point: the boar never gets there */
.rush-sign.cash span { background: linear-gradient(#7ee26a, #2f9e4a); border-color: #134a1d; color: #fff; text-shadow: 0 2px 0 #134a1d; transform: translateX(-50%) rotate(2deg); }
.rush-sign.cash::before { background: linear-gradient(90deg, #e8e0c8, #9a8f78); }

/* the Fire Boar: feet at (--bx, --gy), facing right */
.rush-boar { position: absolute; z-index: 5; left: var(--bx); top: var(--gy); width: 0; height: 0; }
.rush-boar::before {
  content: ""; position: absolute; left: calc(var(--px) * -40px); top: calc(var(--px) * -4px);
  width: calc(var(--px) * 80px); height: calc(var(--px) * 9px); border-radius: 50%; background: rgba(40, 20, 8, 0.32);
}
.rush-boar .face { position: absolute; left: 0; top: 0; width: 0; height: 0; transform: scaleX(-1); }
.rush-boar .hop { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
.rush .spr {
  position: absolute;
  left: calc(var(--ax) * var(--px) * -1px); top: calc(var(--ay) * var(--px) * -1px);
  width: calc(var(--cw) * var(--px) * 1px); height: calc(var(--ch) * var(--px) * 1px);
  background-repeat: no-repeat; background-position: 0 0;
  background-size: calc(var(--cw) * var(--n) * var(--px) * 1px) 100%;
  image-rendering: pixelated;
  transform-origin: calc(var(--ax) * var(--px) * 1px) calc(var(--ay) * var(--px) * 1px);
}
.rush .spr.loop { animation: rush-spr var(--dur) steps(var(--n)) infinite; }
.rush .spr.once { animation: rush-spr-once var(--dur) steps(var(--steps)) 1 forwards; }
@keyframes rush-spr { to { background-position: calc(var(--cw) * var(--n) * var(--px) * -1px) 0; } }
@keyframes rush-spr-once { to { background-position: calc(var(--cw) * var(--n1) * var(--px) * -1px) 0; } }
.rush.running:not(.bonked) .rush-boar .hop { animation: gallop 300ms ease-in-out infinite; }
@keyframes gallop { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(calc(var(--px) * -4px)) scale(1.03, 0.97); } }
.rush-boar.down .hop { transform: translateY(calc(var(--px) * 3px)); transition: transform 0.2s; }

/* dizzy stars over its head after the bonk */
.boar-stars {
  position: absolute; left: calc(var(--px) * 30px); top: calc(var(--px) * -56px); width: 0; height: 0;
  transform: scaleY(0.4); animation: rush-in 0.3s both;
}
.boar-stars::before { content: ""; position: absolute; inset: 0; }
.boar-stars i {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; background: #ffd84a;
  clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%);
  filter: drop-shadow(0 0 3px rgba(255, 216, 74, 0.9));
  animation: star-orbit 1.1s linear infinite;
}
.boar-stars i:nth-child(2) { animation-delay: -0.37s; background: #fff3b0; }
.boar-stars i:nth-child(3) { animation-delay: -0.73s; }
@keyframes star-orbit {
  from { transform: rotate(0deg) translateX(calc(var(--px) * 22px)) rotate(0deg) scaleY(2.4); }
  to { transform: rotate(360deg) translateX(calc(var(--px) * 22px)) rotate(-360deg) scaleY(2.4); }
}
@keyframes rush-in { from { opacity: 0; } to { opacity: 1; } }

/* the dead tree that ends every run: planted on the road just out of sight once the
   run is lost, it rolls in with the ground and the boar charges into it */
.rush-tree { position: absolute; z-index: 4; left: 0; pointer-events: none; will-change: transform; }
.rush-tree img { display: block; width: 100%; height: auto; transform-origin: 30% 100%; filter: drop-shadow(0 6px 3px rgba(40, 20, 8, 0.4)); }
.rush-tree.hit img { animation: tree-shake 0.55s ease-out 0.02s; }
@keyframes tree-shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(4deg); }
  45% { transform: rotate(-3deg); }
  70% { transform: rotate(1.5deg); }
}

/* effects: hoof dust, embers off its burning back, the BONK */
.rush-fx { z-index: 7; }
.rush-dust {
  position: absolute; width: 30px; height: 18px; border-radius: 50%; background: rgba(214, 180, 130, 0.75);
  transform: translate(-50%, -50%) scale(var(--s, 1)); animation: rush-dust 0.7s ease-out forwards;
}
@keyframes rush-dust { to { transform: translate(-50%, -50%) translate(-56px, -16px) scale(2.4); opacity: 0; } }
.rush-ember {
  position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #ffb020; box-shadow: 0 0 8px 2px rgba(255, 120, 0, 0.8);
  animation: rush-ember 0.8s ease-out forwards;
}
@keyframes rush-ember { to { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; } }
.rush-bonk { position: absolute; width: 0; height: 0; z-index: 8; }
.rush-bonk::after {
  content: ""; position: absolute; left: -70px; top: -40px; width: 140px; height: 80px; border-radius: 50%;
  border: 5px solid rgba(255, 244, 200, 0.9); animation: rush-ring 0.6s ease-out forwards;
}
.rush-bonk b {
  position: absolute; left: 0; bottom: 40px; transform: translateX(-50%) rotate(-8deg); white-space: nowrap;
  font: 400 calc(var(--k) * 44px) / 1 "Bungee", "Lilita One", system-ui, sans-serif; color: #fff1a8;
  -webkit-text-stroke: 3px #7a1d10; paint-order: stroke fill; text-shadow: 0 5px 0 #7a1d10, 0 10px 16px rgba(0, 0, 0, 0.45);
  animation: rush-bonk-text 1.4s ease-out forwards;
}
.rush-bonk i {
  position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; background: #ffd84a;
  clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%);
  transform: rotate(var(--a)) translateX(0); animation: rush-star 0.75s cubic-bezier(.2, .8, .4, 1) forwards;
}
.rush-bonk i:nth-child(even) { background: #fff6d6; }
.rush-twig {
  position: absolute; width: 18px; height: 5px; border-radius: 3px; background: #5a3a1c;
  animation: rush-twig 1.3s ease-in forwards;
}
@keyframes rush-star { to { transform: rotate(var(--a)) translateX(calc(110px * var(--d))) scale(0.35); opacity: 0; } }
@keyframes rush-ring { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@keyframes rush-bonk-text {
  0% { transform: translateX(-50%) rotate(-8deg) scale(0.3); opacity: 0; }
  16% { transform: translateX(-50%) rotate(-8deg) scale(1.2); opacity: 1; }
  28% { transform: translateX(-50%) rotate(-8deg) scale(1); }
  78% { opacity: 1; }
  100% { transform: translateX(-50%) translateY(-20px) rotate(-8deg); opacity: 0; }
}
@keyframes rush-twig { to { transform: translateY(160px) rotate(var(--r)); opacity: 0; } }

/* the big multiplier */
.rush-hud { position: absolute; z-index: 9; left: 50%; top: 13%; transform: translateX(-50%); text-align: center; pointer-events: none; }
.rush-mult {
  font: 400 clamp(50px, calc(var(--k) * 84px), 104px) / 1 "Lilita One", "Bungee", system-ui, sans-serif; letter-spacing: 0.01em;
  color: #fff; -webkit-text-stroke: 3px #3a1a08; paint-order: stroke fill;
  text-shadow: 0 5px 0 #3a1a08, 0 0 26px rgba(255, 140, 40, 0.35);
  font-variant-numeric: tabular-nums; transition: color 0.3s;
}
.rush-mult[data-tier="2"] { color: #ffe27a; }
.rush-mult[data-tier="3"] { color: #ffb347; text-shadow: 0 5px 0 #3a1a08, 0 0 30px rgba(255, 120, 20, 0.7); }
.rush-mult[data-tier="4"] { color: #ff7a3d; text-shadow: 0 5px 0 #3a1a08, 0 0 40px rgba(255, 80, 0, 0.95); animation: mult-heat 0.6s ease-in-out infinite; }
@keyframes mult-heat { 50% { transform: scale(1.05); } }
.rush.cashed .rush-mult { opacity: 0.55; }
.rush.lost .rush-mult { color: #ff5a5a; opacity: 1; animation: mult-bonk 0.5s ease-out; }
@keyframes mult-bonk { 30% { transform: scale(1.15) rotate(-3deg); } }
.rush-status {
  display: inline-block; margin-top: 8px; padding: 5px 14px; border-radius: 999px;
  font: 800 16px / 1 "Barlow Condensed", var(--cond, system-ui), sans-serif; letter-spacing: 0.08em; text-transform: uppercase;
  color: #fff; background: rgba(30, 14, 6, 0.75); border: 2px solid rgba(232, 210, 168, 0.6);
}
.rush-status[hidden] { display: none; }
.rush-status.good { background: #2f9e4a; border-color: #b8f5c8; }
.rush-status.bad { background: #c93a32; border-color: #ffc0b8; }

/* this player's last crash points, newest first */
.rush-recent { position: absolute; z-index: 9; top: 10px; left: 10px; right: 10px; display: flex; gap: 5px; overflow: hidden; pointer-events: none; }
.rush-chip {
  flex: none; padding: 3px 9px; border-radius: 999px; background: rgba(30, 14, 6, 0.72); border: 1px solid rgba(232, 210, 168, 0.4);
  font: 800 13px / 1.2 "Barlow Condensed", var(--cond, system-ui), sans-serif; font-variant-numeric: tabular-nums;
}
.rush-chip.low { color: #ff9a8a; }
.rush-chip.good { color: #8ff0a8; }
.rush-chip.gold { color: #ffd23f; border-color: #ffd23f; }

/* ---- lobby card art ---- */
.art-boar { background: url("/static/img/maple-perion.jpg") center 55% / cover; position: relative; overflow: hidden; }
.art-boar .mini-ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
  background: url("/static/img/boar/perion/ground-top.png") 0 0 / auto 16px repeat-x, url("/static/img/boar/perion/ground.png") 0 12px / auto 52px repeat;
}
.art-boar .mini-tree { position: absolute; right: 14%; bottom: 22%; width: 120px; filter: drop-shadow(0 4px 3px rgba(40, 20, 8, 0.4)); }
.art-boar .mini-boar {
  position: absolute; left: 22%; bottom: 25%; width: 150px; height: 94px;
  background: url("/static/img/boar/boar-move.png") 0 0 / 300% 100% no-repeat; image-rendering: pixelated;
  transform: scaleX(-1); animation: mini-boar-run 300ms steps(3) infinite;
}
.art-boar .mini-mult {
  position: absolute; left: 50%; top: 14%; transform: translateX(-50%);
  font: 400 36px / 1 "Lilita One", "Bungee", system-ui, sans-serif; color: #ffe27a;
  -webkit-text-stroke: 2px #3a1a08; paint-order: stroke fill; text-shadow: 0 3px 0 #3a1a08;
}
@keyframes mini-boar-run { to { background-position: -450px 0; } }

@media (max-width: 760px) {
  .rush-status { font-size: 14px; }
  .rush-chip { font-size: 12px; padding: 2px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .rush.running .rush-boar .hop, .boar-stars i, .rush-mult[data-tier="4"], .art-boar .mini-boar { animation-duration: 0s !important; animation-iteration-count: 1 !important; }
}
