* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #02040a;
  color: #eefaff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
}

#scene {
  display: block;
  width: 100vw;
  height: 100vh;
}

.scene-assets {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.scene-creature {
  position: absolute;
  object-fit: contain;
  user-select: none;
  will-change: transform;
  max-width: 70vw;
  max-height: 70vh;
}

.scene-swimmer {
  transform-origin: center;
}

.scene-jellyfish {
  left: 0;
  top: 0;
  width: min(30vw, 390px);
  opacity: 1;
  z-index: 1;
  transform:
    translate(var(--jelly-x, 15.5vw), var(--jelly-y, 3vh))
    rotate(var(--jelly-rotate, 0deg))
    scale(var(--jelly-scale, 1))
    scale(var(--jelly-scale-x, 1), var(--jelly-scale-y, 1));
  transform-origin: center top;
  animation: jellyfishGlowPulse 5s ease-in-out infinite;
  filter:
    hue-rotate(var(--jelly-hue, 0deg))
    saturate(0.95)
    contrast(1.04)
    drop-shadow(0 0 6px rgba(88, 236, 255, 0.38));
}

.scene-turtle {
  left: 0;
  top: 0;
  right: auto;
  z-index: 4;
  width: 180px;
  transform: translate(68vw, 58vh) translate(-50%, -50%);
  transform-origin: 48% 56%;
  animation: turtleGlowPulse 3s ease-in-out infinite;
  filter:
    hue-rotate(var(--turtle-hue, 0deg))
    saturate(1.25)
    drop-shadow(0 0 12px rgba(88, 236, 255, 0.86))
    drop-shadow(0 0 26px rgba(139, 92, 246, 0.55));
}

.scene-seahorse {
  width: min(10vw, 130px);
  z-index: 3;
  animation: seahorseGlowPulse 2.6s ease-in-out infinite;
  filter:
    drop-shadow(0 0 9px rgba(255, 225, 120, 0.75))
    drop-shadow(0 0 18px rgba(255, 180, 60, 0.42));
}

.scene-seahorse-main {
  left: 0;
  top: 0;
  transform: translate(58vw, 52vh) translate(-50%, -50%);
}

.scene-seahorse-small {
  left: 0;
  top: 0;
  width: min(8.5vw, 105px);
  transform: translate(78vw, 62vh) translate(-50%, -50%);
  animation-delay: 1s;
}

.scene-crab {
  left: 0;
  top: 0;
  bottom: auto;
  z-index: 3;
  width: min(8.5vw, 105px);
  transform: translate(34vw, 87vh) translate(-50%, -50%);
  transform-origin: 50% 62%;
  animation: crabGlowPulse 2.2s ease-in-out infinite;
  filter:
    drop-shadow(0 0 10px rgba(255, 92, 244, 0.86))
    drop-shadow(0 0 18px rgba(255, 92, 244, 0.48));
}

.scene-eel {
  left: 0;
  top: 0;
  z-index: 2;
  width: min(12vw, 150px);
  transform: translate(38vw, 78vh) translate(-50%, -50%);
  animation: eelGlowPulse 2.8s ease-in-out infinite;
  filter:
    drop-shadow(0 0 10px rgba(125, 249, 255, 0.88))
    drop-shadow(0 0 18px rgba(0, 217, 255, 0.45));
}

.scene-eel-two {
  width: min(10vw, 130px);
  transform: translate(48vw, 86vh) translate(-50%, -50%) scaleX(-1);
}

.scene-eel-three {
  width: min(9vw, 115px);
  transform: translate(29vw, 84vh) translate(-50%, -50%);
}

.scene-fish {
  left: 0;
  top: 0;
  width: min(4.8vw, 58px);
  opacity: 0.86;
  transform-origin: 50% 54%;
  animation: fishGlowPulse 3.4s ease-in-out infinite;
}

.fish-one {
  transform: translate(43vw, 44vh) translate(-50%, -50%);
  animation-delay: -0.4s;
}

.fish-two {
  transform: translate(51vw, 39vh) translate(-50%, -50%);
  animation-delay: -1.5s;
}

.fish-three {
  transform: translate(60vw, 47vh) translate(-50%, -50%);
  animation-delay: -3s;
}

.fish-four {
  transform: translate(56vw, 34vh) translate(-50%, -50%) scaleX(-1);
  animation-delay: -4.5s;
}

@keyframes floatJelly {
  0%, 100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-14px) scale(1.02);
  }
}

@keyframes turtleSwimFlap {
  0%, 100% {
    transform: translate(-50%, -50%) translate(0, 0) rotate(3deg) scaleX(1) scaleY(1);
  }

  20% {
    transform: translate(-50%, -50%) translate(-8px, 6px) rotate(0deg) scaleX(0.97) scaleY(1.04);
  }

  40% {
    transform: translate(-50%, -50%) translate(-18px, 14px) rotate(-4deg) scaleX(1.04) scaleY(0.96);
  }

  65% {
    transform: translate(-50%, -50%) translate(-10px, 6px) rotate(1deg) scaleX(0.98) scaleY(1.03);
  }

  82% {
    transform: translate(-50%, -50%) translate(4px, -2px) rotate(5deg) scaleX(1.03) scaleY(0.97);
  }
}

@keyframes floatSeahorse {
  0%, 100% {
    transform: translateY(0) rotate(-2deg);
  }

  50% {
    transform: translateY(-16px) rotate(3deg);
  }
}

@keyframes eelDrift {
  0%, 100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(18px);
  }
}

@keyframes fishDrift {
  0%, 100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(28px);
  }
}

@keyframes pulseCreature {
  0%, 100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.06);
  }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  padding: clamp(18px, 4vw, 52px) clamp(18px, 5vw, 70px);
  pointer-events: auto;
  text-shadow: 0 0 18px rgba(53, 232, 255, 0.5);
}

.hero-copy {
  max-width: min(680px, 48vw);
}

.kicker {
  margin: 0 0 7px;
  color: #66f6ff;
  font-size: clamp(0.72rem, 1.8vw, 0.86rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  max-width: min(10ch, 86vw);
  margin: 0;
  font-size: clamp(3rem, 11vw, 8.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(14px, 2vw, 22px);
  color: #dcfbff;
  font-size: clamp(0.78rem, 2vw, 0.96rem);
  font-weight: 650;
  text-transform: uppercase;
}

.status span:first-child {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #58c8ff;
  box-shadow: 0 0 14px #58c8ff, 0 0 28px #006cff;
}

.story {
  max-height: min(34vh, 310px);
  max-width: 390px;
  overflow: auto;
  scrollbar-color: #000 #02040a;
  scrollbar-width: thin;
  margin-top: clamp(18px, 2.5vw, 28px);
  padding: clamp(13px, 2vw, 18px);
  pointer-events: auto;
  color: rgba(238, 250, 255, 0.88);
  background: rgba(2, 8, 24, 0.58);
  border: 1px solid rgba(102, 246, 255, 0.24);
  border-radius: 8px;
  box-shadow: 0 0 32px rgba(0, 108, 255, 0.18);
  text-shadow: none;
  backdrop-filter: blur(16px);
}

@keyframes jellyfishGlowPulse {
  0%, 100% {
    filter:
      hue-rotate(var(--jelly-hue, 0deg))
      saturate(0.95)
      contrast(1.04)
      drop-shadow(0 0 6px rgba(88, 236, 255, 0.34));
  }

  50% {
    filter:
      hue-rotate(var(--jelly-hue, 0deg))
      saturate(1.04)
      contrast(1.08)
      drop-shadow(0 0 12px rgba(88, 236, 255, 0.52));
  }
}

@keyframes turtleGlowPulse {
  0%, 100% {
    filter:
      hue-rotate(var(--turtle-hue, 0deg))
      saturate(1.2)
      drop-shadow(0 0 9px rgba(88, 236, 255, 0.74))
      drop-shadow(0 0 20px rgba(139, 92, 246, 0.44));
  }

  50% {
    filter:
      hue-rotate(var(--turtle-hue, 0deg))
      saturate(1.45)
      drop-shadow(0 0 16px rgba(88, 236, 255, 0.96))
      drop-shadow(0 0 34px rgba(139, 92, 246, 0.66));
  }
}

@keyframes seahorseGlowPulse {
  0%, 100% {
    filter:
      drop-shadow(0 0 8px rgba(255, 225, 120, 0.66))
      drop-shadow(0 0 17px rgba(255, 180, 60, 0.38));
  }

  50% {
    filter:
      drop-shadow(0 0 15px rgba(255, 232, 132, 0.92))
      drop-shadow(0 0 30px rgba(255, 180, 60, 0.58));
  }
}

@keyframes crabGlowPulse {
  0%, 100% {
    filter:
      drop-shadow(0 0 8px rgba(255, 92, 244, 0.68))
      drop-shadow(0 0 17px rgba(255, 92, 244, 0.38));
  }

  50% {
    filter:
      drop-shadow(0 0 15px rgba(255, 92, 244, 0.92))
      drop-shadow(0 0 30px rgba(255, 141, 240, 0.58));
  }
}

@keyframes eelGlowPulse {
  0%, 100% {
    filter:
      drop-shadow(0 0 8px rgba(125, 249, 255, 0.7))
      drop-shadow(0 0 17px rgba(0, 217, 255, 0.36));
  }

  50% {
    filter:
      drop-shadow(0 0 15px rgba(125, 249, 255, 0.96))
      drop-shadow(0 0 30px rgba(0, 217, 255, 0.58));
  }
}

@keyframes fishGlowPulse {
  0%, 100% {
    filter:
      drop-shadow(0 0 5px rgba(125, 249, 255, 0.5))
      drop-shadow(0 0 10px rgba(0, 217, 255, 0.26));
  }

  50% {
    filter:
      drop-shadow(0 0 9px rgba(125, 249, 255, 0.82))
      drop-shadow(0 0 18px rgba(0, 217, 255, 0.42));
  }
}

.story::-webkit-scrollbar {
  width: 10px;
}

.story::-webkit-scrollbar-track {
  background: #02040a;
}

.story::-webkit-scrollbar-thumb {
  background: #000;
  border: 2px solid #02040a;
  border-radius: 999px;
}

.story h2 {
  margin: 0 0 10px;
  color: #eefaff;
  font-size: clamp(1.18rem, 2.2vw, 1.55rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.story p {
  margin: 0 0 9px;
  font-size: clamp(0.78rem, 1.35vw, 0.9rem);
  line-height: 1.45;
}

.story p:last-child {
  margin-bottom: 0;
}

.story-ending {
  color: #9ff7ff;
  font-weight: 750;
}

.friends-button {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 20;
  min-width: 104px;
  padding: 11px 14px;
  color: #dcfbff;
  background: rgba(2, 8, 24, 0.68);
  border: 1px solid rgba(102, 246, 255, 0.38);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(0, 108, 255, 0.24);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.friends-button:hover,
.friends-button:focus-visible,
.friends-button[aria-expanded="true"] {
  border-color: rgba(159, 247, 255, 0.82);
  box-shadow: 0 0 28px rgba(88, 236, 255, 0.36);
  outline: none;
}

.friends-panel {
  position: fixed;
  top: calc(max(16px, env(safe-area-inset-top)) + 52px);
  right: max(18px, env(safe-area-inset-right));
  z-index: 20;
  width: min(330px, 34vw);
  padding: 10px;
  background: rgba(2, 8, 24, 0.68);
  border: 1px solid rgba(102, 246, 255, 0.28);
  border-radius: 8px;
  box-shadow: 0 0 32px rgba(0, 108, 255, 0.24);
  backdrop-filter: blur(16px);
}

.friends-panel[hidden] {
  display: none;
}

.friends-panel img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.control-panel {
  position: fixed;
  right: clamp(18px, 4vw, 52px);
  bottom: clamp(18px, 4vw, 44px);
  z-index: 3;
  display: flex;
  gap: 10px;
}

.control-button {
  min-width: 108px;
  padding: 11px 14px;
  color: #dcfbff;
  background: rgba(2, 8, 24, 0.64);
  border: 1px solid rgba(102, 246, 255, 0.34);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(0, 108, 255, 0.2);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.control-button:hover,
.control-button:focus-visible {
  border-color: rgba(159, 247, 255, 0.8);
  box-shadow: 0 0 28px rgba(88, 236, 255, 0.32);
  outline: none;
}

.control-button[aria-pressed="true"] {
  color: #06121c;
  background: #9ff7ff;
  box-shadow: 0 0 28px rgba(159, 247, 255, 0.42);
}

@media (max-width: 700px) {
  .overlay {
    padding: 16px;
    overflow: visible;
  }

  h1 {
    max-width: 9ch;
    font-size: clamp(2.7rem, 16vw, 4.8rem);
  }

  .hero-copy {
    max-width: min(330px, 86vw);
  }

  .story {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 78px;
    z-index: 2;
    max-width: none;
    max-height: 24vh;
    margin-top: 0;
    padding: 11px 12px;
    background: rgba(2, 8, 24, 0.72);
  }

  .scene-jellyfish {
    width: 46vw;
  }

  .scene-turtle {
    left: 0;
    top: 0;
    right: auto;
    width: 34vw;
  }

  .scene-seahorse-main {
    width: 16vw;
  }

  .scene-seahorse-small {
    width: 13vw;
  }

  .scene-crab,
  .scene-eel,
  .scene-fish {
    opacity: 0.72;
  }

  .scene-crab {
    left: 0;
    top: 0;
    bottom: auto;
    width: 15vw;
  }

  .story .kicker {
    margin-bottom: 5px;
    font-size: 0.62rem;
  }

  .story h2 {
    margin-bottom: 7px;
    font-size: 1rem;
  }

  .story p {
    margin-bottom: 7px;
    font-size: 0.72rem;
    line-height: 1.34;
  }

  .control-panel {
    right: 18px;
    bottom: 18px;
    z-index: 3;
  }

  .friends-button {
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: auto;
    min-width: 86px;
    padding: 10px 11px;
    font-size: 0.72rem;
  }

  .friends-panel {
    top: calc(max(12px, env(safe-area-inset-top)) + 48px);
    left: max(12px, env(safe-area-inset-left));
    right: auto;
    width: min(260px, calc(100vw - 32px));
  }

  .control-button {
    min-width: 86px;
    padding: 10px 11px;
    font-size: 0.72rem;
  }
}

@media (max-width: 460px) {
  .overlay {
    padding: 12px;
  }

  h1 {
    max-width: 8ch;
    font-size: clamp(2.35rem, 15vw, 3.9rem);
  }

  .status {
    max-width: 210px;
    gap: 8px;
    font-size: 0.7rem;
  }

  .story {
    left: 12px;
    right: 12px;
    bottom: 70px;
    max-height: 22vh;
  }

  .scene-jellyfish {
    width: 42vw;
  }

  .scene-turtle {
    width: 30vw;
  }

  .friends-panel {
    width: calc(100vw - 24px);
    left: 12px;
    right: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene-creature,
  .scene-fish,
  .scene-turtle,
  .scene-seahorse,
  .scene-crab,
  .scene-eel {
    animation-duration: 12s;
    animation-iteration-count: infinite;
  }

  .scene-jellyfish {
    animation: none;
  }
}
