:root {
  color-scheme: light;
  --surface: rgba(255, 255, 255, 0.68);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --ink: #266070;
  --accent: #ffb84e;
  --coral: #ff7d6e;
  --bubble-edge: rgba(255, 255, 255, 0.9);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

body {
  background: #88e3ee;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

.game {
  position: relative;
  width: min(100vw, 58vh);
  height: 100dvh;
  min-height: 520px;
  margin: 0 auto;
  overflow: hidden;
  background-image: url("./assets/pond-background.png");
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 60px rgba(27, 111, 132, 0.28);
  isolation: isolate;
}

.water-sheen {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.32), transparent 12%),
    radial-gradient(circle at 84% 74%, rgba(255, 225, 123, 0.18), transparent 16%),
    linear-gradient(115deg, transparent 16%, rgba(255, 255, 255, 0.16) 24%, transparent 36%, transparent 58%, rgba(255, 255, 255, 0.12) 66%, transparent 78%);
  mix-blend-mode: soft-light;
  animation: driftSheen 9s ease-in-out infinite alternate;
  z-index: 1;
}

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
}

.brand,
.counter,
.icon-button {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(25, 105, 130, 0.12);
  backdrop-filter: blur(14px);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 156px);
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: clamp(15px, 3.8vw, 18px);
  font-weight: 800;
  white-space: nowrap;
  text-decoration: none;
}

.home-link {
  pointer-events: auto;
}

.brand span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #fff 0 16%, transparent 18%),
    radial-gradient(circle at 62% 72%, rgba(255, 255, 255, 0.65) 0 13%, transparent 15%),
    linear-gradient(145deg, #aef6ff, #45bdd2);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.64);
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.counter {
  min-width: 50px;
  height: 42px;
  padding: 0 9px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 900;
  font-size: 19px;
}

.counter::before {
  content: "";
  width: 16px;
  height: 12px;
  margin-right: 3px;
  border-radius: 50% 58% 58% 50%;
  background: var(--accent);
  box-shadow: 10px 0 0 -5px var(--accent);
}

.counter {
  grid-template-columns: auto auto;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

.icon-button:active {
  transform: scale(0.94);
}

.pond {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
}

.bubble {
  position: absolute;
  width: clamp(74px, 24vw, 126px);
  aspect-ratio: 1;
  left: var(--x);
  top: var(--y);
  border-radius: 50%;
  translate: -50% -50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 31% 24%, rgba(255, 255, 255, 0.96) 0 8%, transparent 9%),
    radial-gradient(circle at 66% 72%, rgba(255, 255, 255, 0.42) 0 10%, transparent 11%),
    radial-gradient(circle at 52% 48%, rgba(255, 255, 255, 0.24), rgba(144, 236, 255, 0.22) 48%, rgba(255, 255, 255, 0.42) 69%, rgba(255, 255, 255, 0.82) 72%, rgba(126, 220, 245, 0.18) 100%);
  border: 2px solid var(--bubble-edge);
  box-shadow:
    inset -10px -12px 18px rgba(83, 180, 205, 0.18),
    inset 12px 12px 22px rgba(255, 255, 255, 0.42),
    0 10px 22px rgba(47, 141, 167, 0.17);
  animation: bubbleHatch 1.35s ease-in-out forwards;
}

.bubble::before,
.bubble::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 12px rgba(255, 246, 186, 0.82);
  opacity: 0;
}

.bubble::before {
  width: 10px;
  height: 10px;
  left: -9px;
  top: 18%;
  animation: sparkle 1.35s 0.35s ease-out forwards;
}

.bubble::after {
  width: 8px;
  height: 8px;
  right: -10px;
  bottom: 24%;
  animation: sparkle 1.35s 0.52s ease-out forwards;
}

.pop-ring {
  position: absolute;
  width: clamp(94px, 32vw, 164px);
  aspect-ratio: 1;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.76);
  pointer-events: none;
  animation: popRing 620ms ease-out forwards;
}

.fish {
  position: absolute;
  width: clamp(126px, 34vw, 190px);
  aspect-ratio: 1;
  left: var(--start-x);
  top: var(--start-y);
  translate: -50% -50%;
  pointer-events: none;
  z-index: 6;
  animation: swimAway var(--duration) cubic-bezier(0.25, 0.75, 0.36, 1) forwards;
}

.fish-sprite {
  width: 100%;
  height: 100%;
  background-image: url("./assets/fish-sprites.png");
  background-size: 300% 200%;
  background-position: var(--sprite-pos);
  filter: drop-shadow(0 9px 13px rgba(43, 103, 119, 0.18));
  transform: scaleX(var(--flip));
  animation: fishBob 760ms ease-in-out infinite alternate;
}

.trail-bubble {
  position: absolute;
  width: var(--size);
  aspect-ratio: 1;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
  border-radius: 50%;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(220, 251, 255, 0.24);
  animation: trailRise 1.4s ease-out forwards;
}

@keyframes driftSheen {
  from {
    transform: translate3d(-3%, -2%, 0) rotate(0deg);
  }
  to {
    transform: translate3d(3%, 2%, 0) rotate(4deg);
  }
}

@keyframes bubbleHatch {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(18px);
  }
  18% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  38% {
    transform: scale(1.06) translateY(-10px) rotate(-3deg);
  }
  58% {
    transform: scale(0.98) translateY(-14px) rotate(4deg);
  }
  78% {
    transform: scale(1.1) translateY(-18px) rotate(-2deg);
    filter: brightness(1.12);
  }
  100% {
    opacity: 1;
    transform: scale(1.16) translateY(-20px);
    filter: brightness(1.25);
  }
}

@keyframes sparkle {
  0% {
    opacity: 0;
    transform: scale(0.35);
  }
  45% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.8) translateY(-18px);
  }
}

@keyframes popRing {
  from {
    opacity: 0.85;
    transform: scale(0.35);
  }
  to {
    opacity: 0;
    transform: scale(1.4);
  }
}

@keyframes fishBob {
  from {
    transform: scaleX(var(--flip)) translateY(-3px) rotate(-2deg);
  }
  to {
    transform: scaleX(var(--flip)) translateY(5px) rotate(2deg);
  }
}

@keyframes swimAway {
  0% {
    opacity: 1;
    transform: translate3d(0, 6px, 0) scale(0.78);
  }
  12% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    opacity: 0.95;
    transform: translate3d(var(--travel-x), var(--travel-y), 0) scale(0.92);
  }
}

@keyframes trailRise {
  to {
    opacity: 0;
    transform: translateY(-48px) scale(1.55);
  }
}

@media (max-width: 380px) {
  .brand {
    max-width: calc(100% - 140px);
    padding-inline: 9px;
  }

  .counter,
  .icon-button {
    min-width: 38px;
    height: 38px;
  }

  .hud-actions {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .water-sheen,
  .fish-sprite {
    animation: none;
  }
}
