/* ============================================================
   Coral Cove: Reef Rescue — kid-friendly mobile-first styles
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ocean-top: #45d0f5;
  --ocean-mid: #1487d8;
  --ocean-deep: #0b3d6e;
  --sand: #f8d987;
  --sand-dark: #e5b95c;
  --coral: #ff6f61;
  --coral-dark: #e2503f;
  --sunny: #ffd93d;
  --leaf: #4cd964;
  --ink: #143a5c;
  --white: #ffffff;
  --card: #f2fbff;
  --rare: #3d9bff;
  --legend: #ffb02e;
  --hud-h: 64px;
  --nav-h: 92px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Fredoka', 'Comic Sans MS', 'Chalkboard SE', sans-serif;
  color: var(--ink);
  background: var(--ocean-deep);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,.5);
}

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }
.main-screen {
  padding-top: calc(var(--hud-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

/* ---------- Ocean backgrounds ---------- */
.ocean-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--ocean-top) 0%, var(--ocean-mid) 45%, var(--ocean-deep) 100%);
  overflow: hidden;
}
.game-bg { background: linear-gradient(180deg, #2fb9ea 0%, #0f6cb8 60%, #0a3560 100%); }
.map-bg  { background: linear-gradient(180deg, #1a9ede 0%, #0f5fa8 55%, #093056 100%); }

.sun-rays {
  position: absolute;
  top: -30%; left: 50%;
  width: 160%; height: 80%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at top, rgba(255,255,220,.45), transparent 65%);
  animation: shimmer 6s ease-in-out infinite alternate;
}
@keyframes shimmer { from { opacity: .6; } to { opacity: 1; } }

.bubbles-layer { position: absolute; inset: 0; pointer-events: none; }
.bubble {
  position: absolute;
  bottom: -40px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.9), rgba(255,255,255,.15) 60%);
  opacity: .5;
  animation: rise linear infinite;
}
@keyframes rise {
  from { transform: translateY(0) translateX(0); opacity: .55; }
  50%  { transform: translateY(-45vh) translateX(14px); }
  to   { transform: translateY(-105vh) translateX(-10px); opacity: 0; }
}

/* ---------- Splash ---------- */
.splash-content {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}
.logo-badge {
  font-size: 64px;
  background: rgba(255,255,255,.9);
  width: 116px; height: 116px;
  border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 8px 0 rgba(0,0,0,.15), inset 0 -6px 0 rgba(0,0,0,.06);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }

.game-title {
  font-size: 56px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 1px;
  text-shadow: 0 4px 0 rgba(11,61,110,.55);
  line-height: 1;
  margin-top: 8px;
}
.game-subtitle {
  font-size: 26px;
  font-weight: 600;
  color: var(--sunny);
  text-shadow: 0 3px 0 rgba(11,61,110,.5);
  margin-top: -4px;
}
.splash-tagline {
  color: rgba(255,255,255,.92);
  font-size: 16px;
  font-weight: 500;
  margin: 14px 0 22px;
  line-height: 1.45;
}
.splash-footer { position: absolute; bottom: 18px; font-size: 12px; color: rgba(255,255,255,.65); }
.splash-fish { position: absolute; font-size: 42px; animation: swimAcross 14s linear infinite; top: 18%; z-index: 1; }
.splash-fish.f2 { top: 66%; font-size: 52px; animation-duration: 22s; animation-delay: -8s; }
.splash-fish.f3 { top: 40%; font-size: 36px; animation-duration: 17s; animation-delay: -4s; }
@keyframes swimAcross {
  from { left: -70px; transform: scaleX(1); }
  49%  { transform: scaleX(1); }
  50%  { left: calc(100% + 10px); transform: scaleX(-1); }
  99%  { transform: scaleX(-1); }
  to   { left: -70px; transform: scaleX(1); }
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: var(--white);
  transition: transform .1s;
}
.btn:active { transform: scale(.93); }
.btn-big { font-size: 28px; padding: 16px 64px; }
.btn-play {
  background: linear-gradient(180deg, #ff8a5c, var(--coral));
  box-shadow: 0 6px 0 var(--coral-dark), 0 10px 18px rgba(0,0,0,.25);
  font-size: 22px;
  padding: 13px 36px;
}
.btn-secondary {
  background: linear-gradient(180deg, #58c8f2, #1a90d6);
  box-shadow: 0 6px 0 #0e6aa8, 0 10px 18px rgba(0,0,0,.2);
  font-size: 22px;
  padding: 13px 36px;
}
.btn-sail {
  background: linear-gradient(180deg, var(--sunny), #ffb52e);
  color: #6e4a00;
  box-shadow: 0 6px 0 #d18f16, 0 10px 18px rgba(0,0,0,.2);
  font-size: 19px;
  padding: 14px 26px;
  width: 100%;
}
.btn-sail:disabled { filter: grayscale(.7); opacity: .7; }

/* ---------- Shared HUD ---------- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 15;
  display: none;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 10px 6px;
}
.hud.show { display: flex; }
.hud-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.92);
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: 0 3px 0 rgba(11,61,110,.25);
  font-weight: 600;
}
.hud-level, .hud-health { flex: 1; min-width: 0; }
.hud-icon { font-size: 18px; }
.hud-value { font-size: 18px; font-weight: 700; }
.hud-stack { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hud-label { font-size: 10.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp-bar { height: 8px; border-radius: 99px; background: #d5e7f2; overflow: hidden; }
.xp-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--sunny), #ffb52e);
  transition: width .6s cubic-bezier(.34,1.56,.64,1);
}
.xp-bar.health .xp-fill { background: linear-gradient(90deg, #58e0ff, #2e8bff); }

/* ---------- Reef stage ---------- */
.reef-stage { position: relative; flex: 1; z-index: 2; }
.sand {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 24%;
  background: linear-gradient(180deg, var(--sand), var(--sand-dark));
  border-radius: 100% 100% 0 0 / 36px 36px 0 0;
  box-shadow: inset 0 8px 12px rgba(0,0,0,.08);
}
.reef-items { position: absolute; inset: 0; pointer-events: none; }
.reef-item {
  position: absolute;
  font-size: 40px;
  transform-origin: bottom center;
  animation: sway 4s ease-in-out infinite alternate;
  filter: drop-shadow(0 4px 3px rgba(0,0,0,.25));
}
@keyframes sway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

.reef-swimmers { position: absolute; inset: 0; pointer-events: none; }
.swimmer {
  position: absolute;
  font-size: 40px;
  filter: drop-shadow(0 4px 3px rgba(0,0,0,.25));
  animation: swimAcross linear infinite;
}

.reef-message {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 18px;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(11,61,110,.2);
  max-width: 88%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s;
}
.reef-message.show { opacity: 1; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 15;
  display: none;
  justify-content: space-around;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(6,30,58,0), rgba(6,30,58,.55));
}
.bottom-nav.show { display: flex; }
.nav-btn {
  position: relative;
  font-family: inherit;
  border: none;
  cursor: pointer;
  background: rgba(255,255,255,.94);
  color: var(--ink);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 5px 0 rgba(11,61,110,.35);
  transition: transform .1s;
  min-width: 92px;
}
.nav-btn:active { transform: scale(.93); }
.nav-btn.current { outline: 4px solid rgba(255,217,61,.8); }
.nav-icon { font-size: 26px; }
.nav-btn-main {
  background: linear-gradient(180deg, var(--sunny), #ffb52e);
  font-size: 16px;
  padding: 14px 22px;
  border-radius: 26px;
  box-shadow: 0 6px 0 #d18f16;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.shop-dot {
  position: absolute;
  top: -4px; right: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--coral);
  border: 3px solid var(--white);
  display: none;
}
.shop-dot.show { display: block; animation: pulse 1.2s infinite; }

/* ---------- Journey map ---------- */
.journey-scroll {
  position: relative;
  z-index: 5;
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 24px;
}
.journey-title {
  text-align: center;
  color: var(--white);
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 3px 0 rgba(11,61,110,.5);
}
.journey-sub {
  text-align: center;
  color: rgba(255,255,255,.85);
  font-size: 13px;
  font-weight: 600;
  margin: 2px 0 16px;
}
.journey-list { display: flex; flex-direction: column; align-items: center; }
.path-dots {
  color: rgba(255,255,255,.65);
  font-size: 18px;
  letter-spacing: 4px;
  line-height: 1;
  padding: 6px 0;
  text-shadow: 0 2px 0 rgba(11,61,110,.4);
}
.area-node {
  font-family: inherit;
  width: 100%;
  max-width: 340px;
  border: 3px solid #cfe9f7;
  background: rgba(255,255,255,.95);
  border-radius: 22px;
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  text-align: left;
  box-shadow: 0 5px 0 rgba(11,61,110,.25);
  transition: transform .1s;
}
.area-node:active { transform: scale(.96); }
.area-node:nth-child(4n+1) { transform: translateX(-14px); }
.area-node:nth-child(4n+3) { transform: translateX(14px); }
.area-node:nth-child(4n+1):active { transform: translateX(-14px) scale(.96); }
.area-node:nth-child(4n+3):active { transform: translateX(14px) scale(.96); }
.area-node .flag { grid-row: span 2; font-size: 38px; text-align: center; }
.area-node .a-name { font-size: 16.5px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.area-node .a-place { font-size: 11px; color: #4c7395; font-weight: 600; }
.area-node .a-status { grid-row: span 2; font-size: 22px; }
.area-node .a-crit { grid-column: 2 / 4; font-size: 17px; letter-spacing: 3px; margin-top: 2px; }
.area-node .a-crit .off { filter: grayscale(1) brightness(.45); opacity: .75; }
.area-node.locked { filter: saturate(.35); opacity: .75; }
.area-node.current { border-color: var(--sunny); box-shadow: 0 5px 0 #d18f16, 0 0 0 5px rgba(255,217,61,.35); }
.area-node.done { border-color: #9be3ae; }

/* ---------- Area panel ---------- */
.area-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.area-head .flag { font-size: 42px; }
.area-head-txt { text-align: left; flex: 1; }
.area-head-txt h2 { font-size: 21px; font-weight: 700; line-height: 1.1; }
.area-head-txt p { font-size: 11.5px; color: #4c7395; font-weight: 600; }
.area-blurb {
  font-size: 13px;
  color: #33586f;
  background: #e4f5ff;
  border-radius: 14px;
  padding: 9px 12px;
  margin: 8px 0 12px;
  line-height: 1.4;
  text-align: left;
}
.mission-list { display: flex; flex-direction: column; gap: 9px; }
.mission-row {
  font-family: inherit;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  column-gap: 10px;
  text-align: left;
  background: var(--white);
  border: 3px solid #cfe9f7;
  border-radius: 18px;
  padding: 9px 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(11,61,110,.15);
  transition: transform .1s;
}
.mission-row:active { transform: scale(.97); }
.mission-row.passed { border-color: #9be3ae; background: #f2fff5; }
.mission-row .m-icon { font-size: 30px; text-align: center; }
.mission-row .m-name { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.mission-row .m-desc { font-size: 11px; color: #4c7395; line-height: 1.25; }
.mission-row .m-stars { font-size: 14px; letter-spacing: 1px; }
.mission-row .m-stars .dim { filter: grayscale(1) brightness(.6); opacity: .5; }
.rescue-preview {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 12px 0;
  font-size: 30px;
}
.rescue-preview .slot {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: #e4f5ff;
  display: grid;
  place-items: center;
  border: 3px dashed #a9d7ef;
}
.rescue-preview .slot.got { border-style: solid; border-color: var(--leaf); background: #eafff0; }
.rescue-preview .slot.mystery span { filter: grayscale(1) brightness(.35); opacity: .8; }
.sail-hint { font-size: 12.5px; color: #4c7395; margin: 8px 0 4px; line-height: 1.4; }

/* ---------- Modals ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(6,30,58,.62);
  backdrop-filter: blur(3px);
}
.modal.open { display: flex; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 28px;
  padding: 26px 20px 22px;
  box-shadow: 0 12px 0 rgba(11,61,110,.35), 0 24px 50px rgba(0,0,0,.35);
  text-align: center;
  animation: popIn .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-tall { max-height: 84dvh; overflow-y: auto; }
.modal-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.modal-close {
  position: absolute;
  top: -12px; right: -6px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--coral);
  color: var(--white);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--coral-dark);
  z-index: 2;
}
.modal-close:active { transform: scale(.9); }

/* ---------- Sea Book ---------- */
.book-wrap {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 16px 0;
  min-height: 0;
}
.book-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.book-tab {
  font-family: inherit;
  border: none;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 13px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(11,61,110,.3);
}
.book-tab.on { background: var(--sunny); box-shadow: 0 3px 0 #d18f16; }
.book-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-content: start;
  padding-bottom: 12px;
  min-height: 0;
}
.book-card {
  font-family: inherit;
  border: 3px solid #cfe9f7;
  background: rgba(255,255,255,.95);
  border-radius: 18px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(11,61,110,.2);
  transition: transform .1s;
}
.book-card:active { transform: scale(.94); }
.book-card-emoji { font-size: 36px; }
.book-card.locked .book-card-emoji { filter: grayscale(1) brightness(.35); opacity: .8; }
.book-card-name { font-size: 10.5px; font-weight: 700; line-height: 1.1; text-align: center; }
.book-card.locked .book-card-name { color: #90a9bd; }
.book-card.r-rare { border-color: #a9cfff; }
.book-card.r-legendary { border-color: #ffd98c; }

/* ---------- Book detail ---------- */
.book-detail {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  background: linear-gradient(180deg, #1a9ede 0%, #0f5fa8 55%, #093056 100%);
  padding-top: calc(12px + env(safe-area-inset-top));
}
.book-detail.open { display: flex; }
.btn-back {
  font-family: inherit;
  align-self: flex-start;
  margin: 4px 0 0 14px;
  border: none;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(11,61,110,.35);
}
.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px calc(30px + env(safe-area-inset-bottom));
  text-align: center;
}
.detail-ring {
  width: 168px; height: 168px;
  margin: 6px auto 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #eafaff, #bfe8fb 70%);
  display: grid;
  place-items: center;
  font-size: 96px;
  border: 6px solid var(--white);
  box-shadow: 0 10px 0 rgba(11,61,110,.35), 0 18px 40px rgba(0,0,0,.3);
}
.detail-ring.r-rare { border-color: var(--rare); }
.detail-ring.r-legendary {
  border-color: var(--legend);
  background: radial-gradient(circle at 35% 30%, #fff8e2, #ffe9b3 70%);
}
.rarity-chip {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 14px;
  background: #dfeaf2;
  color: #51708c;
  margin-bottom: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.rarity-chip.r-rare { background: #dcecff; color: #1c6ed6; }
.rarity-chip.r-legendary { background: #fff0cd; color: #a86e00; }
.detail-name { color: var(--white); font-size: 27px; font-weight: 700; text-shadow: 0 3px 0 rgba(11,61,110,.5); }
.detail-chips { display: flex; gap: 6px; justify-content: center; margin: 8px 0 12px; flex-wrap: wrap; }
.detail-chip {
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
}
.detail-sum {
  background: rgba(255,255,255,.95);
  border-radius: 18px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 12px;
  box-shadow: 0 5px 0 rgba(11,61,110,.3);
}
.detail-profile {
  background: rgba(255,255,255,.95);
  border-radius: 18px;
  padding: 6px 16px 10px;
  text-align: left;
  box-shadow: 0 5px 0 rgba(11,61,110,.3);
}
.profile-row { padding: 10px 0; border-bottom: 2px dashed #d9ecf7; }
.profile-row:last-child { border-bottom: none; }
.profile-row .p-label { font-size: 12px; font-weight: 700; color: #1c6ed6; margin-bottom: 2px; }
.profile-row .p-text { font-size: 13.5px; line-height: 1.45; color: #24506e; }

/* ---------- Mini-game screen ---------- */
.game-hud {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 6px;
}
.btn-quit {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.92);
  color: var(--coral-dark);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(11,61,110,.25);
}
.timer-pill.hurry { animation: pulse .5s infinite; background: #ffe2de; }

.game-banner { position: relative; z-index: 9; text-align: center; min-height: 34px; padding: 2px 16px; }
.game-banner .msg {
  display: inline-block;
  background: rgba(255,255,255,.94);
  border-radius: 16px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 700;
  animation: popIn .25s;
}
.game-banner .msg.bad { color: var(--coral-dark); }
.game-banner .msg.good { color: #178a4c; }

.game-area { position: relative; flex: 1; z-index: 5; overflow: hidden; }
.game-item {
  position: absolute;
  border: none;
  background: none;
  font-size: 44px;
  cursor: pointer;
  padding: 8px;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.3));
  transition: transform .1s;
}
.game-item .tag {
  position: absolute;
  bottom: -6px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  background: rgba(255,255,255,.9);
  border-radius: 99px;
  padding: 1px 7px;
  color: var(--ink);
  white-space: nowrap;
}
.game-item.pop { animation: popAway .3s forwards; }
@keyframes popAway { to { transform: scale(1.6); opacity: 0; } }

.float-score {
  position: absolute;
  z-index: 20;
  font-size: 22px;
  font-weight: 700;
  color: var(--sunny);
  text-shadow: 0 2px 0 rgba(0,0,0,.4);
  pointer-events: none;
  animation: floatUp .8s forwards;
}
.float-score.bad { color: #ff8d81; }
@keyframes floatUp { to { transform: translateY(-60px); opacity: 0; } }

/* ---------- Quiz ---------- */
.quiz-box {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 20px 22px 40px;
}
.quiz-box.active { display: flex; }
.quiz-progress { text-align: center; color: rgba(255,255,255,.9); font-weight: 700; font-size: 14px; letter-spacing: 2px; }
.quiz-question {
  background: rgba(255,255,255,.96);
  border-radius: 22px;
  padding: 22px 18px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 6px 0 rgba(11,61,110,.3);
}
.quiz-answers { display: flex; flex-direction: column; gap: 10px; }
.quiz-answer {
  font-family: inherit;
  border: none;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(11,61,110,.25);
  transition: transform .1s;
}
.quiz-answer:active { transform: scale(.96); }
.quiz-answer.correct { background: var(--leaf); color: var(--white); }
.quiz-answer.wrong { background: var(--coral); color: var(--white); }

/* ---------- Result & rescue ---------- */
.result-card { padding-top: 34px; }
.result-stars { font-size: 42px; letter-spacing: 6px; margin-bottom: 4px; }
.result-stars .dim { filter: grayscale(1) brightness(.6); opacity: .5; }
.result-pearls { font-size: 34px; font-weight: 700; color: #0e86c9; margin: 6px 0 12px; }
.fact-bubble {
  background: #e4f5ff;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 18px;
  text-align: left;
}
.result-buttons { display: flex; gap: 10px; justify-content: center; }

.rescue-card { padding-top: 20px; }
.rescue-banner {
  font-size: 15px;
  font-weight: 700;
  color: #a86e00;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.rescue-ring {
  width: 130px; height: 130px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #eafaff, #bfe8fb 70%);
  display: grid;
  place-items: center;
  font-size: 72px;
  border: 6px solid var(--white);
  box-shadow: 0 8px 0 rgba(11,61,110,.25);
  animation: bob 2.4s ease-in-out infinite;
}
.rescue-ring.r-rare { border-color: var(--rare); }
.rescue-ring.r-legendary {
  border-color: var(--legend);
  background: radial-gradient(circle at 35% 30%, #fff8e2, #ffe9b3 70%);
}

/* ---------- Popup ---------- */
.popup-card { padding-top: 30px; }
.popup-emoji { font-size: 62px; animation: bob 2s ease-in-out infinite; }
.popup-text { font-size: 15px; line-height: 1.5; margin: 8px 0 18px; color: #33586f; }

/* ---------- Story overlay ---------- */
.story-overlay {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: linear-gradient(180deg, rgba(4,22,44,.88), rgba(6,40,74,.92));
  backdrop-filter: blur(4px);
}
.story-overlay.open { display: flex; }
.story-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 28px;
  padding: 30px 24px 24px;
  text-align: center;
  box-shadow: 0 12px 0 rgba(0,0,0,.3), 0 24px 60px rgba(0,0,0,.45);
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1);
}
.story-emoji { font-size: 58px; margin-bottom: 12px; animation: bob 3s ease-in-out infinite; }
.story-text { font-size: 16.5px; line-height: 1.55; color: #24506e; font-weight: 500; min-height: 104px; }
.story-dots { margin: 14px 0 16px; font-size: 13px; letter-spacing: 5px; color: #a9c6da; }
.story-dots .on { color: var(--coral); }

/* ---------- Confetti ---------- */
#confetti-layer { position: absolute; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute;
  top: -20px;
  width: 12px; height: 12px;
  border-radius: 3px;
  animation: confFall linear forwards;
}
@keyframes confFall { to { transform: translateY(110dvh) rotate(720deg); opacity: .8; } }

/* ---------- Sound toggle ---------- */
.sound-toggle {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  right: 10px;
  z-index: 25; /* below modals so it never covers dialog buttons */
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.85);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(11,61,110,.25);
}
