/* ============ Base ============ */

:root {
  --ui-bg: rgba(16, 24, 22, 0.72);
  --ui-border: rgba(255, 255, 255, 0.14);
  --ui-text: #f2f5ef;
  --ui-muted: rgba(242, 245, 239, 0.65);
  --void: #14201a;
  --grass: #6c9c55;
  --grass-dark: #5f8f4a;
  --tier1: #9fb4c8;
  --tier2: #b48cff;
  --tier3: #ffc94d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

@property --p {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ui-text);
  font: 500 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
  background: radial-gradient(ellipse at center, #1d2e24, var(--void) 70%);
}

#world {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  background-color: var(--grass);
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.07) 1.5px, transparent 2.5px),
    conic-gradient(var(--grass-dark) 25%, transparent 0 50%, var(--grass-dark) 0 75%, transparent 0);
  background-size: 40px 40px, 320px 320px;
  border-radius: 24px;
  box-shadow: 0 0 0 10px #4c7a3b, 0 0 0 22px #3a5f2d, 0 0 80px 30px rgba(0, 0, 0, 0.6);
}

#props,
#entities,
#fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ============ Props ============ */

.prop {
  position: absolute;
  left: 0;
  top: 0;
}

.prop.tree {
  scale: var(--s);
}

.tree .trunk {
  position: absolute;
  left: -6px;
  top: -26px;
  width: 12px;
  height: 28px;
  border-radius: 4px;
  background: linear-gradient(90deg, #6b4a2f, #8a6240);
}

.tree .canopy {
  position: absolute;
  left: -32px;
  top: -86px;
  width: 64px;
  height: 66px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 35% 30%, #8fd06b, #4f9a3c 55%, #36702b);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  transform-origin: 50% 100%;
  animation: sway 4s ease-in-out var(--dl) infinite alternate;
}

.tree::before {
  /* shadow */
  content: "";
  position: absolute;
  left: -26px;
  top: -8px;
  width: 52px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
}

@keyframes sway {
  from {
    transform: rotate(-2deg);
  }
  to {
    transform: rotate(2deg);
  }
}

.prop.rock {
  width: 38px;
  height: 26px;
  translate: -50% -80%;
  scale: var(--s);
  border-radius: 48% 52% 40% 44% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 35% 30%, #c3c7c2, #8b918b 60%, #6b716b);
  box-shadow: 0 5px 0 -1px rgba(0, 0, 0, 0.2);
}

.prop.flower {
  width: 8px;
  height: 8px;
  translate: -50% -50%;
  border-radius: 50%;
  background: hsl(var(--hue) 85% 72%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* ============ Players ============ */

.player {
  position: absolute;
  left: 0;
  top: 0;
  animation: pop-in 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

.player.leaving {
  animation: pop-out 0.4s ease-in forwards;
}

@keyframes pop-in {
  from {
    scale: 0;
    opacity: 0;
  }
}

@keyframes pop-out {
  to {
    scale: 0;
    opacity: 0;
  }
}

.player .shadow {
  position: absolute;
  left: -18px;
  top: -6px;
  width: 36px;
  height: 12px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
}

.player.me .shadow {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
  animation: me-ring 1.6s ease-in-out infinite;
}

@keyframes me-ring {
  50% {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
  }
}

.player .sprite {
  position: absolute;
  left: -20px;
  top: -44px;
  width: 40px;
  height: 44px;
}

.player.left .sprite {
  scale: -1 1;
}

.player .body {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 42% 42% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 35% 28%, hsl(var(--h) 90% 80%), hsl(var(--h) 70% 58%) 55%, hsl(var(--h) 60% 42%));
  box-shadow: inset -4px -5px 0 rgba(0, 0, 0, 0.12);
  transform-origin: 50% 100%;
  animation: idle 2.4s ease-in-out infinite;
}

.player.walking .body {
  animation: hop 0.36s ease-in-out infinite;
}

@keyframes idle {
  50% {
    transform: scale(1.04, 0.96);
  }
}

@keyframes hop {
  0%,
  100% {
    transform: translateY(0) scale(1.06, 0.94);
  }
  50% {
    transform: translateY(-7px) scale(0.95, 1.05);
  }
}

.player .eyes {
  position: absolute;
  left: 20px;
  top: 14px;
  width: 6px;
  height: 9px;
  border-radius: 3px;
  background: #1b1b22;
  box-shadow: 10px 0 0 #1b1b22;
  animation: blink 4s infinite;
}

@keyframes blink {
  0%,
  94%,
  100% {
    transform: scaleY(1);
  }
  97% {
    transform: scaleY(0.1);
  }
}

.player .tag {
  position: absolute;
  left: 0;
  top: -66px;
  translate: -50% 0;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid hsl(var(--h) 80% 70% / 0.6);
}

.player.me .tag {
  background: hsl(var(--h) 60% 30% / 0.85);
}

.cast-label {
  position: absolute;
  left: 0;
  top: -92px;
  translate: -50% 0;
  white-space: nowrap;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  animation: float-up 1.2s ease-out forwards;
}

.cast-label.tier2 {
  color: #e3d3ff;
}

.cast-label.tier3 {
  color: #ffe08a;
  font-size: 15px;
}

@keyframes float-up {
  0% {
    transform: translateY(8px) scale(0.6);
    opacity: 0;
  }
  15% {
    transform: translateY(0) scale(1.1);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translateY(-28px) scale(1);
    opacity: 0;
  }
}

.tap-marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 17px;
  translate: -50% -50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  animation: tap 0.55s ease-out forwards;
}

@keyframes tap {
  from {
    transform: scale(0.3);
    opacity: 1;
  }
  to {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* ============ HUD ============ */

.hud-top {
  position: fixed;
  top: calc(10px + var(--safe-t));
  left: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
  max-width: calc(100% - 150px);
}

.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 650;
  animation: slide-down 0.5s ease-out both;
}

#online {
  color: var(--ui-muted);
  animation-delay: 0.1s;
}

.badge .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: hsl(var(--h, 120) 80% 65%);
  box-shadow: 0 0 8px hsl(var(--h, 120) 80% 65%);
}

@keyframes slide-down {
  from {
    translate: 0 -20px;
    opacity: 0;
  }
}

#minimap {
  position: fixed;
  top: calc(10px + var(--safe-t));
  right: 10px;
  width: 120px;
  height: 120px;
  border-radius: 14px;
  background: rgba(60, 100, 50, 0.55);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(108px + var(--safe-b));
  translate: -50% 0;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ui-bg);
  color: var(--ui-muted);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.6s;
}

.hint.gone {
  opacity: 0;
}

.hotbar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--safe-b));
  translate: -50% 0;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 20px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.hotbar:empty {
  display: none;
}

.slot {
  --c: var(--tier1);
  position: relative;
  width: 68px;
  height: 72px;
  padding: 0;
  border: 2px solid color-mix(in srgb, var(--c) 70%, transparent);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 22%, #1c2622), #141b18);
  color: var(--ui-text);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  display: grid;
  place-items: center;
  grid-template-rows: 1fr auto;
  animation: slot-in 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) backwards;
  transition: transform 0.12s, box-shadow 0.2s;
}

.slot.tier2 {
  --c: var(--tier2);
}

.slot.tier3 {
  --c: var(--tier3);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent);
}

.slot.tier3::before {
  /* slow shimmer on grandiose spells */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 240, 190, 0.35) 50%, transparent 65%);
  background-size: 250% 100%;
  animation: shimmer 3s linear infinite;
  pointer-events: none;
}

@keyframes shimmer {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -100% 0;
  }
}

@keyframes slot-in {
  from {
    transform: translateY(40px) scale(0.6);
    opacity: 0;
  }
}

@media (hover: hover) {
  .slot:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--c) 45%, transparent);
  }
}

.slot:active {
  transform: scale(0.92);
}

.slot .icon {
  font-size: 28px;
  line-height: 1;
  padding-top: 8px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.slot .name {
  font-size: 10.5px;
  font-weight: 650;
  padding-bottom: 6px;
  color: var(--ui-muted);
  white-space: nowrap;
}

.slot kbd {
  position: absolute;
  top: 3px;
  left: 6px;
  font: 700 10px/1 inherit;
  color: var(--ui-muted);
}

.slot .cd {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: conic-gradient(rgba(0, 0, 0, 0.62) var(--p), transparent 0);
  opacity: 0;
}

.slot.cooling .cd {
  opacity: 1;
  animation: cooldown var(--cd) linear forwards;
}

.slot.cooling .icon {
  filter: grayscale(0.8) brightness(0.7);
}

.slot.ready .icon {
  animation: ready 0.5s ease-out;
}

@keyframes cooldown {
  from {
    --p: 100%;
  }
  to {
    --p: 0%;
  }
}

@keyframes ready {
  40% {
    transform: scale(1.3);
    filter: drop-shadow(0 0 10px var(--c));
  }
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity 0.4s;
}

.overlay[hidden] {
  display: none;
}

.overlay.out {
  opacity: 0;
}

.card {
  padding: 18px 30px;
  border-radius: 20px;
  text-align: center;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  animation: card-in 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}

.card p {
  margin: 0;
  color: var(--ui-muted);
}

.card .small {
  font-size: 12px;
}

.card h2 {
  margin: 4px 0 6px;
  font-size: 30px;
  font-weight: 850;
  letter-spacing: 0.01em;
  color: hsl(var(--h, 45) 90% 75%);
  text-shadow: 0 0 24px hsl(var(--h, 45) 90% 60% / 0.6);
}

@keyframes card-in {
  from {
    transform: scale(0.6) translateY(20px);
    opacity: 0;
  }
}

@media (max-width: 420px) {
  .hotbar {
    gap: 5px;
    padding: 6px;
  }
  .slot {
    width: 58px;
    height: 64px;
  }
  .slot .icon {
    font-size: 24px;
  }
  .slot .name {
    font-size: 9px;
  }
  #minimap {
    width: 84px;
    height: 84px;
  }
  .hud-top {
    max-width: calc(100% - 110px);
  }
  .hint {
    bottom: calc(96px + var(--safe-b));
  }
}

@media (pointer: coarse) {
  .slot kbd {
    display: none;
  }
}

/* ============ Spells ============
   .c centers an element on its parent's origin via the independent `translate`
   property, leaving `transform` free for animation. Particles that start
   delayed begin at opacity 0 so they stay hidden until their turn. */

.spell,
.grp,
.flat,
.proj,
.fade-end {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.flat {
  scale: 1 0.5;
}

.c {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -50%;
}

.flash {
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle, var(--col) 0, color-mix(in srgb, var(--col) 50%, transparent) 30%, transparent 70%);
  animation: flash 0.55s ease-out var(--dl, 0s) both;
}

@keyframes flash {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.ring {
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 4px solid var(--col);
  box-shadow: 0 0 16px var(--col), inset 0 0 16px var(--col);
  animation: ring var(--dur, 0.9s) cubic-bezier(0.2, 0.7, 0.3, 1) var(--dl, 0s) both;
}

@keyframes ring {
  0% {
    transform: scale(0.1);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.glow {
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle, var(--col), transparent 70%);
  animation: glow 1.4s ease-out var(--dl, 0s) both;
}

.glow.late {
  animation-duration: 1.8s;
}

@keyframes glow {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  20% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

.spark {
  width: var(--sz, 8px);
  height: var(--sz, 8px);
  border-radius: 50%;
  background: hsl(var(--hue) 100% 75%);
  box-shadow: 0 0 8px hsl(var(--hue) 100% 60%);
  animation: burst 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) var(--dl) both;
}

@keyframes burst {
  0% {
    transform: rotate(var(--a)) translateX(0) scale(1.3);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: rotate(var(--a)) translateX(var(--d)) scale(0);
    opacity: 0;
  }
}

/* Confetti */
.confetti {
  width: 7px;
  height: 12px;
  border-radius: 2px;
  background: hsl(var(--hue) 90% 62%);
  animation: confetti 1.6s cubic-bezier(0.15, 0.7, 0.4, 1) var(--dl) both;
}

@keyframes confetti {
  0% {
    transform: translate(0, 0) rotate(0);
    opacity: 1;
  }
  35% {
    transform: translate(var(--x), var(--y)) rotate(calc(var(--r) * 0.4));
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--x) * 1.4), calc(var(--y) + 210px)) rotate(var(--r));
    opacity: 0;
  }
}

/* Mend */
.plus {
  color: #9dffc2;
  font: 900 24px/1 system-ui, sans-serif;
  text-shadow: 0 0 10px #3dff8a;
  animation: rise 1s ease-out var(--dl) both;
}

@keyframes rise {
  0% {
    transform: translate(var(--x), -10px) scale(0.5);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), -120px) scale(1.2);
    opacity: 0;
  }
}

/* Frost Nova */
.shard {
  width: 12px;
  height: 30px;
  background: linear-gradient(#fff, #9fe6ff 60%, #4fb6e8);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  filter: drop-shadow(0 0 4px #bfefff);
  animation: shard 1.1s cubic-bezier(0.2, 0.8, 0.3, 1) var(--dl) both;
}

@keyframes shard {
  0% {
    transform: rotate(var(--a)) translateX(10px) rotate(90deg) scale(0.2);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: rotate(var(--a)) translateX(var(--d)) rotate(90deg) scale(1);
    opacity: 0;
  }
}

/* Projectiles (Fireball, Cyclone) */
.proj {
  animation: travel var(--dur) cubic-bezier(0.45, 0, 0.8, 0.6) forwards;
}

.proj.slow {
  animation-timing-function: ease-in-out;
}

@keyframes travel {
  to {
    transform: translate(var(--tx), var(--ty));
  }
}

.fireball {
  width: 36px;
  height: 36px;
  margin-top: -20px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fffbe0, #ffd34d 30%, #ff7a1a 60%, #c4250a);
  box-shadow: 0 0 24px 8px rgba(255, 120, 20, 0.7);
  animation: flicker 0.1s infinite alternate, vanish 0.01s linear 0.5s forwards;
}

@keyframes flicker {
  to {
    transform: scale(1.15);
  }
}

@keyframes vanish {
  to {
    opacity: 0;
  }
}

.ember {
  width: 14px;
  height: 14px;
  margin-top: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd34d, #ff6a00 60%, transparent 70%);
  animation: ember 0.55s ease-out var(--dl) both;
}

@keyframes ember {
  0% {
    transform: translate(var(--x), var(--y)) scale(1.2);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), calc(var(--y) - 24px)) scale(0);
    opacity: 0;
  }
}

/* Thunder */
.bolt-glow {
  position: absolute;
  left: 0;
  top: 0;
  filter: drop-shadow(0 0 6px #cfe0ff) drop-shadow(0 0 14px #8fb4ff);
}

.bolt {
  position: absolute;
  left: 0;
  top: 0;
  width: 90px;
  height: 480px;
  translate: -50% -100%;
  background: linear-gradient(to top, #fff 0, #fffbd0 50%, rgba(170, 200, 255, 0));
  clip-path: polygon(46% 0, 30% 30%, 52% 33%, 24% 64%, 50% 67%, 42% 100%, 58% 100%, 76% 60%, 53% 57%, 78% 26%, 56% 23%, 68% 0);
  animation: bolt 0.5s linear var(--dl) both;
}

@keyframes bolt {
  0% {
    opacity: 0;
  }
  4% {
    opacity: 1;
  }
  20% {
    opacity: 0.15;
  }
  30% {
    opacity: 1;
  }
  60% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
  }
}

.scorch {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(30, 20, 10, 0.55), transparent 70%);
  animation: decal 1.1s ease-out var(--dl) both;
}

@keyframes decal {
  0% {
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Ward */
.ward {
  top: -26px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(160, 210, 255, 0.95);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), rgba(120, 180, 255, 0.12) 40%, rgba(120, 180, 255, 0.35) 72%);
  box-shadow: 0 0 22px rgba(120, 180, 255, 0.75), inset 0 0 18px rgba(160, 210, 255, 0.6);
  animation: ward 3.2s ease both;
}

@keyframes ward {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  8% {
    transform: scale(1.18);
    opacity: 1;
  }
  14% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
  86% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.ward-ring {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 2px dashed rgba(220, 240, 255, 0.8);
  animation: spin 3s linear infinite;
}

.ward-ring.rev {
  inset: 16px;
  border-style: dotted;
  animation-direction: reverse;
  animation-duration: 2s;
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

/* Cyclone */
.twister {
  position: absolute;
  left: 0;
  top: 0;
  animation: twister 2.5s ease both;
}

@keyframes twister {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  12% {
    transform: scale(1);
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

.whorl {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--w);
  height: 16px;
  translate: -50% calc(var(--i) * -17px - 8px);
  border-radius: 50%;
  border: 3px solid rgba(235, 242, 255, 0.75);
  border-bottom-color: rgba(190, 205, 225, 0.35);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
  animation: wobble 0.45s ease-in-out var(--dl) infinite alternate;
}

@keyframes wobble {
  from {
    transform: translateX(-7px) rotate(-5deg);
  }
  to {
    transform: translateX(7px) rotate(5deg);
  }
}

.orbit-plane {
  top: -50px;
}

.leaf {
  position: absolute;
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 0 50%;
  background: #8fcf5b;
  animation: orbit 0.9s linear var(--dl) infinite;
}

@keyframes orbit {
  from {
    transform: rotate(0) translateX(var(--r));
  }
  to {
    transform: rotate(360deg) translateX(var(--r));
  }
}

/* Quake */
.crack {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--len);
  height: 8px;
  margin-top: -4px;
  rotate: var(--a);
  transform-origin: 0 50%;
  background: #3a2716;
  clip-path: polygon(0 35%, 25% 0, 50% 60%, 75% 15%, 100% 50%, 75% 75%, 50% 100%, 25% 45%, 0 65%);
  animation: crack 2s cubic-bezier(0.1, 0.9, 0.2, 1) var(--dl) both;
}

@keyframes crack {
  0% {
    transform: scaleX(0);
    opacity: 0;
  }
  3% {
    opacity: 1;
  }
  20% {
    transform: scaleX(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}

.dust {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 175, 135, 0.75), transparent 70%);
  animation: puff 1.1s ease-out var(--dl) both;
}

@keyframes puff {
  0% {
    transform: rotate(var(--a)) translateX(0) scale(0.4);
    opacity: 0;
  }
  20% {
    opacity: 0.9;
  }
  100% {
    transform: rotate(var(--a)) translateX(var(--d)) scale(1.8);
    opacity: 0;
  }
}

.chunk {
  width: 12px;
  height: 10px;
  border-radius: 3px 5px 2px 4px;
  background: #7b6248;
  animation: hop-out 0.9s cubic-bezier(0.3, 0.6, 0.6, 1) var(--dl) both;
}

.chunk.hot {
  background: radial-gradient(circle, #ffcc66, #b8430e);
  box-shadow: 0 0 8px #ff7a1a;
}

@keyframes hop-out {
  0% {
    transform: translate(0, 0) rotate(0);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  45% {
    transform: translate(calc(var(--x) * 0.6), calc(var(--h) * -1)) rotate(180deg);
  }
  100% {
    transform: translate(var(--x), 0) rotate(400deg);
    opacity: 0;
  }
}

/* Meteor */
.meteor-fly {
  position: absolute;
  left: 0;
  top: 0;
  animation: fall 0.6s cubic-bezier(0.55, 0, 1, 0.45) both, vanish 0.01s linear 0.6s forwards;
}

@keyframes fall {
  from {
    transform: translate(-280px, -560px) scale(0.6);
  }
  to {
    transform: translate(0, 0) scale(1);
  }
}

.meteor-rock {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 60% 35%, #ffe7a0, #ff7a1a 40%, #7a2300 75%);
  box-shadow: 0 0 34px 12px rgba(255, 110, 20, 0.75);
}

.meteor-tail {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 300px;
  translate: -50% 0;
  transform-origin: 50% 0;
  rotate: 153.4deg;
  border-radius: 50%;
  background: linear-gradient(rgba(255, 190, 80, 0.95), rgba(255, 90, 20, 0.5) 40%, transparent);
}

.crater {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, #2a1a10 0, #4a2c18 40%, rgba(90, 55, 30, 0.6) 58%, transparent 70%);
  animation: decal 1.8s ease-out var(--dl) both;
}

/* Void Rift */
.void-core {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #05000c 28%, transparent 34%),
    conic-gradient(#2b0057, #8a2be2, #14002a, #ff4df0, #3c007a, #8a2be2, #2b0057);
  box-shadow: 0 0 40px 8px rgba(160, 60, 255, 0.7);
  animation: void-life 3s ease both, spin 1s linear infinite;
}

@keyframes void-life {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  12% {
    transform: scale(1.15);
    opacity: 1;
  }
  18% {
    transform: scale(1);
  }
  78% {
    transform: scale(1.05);
  }
  84% {
    transform: scale(1.35);
  }
  92%,
  100% {
    transform: scale(0);
    opacity: 1;
  }
}

.fade-end {
  animation: fade-end var(--dur) linear both;
}

@keyframes fade-end {
  0%,
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.void-halo {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 3px solid rgba(200, 120, 255, 0.7);
  box-shadow: 0 0 20px rgba(180, 90, 255, 0.6);
  animation: inhale 1s ease-in var(--dl, 0s) infinite both;
}

@keyframes inhale {
  0% {
    transform: scale(1.2);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: scale(0.3);
    opacity: 0;
  }
}

.mote {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e2b8ff;
  box-shadow: 0 0 8px #b56cff;
  animation: suck 0.8s ease-in var(--dl) both;
}

@keyframes suck {
  0% {
    transform: rotate(var(--a)) translateX(var(--d)) scale(1);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: rotate(calc(var(--a) + 120deg)) translateX(0) scale(0.2);
    opacity: 0;
  }
}

/* Starfall */
.star-aura {
  width: 440px;
  height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(60, 40, 170, 0.55), rgba(70, 60, 190, 0.3) 45%, transparent 70%);
  animation: aura 2.8s ease both;
}

@keyframes aura {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  15%,
  85% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.star-fly {
  position: absolute;
  left: 0;
  top: 0;
  animation: star-fall 0.5s cubic-bezier(0.5, 0, 1, 0.6) var(--dl) both;
}

@keyframes star-fall {
  0% {
    transform: translate(-150px, -400px);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  99% {
    transform: translate(0, 0);
    opacity: 1;
  }
  100% {
    transform: translate(0, 0);
    opacity: 0;
  }
}

.star {
  width: 22px;
  height: 22px;
  background: #fffbe0;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  filter: drop-shadow(0 0 6px #fff);
}

.star-tail {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 120px;
  translate: -50% 0;
  transform-origin: 50% 0;
  rotate: 159.4deg;
  border-radius: 50%;
  background: linear-gradient(rgba(220, 235, 255, 0.9), transparent);
}

/* Sunbeam */
.beam {
  position: absolute;
  left: 0;
  top: 0;
  width: 120px;
  height: 1100px;
  translate: -50% -100%;
  transform-origin: 50% 100%;
  background: linear-gradient(to top, rgba(255, 255, 240, 0.95), rgba(255, 230, 140, 0.7) 40%, rgba(255, 220, 120, 0));
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
  animation: beam 2.7s ease both;
}

.beam.core {
  width: 40px;
  background: linear-gradient(to top, #fff, rgba(255, 255, 255, 0.85) 50%, rgba(255, 255, 255, 0));
}

@keyframes beam {
  0% {
    transform: scaleX(0);
    opacity: 0;
  }
  8% {
    transform: scaleX(1.5);
    opacity: 1;
  }
  18% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(1.12);
  }
  82% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(0);
    opacity: 0;
  }
}

.rays-wrap {
  width: 420px;
  height: 420px;
  animation: aura 2.8s ease both;
}

.rays {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 228, 140, 0.6) 0 7deg, transparent 7deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 15%, transparent 70%);
  mask-image: radial-gradient(circle, #000 15%, transparent 70%);
  animation: spin 7s linear infinite;
}

.lift {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff6c8;
  box-shadow: 0 0 10px #ffd86b;
  animation: lift 1s ease-out var(--dl) both;
}

@keyframes lift {
  0% {
    transform: translate(var(--x), 0) scale(1);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), -340px) scale(0.3);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tree .canopy,
  .player .body,
  .slot.tier3::before {
    animation: none;
  }
}
