:root {
  color-scheme: light;
  --ink: #23433c;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  background: #bcefff;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.game {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 480px;
  overflow: hidden;
  background: #bcefff;
}

.background-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url("assets/bg1.jpg") center / cover no-repeat;
  opacity: 0.58;
  transition: opacity 1400ms ease-in-out;
}

@media (max-width: 680px) {
  .background-layer {
    background-image: url("assets/bgv1.png");
  }
}

.background-layer-next {
  opacity: 0;
}

.game.is-bg-fading .background-layer-current {
  opacity: 0;
}

.game.is-bg-fading .background-layer-next {
  opacity: 0.58;
}

.pond {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: var(--ink);
  background: rgb(255 255 255 / 0.74);
  box-shadow: 0 8px 18px rgb(37 102 112 / 0.14);
  white-space: nowrap;
}

.hud strong {
  font-size: clamp(18px, 3vw, 28px);
}

.frog {
  position: absolute;
  z-index: 2;
  width: var(--frog-size);
  height: var(--frog-size);
  border: 0;
  padding: 0;
  border-radius: 0;
  overflow: visible;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  -webkit-user-drag: none;
  transform-origin: 50% 88%;
  transition: filter 120ms ease;
  will-change: transform;
}

.frog:focus-visible {
  outline: 7px solid rgb(255 255 255 / 0.9);
  outline-offset: 4px;
}

.frog img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
  object-fit: contain;
  filter: none;
  transform-origin: 50% 80%;
  transition: transform 160ms ease;
  animation: idle-wiggle 2.8s ease-in-out infinite;
  animation-delay: calc(var(--idle-delay, 0) * 1s);
  animation-play-state: paused;
}

.game.is-playing .frog img {
  animation-play-state: running;
}

.game.is-paused .frog img,
.frog.is-pressing img,
.frog.is-hopping img {
  animation-play-state: paused;
}

.frog.is-pressing {
  filter: brightness(1.08) saturate(1.12);
}

.frog.is-pressing img,
.frog.is-hopping img {
  animation: none;
}

.frog.is-charging img {
  animation: charge-grow 1s linear forwards;
}

.frog.is-charged img {
  transform: scale(1.22);
}

.splash {
  position: absolute;
  z-index: 1;
  width: 92px;
  height: 30px;
  border: 5px solid rgb(255 255 255 / 0.6);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.2);
  animation: splash 650ms ease-out forwards;
}

.start-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: rgb(33 80 74 / 0.34);
}

.start-modal.is-hidden {
  display: none;
}

.menu-panel {
  width: min(92vw, 430px);
  padding: 22px;
  border: 4px solid rgb(255 255 255 / 0.82);
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
  background: rgb(255 255 255 / 0.86);
  box-shadow: 0 24px 46px rgb(28 83 70 / 0.26);
}

.menu-frog {
  display: block;
  width: clamp(108px, 34vw, 168px);
  height: clamp(108px, 34vw, 168px);
  margin: 0 auto -4px;
  object-fit: contain;
  filter: drop-shadow(0 12px 8px rgb(24 94 63 / 0.2));
}

.menu-panel h1 {
  margin: 0 0 18px;
  font-size: clamp(26px, 7vw, 42px);
  line-height: 1.12;
  letter-spacing: 0;
  white-space: nowrap;
}

.menu-home,
.howto {
  display: grid;
  gap: 12px;
}

.howto p {
  margin: 0;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 800;
  line-height: 1.55;
}

.menu-button {
  min-height: 64px;
  border: 4px solid #1f4b42;
  border-radius: 8px;
  color: #1f4b42;
  background: #fffdf2;
  box-shadow: 0 7px 0 #b6d48b;
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 900;
  cursor: pointer;
}

.menu-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #b6d48b;
}

.menu-button:focus-visible {
  outline: 5px solid #ffde59;
  outline-offset: 4px;
}

.menu-button-primary {
  color: #173f36;
  background: #ffdf63;
  box-shadow: 0 7px 0 #e7a83f;
}

@keyframes splash {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.7);
  }
}

@keyframes idle-wiggle {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }

  25% {
    transform: translateY(-3px) rotate(-2deg) scale(1.015);
  }

  50% {
    transform: translateY(1px) rotate(2deg) scale(0.995);
  }

  75% {
    transform: translateY(-2px) rotate(-1deg) scale(1.01);
  }
}

@keyframes charge-grow {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.22);
  }
}

@media (max-width: 680px) {
  .game {
    min-height: 420px;
  }

  .pond {
    min-height: 350px;
  }

  .hud {
    top: 10px;
    gap: 8px;
    padding: 7px 11px;
  }

  .menu-panel {
    padding: 18px;
  }
}
