* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #02121f;
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    Roboto,
    Arial,
    sans-serif;
  color: #eaf7ff;
}
#wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 700px at 50% -10%, #0a3a5a 0%, #041e33 55%, #010c16 100%);
}
#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #032338;
}
.gamelogo {
  width: min(330px, 82%);
  height: auto;
  display: block;
  margin: 0 auto 6px;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.5));
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 5;
}
.pill {
  pointer-events: auto;
  background: rgba(3, 25, 40, 0.62);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(125, 220, 255, 0.22);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}
.pill small {
  font-weight: 600;
  opacity: 0.75;
  font-size: 11px;
}
#progressWrap {
  flex: 1;
  height: 14px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.18);
  min-width: 80px;
}
#progressBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ee6a8, #22c1ee 60%, #ff9f43);
  border-radius: 999px;
  transition: width 0.2s linear;
  box-shadow: 0 0 12px rgba(46, 230, 168, 0.7);
}
#progressFish {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  transition: left 0.2s linear;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}
#hearts {
  color: #ff6b81;
  letter-spacing: 2px;
  font-size: 15px;
}
#hpWrap {
  width: 74px;
  height: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
#hpBar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #3df5a6, #22c8ee);
  border-radius: 999px;
  transition: width 0.2s;
}
#hpPill.low #hpBar {
  animation: hpPulse 0.55s infinite alternate;
}
@keyframes hpPulse {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.9);
  }
}
.btn {
  pointer-events: auto;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: #03202f;
  background: linear-gradient(135deg, #3df5a6, #22c8ee);
  box-shadow:
    0 8px 24px rgba(34, 200, 238, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition:
    transform 0.12s,
    box-shadow 0.12s,
    filter 0.12s;
}
.btn:hover {
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.06);
}
.btn:active {
  transform: scale(0.97);
}
.btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #eaf7ff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
  font-weight: 700;
}
.btn.warn {
  background: linear-gradient(135deg, #ffb347, #ff5e62);
  color: #2b0a0a;
}
.iconbtn {
  pointer-events: auto;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(3, 25, 40, 0.62);
  color: #eaf7ff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  padding: 18px;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(
    800px 500px at 50% 20%,
    rgba(20, 90, 130, 0.55),
    rgba(1, 10, 20, 0.78)
  );
}
.overlay > .card {
  margin: auto;
}
.hidden {
  display: none !important;
}
.card {
  width: min(520px, 94%);
  background: linear-gradient(180deg, rgba(8, 42, 64, 0.92), rgba(3, 20, 33, 0.94));
  border: 1px solid rgba(110, 210, 255, 0.25);
  border-radius: 20px;
  padding: 26px 26px 22px;
  text-align: center;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(34, 200, 238, 0.12) inset;
}
.card h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffd66e, #ff8c42 30%, #3df5a6 65%, #4dc9ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 900;
  margin-bottom: 6px;
  text-shadow: 0 0 30px rgba(77, 201, 255, 0.25);
}
.card h2 {
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 900;
  margin-bottom: 8px;
}
.card p {
  font-size: 14px;
  line-height: 1.55;
  opacity: 0.88;
  margin: 8px 0;
}
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(61, 245, 166, 0.15);
  border: 1px solid rgba(61, 245, 166, 0.4);
  color: #7dffc4;
  margin-bottom: 10px;
}
.tag.blue {
  background: rgba(77, 201, 255, 0.14);
  border-color: rgba(77, 201, 255, 0.45);
  color: #aee7ff;
}
.tag.gold {
  background: rgba(255, 214, 110, 0.14);
  border-color: rgba(255, 214, 110, 0.5);
  color: #ffe9a8;
}
.row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.stats {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 14px 0 4px;
  flex-wrap: wrap;
}
.stat {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 16px;
  min-width: 100px;
}
.stat b {
  display: block;
  font-size: 20px;
}
.stat span {
  font-size: 11px;
  opacity: 0.7;
  letter-spacing: 0.6px;
  font-weight: 700;
}
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
  text-align: left;
  font-size: 13px;
}
.controls-grid div {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 9px 11px;
}
kbd {
  background: #0b2f47;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 800;
}
#toast {
  position: absolute;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.floatTxt {
  font-weight: 900;
  font-size: 22px;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
  animation: pop 1s ease-out forwards;
}
@keyframes pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  15% {
    transform: scale(1.15);
    opacity: 1;
  }
  30% {
    transform: scale(1);
  }
  80% {
    opacity: 1;
    transform: translateY(-10px);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}
#combo {
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #ff9f43, #ff5e62);
  padding: 4px 12px;
  border-radius: 999px;
  display: none;
  box-shadow: 0 4px 16px rgba(255, 94, 98, 0.5);
}
#hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.9;
  white-space: nowrap;
}
#vignetteFlash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 30, 40, 0.55) 100%);
  transition: opacity 0.15s;
}
#levelBanner {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
}
#levelBanner h2 {
  font-size: clamp(30px, 6vw, 58px);
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow:
    0 0 30px rgba(77, 201, 255, 0.8),
    0 4px 0 rgba(0, 0, 0, 0.4);
}
#levelBanner p {
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 13px;
  color: #7dffc4;
}
#stage {
  touch-action: none;
}
/* ---- touch navigation buttons (phones): UP left, DOWN right, BOOST above DOWN ---- */
#touchNav {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  z-index: 7;
  display: none;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
#touchNav.show {
  display: flex;
}
#touchNav .navbtn {
  pointer-events: auto;
}
.navbtn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(3, 25, 40, 0.55);
  backdrop-filter: blur(8px);
  color: #eaf7ff;
  font-size: 26px;
  font-weight: 900;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.navbtn:active {
  background: rgba(34, 200, 238, 0.55);
  transform: scale(0.94);
}
/* ---- boost button + tank (right side, above DOWN; auto-refills) ---- */
#boostWrap {
  position: absolute;
  left: auto;
  right: 28px;
  bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  z-index: 7;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#boostWrap.show {
  display: flex;
}
#boostBtn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 2px solid rgba(255, 214, 110, 0.55);
  background: rgba(3, 25, 40, 0.55);
  backdrop-filter: blur(8px);
  color: #ffe9a8;
  font-size: 28px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
#boostBtn.on {
  background: rgba(255, 159, 67, 0.65);
  box-shadow: 0 0 22px rgba(255, 159, 67, 0.8);
  transform: scale(1.05);
}
#boostBar {
  width: 66px;
  height: 9px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
#boostFill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffd66e, #ff9f43);
  border-radius: 999px;
  transition: width 0.15s linear;
}
/* ---- roster / shop ---- */
.tagline {
  font-size: 13px;
  opacity: 0.8;
  margin: 2px 0 10px;
}
#gemBar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 16px;
  background: rgba(255, 214, 110, 0.12);
  border: 1px solid rgba(255, 214, 110, 0.5);
  color: #ffe9a8;
  border-radius: 999px;
  padding: 5px 16px;
  margin-bottom: 10px;
}
#endlessLock {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 8px;
}
.ver {
  font-size: 10px;
  opacity: 0.45;
  margin-top: 6px;
  letter-spacing: 1px;
}
#menuBest {
  font-size: 13px;
  font-weight: 800;
  opacity: 0.9;
  margin: 2px 0 8px;
}
/* ---- install banner (top strip, like a proper app) ---- */
#installBanner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(2, 12, 22, 0.92);
  border-bottom: 1px solid rgba(125, 220, 255, 0.25);
}
#installBanner.hidden {
  display: none;
}
#installBanner img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}
#installBanner .ib-text {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
#installBanner .ib-text b {
  font-size: 13px;
}
#installBanner .ib-badge {
  font-size: 10px;
  font-weight: 800;
  color: #7dffc4;
  border: 1px solid rgba(125, 255, 196, 0.5);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
  white-space: nowrap;
}
#installBanner .ib-text small {
  display: block;
  font-size: 11px;
  opacity: 0.7;
}
#btnInstallTop {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #03202f;
  background: linear-gradient(135deg, #3df5a6, #22c8ee);
  white-space: nowrap;
}
#btnInstallX {
  cursor: pointer;
  border: none;
  background: none;
  color: #eaf7ff;
  font-size: 20px;
  opacity: 0.6;
  padding: 4px 6px;
}
#stage.show-ib #gameHud {
  top: 56px;
}
/* ---- reef select grid ---- */
#levelGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px 2px 8px;
  margin-top: 8px;
}
.lvCard {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.12s,
    border-color 0.12s;
}
.lvCard:hover {
  transform: translateY(-2px);
}
.lvCard b {
  display: block;
  font-size: 26px;
  font-weight: 900;
}
.lvCard span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
  margin: 2px 0 4px;
  min-height: 30px;
}
.lvCard em {
  font-style: normal;
  font-size: 16px;
}
.lvCard.done {
  border-color: rgba(255, 214, 110, 0.6);
}
.lvCard.current {
  border-color: #3df5a6;
  box-shadow: 0 0 16px rgba(61, 245, 166, 0.35);
}
.lvCard.locked {
  opacity: 0.45;
}
.lvCard.endless b {
  color: #7de9ff;
}
#roster {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  margin: 4px -4px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.fishCard {
  flex: 0 0 128px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 10px 8px;
  text-align: center;
}
.fishCard.sel {
  border-color: #3df5a6;
  box-shadow: 0 0 16px rgba(61, 245, 166, 0.35);
}
.fishCard .art {
  font-size: 40px;
  line-height: 1.1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
.fishCard b {
  display: block;
  font-size: 13px;
  margin-top: 2px;
}
.fishCard .spec {
  font-size: 11px;
  opacity: 0.8;
  margin: 3px 0 8px;
  line-height: 1.5;
}
.fishCard button {
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 12px;
  color: #03202f;
  background: linear-gradient(135deg, #ffd66e, #ff9f43);
  width: 100%;
}
.fishCard button.owned {
  background: linear-gradient(135deg, #3df5a6, #22c8ee);
}
.fishCard button.current {
  background: rgba(255, 255, 255, 0.15);
  color: #7dffc4;
  border: 1px solid rgba(125, 255, 196, 0.5);
}
.fishCard button.cant {
  opacity: 0.55;
}
.card.wide {
  width: min(600px, 96%);
}
/* ---- error trap ---- */
#errBox {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 50;
  display: none;
  max-width: 70%;
  font-size: 11px;
  font-weight: 700;
  background: rgba(120, 10, 20, 0.9);
  border: 1px solid #ff6b81;
  border-radius: 10px;
  padding: 6px 10px;
}
#rotate {
  z-index: 40;
}
#rotate .card p {
  font-size: 15px;
}
@media (max-width: 640px) {
  .pill {
    padding: 4px 9px;
    font-size: 11px;
    gap: 5px;
  }
  .btn {
    padding: 9px 15px;
    font-size: 13px;
  }
  .row {
    gap: 8px;
  }
  .pill small {
    display: none;
  }
  #hpWrap {
    width: 44px;
  }
  #progressWrap {
    min-width: 40px;
    height: 11px;
  }
  #progressFish {
    font-size: 12px;
  }
  .hud {
    gap: 6px;
    padding: 8px;
    flex-wrap: wrap;
  }
  #hint {
    font-size: 10px;
    bottom: 8px;
  }
  .card {
    padding: 18px 14px 16px;
  }
  .fishCard {
    flex-basis: 112px;
  }
  .navbtn {
    width: 60px;
    height: 60px;
  }
}
/* short landscape screens (phones sideways): slim compact HUD that always fits */
@media (max-height: 500px) {
  .hud {
    gap: 6px;
    padding: 6px 8px;
    flex-wrap: wrap;
  }
  .pill {
    padding: 3px 9px;
    font-size: 11px;
    gap: 5px;
  }
  .pill small {
    display: none;
  }
  #hpWrap {
    width: 44px;
  }
  #progressWrap {
    min-width: 40px;
    height: 10px;
  }
  #progressFish {
    font-size: 12px;
  }
  #hint {
    display: none !important;
  }
  /* short landscape phones: compact menu so everything fits, rest scrolls */
  .gamelogo {
    width: min(190px, 52%);
  }
  .card {
    padding: 14px 12px;
  }
  .fishCard {
    flex-basis: 96px;
    padding: 6px;
  }
  .fishCard .art {
    font-size: 28px;
  }
  .fishCard .spec {
    display: none;
  }
  .fishCard button {
    padding: 6px 8px;
    font-size: 11px;
  }
}
/* touch GPUs: backdrop blur forces a full-screen blur pass every frame while the
   reef animates behind it. Flat translucent fills look the same, cost ~nothing. */
@media (pointer: coarse) {
  .pill,
  .iconbtn,
  .navbtn,
  #boostBtn {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .pill {
    background: rgba(3, 25, 40, 0.85);
  }
  .iconbtn,
  .navbtn,
  #boostBtn {
    background: rgba(3, 25, 40, 0.8);
  }
  .overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
