:root {
  --bg-a: #bfeeff;
  --bg-b: #fff3c9;
  --bg-c: #ffd4e6;
  --ink: #45324b;
  --muted: #806a84;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --tile-a: #fffefd;
  --tile-b: #fff0c6;
  --tile-c: #ffd8e8;
  --accent: #ff7fab;
  --accent-strong: #ff4f8f;
  --honey: #ffbf4e;
  --mint: #63d9c4;
  --sky: #6bcdf4;
  --shadow: 0 22px 60px rgba(91, 70, 101, 0.2);
  --tile-shadow: 0 10px 0 #e8b877, 0 16px 26px rgba(111, 77, 88, 0.18);
  --board-size: min(88vw, 548px);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Nunito", "Trebuchet MS", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 14% 16%, rgba(255, 255, 255, 0.78), transparent 24%),
    radial-gradient(circle at 86% 14%, rgba(255, 255, 255, 0.62), transparent 22%),
    radial-gradient(circle at 80% 82%, rgba(255, 255, 255, 0.54), transparent 26%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b) 48%, var(--bg-c));
  display: grid;
  place-items: center;
  overflow-x: hidden;
  padding: 24px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 127, 171, 0.18) 0 8px, transparent 9px),
    radial-gradient(circle, rgba(99, 217, 196, 0.16) 0 7px, transparent 8px),
    radial-gradient(ellipse, rgba(255, 255, 255, 0.42) 0 18px, transparent 19px);
  background-position: 32px 44px, 120px 132px, 72px 210px;
  background-size: 170px 170px, 210px 210px, 260px 260px;
  opacity: 0.9;
}

button {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.pet-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.pet-bg span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.48);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
  font-size: 2.2rem;
  filter: drop-shadow(0 14px 20px rgba(97, 72, 99, 0.12));
  animation: floatPet 7s ease-in-out infinite;
}

.pet-bg span:nth-child(1) {
  left: 6vw;
  top: 12vh;
}

.pet-bg span:nth-child(2) {
  right: 8vw;
  top: 16vh;
  animation-delay: -2s;
}

.pet-bg span:nth-child(3) {
  left: 9vw;
  bottom: 9vh;
  animation-delay: -4s;
}

.pet-bg span:nth-child(4) {
  right: 10vw;
  bottom: 12vh;
  animation-delay: -1s;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 900px);
  min-height: calc(100vh - 48px);
  display: grid;
  align-content: center;
  gap: 16px;
}

.screen {
  width: 100%;
}

.game-shell {
  width: 100%;
  display: grid;
  gap: 18px;
}

.hero-panel,
.menu-panel {
  position: relative;
  overflow: hidden;
  width: min(100%, 620px);
  margin: 0 auto;
  text-align: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.88), transparent 24%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(255, 237, 202, 0.82));
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 34px;
  box-shadow: var(--shadow), inset 0 -5px 0 rgba(255, 190, 96, 0.18);
  padding: clamp(26px, 5vw, 46px);
  backdrop-filter: blur(18px);
}

.hero-panel::before,
.menu-panel::before {
  content: "🐾";
  position: absolute;
  right: 22px;
  top: 20px;
  color: rgba(255, 127, 171, 0.24);
  font-size: 4rem;
  transform: rotate(18deg);
}

.hero-copy,
.menu-heading p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.24rem);
  font-weight: 800;
}

.hero-pets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(100%, 360px);
  margin: 26px auto;
}

.hero-pets span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 24px;
  background: linear-gradient(145deg, #ffffff, #ffefc5);
  box-shadow: 0 9px 0 #e8b877, 0 16px 24px rgba(111, 77, 88, 0.14);
  font-size: clamp(2rem, 8vw, 3.2rem);
}

.hero-actions,
.menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.main-button {
  min-width: 168px;
}

.menu-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0;
}

.level-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.level-tile {
  min-height: 170px;
  display: grid;
  gap: 7px;
  align-content: center;
  justify-items: center;
  border: 0;
  border-radius: 26px;
  padding: 18px 12px;
  color: var(--ink);
  background:
    radial-gradient(circle at 26% 20%, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(150deg, #ffffff, #fff0c8 62%, #ffd5e7);
  box-shadow: 0 10px 0 #e8b877, 0 18px 28px rgba(111, 77, 88, 0.15);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.level-tile:not(.locked):hover {
  transform: translateY(-3px);
  box-shadow: 0 13px 0 #e2aa68, 0 22px 32px rgba(111, 77, 88, 0.18);
}

.level-tile:active,
.restart-button:active,
.ghost-button:active {
  animation: buttonPress 170ms ease;
}

.level-tile.locked {
  color: #998a9b;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.78), rgba(232, 226, 235, 0.9));
  box-shadow: 0 8px 0 #c9bccf, 0 14px 22px rgba(111, 77, 88, 0.12);
  filter: grayscale(0.35);
}

.level-number {
  font-size: 1.35rem;
  font-weight: 1000;
}

.level-goal,
.level-moves {
  color: var(--muted);
  font-weight: 800;
}

.level-status {
  min-width: 86px;
  margin-top: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--mint), var(--sky));
  font-size: 0.86rem;
  font-weight: 900;
}

.level-tile.locked .level-status {
  background: #b6aabb;
}

.top-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 18px;
  background: var(--panel);
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 28px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  padding: 18px;
  backdrop-filter: blur(18px);
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.45rem);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 5px 0 rgba(255, 255, 255, 0.7);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(76px, 1fr));
  gap: 10px;
}

.stat-card {
  min-width: 78px;
  padding: 10px 12px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 246, 225, 0.94));
  border: 1px solid rgba(255, 144, 180, 0.25);
  border-radius: 18px;
  box-shadow:
    0 8px 18px rgba(99, 74, 94, 0.1),
    inset 0 -3px 0 rgba(255, 190, 96, 0.18);
}

.level-card {
  border-color: rgba(107, 205, 244, 0.36);
}

.best-card {
  border-color: rgba(99, 217, 196, 0.36);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 2px;
  font-size: 1.32rem;
}

.play-area {
  position: relative;
  display: grid;
  place-items: center;
}

.board {
  width: var(--board-size);
  height: var(--board-size);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: clamp(6px, 1.25vw, 10px);
  padding: clamp(11px, 2vw, 16px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(255, 218, 237, 0.48)),
    linear-gradient(135deg, #f9c66a, #ff8cb8 54%, #75d9cc);
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  box-shadow:
    0 18px 0 rgba(207, 145, 86, 0.42),
    var(--shadow),
    inset 0 0 0 2px rgba(255, 255, 255, 0.42);
  touch-action: manipulation;
  user-select: none;
}

.tile {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background:
    radial-gradient(circle at 32% 25%, rgba(255, 255, 255, 0.98), transparent 34%),
    linear-gradient(145deg, var(--tile-a), var(--tile-b) 62%, var(--tile-c));
  box-shadow: var(--tile-shadow), inset 0 -5px 0 rgba(188, 126, 69, 0.18);
  cursor: pointer;
  font-size: clamp(1.65rem, 7vw, 2.85rem);
  line-height: 1;
  transform: translateY(0) scale(1);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease,
    outline-color 160ms ease,
    opacity 180ms ease;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 10% 14% auto auto;
  width: 28%;
  height: 18%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  transform: rotate(-18deg);
  pointer-events: none;
}

.tile:hover {
  filter: brightness(1.04);
  transform: translateY(-3px) scale(1.025);
  box-shadow: 0 12px 0 #e2aa68, 0 20px 30px rgba(111, 77, 88, 0.2);
}

.tile:active {
  transform: translateY(4px) scale(0.96);
  box-shadow: 0 5px 0 #d99f61, 0 10px 18px rgba(111, 77, 88, 0.16);
}

.tile.selected {
  outline: 5px solid var(--accent-strong);
  outline-offset: -5px;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.84),
    0 14px 0 #e2aa68,
    0 22px 34px rgba(255, 79, 143, 0.32);
  transform: translateY(-4px) scale(1.06);
}

.tile.removing {
  animation: popAway 330ms ease forwards;
}

.tile.falling {
  animation: dropIn 360ms cubic-bezier(0.16, 0.92, 0.22, 1.16);
}

.tile.hint-shuffle {
  animation: wiggle 420ms ease;
}

.combo-toast {
  position: absolute;
  top: 43%;
  z-index: 4;
  min-width: 160px;
  padding: 12px 18px;
  text-align: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--honey), var(--accent-strong));
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  box-shadow: 0 16px 32px rgba(126, 77, 82, 0.26);
  font-size: clamp(1.3rem, 5vw, 2.1rem);
  font-weight: 1000;
  text-shadow: 0 2px 0 rgba(119, 62, 72, 0.24);
  opacity: 0;
  transform: translateY(14px) scale(0.8);
  pointer-events: none;
}

.combo-toast.hidden {
  display: none;
}

.combo-toast.show {
  display: block;
  animation: comboPop 900ms ease forwards;
}

.bottom-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.restart-button,
.ghost-button {
  min-width: 148px;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.restart-button {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 22px rgba(255, 79, 143, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.26);
}

.ghost-button {
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 18px rgba(99, 74, 94, 0.12);
}

.restart-button:hover,
.ghost-button:hover {
  filter: brightness(1.04);
  transform: translateY(-2px);
  box-shadow: 0 16px 26px rgba(255, 79, 143, 0.28);
}

.restart-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

.brand-footer {
  margin: 0;
  text-align: center;
  color: rgba(69, 50, 75, 0.62);
  font-size: 0.82rem;
  font-weight: 900;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(73, 55, 78, 0.4);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(92vw, 420px);
  position: relative;
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 241, 156, 0.52), transparent 34%),
    var(--panel-strong);
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 28px;
  box-shadow: 0 28px 76px rgba(52, 38, 56, 0.3);
  padding: 30px 24px 24px;
}

.modal-card::before {
  content: "🐾";
  position: absolute;
  left: 18px;
  top: 14px;
  color: rgba(255, 127, 171, 0.18);
  font-size: 3.2rem;
  transform: rotate(-18deg);
}

.info-card {
  width: min(92vw, 460px);
}

.modal-kicker {
  margin: 0 0 8px;
  color: var(--mint);
  font-weight: 900;
}

.modal[data-type="fail"] .modal-kicker {
  color: var(--accent-strong);
}

.modal-card h2 {
  margin: 0;
  font-size: 2rem;
}

.modal-card p {
  color: var(--muted);
}

.rule-list {
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.rule-list li {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 246, 225, 0.86);
  color: var(--ink);
  font-weight: 800;
}

.rule-list li::before {
  content: "🐾";
  margin-right: 8px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

@keyframes floatPet {
  0%, 100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-18px) rotate(5deg);
  }
}

@keyframes popAway {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  42% {
    opacity: 1;
    transform: scale(1.24) rotate(-4deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.18) rotate(12deg);
  }
}

@keyframes dropIn {
  0% {
    opacity: 0.2;
    transform: translateY(-72%) scale(0.82);
  }
  72% {
    opacity: 1;
    transform: translateY(6%) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes comboPop {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.75);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1.1);
  }
  68% {
    opacity: 1;
    transform: translateY(-8px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-18px) scale(0.94);
  }
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(-4deg) scale(0.96);
  }
  75% {
    transform: rotate(4deg) scale(1.02);
  }
}

@keyframes buttonPress {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(3px) scale(0.97);
  }
}

.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  margin: 0 0 10px;
  padding: 7px 13px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--mint), var(--sky));
  box-shadow: 0 10px 18px rgba(99, 217, 196, 0.22);
  font-size: 0.86rem;
  font-weight: 1000;
}

.level-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.level-tile {
  min-height: 154px;
  padding: 15px 10px;
}

.level-tile.cleared {
  background:
    radial-gradient(circle at 26% 20%, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(150deg, #ffffff, #e7fff8 56%, #d7f3ff);
}

.level-number {
  font-size: 1.18rem;
}

.level-best {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.effect-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.board-effect {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 30px;
  pointer-events: none;
}

.effect-row {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.88), transparent);
  animation: rowSweep 360ms ease forwards;
}

.effect-col {
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.88), transparent);
  animation: colSweep 360ms ease forwards;
}

.effect-bomb {
  background: radial-gradient(circle, rgba(255, 205, 78, 0.72), rgba(255, 79, 143, 0.32) 38%, transparent 64%);
  animation: bombPulse 420ms ease forwards;
}

.effect-rainbow {
  background: conic-gradient(from 0deg, rgba(255, 80, 143, 0.35), rgba(255, 191, 78, 0.35), rgba(99, 217, 196, 0.35), rgba(107, 205, 244, 0.35), rgba(255, 80, 143, 0.35));
  animation: rainbowWave 480ms ease forwards;
}

.special-tile {
  color: #ffffff;
  background:
    radial-gradient(circle at 34% 25%, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, #ff8db8, #ffbf4e 62%, #72dcca);
  box-shadow:
    0 10px 0 #c98a58,
    0 0 0 4px rgba(255, 255, 255, 0.8),
    0 0 22px rgba(255, 79, 143, 0.38);
  animation: specialGlow 1.8s ease-in-out infinite;
}

.special-tile::before,
.obstacle-tile::before {
  position: absolute;
  left: 7px;
  top: 6px;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(69, 50, 75, 0.55);
  font-size: 0.72rem;
  font-weight: 1000;
}

.special-row::before {
  content: "↔";
}

.special-col::before {
  content: "↕";
}

.special-bomb::before {
  content: "3x3";
}

.special-rainbow::before {
  content: "ALL";
}

.obstacle-tile {
  color: #5a5360;
  background:
    radial-gradient(circle at 34% 25%, rgba(255, 255, 255, 0.38), transparent 30%),
    linear-gradient(145deg, #d8d3db, #aaa2ad);
  box-shadow: 0 9px 0 #817a86, 0 16px 24px rgba(76, 68, 82, 0.18);
}

.obstacle-tile::before {
  content: "1";
}

.tool-panel {
  display: grid;
  gap: 10px;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 30px rgba(91, 70, 101, 0.14);
  backdrop-filter: blur(14px);
}

.tool-hint {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  font-weight: 900;
}

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

.tool-button {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 18px;
  padding: 10px;
  color: var(--ink);
  background: linear-gradient(145deg, #ffffff, #fff1ca);
  box-shadow: 0 7px 0 #e8b877, 0 12px 18px rgba(111, 77, 88, 0.14);
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.tool-button:hover:not(:disabled),
.tool-button.active {
  filter: brightness(1.04);
  transform: translateY(-2px);
  box-shadow: 0 9px 0 #e2aa68, 0 16px 22px rgba(111, 77, 88, 0.18);
}

.tool-button:active {
  animation: buttonPress 170ms ease;
}

.tool-button:disabled {
  color: #9d92a1;
  background: linear-gradient(145deg, #ffffff, #e9e3ec);
  box-shadow: 0 5px 0 #c7bdcb, 0 9px 14px rgba(111, 77, 88, 0.1);
  filter: grayscale(0.35);
}

.tool-icon {
  font-size: 1.35rem;
}

.tool-button strong {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  color: white;
  background: var(--accent-strong);
}

.secondary-button {
  background: linear-gradient(135deg, var(--mint), var(--sky));
}

.danger-button {
  color: #c44d73;
}

.intro-stats,
.modal-detail {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.intro-stats span,
.modal-detail p {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 246, 225, 0.86);
  color: var(--ink);
  font-weight: 900;
}

@keyframes specialGlow {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.16);
  }
}

@keyframes rowSweep {
  from {
    opacity: 0;
    transform: translateX(-70%) scaleY(0.22);
  }
  to {
    opacity: 0;
    transform: translateX(70%) scaleY(0.22);
  }
}

@keyframes colSweep {
  from {
    opacity: 0;
    transform: translateY(-70%) scaleX(0.22);
  }
  to {
    opacity: 0;
    transform: translateY(70%) scaleX(0.22);
  }
}

@keyframes bombPulse {
  0% {
    opacity: 0;
    transform: scale(0.2);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}

@keyframes rainbowWave {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(0deg);
  }
  45% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: scale(1.1) rotate(80deg);
  }
}

@media (max-width: 820px) {
  .top-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .stats {
    grid-template-columns: repeat(5, 1fr);
  }

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

  .level-tile {
    min-height: 132px;
  }
}

@media (max-width: 680px) {
  body {
    padding: 12px;
  }

  .pet-bg span {
    width: 62px;
    height: 62px;
    font-size: 1.6rem;
  }

  .app-shell {
    min-height: calc(100vh - 24px);
    gap: 12px;
  }

  .hero-panel,
  .menu-panel {
    border-radius: 26px;
    padding: 24px 16px;
  }

  .hero-pets {
    gap: 8px;
    margin: 22px auto;
  }

  .hero-pets span {
    border-radius: 18px;
    box-shadow: 0 7px 0 #e8b877, 0 12px 20px rgba(111, 77, 88, 0.14);
  }

  .hero-actions,
  .menu-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .game-shell {
    gap: 12px;
  }

  .top-panel {
    border-radius: 22px;
    gap: 12px;
    padding: 12px;
  }

  h1 {
    font-size: clamp(1.9rem, 10vw, 2.55rem);
  }

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

  .best-card {
    grid-column: span 2;
  }

  .stat-card {
    min-width: 0;
    padding: 8px 6px;
    border-radius: 15px;
  }

  .stat-label {
    font-size: 0.72rem;
  }

  .stat-card strong {
    font-size: 1rem;
  }

  .board {
    --board-size: min(94vw, 510px);
    gap: 5px;
    padding: 9px;
    border-radius: 22px;
    box-shadow:
      0 12px 0 rgba(207, 145, 86, 0.42),
      var(--shadow),
      inset 0 0 0 2px rgba(255, 255, 255, 0.42);
  }

  .tile {
    border-radius: 15px;
  }

  .level-list {
    grid-template-columns: 1fr;
  }

  .level-tile {
    min-height: 124px;
  }

  .tool-panel {
    padding: 10px;
  }

  .tools {
    gap: 7px;
  }

  .tool-button {
    min-height: 62px;
    grid-template-columns: 1fr;
    gap: 3px;
    justify-items: center;
    padding: 8px 5px;
    font-size: 0.82rem;
  }

  .tool-button strong {
    min-width: 24px;
    height: 24px;
  }

  .restart-button,
  .ghost-button {
    min-height: 50px;
    padding: 13px 18px;
    font-size: 1rem;
  }

  .modal-actions {
    display: grid;
  }

  .modal-card {
    border-radius: 24px;
    padding: 28px 18px 20px;
  }
}

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