:root {
  color-scheme: light;
  --ink: #163047;
  --muted: #5c7184;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(22, 48, 71, 0.13);
  --sky: #9be5ff;
  --water: #2fb5d2;
  --water-dark: #137eac;
  --leaf: #57b96c;
  --coral: #ff6b6b;
  --gold: #ffd166;
  --purple: #8f75ff;
  --shadow: 0 18px 50px rgba(21, 68, 94, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(180deg, #dff7ff 0%, #f5fcff 47%, #fdf8ed 100%);
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 22px;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.game-panel,
.side-panel {
  min-width: 0;
}

.game-panel {
  display: grid;
  grid-template-rows: auto auto 430px auto;
  gap: 16px;
}

.top-bar,
.score-row,
.typing-box,
.captain,
.level-card,
.miss-card,
.aquarium,
.word-bank {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #2d7f9f;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.94;
}

h2 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.controls {
  display: flex;
  align-items: end;
  gap: 10px;
}

.select-wrap {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
.typing-box input {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

select {
  min-width: 130px;
  padding: 10px 36px 10px 12px;
}

.controls button,
.home-link,
.typing-box button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #f15d5d;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(241, 93, 93, 0.25);
}

.home-link {
  display: grid;
  place-items: center;
  min-width: 86px;
  padding: 12px 14px;
  background: #1598bd;
  text-decoration: none;
}

.controls button {
  min-width: 104px;
  padding: 12px 16px;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}

.score-row div {
  display: grid;
  gap: 1px;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.score-row div:last-child {
  border-right: 0;
}

.score-row span {
  font-size: 1.45rem;
  font-weight: 950;
}

.score-row small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.pond {
  position: relative;
  height: 430px;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid rgba(16, 96, 128, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, var(--sky) 0 31%, var(--water) 31% 100%);
  box-shadow: var(--shadow);
}

.sun {
  position: absolute;
  top: 26px;
  right: 34px;
  width: 76px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 14px rgba(255, 209, 102, 0.25);
}

.cloud,
.cloud::before,
.cloud::after {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
}

.cloud {
  width: 130px;
  height: 34px;
}

.cloud::before,
.cloud::after {
  content: "";
}

.cloud::before {
  left: 22px;
  bottom: 12px;
  width: 48px;
  height: 48px;
}

.cloud::after {
  right: 24px;
  bottom: 9px;
  width: 58px;
  height: 58px;
}

.cloud-one {
  top: 54px;
  left: 46px;
}

.cloud-two {
  top: 90px;
  left: 270px;
  transform: scale(0.72);
  opacity: 0.8;
}

.pier {
  position: absolute;
  left: 0;
  top: 108px;
  width: 190px;
  height: 66px;
  background:
    repeating-linear-gradient(90deg, #9c673a 0 28px, #83522c 28px 31px),
    #9c673a;
  border: 5px solid #704323;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  z-index: 2;
}

.rod {
  position: absolute;
  left: 92px;
  top: -86px;
  width: 248px;
  height: 258px;
  object-fit: contain;
  transform: rotate(-1deg);
  transform-origin: 15% 82%;
  filter: drop-shadow(0 3px 1px rgba(76, 44, 22, 0.22));
}

.water-line {
  position: absolute;
  top: calc(31% - 14px);
  left: -120px;
  width: calc(100% + 240px);
  height: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='32' viewBox='0 0 160 32'%3E%3Cpath d='M0 16 C20 0 40 0 60 16 S100 32 120 16 S150 0 160 16 V32 H0 Z' fill='rgba(255,255,255,0.62)'/%3E%3Cpath d='M0 18 C20 6 40 6 60 18 S100 30 120 18 S150 6 160 18' fill='none' stroke='rgba(255,255,255,0.9)' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 160px 32px;
  opacity: 0.9;
  animation: wave-roll 6s linear infinite, wave-bob 2.8s ease-in-out infinite;
}

.ripples {
  position: absolute;
  inset: 31% 0 0;
  opacity: 0.38;
  background:
    radial-gradient(ellipse at 20% 20%, transparent 0 45px, rgba(255,255,255,0.55) 46px 48px, transparent 49px),
    radial-gradient(ellipse at 78% 45%, transparent 0 60px, rgba(255,255,255,0.52) 61px 64px, transparent 65px),
    radial-gradient(ellipse at 42% 75%, transparent 0 76px, rgba(255,255,255,0.42) 77px 80px, transparent 81px);
  animation: ripple-drift 7s ease-in-out infinite alternate;
}

.message-card {
  position: absolute;
  left: 50%;
  top: 52%;
  display: grid;
  gap: 4px;
  width: min(320px, calc(100% - 32px));
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  color: #11405a;
  text-align: center;
  background: rgba(255, 255, 255, 0.74);
  transform: translate(-50%, -50%);
  z-index: 5;
}

.message-card.hidden {
  display: none;
}

.message-card strong {
  font-size: 1.35rem;
}

.fish {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  height: 54px;
  padding: 0 30px 0 34px;
  border-radius: 58% 42% 46% 54% / 52% 45% 55% 48%;
  color: #11364d;
  font-size: 1.05rem;
  font-weight: 950;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  background-image:
    radial-gradient(ellipse at 35% 72%, rgba(255,255,255,0.42) 0 28%, transparent 29%),
    linear-gradient(180deg, rgba(255,255,255,0.22), transparent 48%);
  box-shadow: 0 10px 12px rgba(6, 71, 92, 0.13);
  contain: layout paint;
  transform: translate3d(var(--fish-x), var(--fish-y), 0);
  backface-visibility: hidden;
  will-change: transform, opacity;
  transition: opacity 0.16s ease;
}

.fish::before,
.fish::after {
  content: "";
  position: absolute;
}

.fish::before {
  right: -25px;
  width: 40px;
  height: 42px;
  clip-path: polygon(0 50%, 100% 0, 72% 50%, 100% 100%);
  background: inherit;
  background-image: inherit;
}

.fish::after {
  left: 18px;
  top: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #173043;
  box-shadow:
    2px -2px 0 -1px rgba(255, 255, 255, 0.9),
    13px 20px 0 -4px rgba(255, 255, 255, 0.55);
}

.fish-word {
  position: relative;
  z-index: 2;
}

.image-fish {
  padding: 0 34px;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none;
  overflow: visible;
}

.image-fish::before,
.image-fish::after,
.image-fish .fin {
  display: none !important;
}

.fish-img {
  position: absolute;
  inset: -16px -28px;
  width: calc(100% + 56px);
  height: calc(100% + 32px);
  object-fit: fill;
  filter: drop-shadow(0 10px 10px rgba(6, 71, 92, 0.16));
  pointer-events: none;
  animation: fish-bob 2.8s ease-in-out infinite;
  transform: scaleX(var(--fish-facing, 1));
}

.image-fish.fish-shape-spiky {
  clip-path: none;
}

.fish .fin {
  position: absolute;
  left: 47%;
  top: -13px;
  width: 34px;
  height: 24px;
  border-radius: 80% 20% 0 0;
  background: rgba(255, 255, 255, 0.34);
  transform: translateX(-50%) rotate(-5deg);
}

.fish .fin::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 32px;
  width: 38px;
  height: 24px;
  border-radius: 0 0 70% 30%;
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(9deg);
}

.fish.fish-shape-long {
  min-width: 142px;
  height: 40px;
  padding-inline: 42px 34px;
  border-radius: 75% 30% 34% 66% / 50% 38% 62% 50%;
}

.fish.fish-shape-long::before {
  right: -36px;
  width: 50px;
  height: 34px;
  clip-path: polygon(0 50%, 100% 0, 84% 50%, 100% 100%);
}

.fish.fish-shape-long .fin {
  left: 58%;
  top: -11px;
  width: 46px;
  height: 18px;
}

.fish.fish-shape-round {
  min-width: 96px;
  height: 78px;
  padding-inline: 30px 24px;
  border-radius: 58% 48% 50% 56% / 66% 54% 46% 38%;
}

.fish.fish-shape-round::before {
  right: -22px;
  top: 22px;
  width: 32px;
  height: 32px;
}

.fish.fish-shape-round .fin {
  left: 52%;
  top: -16px;
  width: 30px;
  height: 30px;
  border-radius: 80% 80% 0 0;
}

.fish.fish-shape-spiky {
  min-width: 120px;
  height: 58px;
  border-radius: 42% 34% 50% 44% / 45% 36% 64% 55%;
  clip-path: polygon(0 50%, 10% 20%, 27% 30%, 41% 8%, 55% 30%, 72% 15%, 100% 50%, 72% 85%, 55% 70%, 41% 92%, 27% 70%, 10% 80%);
}

.fish.fish-shape-spiky::before {
  display: none;
}

.fish.fish-shape-spiky::after {
  left: 22px;
}

.fish.fish-shape-spiky .fin {
  display: none;
}

.fish.fish-shape-flat {
  min-width: 148px;
  height: 34px;
  padding-inline: 42px 34px;
  border-radius: 78% 28% 30% 70% / 48% 42% 58% 52%;
}

.fish.fish-shape-flat::after {
  top: 9px;
}

.fish.fish-shape-flat::before {
  right: -31px;
  top: 3px;
  width: 42px;
  height: 28px;
}

.fish.fish-shape-flat .fin {
  left: 55%;
  top: 25px;
  width: 48px;
  height: 18px;
  border-radius: 0 0 80% 20%;
}

.fish.fish-shape-tiny {
  min-width: 82px;
  height: 38px;
  padding-inline: 25px 17px;
  border-radius: 64% 34% 40% 58% / 56% 42% 58% 44%;
  font-size: 0.92rem;
}

.fish.fish-shape-tiny::before {
  right: -19px;
  width: 27px;
  height: 27px;
}

.fish.fish-shape-big {
  min-width: 158px;
  height: 86px;
  padding-inline: 44px 34px;
  border-radius: 70% 42% 50% 62% / 60% 44% 56% 40%;
  font-size: 1.08rem;
}

.fish.fish-shape-big::before {
  right: -33px;
  top: 22px;
  width: 44px;
  height: 44px;
}

.fish.fish-shape-big .fin {
  left: 50%;
  top: -18px;
  width: 52px;
  height: 34px;
}

.fish-speed-slow {
  opacity: 0.9;
}

.fish-speed-fast {
  outline: 3px solid rgba(255, 255, 255, 0.45);
}

.fish-speed-quick {
  outline: 3px solid rgba(255, 255, 255, 0.68);
  box-shadow: 0 0 0 5px rgba(255, 209, 102, 0.2);
}

.fish-speed-quick::before {
  filter: brightness(1.08);
}

.image-fish.fish-speed-fast,
.image-fish.fish-speed-quick {
  outline: 0;
  box-shadow: none;
}

.fish.caught {
  transform: translate3d(var(--fish-x), calc(var(--fish-y) - 55px), 0) scale(1.16) rotate(-8deg);
  opacity: 0;
}

.typing-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 10px;
  padding: 12px;
}

.typing-box input {
  min-width: 0;
  padding: 15px 16px;
  font-size: 1.15rem;
  font-weight: 850;
  outline: none;
}

.typing-box input:focus {
  border-color: #1598bd;
  box-shadow: 0 0 0 4px rgba(21, 152, 189, 0.16);
}

.typing-box button {
  padding: 0 16px;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.captain,
.level-card,
.miss-card,
.aquarium,
.word-bank {
  padding: 16px;
}

.captain {
  display: flex;
  gap: 14px;
}

.avatar {
  position: relative;
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #ffd69b;
  border: 4px solid #fff;
  box-shadow: 0 8px 18px rgba(21, 68, 94, 0.14);
}

.avatar::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -9px;
  height: 23px;
  border-radius: 28px 28px 8px 8px;
  background: #3b9d74;
}

.avatar span {
  position: absolute;
  left: 17px;
  top: 27px;
  width: 28px;
  height: 11px;
  border-bottom: 4px solid #744b2b;
  border-radius: 0 0 28px 28px;
}

.captain p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.progress-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 48, 71, 0.12);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #57b96c, #ffd166, #ff7b7b);
  transition: width 0.22s ease;
}

.chance-dots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.chance-dots span {
  height: 12px;
  border-radius: 999px;
  background: #57b96c;
}

.chance-dots span.lost {
  background: rgba(22, 48, 71, 0.14);
}

.tank {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  min-height: 132px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0)),
    #91def1;
}

.mini-fish {
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 42px;
  padding: 0 4px;
  border-radius: 50% 42% 42% 50%;
  color: #123447;
  font-size: 0.68rem;
  font-weight: 950;
  text-align: center;
  word-break: break-word;
}

.mini-fish.fish-shape-round {
  border-radius: 50%;
}

.mini-fish.fish-shape-flat,
.mini-fish.fish-shape-long {
  border-radius: 46% 36% 36% 46%;
}

.mini-fish.fish-shape-spiky {
  clip-path: polygon(0 15%, 78% 15%, 100% 50%, 78% 85%, 0 85%, 12% 50%);
  border-radius: 0;
}

.mini-fish.fish-speed-fast,
.mini-fish.fish-speed-quick {
  outline: 2px solid rgba(255, 255, 255, 0.65);
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 300px;
  margin-top: 12px;
  padding-right: 4px;
  overflow-y: auto;
}

.word-list span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #24475f;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 850;
}

@keyframes wave-roll {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: 160px;
  }
}

@keyframes wave-bob {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, 3px, 0);
  }
}

@keyframes ripple-drift {
  from {
    transform: translate3d(-8px, 0, 0) scale(1);
  }
  to {
    transform: translate3d(10px, 4px, 0) scale(1.03);
  }
}

@keyframes fish-bob {
  0%,
  100% {
    transform: scaleX(var(--fish-facing, 1)) translateY(0) rotate(0deg);
  }
  50% {
    transform: scaleX(var(--fish-facing, 1)) translateY(-4px) rotate(-1deg);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    padding: 10px 0 20px;
  }

  .top-bar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  select,
  .controls button {
    width: 100%;
  }

  .game-panel {
    grid-template-rows: auto auto 56vh auto;
  }

  .score-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .score-row div:nth-child(2) {
    border-right: 0;
  }

  .score-row div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .pond {
    height: 56vh;
    min-height: 360px;
  }

  .cloud-two {
    display: none;
  }

  .typing-box {
    grid-template-columns: 1fr;
  }

  .typing-box button {
    min-height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
