:root {
  color-scheme: dark;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  background: #03162c;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  background: #03162c;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 4px solid #ffffff;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.game {
  position: relative;
  width: min(100vw, calc(100dvh * 390 / 844), 430px);
  max-height: 100dvh;
  aspect-ratio: 390 / 844;
  overflow: hidden;
  isolation: isolate;
  background: #03162c url("image-src/background.png") center / cover no-repeat;
}

.game::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: rgb(1 14 32 / 0.14);
  content: "";
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  padding:
    max(24px, env(safe-area-inset-top))
    20px
    max(20px, env(safe-area-inset-bottom));
}

.sound-toggle {
  position: absolute;
  z-index: 40;
  top: auto;
  right: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid rgb(255 255 255 / 0.58);
  border-radius: 50%;
  color: #ffffff;
  background: rgb(3 22 44 / 0.68);
  box-shadow:
    inset 0 0 12px rgb(255 255 255 / 0.12),
    0 4px 12px rgb(0 7 20 / 0.38);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 1.35rem;
  opacity: 0.88;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.sound-toggle[aria-pressed="true"] {
  background: rgb(3 22 44 / 0.78);
  opacity: 0.72;
}

.intro-screen {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding-top: 13%;
  padding-bottom: 14%;
  text-align: center;
}

h1,
h2,
.hud,
.round-length,
.result-score,
.countdown-screen output {
  color: #fff3d7;
  text-shadow:
    -2px -2px 0 #402822,
    2px -2px 0 #402822,
    -2px 2px 0 #402822,
    2px 2px 0 #402822;
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 10vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.rules,
.hud,
.result-score {
  border: 3px solid rgb(255 255 255 / 0.72);
  border-radius: 32px;
  background: rgb(123 166 203 / 0.62);
  box-shadow:
    inset 0 0 18px rgb(255 255 255 / 0.24),
    0 8px 20px rgb(0 11 27 / 0.26);
}

.rules {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr 1fr;
  padding: 10px;
}

.rule {
  display: flex;
  min-width: 0;
  min-height: 100px;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.rule + .rule {
  border-left: 2px dashed rgb(255 255 255 / 0.65);
}

.rule img {
  width: 51%;
  max-height: 92px;
  object-fit: contain;
}

.rule strong,
.score-pop {
  color: #fff3d7;
  text-shadow: 0 2px 0 #402822;
  font-size: 1.9rem;
  font-weight: 900;
}

.rule:last-child strong,
.score-pop.negative {
  color: #ff6f6f;
}

.round-length {
  margin: -2px 0 0;
  font-size: 1.75rem;
  font-weight: 900;
}

.primary-button,
.result-actions button {
  min-height: 58px;
  border: 3px solid #402822;
  border-radius: 999px;
  color: #402822;
  background: #fff3d7;
  box-shadow: 0 5px 0 rgb(64 40 34 / 0.38);
  font-weight: 900;
}

.primary-button {
  width: min(82%, 320px);
  min-height: 76px;
  background: #dc7773;
  font-size: 1.75rem;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.countdown-screen {
  display: grid;
  place-items: center;
}

.countdown-screen output {
  font-size: clamp(7rem, 34vw, 10rem);
  font-weight: 900;
}

.play-screen {
  padding-inline: 14px;
}

.hud {
  position: relative;
  z-index: 5;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding-right: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.4rem;
  font-weight: 900;
}

#time,
#score {
  display: inline-flex;
  align-items: center;
  min-height: 62px;
  border: 3px solid rgb(255 255 255 / 0.72);
  border-radius: 999px;
  background: rgb(123 166 203 / 0.62);
  box-shadow:
    inset 0 0 18px rgb(255 255 255 / 0.24),
    0 8px 20px rgb(0 11 27 / 0.26);
}

#time {
  padding-inline: 14px;
}

#score {
  gap: 6px;
  margin-left: auto;
  padding: 6px 10px;
  transform-origin: center;
}

#score.score-gain {
  background: rgb(94 207 171 / 0.78);
  animation: score-gain 420ms ease-out;
}

#score.score-loss {
  background: rgb(222 84 92 / 0.82);
  animation: score-loss 420ms ease-out;
}

#score img {
  width: 45px;
  height: 34px;
  object-fit: contain;
}

.pools {
  position: absolute;
  inset: 28% 2% 7%;
}

.pool {
  position: absolute;
  width: 35%;
  min-width: 64px;
  aspect-ratio: 1.45;
  overflow: visible;
  touch-action: manipulation;
  border: 4px solid #54c9ff;
  border-radius: 50%;
  background: rgb(0 47 91 / 0.72);
  box-shadow:
    inset 0 6px 18px rgb(0 9 30 / 0.7),
    0 0 18px #24b9ff;
}

.pool:nth-child(1) {
  top: 8%;
  left: 9%;
  transform: scale(0.78);
}

.pool:nth-child(2) {
  top: 8%;
  right: 9%;
  transform: scale(0.78);
}

.pool:nth-child(3) {
  top: 36%;
  left: 5%;
  transform: scale(0.9);
}

.pool:nth-child(4) {
  top: 36%;
  right: 5%;
  transform: scale(0.9);
}

.pool:nth-child(5) {
  top: 66%;
  left: 7%;
}

.pool:nth-child(6) {
  top: 66%;
  right: 7%;
}

.pool img {
  position: absolute;
  bottom: 12%;
  left: 50%;
  width: 92%;
  height: 125%;
  object-fit: contain;
  pointer-events: none;
  transform: translateX(-50%);
}

.pool.target-visible img {
  animation: target-rise 140ms cubic-bezier(.2, .9, .35, 1.2);
}

.pool.target-hit img {
  animation: target-hit 240ms ease-out forwards;
}

.pool.target-hit img.fishmeat-hit {
  width: 74%;
}

.strike-bat {
  position: absolute;
  width: 34%;
  transform: translate(-20%, -88%) rotate(-34deg);
  transform-origin: 85% 80%;
  animation: bat-strike 180ms ease-out forwards;
}

.score-pop,
.fish-scale {
  position: absolute;
  transform: translate(-50%, -50%);
}

.score-pop {
  animation: score-pop 900ms cubic-bezier(.2, .8, .25, 1) forwards;
}

.fish-scale {
  width: 15%;
  animation: scale-burst 520ms ease-out forwards;
}

.result-screen {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 13px;
  padding-top: 10%;
  padding-bottom: 16%;
  text-align: center;
}

.result-screen h2 {
  margin: 0;
  font-size: clamp(3rem, 15vw, 5rem);
}

.result-score {
  display: grid;
  width: min(100%, 330px);
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 14px 20px 18px;
  font-size: 3.5rem;
  font-weight: 900;
}

.result-score span {
  grid-column: 1 / -1;
  font-size: 1.35rem;
}

.result-score img {
  width: 80%;
  justify-self: center;
}

.hit-counts {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 2px dashed rgb(255 255 255 / 0.55);
  font-size: 1.35rem;
}

.hit-counts > div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.result-score .hit-counts img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.result-actions {
  display: grid;
  width: min(82%, 320px);
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.result-actions button {
  font-size: 1rem;
}

.result-actions button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.result-action-wide {
  grid-column: 1 / -1;
}

.result-actions .result-share-score {
  background: #dc7773;
}

.result-actions .replay-button {
  margin-top: 9px;
  background: #7fcdb7;
}

#share-status {
  min-height: 1.2em;
  margin: -3px 0;
  color: #fff3d7;
  font-size: 0.78rem;
  font-weight: 900;
}

#manual-link {
  width: min(82%, 320px);
  min-height: 44px;
  border: 2px solid #fff3d7;
  border-radius: 12px;
  color: #03162c;
  background: #ffffff;
  padding-inline: 10px;
}

.helper {
  position: absolute;
  z-index: 20;
  right: 4%;
  bottom: max(7%, env(safe-area-inset-bottom));
  width: 35%;
  pointer-events: none;
}

.helper-image {
  display: block;
  width: 100%;
}

.game[data-mode="playing"] .helper {
  bottom: max(2%, env(safe-area-inset-bottom));
}

.effects {
  position: absolute;
  z-index: 30;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

@keyframes target-rise {
  from {
    opacity: 0;
    transform: translate(-50%, 35%) scale(0.7);
  }
}

@keyframes target-hit {
  to {
    opacity: 0;
    transform: translate(-50%, 18%) rotate(8deg) scale(0.82);
  }
}

@keyframes bat-strike {
  from {
    opacity: 0.8;
    transform: translate(-20%, -88%) rotate(-95deg);
  }
  60% {
    opacity: 1;
    transform: translate(-20%, -88%) rotate(-20deg);
  }
  to {
    opacity: 0;
    transform: translate(-20%, -88%) rotate(-5deg);
  }
}

@keyframes score-pop {
  from {
    opacity: 1;
    transform: translate(-50%, -35%) scale(0.65);
  }
  28% {
    opacity: 1;
    transform: translate(-50%, -85%) scale(1.3);
  }
  65% {
    opacity: 1;
    transform: translate(-50%, -125%) scale(1.12);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -165%) scale(1);
  }
}

@keyframes score-gain {
  45% {
    background: rgb(94 207 171 / 0.78);
    transform: scale(1.12);
  }
}

@keyframes score-loss {
  25% {
    background: rgb(222 84 92 / 0.82);
    transform: translateX(-5px) scale(1.08);
  }
  55% {
    transform: translateX(5px) scale(1.08);
  }
}

@keyframes scale-burst {
  to {
    opacity: 0;
    transform:
      translate(
        calc(-50% + var(--scale-x)),
        calc(-50% + var(--scale-y))
      )
      rotate(var(--scale-r))
      scale(0.55);
  }
}

@media (max-height: 690px) {
  .intro-screen {
    gap: 10px;
    padding-top: 10%;
  }

  .rule {
    min-height: 78px;
  }

  .rule img {
    max-height: 72px;
  }

  .primary-button {
    min-height: 62px;
  }

  .helper {
    width: 31%;
  }
}

@media (display-mode: standalone) {
  .game {
    width: 100vw;
    height: 100vh;
    max-height: none;
    aspect-ratio: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  .pool img,
  .strike-bat,
  .fish-scale,
  .score-pop,
  #score {
    animation: none !important;
  }

  .score-pop {
    opacity: 1;
    transform: translate(-50%, -100%);
  }

  .fish-scale {
    opacity: 0.75;
    transform: translate(-50%, -50%) scale(0.55);
  }
}
