:root {
  --animal-primary-color: #19bcae;
  --animal-warning-color: #f6b739;
  --animal-error-color: #e9584f;
  --animal-text-color: #604d34;
  --animal-bg-color: #fff9ea;
  --animal-border-color: #d8c495;
  --shadow: 0 8px 0 rgba(92, 65, 35, 0.18);
  --hammer-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg transform='rotate(-35 28 28)'%3E%3Crect x='23' y='18' width='8' height='34' rx='4' fill='%23825536'/%3E%3Crect x='12' y='8' width='31' height='17' rx='5' fill='%23d9a15b' stroke='%23633d25' stroke-width='3'/%3E%3Cpath d='M16 11h23' stroke='%23ffe0a0' stroke-width='3' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E") 18 18, pointer;
}

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

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

body {
  margin: 0;
  color: var(--animal-text-color);
  font-family: "Nunito", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 246, 151, 0.86), transparent 19rem),
    linear-gradient(#a9e5ff 0 34%, #8ed06b 34% 100%);
  cursor: var(--hammer-cursor);
  overscroll-behavior: none;
}

button,
.hole,
.mole {
  cursor: var(--hammer-cursor);
  font: inherit;
}

.game-shell {
  width: min(1120px, calc(100vw - 20px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 12px 0;
  display: grid;
  grid-template-rows: auto auto minmax(330px, 1fr) auto;
  gap: 10px;
}

.topbar,
.hud,
.controls {
  border: 3px solid rgba(93, 70, 38, 0.25);
  background: rgba(255, 249, 234, 0.94);
  box-shadow: var(--shadow);
  border-radius: 20px;
}

.topbar {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.leaf-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 56% 44% 58% 42%;
  background: linear-gradient(135deg, #67d673, #17b7aa);
  border: 3px solid #fff9ea;
  box-shadow: 0 4px 0 #91b968;
  transform: rotate(-18deg);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 5px;
  font-size: 15px;
  font-weight: 900;
  color: #766348;
}

.animal-btn {
  min-height: 42px;
  padding: 0 18px;
  border: 2px solid #f8f8f0;
  border-radius: 999px;
  color: #794f27;
  background: #f8f8f0;
  box-shadow: 0 5px 0 #bdaea0;
  font-weight: 1000;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.animal-btn.primary {
  color: #fffaf0;
  background: #20b9aa;
  border-color: #68e4d9;
  box-shadow: 0 5px 0 #128d82;
}

.animal-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #8b7968;
}

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

.stat {
  min-height: 54px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-radius: 15px;
  background: #fffef6;
  border: 2px dashed var(--animal-border-color);
}

.stat span {
  font-size: 14px;
  font-weight: 1000;
}

.stat strong {
  color: #138b82;
  font-size: 25px;
  line-height: 1;
}

.play-area {
  position: relative;
  overflow: hidden;
  min-height: 330px;
  border-radius: 24px;
  border: 4px solid rgba(76, 62, 35, 0.23);
  background: linear-gradient(#9de1ff 0 30%, #7fca6e 30% 70%, #5fae4b 70%);
  box-shadow: inset 0 -16px 0 rgba(50, 101, 42, 0.22), var(--shadow);
  touch-action: manipulation;
}

.forest-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sky::before,
.sky::after {
  content: "";
  position: absolute;
  width: 108px;
  height: 36px;
  top: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 40px 8px 0 -8px rgba(255, 255, 255, 0.7), -34px 10px 0 -10px rgba(255, 255, 255, 0.66);
  animation: drift 14s linear infinite;
}

.sky::before {
  left: 9%;
}

.sky::after {
  left: 66%;
  top: 66px;
  animation-duration: 18s;
}

.trees::before,
.trees::after {
  content: "";
  position: absolute;
  bottom: 31%;
  width: 160px;
  height: 230px;
  background:
    conic-gradient(from 135deg at 50% 22%, transparent 0 25%, #246544 0 50%, transparent 0),
    conic-gradient(from 135deg at 50% 44%, transparent 0 25%, #2d794b 0 50%, transparent 0),
    linear-gradient(#7c5633, #5c3e27);
  background-size: 160px 132px, 160px 132px, 30px 112px;
  background-position: 0 0, 0 62px, 65px 112px;
  background-repeat: no-repeat;
  opacity: 0.78;
}

.trees.back::before {
  left: 2%;
  transform: scale(0.72);
}

.trees.back::after {
  right: -1%;
  transform: scale(0.82);
}

.trees.front::before {
  left: 26%;
  bottom: 28%;
  transform: scale(0.58);
  opacity: 0.55;
}

.trees.front::after {
  right: 25%;
  bottom: 28%;
  transform: scale(0.58);
  opacity: 0.55;
}

.board {
  position: absolute;
  inset: 21% 3.5% 2.5%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 18px);
  z-index: 3;
}

.hole {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  outline: none;
  isolation: isolate;
}

.hole::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: min(96%, 180px);
  aspect-ratio: 2.25 / 1;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, #46311d 0 48%, #724c26 51% 64%, #238b45 66% 100%);
  box-shadow: inset 0 10px 12px rgba(0, 0, 0, 0.34), 0 7px 0 rgba(36, 101, 44, 0.36);
  z-index: 5;
}

.mole {
  position: absolute;
  left: 50%;
  bottom: 17%;
  width: min(82%, 145px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  transform: translate(-50%, 78%) scale(0.82);
  transition: transform 0.18s cubic-bezier(0.2, 1.3, 0.4, 1);
  z-index: 4;
}

.mole.up {
  transform: translate(-50%, 0) scale(1);
  z-index: 6;
}

.mole img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #fff9ea;
  box-shadow: 0 7px 0 rgba(94, 64, 36, 0.2);
  pointer-events: none;
  user-select: none;
}

.mole.golden img {
  filter: sepia(0.35) saturate(1.45) brightness(1.08);
  border-color: #ffd75a;
  box-shadow: 0 0 0 5px rgba(255, 216, 72, 0.3), 0 7px 0 rgba(142, 94, 10, 0.25);
}

.mole.hatted::before {
  content: "帽";
  position: absolute;
  right: 1px;
  top: -2px;
  width: 38px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 38% 38%;
  color: #fff9ea;
  font-size: 15px;
  font-weight: 1000;
  background: #674a2b;
  border: 3px solid #f4d26f;
  z-index: 2;
}

.mole.bomb {
  width: min(74%, 124px);
}

.mole.bomb img {
  object-fit: contain;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 8px 0 rgba(46, 34, 25, 0.24));
}

.mole.hit {
  animation: bonk 0.36s ease forwards;
}

.mole.boss {
  width: min(108%, 208px);
}

.boss-bar {
  position: absolute;
  left: 50%;
  top: 10px;
  width: min(410px, calc(100% - 22px));
  transform: translateX(-50%);
  z-index: 8;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 249, 234, 0.96);
  border: 3px solid var(--animal-border-color);
  font-weight: 1000;
}

.boss-bar.hidden {
  display: none;
}

.boss-bar div {
  height: 17px;
  border-radius: 999px;
  overflow: hidden;
  background: #ead9b6;
}

.boss-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #e9584f, #f6b739);
  transition: width 0.18s ease;
}

.combo-pop {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translate(-50%, -50%) scale(0.75);
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  color: #fffdf4;
  text-shadow: 0 4px 0 #604d34;
  font-size: clamp(30px, 8vw, 82px);
  font-weight: 1000;
}

.combo-pop.show {
  animation: combo 0.72s ease;
}

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

.leaderboard {
  min-height: 50px;
  padding: 7px 11px;
  border-radius: 15px;
  background: #fffef6;
  border: 2px dashed var(--animal-border-color);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}

.leaderboard ol {
  margin: 0;
  padding-left: 20px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-weight: 1000;
}

.welcome {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 244, 143, 0.9), transparent 18rem),
    linear-gradient(rgba(126, 203, 104, 0.92), rgba(75, 149, 78, 0.94));
}

.welcome.hidden {
  display: none;
}

.welcome-panel {
  width: min(460px, 92vw);
  min-height: 330px;
  padding: 30px 24px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  text-align: center;
  border-radius: 30px 24px 34px 22px;
  border: 4px solid rgba(101, 75, 39, 0.28);
  background: #fff9ea;
  box-shadow: 0 14px 0 rgba(83, 59, 30, 0.22);
}

.welcome-badge {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 54% 46% 50% 50%;
  color: #fff9ea;
  background: #20b9aa;
  border: 4px solid #68e4d9;
  box-shadow: 0 6px 0 #128d82;
  font-weight: 1000;
}

.welcome h2 {
  font-size: clamp(32px, 9vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
}

.welcome p {
  color: #7b5c34;
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 1000;
}

.welcome-start {
  min-height: 54px;
  padding: 0 36px;
  font-size: 20px;
}

.particle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--animal-warning-color);
  z-index: 20;
  pointer-events: none;
  animation: spark 0.58s ease-out forwards;
}

.score-float {
  position: absolute;
  z-index: 21;
  color: #fff8df;
  text-shadow: 0 3px 0 #604d34;
  font-weight: 1000;
  pointer-events: none;
  animation: floatScore 0.8s ease-out forwards;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 70;
  padding: 9px 15px;
  border-radius: 999px;
  color: #fff9ea;
  background: rgba(67, 50, 31, 0.88);
  transform: translate(-50%, 130%);
  transition: transform 0.24s ease;
  font-weight: 1000;
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, 0);
}

.hammer {
  position: fixed;
  left: 0;
  top: 0;
  width: 58px;
  height: 58px;
  z-index: 100;
  pointer-events: none;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='58' height='58' viewBox='0 0 58 58'%3E%3Cg transform='rotate(-35 29 29)'%3E%3Crect x='24' y='18' width='8' height='36' rx='4' fill='%23825536'/%3E%3Crect x='11' y='7' width='34' height='18' rx='5' fill='%23d9a15b' stroke='%23633d25' stroke-width='3'/%3E%3Cpath d='M16 11h24' stroke='%23ffe0a0' stroke-width='3' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E");
  transform: translate(-100px, -100px);
  transition: transform 0.05s linear;
  display: none;
}

.hammer.down {
  filter: drop-shadow(0 6px 0 rgba(70, 45, 24, 0.22));
}

@media (pointer: coarse), (max-width: 780px) {
  body {
    cursor: default;
  }

  .hammer {
    display: block;
  }
}

@media (max-width: 780px) {
  .game-shell {
    width: calc(100vw - 10px);
    min-height: 100svh;
    padding: 6px 0;
    grid-template-rows: auto auto minmax(350px, 1fr) auto;
    gap: 6px;
  }

  .topbar {
    padding: 9px 10px;
    border-radius: 16px;
  }

  .leaf-mark {
    width: 34px;
    height: 34px;
  }

  h1 {
    font-size: 24px;
  }

  .brand p {
    font-size: 12px;
  }

  .topbar .animal-btn {
    min-height: 38px;
    padding: 0 12px;
    font-size: 14px;
  }

  .hud {
    padding: 6px;
    gap: 5px;
  }

  .stat {
    min-height: 42px;
    padding: 5px;
    flex-direction: column;
    justify-content: center;
  }

  .stat span {
    font-size: 12px;
  }

  .stat strong {
    font-size: 21px;
  }

  .play-area {
    min-height: 350px;
    border-radius: 18px;
  }

  .board {
    inset: 18% 2.5% 2%;
    gap: 6px;
  }

  .mole {
    bottom: 16%;
    width: min(88%, 95px);
  }

  .mole.bomb {
    width: min(82%, 88px);
  }

  .mole.boss {
    width: min(116%, 122px);
  }

  .mole img {
    border-width: 3px;
  }

  .mole.hatted::before {
    width: 28px;
    height: 22px;
    font-size: 12px;
    border-width: 2px;
  }

  .controls {
    grid-template-columns: 1fr;
    padding: 7px;
  }

  .controls .animal-btn {
    min-height: 38px;
  }

  .leaderboard {
    min-height: 42px;
    grid-template-columns: auto 1fr;
    font-size: 13px;
  }

  .leaderboard ol {
    gap: 12px;
  }
}

@media (max-width: 430px) {
  .game-shell {
    grid-template-rows: auto auto minmax(330px, 1fr) auto;
  }

  .topbar {
    gap: 8px;
  }

  .play-area {
    min-height: 330px;
  }

  .board {
    inset: 17% 2% 2%;
    gap: 5px;
  }

  .trees::before,
  .trees::after {
    opacity: 0.45;
  }
}

@keyframes drift {
  0% {
    transform: translateX(-22px);
  }
  50% {
    transform: translateX(28px);
  }
  100% {
    transform: translateX(-22px);
  }
}

@keyframes bonk {
  0% {
    transform: translate(-50%, 0) rotate(0deg) scale(1);
    filter: none;
  }
  45% {
    transform: translate(-50%, -5px) rotate(24deg) scale(1.08);
    filter: saturate(1.4);
  }
  100% {
    transform: translate(-50%, 78%) rotate(380deg) scale(0.25);
    filter: grayscale(0.4);
  }
}

@keyframes combo {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55) rotate(-8deg);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(3deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -86%) scale(0.96) rotate(0deg);
  }
}

@keyframes spark {
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.12);
  }
}

@keyframes floatScore {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.8);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58px) scale(1.05);
  }
}
