:root {
  color-scheme: dark;
  --navy: #073b54;
  --ocean: #0784a1;
  --foam: #ddfff7;
  --lime: #d6ed74;
  --coral: #ff715b;
  --yellow: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--navy);
  font-family: "Trebuchet MS", Arial, sans-serif;
}

button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.game {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 480px;
  overflow: hidden;
  isolation: isolate;
  background: var(--ocean);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  z-index: 10;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: 24px 28px;
  color: var(--foam);
  pointer-events: none;
}

.logo {
  display: flex;
  gap: 10px;
  align-items: center;
  width: max-content;
  color: inherit;
  text-decoration: none;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: .8;
  pointer-events: auto;
}

.logo small {
  display: block;
  margin-top: 7px;
  color: var(--lime);
  font-size: 7px;
  letter-spacing: .2em;
}

.logo-fish {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border: 2px solid var(--lime);
  border-radius: 50% 50% 46% 54%;
  color: var(--lime);
  font-size: 22px;
  transform: rotate(90deg);
}

.score-box { text-align: center; }
.score-box span,
.energy-row span,
.final-score span,
.final-score small {
  display: block;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .2em;
  opacity: .75;
}

.score-box strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .05em;
}

.power-up {
  position: absolute;
  top: 116px;
  left: 50%;
  min-width: 174px;
  padding: 9px 14px 8px;
  border: 2px solid var(--foam);
  border-radius: 14px;
  color: var(--navy);
  background: var(--yellow);
  box-shadow: 0 5px 0 rgba(7,59,84,.35);
  text-align: center;
  transform: translateX(-50%);
}

.power-up span { display: block; font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.power-up strong { display: block; margin-top: 2px; font-size: 15px; font-variant-numeric: tabular-nums; }

.level-status {
  position: absolute;
  top: 69px;
  left: 50%;
  width: 188px;
  transform: translateX(-50%);
}
.level-status > div:first-child { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 8px; font-weight: 900; letter-spacing: .15em; }
.level-status time { color: var(--lime); font-size: 10px; font-variant-numeric: tabular-nums; }
.level-bar { height: 6px; overflow: hidden; border: 1px solid rgba(221,255,247,.75); border-radius: 6px; background: rgba(2,50,69,.32); }
.level-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--lime); }

.vitals { justify-self: end; width: min(220px, 25vw); }
.lives { height: 18px; margin-bottom: 6px; text-align: right; }
.life { display: inline-block; margin-left: 6px; color: rgba(255,255,255,.24); font-size: 15px; }
.life.active { color: var(--yellow); filter: drop-shadow(0 2px 0 rgba(0,0,0,.18)); }
.energy-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.energy-row b { color: var(--lime); font-size: 10px; font-variant-numeric: tabular-nums; }
.energy-bar { height: 8px; overflow: hidden; border: 2px solid rgba(221,255,247,.9); border-radius: 8px; background: rgba(2,50,69,.35); }
.energy-bar i { display: block; width: 100%; height: 100%; border-radius: 5px; background: var(--lime); transition: width .25s ease, background .25s ease; }

.screen {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 24px 42px;
  color: var(--foam);
  text-align: center;
  background: radial-gradient(circle at 50% 45%, rgba(1,120,147,.08), rgba(4,54,73,.54));
}

.hidden { display: none !important; }

.bubble-title { position: relative; }
.hello, .tag {
  display: inline-block;
  padding: 7px 13px;
  border-radius: 99px;
  background: var(--lime);
  color: var(--navy);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .18em;
  transform: rotate(-3deg);
}

.bubble-title h1 {
  margin: 5px 0 4px;
  color: var(--foam);
  font-size: clamp(74px, 13vw, 148px);
  font-weight: 900;
  line-height: .78;
  letter-spacing: -.09em;
  text-shadow: 0 7px 0 rgba(4,65,82,.38);
}

.bubble-title h1 span { color: var(--lime); }
.bubble-title p { margin: 22px 0 0; color: rgba(221,255,247,.82); font-size: clamp(15px, 2vw, 19px); font-weight: 700; line-height: 1.35; }
.instructions { margin-top: 24px; }
.instructions > p, .gameover-screen > p { margin: 0 0 16px; color: rgba(221,255,247,.72); font-size: 12px; }
.legend { display: flex; justify-content: center; gap: 8px; margin: 0 0 17px; }
.legend span { padding: 6px 9px; border: 1px solid rgba(221,255,247,.28); border-radius: 10px; color: rgba(221,255,247,.8); background: rgba(5,70,91,.3); font-size: 8px; font-weight: 800; letter-spacing: .05em; }
.legend b { margin-right: 3px; font-size: 13px; }

.play-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 220px;
  height: 54px;
  padding: 0 0 0 24px;
  border: 0;
  border-radius: 15px;
  color: var(--navy);
  background: var(--lime);
  box-shadow: 0 7px 0 #799b60, 0 15px 30px rgba(0,45,61,.25);
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
}

.play-button:hover { transform: translateY(-2px); box-shadow: 0 9px 0 #799b60, 0 17px 32px rgba(0,45,61,.25); }
.play-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #799b60; }
.play-button span { font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.play-button b { display: grid; place-items: center; width: 52px; height: 100%; border-left: 2px solid rgba(7,59,84,.12); font-size: 20px; }
.pepe-preview { position: relative; width: 76px; height: 98px; margin: 21px auto 0; filter: drop-shadow(0 7px 0 rgba(4,65,82,.28)); }
.preview-body { position: absolute; z-index: 2; top: 0; left: 19px; width: 38px; height: 72px; border: 4px solid var(--navy); border-radius: 50% 50% 42% 42%; background: var(--lime); }
.preview-body::after { content: ""; position: absolute; top: 18px; bottom: 9px; left: 50%; width: 3px; border-radius: 2px; background: rgba(7,59,84,.2); transform: translateX(-50%); }
.preview-body b { position: absolute; z-index: 1; top: 12px; width: 6px; height: 6px; border-radius: 50%; background: var(--navy); }
.preview-body b:first-child { left: 7px; }.preview-body b:last-child { right: 7px; }
.preview-tail { position: absolute; z-index: 1; bottom: 3px; left: 24px; width: 28px; height: 32px; border: 4px solid var(--navy); background: var(--lime); clip-path: polygon(50% 0, 100% 100%, 50% 72%, 0 100%); transform-origin: 50% 0; animation: preview-tail .55s ease-in-out infinite alternate; }
.preview-fin { position: absolute; z-index: 1; top: 39px; width: 26px; height: 13px; border: 4px solid var(--navy); border-radius: 70% 20% 70% 20%; background: var(--yellow); }
.preview-fin.left { left: 4px; transform: rotate(-30deg); }.preview-fin.right { right: 4px; transform: scaleX(-1) rotate(-30deg); }
@keyframes preview-tail { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
.instructions small { display: block; margin-top: 9px; color: rgba(221,255,247,.55); font-size: 8px; letter-spacing: .12em; }
kbd { padding: 3px 6px; border: 1px solid rgba(221,255,247,.38); border-radius: 5px; color: var(--foam); font: inherit; }

.pause-screen h2, .gameover-screen h2, .level-complete-screen h2 { margin: 16px 0 28px; font-size: clamp(40px, 7vw, 74px); letter-spacing: -.06em; }
.coral-tag { color: white; background: var(--coral); }
.gameover-screen h2 { margin-bottom: 8px; }
.final-score { display: grid; gap: 2px; margin: 8px 0 24px; }
.final-score strong { color: var(--lime); font-size: 42px; font-variant-numeric: tabular-nums; }
.final-score small { opacity: .58; }
.level-complete-screen { background: linear-gradient(rgba(7,132,161,.28), rgba(7,59,84,.84)), linear-gradient(#5bd4d4 0 45%, #f6d68f 45% 100%); }
.level-complete-screen h2 { margin-bottom: 10px; }
.level-complete-screen > p { max-width: 440px; margin: 0 0 25px; color: rgba(255,255,255,.86); font-size: 13px; line-height: 1.55; }
.beach-tag { background: var(--yellow); }

.pause-button {
  position: absolute;
  z-index: 15;
  right: 28px;
  bottom: 26px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(221,255,247,.7);
  border-radius: 50%;
  color: var(--foam);
  background: rgba(5,65,84,.4);
  cursor: pointer;
}

.sound-button {
  position: absolute;
  z-index: 15;
  right: 82px;
  bottom: 26px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(221,255,247,.7);
  border-radius: 50%;
  color: var(--foam);
  background: rgba(5,65,84,.4);
  cursor: pointer;
}
.sound-button.muted { opacity: .45; text-decoration: line-through; }

.touch-hint { position: absolute; z-index: 7; bottom: 30px; left: 28px; color: rgba(221,255,247,.45); font-size: 8px; font-weight: 800; letter-spacing: .17em; pointer-events: none; }

@media (max-width: 650px) {
  .hud { grid-template-columns: 1fr 1fr; padding: 17px 15px; }
  .logo { display: none; }
  .score-box { text-align: left; }
  .vitals { width: 145px; }
  .level-status { top: 65px; width: 155px; }
  .power-up { top: 103px; }
  .start-screen { justify-content: flex-end; padding-bottom: 70px; }
  .bubble-title h1 { font-size: clamp(76px, 25vw, 122px); }
  .pause-button { right: 15px; bottom: 16px; }
  .sound-button { right: 65px; bottom: 16px; }
  .touch-hint { left: 15px; bottom: 24px; font-size: 7px; }
  .legend { gap: 5px; }
  .legend span { padding: 5px 7px; font-size: 7px; }
}

@media (hover: hover) and (pointer: fine) { .touch-hint { display: none; } }
@media (prefers-reduced-motion: reduce) { .play-button { transition: none; } }
@media (prefers-reduced-motion: reduce) { .preview-tail { animation: none; } }
