/* ================= Zaney Aquarium — pastel UI ================= */
:root {
  --cream: #f7f3ea;
  --sky: #dcebf5;
  --ink: #2b3a55;
  --ink-soft: #5b6b8c;
  --teal: #58c8c8;
  --teal-deep: #2fa8a8;
  --pink: #f3a8c0;
  --lavender: #b8a7e0;
  --gold: #ffd166;
  --card: rgba(255, 255, 255, 0.72);
  --shadow: 0 10px 30px rgba(80, 110, 150, 0.18);
  --radius: 22px;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Quicksand", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--cream) 0%, var(--sky) 55%, #cfe4f2 100%);
  user-select: none; -webkit-user-select: none;
}

#app { position: fixed; inset: 0; touch-action: none; }
.btn { touch-action: manipulation; }
.level-grid { touch-action: pan-y; }

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

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--cream) 0%, var(--sky) 60%, #cfe4f2 100%);
  z-index: 20;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
.screen.visible { display: flex; }

/* ---------- buttons ---------- */
.btn {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-deep) 100%);
  border: none;
  border-radius: 999px;
  padding: 12px 34px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(35, 130, 130, 0.55), 0 12px 24px rgba(80, 110, 150, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(35, 130, 130, 0.55); }
.btn-big { font-size: 1.45rem; padding: 14px 58px; }
.btn-ghost {
  background: var(--card);
  color: var(--ink-soft);
  box-shadow: 0 4px 0 rgba(150, 170, 195, 0.35), 0 8px 18px rgba(80, 110, 150, 0.15);
}
.btn-round {
  width: 52px; height: 52px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card);
  color: var(--ink);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 0 rgba(150, 170, 195, 0.35), 0 8px 18px rgba(80, 110, 150, 0.15);
}
.btn:disabled { opacity: 0.45; cursor: default; filter: grayscale(0.4); }

/* ---------- splash menu (over the live 3D scene) ---------- */
/* Layout mirrors the reference: copy on the left, glowing aquarium right. */
.screen.splash {
  background: radial-gradient(ellipse at 68% 40%,
    rgba(3, 7, 14, 0) 22%, rgba(3, 7, 14, 0.55) 100%);
  pointer-events: none;
  justify-content: flex-start;
  align-items: flex-start;
  padding-top: 14vh;
  padding-left: 7vw;
}
.screen.splash button, .screen.splash a { pointer-events: auto; }

/* Deep, slowly drifting dark-water gradient behind the splash scene. */
#app.splash-bg {
  background: linear-gradient(155deg,
    #04070d 0%, #071527 38%, #0a2334 62%, #051019 85%, #02050a 100%) !important;
  background-size: 260% 260% !important;
  animation: splash-drift 22s ease-in-out infinite;
}
@keyframes splash-drift {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}

.splash-inner {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 14px;
  text-align: left;
  animation: splash-in 0.9s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes splash-in { from { opacity: 0; transform: translateY(18px); } }

.logo-svg {
  width: min(440px, 84vw);
  height: auto;
  filter: drop-shadow(0 4px 0 rgba(10, 16, 34, 0.35)) drop-shadow(0 0 26px rgba(126, 220, 220, 0.4));
  animation: logo-float 4.5s ease-in-out infinite;
}
@keyframes logo-float {
  0%, 100% { transform: translateY(0) rotate(-0.6deg); }
  50% { transform: translateY(-9px) rotate(0.6deg); }
}
.logo-svg text {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-weight: 800;
  fill: #ffffff;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-linejoin: round;
}
.logo-line1 text { font-size: 104px; letter-spacing: 10px; stroke-width: 3px; }
.logo-line2 text { font-size: 86px; letter-spacing: 4px; stroke-width: 2.5px; }

.tagline {
  margin: 0 0 8px;
  color: var(--teal-deep);
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  font-size: 0.85rem;
}
.splash-tagline { color: #aef0ea; text-shadow: 0 2px 12px rgba(10, 16, 34, 0.6); }
.studio-credit {
  margin-top: 10px;
  color: #7f95b5;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}
.studio-credit b { color: #aef0ea; font-weight: 700; }
.studio-credit:hover, .studio-credit:hover b { color: #ffffff; }
.splash-ghost { background: rgba(255, 255, 255, 0.18); color: #eaf6ff; backdrop-filter: blur(6px); }
.credit { position: absolute; bottom: 18px; color: var(--ink-soft); font-size: 0.8rem; opacity: 0.75; }
.splash-credit { color: #7f95b5; left: 7vw; }

/* Portrait: logo centred at the top, cube mid-screen, buttons at the bottom. */
@media (max-width: 720px) {
  .screen.splash {
    align-items: center;
    padding: 7vh 16px calc(26px + env(safe-area-inset-bottom));
    background: radial-gradient(ellipse at 50% 45%,
      rgba(3, 7, 14, 0) 20%, rgba(3, 7, 14, 0.6) 100%);
  }
  .splash-inner {
    align-items: center;
    text-align: center;
    align-self: stretch;
    flex: 1;
    min-height: 0;
  }
  /* Push the buttons + credit below the aquarium animation. */
  .splash-inner #btn-play { margin-top: auto; }
  .splash-credit { display: none; }
}

/* ---------- level select ---------- */
.map-header {
  display: flex; align-items: center; gap: 16px;
  width: min(680px, 94vw);
  margin-bottom: 18px;
}
.map-header h2 {
  font-family: "Baloo 2", sans-serif;
  font-size: 1.7rem; margin: 0; flex: 1;
}
.map-total-stars { font-weight: 700; color: #d9a520; font-size: 1.1rem; }

/* ---------- progression map ---------- */
.level-grid {
  width: min(680px, 94vw);
  max-height: 68vh;
  overflow-y: auto;
  padding: 6px 6px 30px;
}
.world-section {
  margin-bottom: 26px;
  padding: 18px 16px 20px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.world-title {
  display: flex; align-items: center; gap: 10px;
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0 4px 16px;
}
.world-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex: none;
}

.map-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 26px;
  position: relative;
}
.map-row:last-child { margin-bottom: 0; }
.map-row.rev { flex-direction: row-reverse; }

.map-node {
  position: relative;
  flex: none;
  width: 76px; height: 76px;
  border: none;
  border-radius: 42% 44% 46% 42%;
  cursor: pointer;
  font-family: "Baloo 2", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.55) 58%),
    var(--world-tint, var(--teal));
  box-shadow:
    0 6px 0 rgba(90, 120, 155, 0.35),
    0 12px 22px rgba(80, 110, 150, 0.28),
    inset 0 -8px 12px rgba(90, 130, 160, 0.22);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  transition: transform 0.15s ease;
}
.map-node:hover:not(.locked) { transform: translateY(-4px) scale(1.06); }
.map-node .num { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.map-node .stars { font-size: 0.68rem; color: #d9a520; letter-spacing: 1px; }
.map-node .stars .off { color: rgba(120, 140, 165, 0.45); }
.map-node.locked { cursor: default; filter: saturate(0.15) brightness(0.92); opacity: 0.7; }
.map-node.tutorial { --world-tint: #ffd166; }

.map-node .pin {
  position: absolute;
  top: -26px; left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  font-size: 1.5rem;
  filter: drop-shadow(0 3px 4px rgba(60, 40, 40, 0.4));
  animation: pin-bounce 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pin-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-7px); }
}

/* dashed connectors, like the reference progression map */
.map-link {
  flex: 1 1 auto;
  min-width: 14px;
  height: 0;
  border-top: 3px dashed rgba(95, 130, 165, 0.55);
  margin: 0 4px;
}
.map-link-v {
  position: absolute;
  bottom: -26px;
  width: 0;
  height: 26px;
  border-left: 3px dashed rgba(95, 130, 165, 0.55);
}
.map-link-v.at-right { right: 37px; }
.map-link-v.at-left { left: 37px; }

@media (max-width: 640px) {
  .world-section { padding: 14px 10px 16px; }
  .map-node { width: 62px; height: 62px; }
  .map-node .num { font-size: 1.2rem; }
  .map-link { min-width: 10px; }
  .map-link-v.at-right { right: 30px; }
  .map-link-v.at-left { left: 30px; }
}
@media (max-width: 420px) {
  .map-node { width: 56px; height: 56px; }
  .map-node .num { font-size: 1.1rem; }
  .map-node .stars { font-size: 0.58rem; }
  .map-link-v.at-right { right: 27px; }
  .map-link-v.at-left { left: 27px; }
}

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#hud.hidden { display: none; }
#hud button { pointer-events: auto; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
  gap: 12px;
}
.hud-center {
  background: var(--card);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 8px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.hud-level-name { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.05rem; }
.hud-sub { display: flex; gap: 16px; justify-content: center; font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
.hud-stars { color: #d9a520; }

.hud-side {
  position: absolute;
  right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}

/* ---------- power-ups ---------- */
.hud-powers {
  position: absolute;
  left: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.btn-power { position: relative; font-size: 1.5rem; }
.power-count {
  position: absolute;
  top: -4px; right: -4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  color: #7a5300;
  font-size: 0.72rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 4px rgba(80, 110, 150, 0.35);
}
.btn-power.active {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
  animation: power-pulse 1s ease-in-out infinite;
}
@keyframes power-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.btn-power.spent { opacity: 0.4; filter: grayscale(0.6); }
.btn-power.spent .power-count { background: #c9d4e2; color: #7c8aa0; }

/* ---------- toast & tutorial ---------- */
#toast, #tutorial-tip {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(26px + env(safe-area-inset-bottom));
  background: rgba(43, 58, 85, 0.92);
  color: #fff;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 16px;
  max-width: min(440px, 86vw);
  text-align: center;
  z-index: 30;
  box-shadow: var(--shadow);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
#tutorial-tip {
  background: var(--card);
  color: var(--ink);
  backdrop-filter: blur(8px);
  border: 2px solid var(--teal);
}
#toast.hidden, #tutorial-tip.hidden { opacity: 0; transform: translateX(-50%) translateY(12px); }

/* ---------- win modal ---------- */
#win-modal {
  position: absolute; inset: 0;
  z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(120, 150, 185, 0.25);
  backdrop-filter: blur(4px);
  transition: opacity 0.35s ease;
}
#win-modal.hidden { opacity: 0; pointer-events: none; }
.win-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border-radius: 30px;
  padding: 34px 44px 30px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}
#win-modal.hidden .win-card { animation: none; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-title { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.8rem; margin-bottom: 8px; }
.win-stars { font-size: 2.2rem; letter-spacing: 6px; color: var(--gold); margin: 4px 0 6px; text-shadow: 0 2px 0 rgba(200,150,0,0.25); }
.win-stars .off { color: #ccd7e4; text-shadow: none; }
.win-detail { color: var(--ink-soft); font-weight: 600; font-size: 0.9rem; margin-bottom: 20px; }
.win-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.hidden { visibility: hidden; }
#toast.hidden, #tutorial-tip.hidden, #win-modal.hidden { visibility: visible; }

@media (max-width: 520px) {
  .btn-round { width: 46px; height: 46px; }
  .hud-side, .hud-powers { gap: 10px; }
  .btn-power { font-size: 1.25rem; }
}
