:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Noto Sans TC", system-ui, sans-serif;
  color: #2d2118;
  background: #21352b;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@property --sun-left {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 100%;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 220, 112, 0.42), transparent 13rem),
    radial-gradient(circle at 84% 18%, rgba(108, 202, 255, 0.2), transparent 16rem),
    linear-gradient(180deg, #1f3c54 0%, #30533a 48%, #18291f 100%);
}

button,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.yard-game {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(94px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 10px;
  align-items: center;
}

.home-link,
.soft-btn,
.result-card button,
.result-card a {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff8d8, #f7c95d);
  color: #3b2a17;
  box-shadow: 0 8px 0 #9b6428, 0 12px 20px rgba(71, 48, 19, 0.24);
  font-weight: 900;
  text-decoration: none;
}

.home-link {
  display: grid;
  place-items: center;
  font-size: 1.45rem;
}

.title-block p,
.title-block h1 {
  margin: 0;
}

.title-block p {
  font-size: 0.72rem;
  font-weight: 900;
  color: rgba(255, 239, 188, 0.72);
}

.title-block h1 {
  font-size: clamp(1.2rem, 4.8vw, 2.2rem);
  line-height: 1.04;
  color: #fff7d1;
  text-shadow: 0 3px 0 rgba(58, 32, 13, 0.36);
}

.language-picker {
  min-width: 112px;
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 900;
  color: rgba(255, 239, 188, 0.78);
}

.language-picker select {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 8px 9px;
  background: rgba(255, 250, 225, 0.95);
  color: #3b2a17;
  font-weight: 900;
}

.menu-panel,
.play-panel {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.menu-shell {
  border: 5px solid rgba(97, 67, 36, 0.9);
  border-radius: 28px;
  padding: 12px;
  display: grid;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(255, 242, 198, 0.96), rgba(206, 142, 64, 0.9)),
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.74), transparent 13rem);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.38),
    inset 0 -18px rgba(92, 53, 25, 0.12),
    0 18px 36px rgba(8, 16, 12, 0.36);
}

.cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  object-fit: cover;
  object-position: center;
  display: block;
  border: 4px solid rgba(74, 48, 25, 0.82);
  box-shadow: 0 16px 34px rgba(28, 17, 9, 0.34);
}

.menu-copy {
  display: grid;
  gap: 4px;
}

.menu-copy strong {
  font-size: 1.36rem;
}

.menu-copy span,
.hint-text {
  color: rgba(59, 42, 23, 0.72);
  font-weight: 900;
}

.wallet-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.wallet-row span {
  min-width: 112px;
  min-height: 42px;
  border-radius: 14px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #fff7dc, #ffd167);
  box-shadow: inset 0 -4px rgba(130, 82, 23, 0.16), 0 7px 0 rgba(129, 82, 26, 0.5);
  font-weight: 900;
}

.wallet-row i {
  color: #d5a117;
  font-style: normal;
}

.wallet-row span:last-child i {
  color: #5ba5ff;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stage-card {
  min-height: 88px;
  border: 0;
  border-radius: 16px;
  padding: 9px;
  display: grid;
  gap: 4px;
  text-align: left;
  background: linear-gradient(145deg, #ffe590, #fff9df);
  color: #3b2a17;
  box-shadow: 0 9px 0 #b8762f, 0 13px 24px rgba(85, 56, 25, 0.18);
  font-weight: 900;
}

.stage-card.locked {
  filter: grayscale(1);
  opacity: 0.58;
}

.stage-card b {
  width: 44px;
  height: 38px;
  position: relative;
  display: block;
}

.stage-card strong {
  font-size: 0.94rem;
}

.stage-card span {
  color: rgba(59, 42, 23, 0.68);
  font-size: 0.82rem;
  line-height: 1.18;
}

.kennel-panel,
.shop-panel {
  border-radius: 22px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255, 250, 222, 0.86), rgba(250, 207, 124, 0.72));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.48), 0 10px 0 rgba(144, 91, 31, 0.46);
}

.kennel-head {
  display: grid;
  gap: 3px;
}

.kennel-head strong {
  font-size: 1.12rem;
}

.kennel-head span {
  color: rgba(59, 42, 23, 0.66);
  font-weight: 850;
}

.kennel-grid,
.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kennel-card,
.shop-card {
  min-height: 116px;
  border-radius: 18px;
  padding: 10px;
  display: grid;
  grid-template-columns: 72px 1fr;
  grid-template-rows: 1fr auto;
  gap: 8px 10px;
  align-items: center;
  background:
    linear-gradient(145deg, rgba(255, 246, 207, 0.98), rgba(245, 179, 91, 0.86)),
    radial-gradient(circle at 14% 12%, rgba(255, 255, 255, 0.9), transparent 5rem);
  box-shadow: 0 8px 0 rgba(139, 86, 29, 0.48), 0 12px 20px rgba(82, 51, 18, 0.18);
}

.kennel-card.locked {
  background: linear-gradient(145deg, rgba(230, 235, 229, 0.9), rgba(255, 255, 255, 0.72));
}

.kennel-card strong,
.kennel-card span {
  display: block;
}

.kennel-card small,
.unit-card em {
  color: rgba(22, 51, 31, 0.58);
  font-style: normal;
}

.kennel-card span {
  margin-top: 4px;
  color: rgba(59, 42, 23, 0.7);
  font-weight: 850;
  font-size: 0.82rem;
}

.kennel-card button,
.shop-card button {
  grid-column: 1 / -1;
  min-height: 38px;
  border: 0;
  border-radius: 13px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(180deg, #fff07f, #f5a93e);
  color: #3b2a17;
  font-weight: 900;
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.08);
}

.kennel-card button b,
.shop-card button b {
  color: #154b7e;
  font-size: 0.86rem;
  white-space: nowrap;
}

.cost-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 46px;
}

.cost-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 0 rgba(91, 61, 12, 0.18));
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.diamond-token i {
  width: 22px;
  height: 22px;
  display: block;
  transform: rotate(45deg);
  border-radius: 6px 2px 6px 2px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0 24%, transparent 25%),
    linear-gradient(135deg, #bff2ff 0%, #56b7ff 48%, #356cff 100%);
  box-shadow:
    inset -3px -4px rgba(23, 71, 172, 0.22),
    0 2px 0 rgba(48, 74, 148, 0.22);
}

.kennel-card button span,
.shop-card button span {
  margin: 0;
  color: inherit;
  font-size: 0.9rem;
  line-height: 1.1;
}

.kennel-card button:disabled,
.shop-card button:disabled {
  opacity: 0.52;
}

.kennel-animal {
  height: 76px;
  position: relative;
}

.shop-hero {
  height: 96px;
  position: relative;
}

.menu-tabs {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 50;
  width: min(94vw, 500px);
  transform: translateX(-50%);
  border: 4px solid rgba(102, 64, 24, 0.52);
  border-radius: 24px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: rgba(67, 43, 24, 0.86);
  box-shadow: 0 12px 24px rgba(55, 34, 15, 0.3);
  backdrop-filter: blur(8px);
}

.menu-tabs button {
  min-height: 62px;
  border: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  gap: 2px;
  background: linear-gradient(180deg, #fff2c1, #e49a42);
  color: #3b2a17;
  font-weight: 950;
  box-shadow: inset 0 -5px rgba(103, 60, 22, 0.22);
}

.menu-tabs button.active {
  background: linear-gradient(180deg, #fff8df, #ffd75f);
  transform: translateY(-3px);
  box-shadow: 0 7px 0 #a56526, inset 0 -4px rgba(103, 60, 22, 0.14);
}

.menu-tabs img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.menu-tabs span {
  font-size: 0.78rem;
}

.play-head {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.soft-btn {
  padding: 0 13px;
}

.resource-pill,
.base-pill,
.wave-text {
  min-height: 44px;
  border-radius: 14px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 16px rgba(37, 84, 51, 0.15);
  font-weight: 900;
}

.wave-text {
  justify-content: space-between;
}

.unit-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.unit-card {
  min-height: 82px;
  border: 0;
  border-radius: 18px;
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  text-align: left;
  background: linear-gradient(180deg, #fff5c9, #f4b75e);
  color: #3b2a17;
  box-shadow: 0 7px 0 rgba(118, 77, 29, 0.48), 0 10px 18px rgba(37, 84, 51, 0.15);
  font-weight: 900;
}

.unit-card .mini-animal {
  width: 48px;
  aspect-ratio: 1;
  position: relative;
}

.unit-card.selected {
  outline: 4px solid #ffca3a;
  transform: translateY(-2px);
}

.unit-card.disabled {
  opacity: 0.5;
}

.unit-card small {
  display: block;
  color: rgba(22, 51, 31, 0.68);
}

.yard-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1.55 / 1;
  min-height: 318px;
  --grid-cols: 9;
  --grid-rows: 5;
  --cell-w: calc(100% / var(--grid-cols));
  --cell-h: calc(100% / var(--grid-rows));
  overflow: hidden;
  border-radius: 24px;
  border: 5px solid rgba(94, 58, 31, 0.82);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px) 0 0 / calc(100% / var(--grid-cols)) 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.24) 0 1px, transparent 1px) 0 0 / 100% calc(100% / var(--grid-rows)),
    radial-gradient(circle at 77% 16%, rgba(255, 230, 114, 0.35), transparent 10rem),
    radial-gradient(ellipse at 22% 93%, rgba(77, 45, 21, 0.25), transparent 12rem),
    linear-gradient(180deg, #9de08f 0%, #4ca45d 55%, #2e6b42 100%);
  box-shadow:
    inset 0 0 0 4px rgba(255, 245, 190, 0.28),
    inset 0 -18px rgba(33, 72, 42, 0.18),
    0 20px 34px rgba(8, 16, 12, 0.34);
}

.yard-board::before,
.yard-board::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.yard-board::before {
  background: var(--stage-sky, transparent);
  mix-blend-mode: soft-light;
  opacity: var(--stage-sky-opacity, 0.5);
}

.yard-board::after {
  background: var(--stage-weather, transparent);
  opacity: var(--stage-weather-opacity, 0.55);
}

.yard-board.is-danger {
  animation: board-danger 0.34s ease-out 2;
}

.yard-board[data-theme="sunny"] {
  --stage-sky: radial-gradient(circle at 82% 18%, rgba(255, 241, 105, 0.92), transparent 8rem);
  --stage-sky-opacity: 0.55;
}

.yard-board[data-theme="sunset"] {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px) 0 0 / calc(100% / var(--grid-cols)) 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.24) 0 1px, transparent 1px) 0 0 / 100% calc(100% / var(--grid-rows)),
    radial-gradient(circle at 82% 20%, rgba(255, 138, 78, 0.5), transparent 11rem),
    linear-gradient(180deg, #c4c95e 0%, #5ea34f 100%);
}

.yard-board[data-theme="rain"] {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px) 0 0 / calc(100% / var(--grid-cols)) 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0 1px, transparent 1px) 0 0 / 100% calc(100% / var(--grid-rows)),
    radial-gradient(circle at 22% 22%, rgba(115, 188, 255, 0.35), transparent 10rem),
    linear-gradient(180deg, #4b9a8d 0%, #2f8057 100%);
  --stage-weather: repeating-linear-gradient(105deg, transparent 0 16px, rgba(222, 244, 255, 0.36) 17px 19px, transparent 20px 34px);
  --stage-weather-opacity: 0.5;
}

.yard-board[data-theme="swamp"] {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px) 0 0 / calc(100% / var(--grid-cols)) 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px) 0 0 / 100% calc(100% / var(--grid-rows)),
    radial-gradient(ellipse at 22% 78%, rgba(90, 68, 33, 0.38), transparent 8rem),
    radial-gradient(ellipse at 75% 42%, rgba(64, 95, 40, 0.45), transparent 10rem),
    linear-gradient(180deg, #678e42 0%, #426d39 100%);
  --stage-weather: radial-gradient(circle at 18% 70%, rgba(95, 70, 35, 0.28), transparent 5rem), radial-gradient(circle at 64% 30%, rgba(31, 70, 39, 0.24), transparent 7rem);
  --stage-weather-opacity: 0.72;
}

.yard-board[data-theme="boss"] {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px) 0 0 / calc(100% / var(--grid-cols)) 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px) 0 0 / 100% calc(100% / var(--grid-rows)),
    radial-gradient(circle at 82% 20%, rgba(255, 45, 38, 0.32), transparent 10rem),
    linear-gradient(180deg, #7e6942 0%, #334f35 100%);
  --stage-weather: repeating-linear-gradient(45deg, transparent 0 28px, rgba(255, 82, 54, 0.16) 29px 32px, transparent 33px 58px);
  --stage-weather-opacity: 0.75;
}

.cell {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.04);
}

.cell:active {
  background: rgba(255, 255, 255, 0.25);
}

.danger-alert {
  position: absolute;
  left: 50%;
  top: 12px;
  z-index: 18;
  transform: translateX(-50%);
  max-width: min(84%, 360px);
  padding: 8px 14px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 238, 165, 0.96), rgba(245, 93, 63, 0.94));
  color: #55210f;
  font-weight: 1000;
  text-align: center;
  box-shadow: 0 10px 18px rgba(92, 21, 12, 0.28);
  pointer-events: none;
  animation: danger-alert 0.9s ease-out forwards;
}

.actor,
.projectile,
.zombie,
.energy-drop {
  position: absolute;
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: transform;
  overflow: visible;
}

.actor {
  z-index: 5;
  width: calc(var(--cell-w) * 0.82);
  height: calc(var(--cell-h) * 0.82);
  filter: drop-shadow(0 10px 8px rgba(22, 51, 31, 0.28));
}

.hp-bar {
  position: absolute;
  z-index: 10;
  width: calc(var(--cell-w) * 0.48);
  height: max(3px, calc(var(--cell-h) * 0.032));
  overflow: hidden;
  border-radius: 999px;
  background: rgba(80, 22, 22, 0.2);
  box-shadow: 0 1px 2px rgba(45, 18, 18, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.45);
  pointer-events: none;
  will-change: transform;
}

.hp-bar.zombie-hp {
  width: calc(var(--cell-w) * 0.52);
  z-index: 11;
}

.hp-bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: #ef4444;
}

.projectile {
  z-index: 7;
  width: calc(var(--cell-w) * 0.34);
  aspect-ratio: 1.55;
  border-radius: 999px 60% 60% 999px;
  background: radial-gradient(circle at 74% 36%, #fff9bd 0 16%, #ffe066 17% 52%, #f59e0b 53% 100%);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.46), 0 4px 10px rgba(80, 60, 8, 0.24), 0 0 18px rgba(255, 224, 102, 0.56);
}

.projectile::before {
  content: "";
  position: absolute;
  left: -48%;
  top: 30%;
  width: 68%;
  height: 40%;
  border-radius: 999px 0 0 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.72));
}

.projectile.dog {
  display: none;
}

.projectile.owl {
  border-radius: 999px 52% 52% 999px;
  background: radial-gradient(circle at 74% 36%, #f6e7a4 0 16%, #9f86ff 17% 52%, #4d3ca6 53% 100%);
}

.projectile.fox {
  background: radial-gradient(circle at 74% 36%, #fff0c3 0 16%, #59e28b 17% 52%, #138f56 53% 100%);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.44), 0 4px 10px rgba(18, 78, 44, 0.24), 0 0 18px rgba(89, 226, 139, 0.52);
}

.zombie {
  z-index: 6;
  width: calc(var(--cell-w) * 0.84);
  height: calc(var(--cell-h) * 0.84);
  filter: drop-shadow(0 10px 8px rgba(29, 50, 32, 0.32));
}

.zombie.boss {
  width: calc(var(--cell-w) * 1.22);
  height: calc(var(--cell-h) * 1.22);
  filter: drop-shadow(0 15px 12px rgba(29, 50, 32, 0.38));
}

.actor.is-shooting {
  animation: guard-shoot 0.24s ease-out;
}

.actor.is-placed {
  animation: guard-place 0.36s cubic-bezier(0.2, 1.45, 0.32, 1);
}

.actor.is-hit,
.zombie.is-hit {
  animation: actor-hit 0.26s ease-out;
}

.zombie.is-entering {
  animation: zombie-enter 0.5s ease-out;
}

.zombie.near-home {
  filter: drop-shadow(0 10px 8px rgba(29, 50, 32, 0.32)) drop-shadow(0 0 10px rgba(255, 76, 76, 0.64));
}

.zombie.is-biting {
  animation: zombie-bite 0.28s ease-out;
}

.impact {
  position: absolute;
  z-index: 8;
  width: calc(var(--cell-w) * 0.58);
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.98) 0 16%, transparent 17%),
    conic-gradient(from 20deg, transparent 0 10%, #fff3a0 11% 18%, transparent 19% 30%, #ff8f3d 31% 39%, transparent 40% 52%, #fff3a0 53% 62%, transparent 63% 100%);
  filter: drop-shadow(0 4px 5px rgba(79, 45, 12, 0.24));
  animation: impact-pop 0.42s ease-out forwards;
}

.impact.owl {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.98) 0 16%, transparent 17%),
    conic-gradient(from 20deg, transparent 0 10%, #e8dcff 11% 18%, transparent 19% 30%, #8f78ff 31% 39%, transparent 40% 52%, #f6e7a4 53% 62%, transparent 63% 100%);
}

.impact.fox {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.98) 0 16%, transparent 17%),
    conic-gradient(from 20deg, transparent 0 10%, #bdffd2 11% 18%, transparent 19% 30%, #1fb86d 31% 39%, transparent 40% 52%, #fff0c3 53% 62%, transparent 63% 100%);
}

.impact.bite {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.98) 0 14%, transparent 15%),
    conic-gradient(from 20deg, transparent 0 9%, #ff4f5e 10% 18%, transparent 19% 32%, #6b1f2a 33% 42%, transparent 43% 55%, #ffb3b3 56% 65%, transparent 66% 100%);
}

.impact.place {
  width: calc(var(--cell-w) * 0.72);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.92) 0 18%, transparent 19%),
    conic-gradient(from 10deg, transparent 0 8%, #b7f47b 9% 17%, transparent 18% 30%, #fff3a0 31% 39%, transparent 40% 54%, #7ee0ff 55% 65%, transparent 66% 100%);
}

.animal-sprite,
.zombie-sprite {
  position: absolute;
  inset: 0;
  display: block;
}

.animal-sprite {
  transform-origin: center;
  transition: transform 0.14s ease;
}

.actor.facing-right .animal-sprite {
  transform: scaleX(-1);
}

.animal-sprite img,
.zombie-sprite img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.animal-sprite img {
  filter: drop-shadow(0 4px 0 rgba(62, 37, 20, 0.16));
}

.zombie-sprite img {
  filter: drop-shadow(0 4px 0 rgba(21, 40, 28, 0.18));
}

.animal-sprite i,
.zombie-sprite i {
  position: absolute;
  display: block;
}

.animal-sprite .body {
  left: 24%;
  top: 35%;
  width: 52%;
  height: 40%;
  border-radius: 48% 52% 38% 42%;
  background: linear-gradient(145deg, var(--fur-light, #f0b174), var(--fur, #d98a54));
  box-shadow: inset -8px -10px rgba(99, 49, 24, 0.16);
}

.animal-sprite .head {
  left: 37%;
  top: 13%;
  width: 38%;
  height: 34%;
  border-radius: 50% 50% 45% 45%;
  background: linear-gradient(145deg, var(--fur-light, #f0b174), var(--fur, #d98a54));
  box-shadow: inset -5px -7px rgba(99, 49, 24, 0.14);
}

.animal-sprite .ear {
  top: 6%;
  width: 18%;
  height: 21%;
  background: var(--fur-dark, #b46a3d);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.animal-sprite .ear.left {
  left: 36%;
  transform: rotate(-18deg);
}

.animal-sprite .ear.right {
  left: 60%;
  transform: rotate(18deg);
}

.animal-sprite .tail {
  left: 10%;
  top: 38%;
  width: 28%;
  height: 16%;
  border-radius: 999px;
  background: var(--fur-dark, #b46a3d);
  transform: rotate(-22deg);
  transform-origin: right center;
}

.animal-sprite .leg {
  top: 68%;
  width: 13%;
  height: 24%;
  border-radius: 999px;
  background: var(--fur-dark, #b46a3d);
}

.animal-sprite .leg.one {
  left: 35%;
}

.animal-sprite .leg.two {
  left: 57%;
}

.animal-sprite .eye {
  left: 58%;
  top: 25%;
  width: 7%;
  height: 7%;
  border-radius: 50%;
  background: #16331f;
}

.animal-sprite .snout {
  left: 62%;
  top: 34%;
  width: 16%;
  height: 12%;
  border-radius: 999px;
  background: rgba(255, 238, 205, 0.8);
}

.animal-sprite.cat {
  --fur-light: #f3b36f;
  --fur: #d18a55;
  --fur-dark: #a95f37;
}

.animal-sprite.dog {
  --fur-light: #e7b47c;
  --fur: #c89562;
  --fur-dark: #7d5436;
}

.animal-sprite.dog .ear {
  border-radius: 999px;
  clip-path: none;
  height: 28%;
}

.animal-sprite.owl {
  --fur-light: #b5a08a;
  --fur: #8b745d;
  --fur-dark: #57483c;
}

.animal-sprite.owl .body {
  left: 27%;
  width: 48%;
  height: 52%;
  border-radius: 50% 50% 46% 46%;
}

.animal-sprite.owl .tail,
.animal-sprite.owl .snout {
  display: none;
}

.animal-sprite.owl .eye {
  box-shadow: -12px 0 #16331f, 0 0 0 5px #f6e7a4, -12px 0 0 5px #f6e7a4;
}

.animal-sprite.fox {
  --fur-light: #ff9b52;
  --fur: #e46d2f;
  --fur-dark: #9e3f22;
}

.animal-sprite.fox .tail {
  width: 34%;
  height: 20%;
}

.zombie-sprite .body {
  left: 28%;
  top: 32%;
  width: 46%;
  height: 48%;
  border-radius: 38% 42% 24% 28%;
  background: #7ea888;
}

.zombie-sprite .head {
  left: 35%;
  top: 11%;
  width: 40%;
  height: 33%;
  border-radius: 44% 48% 40% 42%;
  background: #94bb9d;
}

.zombie-sprite .arm {
  top: 42%;
  width: 16%;
  height: 40%;
  border-radius: 999px;
  background: #789d80;
}

.zombie-sprite .arm.front {
  left: 66%;
  transform: rotate(-26deg);
}

.zombie-sprite .arm.back {
  left: 18%;
  transform: rotate(24deg);
}

.zombie-sprite .leg {
  top: 72%;
  width: 14%;
  height: 22%;
  border-radius: 999px;
  background: #5d7d67;
}

.zombie-sprite .leg.one {
  left: 37%;
}

.zombie-sprite .leg.two {
  left: 55%;
}

.zombie-sprite .eye {
  left: 54%;
  top: 23%;
  width: 7%;
  height: 7%;
  border-radius: 50%;
  background: #203027;
  box-shadow: -12px 0 #203027;
}

.zombie-sprite.fast .body {
  background: #79a99f;
}

.zombie-sprite.shield .body {
  background: #6f9876;
}

.zombie-sprite.boss .body {
  left: 24%;
  top: 29%;
  width: 52%;
  height: 52%;
  background: #5f8468;
}

.zombie-sprite.boss .head {
  left: 31%;
  top: 6%;
  width: 46%;
  height: 38%;
  background: #7aa684;
}

.zombie-sprite.boss .arm {
  top: 38%;
  height: 46%;
  background: #52745d;
}

.zombie-sprite.boss .eye {
  background: #1f241f;
  box-shadow: -15px 0 #1f241f;
}

.energy-drop {
  --sun-life: 4200ms;
  width: clamp(28px, calc(var(--cell-w) * 0.46), 44px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 999px;
  background: #ffe15a;
  color: #724b00;
  box-shadow: 0 8px 18px rgba(114, 75, 0, 0.22);
  font-size: clamp(1rem, calc(var(--cell-w) * 0.26), 1.35rem);
  pointer-events: auto;
  animation: bob 1.1s ease-in-out infinite alternate;
}

.energy-drop::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(#57f07b var(--sun-left, 100%), rgba(142, 150, 142, 0.72) 0);
  filter: drop-shadow(0 0 5px rgba(88, 240, 123, 0.5));
  pointer-events: none;
  animation: sun-ring-countdown var(--sun-life) linear forwards;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.floating {
  position: fixed;
  left: 50%;
  top: 54%;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(22, 51, 31, 0.88);
  color: white;
  font-weight: 900;
  transform: translate(-50%, -50%);
  animation: float-out 1.1s ease forwards;
  pointer-events: none;
}

.board-pop {
  position: absolute;
  z-index: 12;
  color: #f7d24b;
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(38, 42, 22, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: board-pop 0.9s ease forwards;
}

.result-panel,
.loading-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(22, 51, 31, 0.42);
  backdrop-filter: blur(8px);
}

.result-card,
.loading-card {
  width: min(100%, 390px);
  border-radius: 24px;
  padding: 20px;
  display: grid;
  gap: 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 18px 38px rgba(22, 51, 31, 0.25);
  font-weight: 900;
}

.result-card strong {
  font-size: 1.65rem;
}

.result-report {
  display: grid;
  gap: 10px;
}

.result-summary,
.progress-message {
  margin: 0;
  color: #31513a;
  line-height: 1.35;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.result-stats span {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(89, 199, 101, 0.14);
  color: #1f4c2a;
  font-size: 0.82rem;
  font-weight: 950;
}

.skill-report {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 202, 58, 0.18);
  text-align: left;
}

.skill-report > strong {
  font-size: 0.95rem;
  color: #273f2e;
}

.skill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #31513a;
  font-size: 0.88rem;
}

.skill-row b {
  color: #f6b91e;
  white-space: nowrap;
}

.result-report small {
  color: #6b7c70;
  font-size: 0.72rem;
  line-height: 1.25;
}

.result-card button,
.result-card a {
  display: grid;
  place-items: center;
}

.loading-card div {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 51, 31, 0.12);
}

.loading-card i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ffca3a, #59c765);
  transition: width 0.22s ease;
}

@keyframes bob {
  from { transform: translate(-50%, -50%); }
  to { transform: translate(-50%, calc(-50% - 7px)); }
}

@keyframes sun-ring-countdown {
  from {
    --sun-left: 100%;
    filter: drop-shadow(0 0 5px rgba(88, 240, 123, 0.5));
  }
  to {
    --sun-left: 0%;
    filter: drop-shadow(0 0 2px rgba(142, 150, 142, 0.25));
  }
}

@keyframes float-out {
  to {
    opacity: 0;
    transform: translate(-50%, -95%);
  }
}

@keyframes board-pop {
  to {
    opacity: 0;
    transform: translate(-50%, -120%);
  }
}

@keyframes danger-alert {
  0% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.9);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.04);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -16px) scale(0.96);
  }
}

@keyframes board-danger {
  50% {
    box-shadow:
      inset 0 0 0 4px rgba(255, 245, 190, 0.28),
      inset 0 -18px rgba(33, 72, 42, 0.18),
      0 20px 34px rgba(8, 16, 12, 0.34),
      inset 0 0 0 999px rgba(255, 42, 42, 0.12);
  }
}

@keyframes guard-place {
  0% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(0.45);
    filter: drop-shadow(0 10px 8px rgba(22, 51, 31, 0.28)) brightness(1.35);
  }
  65% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(1.16);
  }
  100% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(1);
  }
}

@keyframes zombie-enter {
  0% {
    opacity: 0.45;
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-35%, -50%) scale(0.82);
  }
  100% {
    opacity: 1;
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(1);
  }
}

@keyframes guard-shoot {
  0% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(1);
  }
  45% {
    filter: drop-shadow(0 12px 9px rgba(22, 51, 31, 0.3)) brightness(1.12);
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-43%, -50%) scale(1.08);
  }
  100% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(1);
  }
}

@keyframes actor-hit {
  0% {
    filter: brightness(1.35) drop-shadow(0 10px 8px rgba(29, 50, 32, 0.28));
  }
  35% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-54%, -50%) rotate(-2deg) scale(1.05);
  }
  70% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-47%, -50%) rotate(2deg) scale(0.98);
  }
  100% {
    filter: drop-shadow(0 10px 8px rgba(29, 50, 32, 0.32));
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) rotate(0deg) scale(1);
  }
}

@keyframes zombie-bite {
  0% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(1);
  }
  50% {
    filter: brightness(1.08) drop-shadow(0 12px 10px rgba(29, 50, 32, 0.34));
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-60%, -50%) scale(1.08);
  }
  100% {
    transform: translate(var(--actor-x, 0), var(--actor-y, 0)) translate(-50%, -50%) scale(1);
  }
}

@keyframes impact-pop {
  0% {
    opacity: 0;
    scale: 0.45;
    rotate: 0deg;
  }
  18% {
    opacity: 1;
    scale: 1.15;
  }
  100% {
    opacity: 0;
    scale: 1.85;
    rotate: 28deg;
  }
}

@media (max-width: 560px) {
  .yard-game {
    gap: 9px;
    padding-inline: 8px;
  }

  .play-panel {
    gap: 7px;
    align-content: stretch;
  }

  .topbar {
    grid-template-columns: 42px 1fr;
  }

  .language-picker {
    grid-column: 1 / -1;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .play-head {
    grid-template-columns: 0.9fr 1fr 1fr;
    gap: 6px;
  }

  .soft-btn,
  .resource-pill,
  .base-pill,
  .wave-text {
    min-height: 36px;
    padding: 6px 8px;
    border-radius: 12px;
    font-size: 0.88rem;
  }

  .unit-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .unit-card {
    min-height: 64px;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 6px 4px;
    gap: 4px;
    border-radius: 14px;
    box-shadow: 0 5px 0 rgba(118, 77, 29, 0.42), 0 8px 14px rgba(37, 84, 51, 0.13);
  }

  .unit-card .mini-animal {
    width: clamp(34px, 10vw, 40px);
  }

  .unit-card small {
    font-size: 0.66rem;
    line-height: 1.1;
  }

  .yard-board {
    height: clamp(282px, calc(100svh - 258px), 360px);
    min-height: 0;
    aspect-ratio: auto;
    border-width: 4px;
    border-radius: 20px;
  }

  .kennel-grid,
  .shop-grid {
    grid-template-columns: 1fr;
  }
}
