:root {
  color-scheme: dark;
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --ocean-top: #40aab5;
  --ocean-mid: #116987;
  --ocean-deep: #073b59;
  --sandpit-inset-top: 0px;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
}

body {
  background: var(--ocean-deep);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.ocean {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: calc(100dvh - var(--sandpit-inset-top));
  min-height: 360px;
  overflow: hidden;
  touch-action: none;
  background:
    linear-gradient(180deg, rgba(100, 206, 193, .2) 0%, transparent 28%),
    linear-gradient(180deg, var(--ocean-top) 0%, #218aa2 28%, var(--ocean-mid) 58%, var(--ocean-deep) 100%);
}

.water-light {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(102deg, transparent 8%, rgba(201, 250, 220, .14) 16%, transparent 25%),
    linear-gradient(76deg, transparent 38%, rgba(255, 226, 169, .12) 46%, transparent 57%),
    linear-gradient(118deg, transparent 65%, rgba(174, 237, 221, .1) 72%, transparent 81%);
  opacity: .9;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, .75) 48%, transparent 78%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, .75) 48%, transparent 78%);
  animation: light-sway 14s ease-in-out infinite alternate;
}

.title-bar {
  position: absolute;
  z-index: 5;
  top: clamp(12px, 3vh, 28px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 136px);
  padding: 7px 0 9px;
}

h1 {
  margin: 0;
  color: #073b59;
  font-size: 22px;
  font-weight: 750;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 1px 0 rgba(231, 255, 244, .5);
}

.fish {
  position: absolute;
  z-index: 1;
  overflow: visible;
  filter: drop-shadow(0 8px 6px rgba(6, 54, 75, .15));
  pointer-events: none;
  transition: filter 180ms ease, scale 180ms ease;
}

.fish.noticed-pop {
  filter: drop-shadow(0 0 15px rgba(255, 245, 173, .72)) drop-shadow(0 8px 6px rgba(6, 54, 75, .15));
  scale: 1.1;
}

.fish--one {
  top: 27%;
  left: -190px;
  width: clamp(120px, 19vw, 190px);
  animation: fish-cross 24s linear infinite;
}

.fish--two {
  top: 58%;
  right: -165px;
  width: clamp(95px, 15vw, 154px);
  transform: scaleX(-1);
  animation: fish-cross-back 31s linear infinite;
}

.bubble-field {
  position: absolute;
  z-index: 3;
  inset: 82px 0 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 58px);
  mask-image: linear-gradient(to bottom, transparent, #000 58px);
}

.bubble-target {
  position: absolute;
  bottom: -160px;
  left: var(--lane);
  display: grid;
  width: var(--hit-size);
  height: var(--hit-size);
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  transform-origin: center;
  animation: bubble-rise var(--duration) linear forwards;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.bubble-target:focus-visible {
  outline: 3px solid #fff5ad;
  outline-offset: 3px;
}

.bubble-skin {
  position: relative;
  display: block;
  width: var(--diameter);
  height: var(--diameter);
  border: 2px solid rgba(242, 255, 249, .9);
  border-radius: 50%;
  box-shadow: inset -9px -11px 16px rgba(11, 70, 94, .11), inset 5px 5px 12px rgba(255, 255, 255, .42), 0 10px 20px rgba(3, 49, 69, .12);
  opacity: .86;
  transform: scale(.74);
  animation: bubble-grow var(--duration) linear forwards;
  will-change: transform, opacity;
}

.bubble-skin::before {
  position: absolute;
  top: 17%;
  left: 23%;
  width: 25%;
  height: 12%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
  content: "";
  transform: rotate(-35deg);
}

.bubble-skin::after {
  position: absolute;
  top: 31%;
  left: 16%;
  width: 6%;
  height: 6%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .68);
  content: "";
}

.bubble--mint { background: radial-gradient(circle at 33% 27%, #e3fff5 0%, #9be9d4 43%, #50b8b5 100%); }
.bubble--coral { background: radial-gradient(circle at 33% 27%, #fff0dc 0%, #ffc3a8 45%, #ef8d83 100%); }
.bubble--lilac { background: radial-gradient(circle at 33% 27%, #f5eaff 0%, #c7d4ee 46%, #81a9ca 100%); }
.bubble--gold { background: radial-gradient(circle at 33% 27%, #fff9ce 0%, #f2dfa0 47%, #cbb86e 100%); }

.bubble-target.is-popping { animation-play-state: paused; }
.bubble-target.is-popping .bubble-skin {
  visibility: hidden;
  animation: none;
}

.bubble-target.is-popping::after {
  position: absolute;
  width: var(--pop-size);
  height: var(--pop-size);
  border: var(--pop-ring-width) solid rgba(233, 255, 246, .9);
  border-radius: 50%;
  box-shadow: 0 0 var(--pop-glow) rgba(233, 255, 246, .72);
  content: "";
  animation: pop-ring 260ms ease-out forwards;
}

.seabed {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: clamp(130px, 27vh, 260px);
  pointer-events: none;
}

.sea-grain {
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  height: 27%;
  background-image: radial-gradient(rgba(255, 242, 199, .45) .7px, transparent .8px);
  background-size: 19px 21px;
  opacity: .12;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 54px);
  mask-image: linear-gradient(to bottom, transparent, #000 54px);
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes bubble-rise {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(var(--drift), -125vh, 0); }
}

@keyframes bubble-grow {
  0% { transform: scale(.74); opacity: .72; }
  82% { opacity: .92; }
  100% { transform: scale(1.08); opacity: .82; }
}

@keyframes pop-ring {
  from { opacity: .8; transform: scale(.62); }
  to { opacity: 0; transform: scale(1.38); }
}

@keyframes fish-cross {
  0% { transform: translateX(0) rotate(-2deg); }
  46% { transform: translateX(calc(100vw + 210px)) rotate(2deg); }
  50% { transform: translateX(calc(100vw + 210px)) scaleX(-1) rotate(2deg); }
  96% { transform: translateX(0) scaleX(-1) rotate(-2deg); }
  100% { transform: translateX(0) rotate(-2deg); }
}

@keyframes fish-cross-back {
  0% { transform: translateX(0) scaleX(-1) rotate(1deg); }
  47% { transform: translateX(calc(-100vw - 180px)) scaleX(-1) rotate(-2deg); }
  51% { transform: translateX(calc(-100vw - 180px)) scaleX(1) rotate(-2deg); }
  96% { transform: translateX(0) scaleX(1) rotate(1deg); }
  100% { transform: translateX(0) scaleX(-1) rotate(1deg); }
}

@keyframes light-sway {
  from { opacity: .58; transform: translateX(-2%); }
  to { opacity: .95; transform: translateX(2%); }
}

@media (max-width: 600px) {
  h1 { font-size: 19px; }
  .bubble-field { inset: 76px 0 0; }
  .fish--one { top: 30%; }
  .fish--two { top: 56%; }
  .seabed { height: 23vh; }
}

@media (prefers-reduced-motion: reduce) {
  .water-light { animation: none; }
  .fish { animation-duration: 65s; }
  .bubble-target, .bubble-skin { animation-duration: 54s; }
  .bubble-target.is-popping .bubble-skin { transition-duration: 100ms; }
  .fish { transition-duration: 100ms; }
}
