/* ============================================================
   E Scapes — Playground (webcam-driven worlds)
   Layered on top of styles.css; scoped to .play-body.
   ============================================================ */
.play-body { background: #05061a; overflow: hidden; }

.play-stage {
  position: fixed; inset: 0;
  width: 100%; height: 100svh;
  background: #05061a;
}
#play-canvas, #fish-canvas, #lem-canvas, #rag-canvas,
#count-canvas, #stars-canvas, #animals-canvas, #bird-canvas {
  display: block;
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
/* the page script activates one playground at a time */
#fish-canvas, #lem-canvas, #rag-canvas,
#count-canvas, #stars-canvas, #animals-canvas, #bird-canvas { display: none; }

/* soft vignette so overlay text always reads */
.play-vignette {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background:
    radial-gradient(120% 85% at 50% 45%, transparent 40%, rgba(3, 4, 16, 0.55) 100%),
    linear-gradient(180deg, rgba(4, 5, 20, 0.72) 0%, transparent 22%, transparent 62%, rgba(4, 5, 20, 0.85) 100%);
}

/* ---------- top bar ---------- */
.play-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 12;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(18px, 4vw, 40px);
}
.play-top .wordmark-text { color: #fff; }
.play-top .play-back {
  font-family: var(--font-display); font-weight: 500; font-size: 0.94rem;
  color: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(12, 14, 40, 0.5);
  backdrop-filter: blur(10px);
  padding: 9px 18px; border-radius: 999px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.play-top .play-back:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* ---------- consent / status gate ---------- */
.play-gate {
  position: fixed; z-index: 14; inset: 0;
  display: grid; place-items: center;
  padding: 20px;
  background: radial-gradient(90% 70% at 50% 50%, rgba(6, 8, 28, 0.6), rgba(4, 5, 18, 0.88));
  backdrop-filter: blur(3px);
}
.play-gate[hidden] { display: none; }
.play-card {
  width: min(560px, 100%);
  background: rgba(18, 18, 52, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(16px);
  padding: clamp(26px, 4vw, 40px);
  text-align: center;
  color: #fff;
}
.play-card .play-badge {
  width: 62px; height: 62px; margin: 0 auto 18px;
  border-radius: 20px; display: grid; place-items: center;
  font-size: 1.9rem;
  background: linear-gradient(150deg, var(--grape), var(--aqua));
  box-shadow: 0 16px 34px -14px rgba(154, 107, 227, 0.9);
}
.play-card h1 { font-size: clamp(1.7rem, 4.6vw, 2.4rem); margin-bottom: 12px; color: #fff; }
.play-card p { color: rgba(255, 255, 255, 0.82); font-size: 1.02rem; margin: 0 0 14px; }
.play-card .play-privacy {
  display: flex; align-items: flex-start; gap: 10px; text-align: left;
  font-size: 0.9rem; line-height: 1.5;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(56, 198, 207, 0.1);
  border: 1px solid rgba(56, 198, 207, 0.28);
  border-radius: 14px; padding: 13px 15px; margin: 18px 0 22px;
}
.play-card .play-privacy .lock { flex: none; font-size: 1.05rem; line-height: 1.3; }
.play-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.play-note { margin-top: 16px; font-size: 0.84rem; color: rgba(255, 255, 255, 0.5); }

/* loading + error variants */
.play-spinner {
  width: 42px; height: 42px; margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--aqua);
  animation: playSpin 0.9s linear infinite;
}
@keyframes playSpin { to { transform: rotate(360deg); } }
.play-progress { font-size: 0.88rem; color: rgba(255, 255, 255, 0.6); margin-top: 6px; }

/* ---------- live HUD ---------- */
/* Groups (Play / Learn / controls) wrap to a second row as whole groups
   rather than scrolling out of sight — the camera Stop must stay visible. */
.play-hud {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%);
  bottom: 22px;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  column-gap: 14px; row-gap: 6px;
  padding: 9px 11px;
  background: rgba(14, 12, 40, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  backdrop-filter: blur(14px);
  width: max-content;
  max-width: calc(100vw - 32px);
  scrollbar-width: none;
}
.play-hud::-webkit-scrollbar { display: none; }
.hud-group { display: flex; align-items: center; gap: 8px; flex: none; }
.play-hud[hidden] { display: none; }
.play-hud .hud-label {
  font-family: var(--font-display); font-weight: 500; font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6); padding: 0 2px 0 8px; white-space: nowrap;
}
.play-hud .chip { font-size: 0.88rem; }
.play-hud .chip.locked { opacity: 0.55; cursor: default; }
.hud-stop {
  font-family: var(--font-display); font-weight: 500; font-size: 0.86rem;
  color: #ffd7d7; background: rgba(224, 85, 107, 0.18);
  border: 1px solid rgba(224, 85, 107, 0.45);
  border-radius: 999px; padding: 8px 15px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.hud-stop:hover { background: rgba(224, 85, 107, 0.3); }
.hud-stop .rec {
  width: 8px; height: 8px; border-radius: 50%; background: #ff5f7a;
  box-shadow: 0 0 9px #ff5f7a; animation: recPulse 1.8s ease-in-out infinite;
}
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- self-view (the live tracking video) ----------
   Must remain visibly rendered while tracking runs — browsers stop
   decoding frames for hidden video elements. */
.play-selfview {
  position: fixed; z-index: 12;
  right: clamp(18px, 4vw, 40px); top: 84px;
  width: clamp(96px, 12vw, 150px);
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(12, 14, 40, 0.5);
  box-shadow: 0 14px 34px -16px rgba(0, 0, 0, 0.8);
}
.play-selfview[hidden] { display: none; }
.play-selfview { cursor: pointer; }
/* what the tracker sees, drawn over the preview (js/track-overlay.js) */
.play-selfview .track-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.play-selfview video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, like the rest of the playground */
  display: block;
}

/* tracking readout */
.play-readout {
  position: fixed; z-index: 12; top: 84px; left: clamp(18px, 4vw, 40px);
  display: flex; flex-direction: column; gap: 7px;
  font-family: var(--font-display); font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.72);
}
.play-readout[hidden] { display: none; }
.play-readout span {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(12, 14, 40, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px; padding: 6px 13px; backdrop-filter: blur(8px);
  white-space: nowrap;
}
/* the display above beats the UA's [hidden] rule, so restate it */
.play-readout span[hidden] { display: none; }
.play-readout .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.3); }
.play-readout .on .dot { background: var(--leaf); box-shadow: 0 0 9px var(--leaf); }

/* hint */
.play-hint {
  position: fixed; z-index: 12; right: clamp(18px, 4vw, 40px);
  bottom: calc(var(--hud-top, 82px) + 10px); /* --hud-top: set by the page from the HUD's real height */
  max-width: 230px; text-align: right;
  font-size: 0.86rem; line-height: 1.5; color: rgba(255, 255, 255, 0.6);
}
.play-hint[hidden] { display: none; }
.play-hint b { color: rgba(255, 255, 255, 0.9); font-weight: 600; }

/* ---------- fishing game UI ---------- */
.fish-ui[hidden] { display: none; }
.fish-status {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--hud-top, 82px) + 10px);
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
  color: #fff;
  background: rgba(10, 40, 60, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px; padding: 10px 22px;
  backdrop-filter: blur(10px);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  white-space: nowrap; max-width: calc(100vw - 30px);
  overflow: hidden; text-overflow: ellipsis;
  transition: background 0.25s, border-color 0.25s;
}
.fish-status.hot  { background: rgba(255, 130, 40, 0.4);  border-color: rgba(255, 190, 90, 0.6); }
.fish-status.warn { background: rgba(220, 60, 80, 0.45);  border-color: rgba(255, 130, 140, 0.65); }

.fish-meter {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--hud-top, 82px) + 66px);
  width: min(320px, 70vw); height: 12px;
  background: rgba(8, 30, 46, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px; overflow: hidden;
  backdrop-filter: blur(8px);
}
.fish-meter[hidden] { display: none; }
.fish-meter i {
  display: block; height: 100%; width: 0%;
  background: #5be49b; border-radius: inherit;
  transition: width 0.12s linear, background 0.3s;
}
.fish-tally {
  position: fixed; z-index: 12; top: 176px; left: clamp(18px, 4vw, 40px);
  font-family: var(--font-display); font-weight: 600; font-size: 1rem;
  color: #fff;
  background: rgba(10, 40, 60, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px; padding: 7px 15px;
  backdrop-filter: blur(8px);
}
.fish-tally[hidden] { display: none; }

/* catch reveal card */
.fish-card {
  position: fixed; z-index: 13; left: 50%; transform: translateX(-50%);
  bottom: clamp(170px, 26vh, 260px);
  text-align: center; color: #fff;
  background: rgba(8, 34, 52, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-lg);
  padding: 18px 34px;
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.8);
  animation: fishCardIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  max-width: calc(100vw - 40px);
}
.fish-card[hidden] { display: none; }
.fish-card-name {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--sun);
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.5);
}
.fish-card-size { font-family: var(--font-display); font-weight: 500; font-size: 1.02rem; margin-top: 4px; }
.fish-card-flavor { font-size: 0.92rem; color: rgba(255, 255, 255, 0.75); font-style: italic; margin-top: 6px; }
@keyframes fishCardIn {
  from { opacity: 0; transform: translateX(-50%) translateY(24px) scale(0.9); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@media (max-width: 720px) {
  /* phones: one scrolling row, with Mute/Stop pinned first so they never scroll away */
  .play-hud { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; border-radius: 999px; width: auto; }
  .hud-controls { order: -1; }
  .play-hint { display: none; }
  .play-readout { top: 74px; font-size: 0.78rem; }
  .fish-tally { top: auto; bottom: 150px; left: 14px; }
  .fish-meter { bottom: 190px; }
}
@media (prefers-reduced-motion: reduce) {
  .play-spinner, .hud-stop .rec { animation: none; }
  .fish-card { animation: none; }
}

/* ---------- kid games: big prompt card + hold-to-confirm ring ---------- */
.kid-prompt {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%);
  top: 74px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 22px 12px;
  background: rgba(14, 16, 48, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  color: #fff; text-align: center;
  max-width: min(460px, calc(100vw - 340px));
}
.kid-prompt[hidden] { display: none; }
.kid-prompt.side { left: clamp(18px, 4vw, 40px); top: 232px; transform: none; padding: 10px 16px; max-width: 190px; }
.kid-ring {
  --p: 0;
  width: 92px; height: 92px; border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(closest-side, rgba(20, 22, 60, 0.95) 79%, transparent 80%),
    conic-gradient(#ffd54a calc(var(--p) * 360deg), rgba(255, 255, 255, 0.16) 0);
  transition: transform 0.2s;
}
.kid-ring.full { transform: scale(1.08); }
.kid-ring-coach { width: 112px; height: 112px; }
.kid-num {
  font-family: var(--font-display); font-weight: 700;
  font-size: 2.6rem; line-height: 1; color: #fff3b0;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}
.kid-ring .kid-num { font-size: 2.2rem; }
.kid-coach { width: 84px; height: 92px; }
.kid-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 260px; align-items: center; }
.kid-dots i { width: 14px; height: 14px; border-radius: 50%; background: #ffd54a; box-shadow: 0 0 10px rgba(255, 213, 74, 0.8); display: block; }
.kid-dots i.d2 { background: #7ad7ff; box-shadow: 0 0 10px rgba(122, 215, 255, 0.8); }
.kid-dots b { font-family: var(--font-display); font-size: 1.2rem; color: #fff; margin: 0 4px; }
.kid-say { font-family: var(--font-display); font-weight: 600; font-size: clamp(1rem, 2.4vw, 1.25rem); text-shadow: 0 2px 10px rgba(0,0,0,0.4); }
.kid-say b { color: #ffd54a; }
#kid-count { top: 176px; }

/* narration on/off */
.hud-mute {
  font-size: 1rem; line-height: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px; padding: 7px 11px; cursor: pointer; color: #fff;
}
.hud-mute:hover { background: rgba(255, 255, 255, 0.18); }
.hud-mute[aria-pressed="true"] { opacity: 0.6; }

@media (max-width: 720px) {
  .kid-prompt { top: 148px; max-width: calc(100vw - 32px); padding: 8px 14px; } /* below the readout pills */
  .kid-prompt.side { top: 148px; left: 10px; padding: 6px 10px; max-width: 140px; }
  .kid-prompt.side .kid-ring { width: 56px; height: 56px; }
  .kid-prompt.side .kid-ring .kid-num { font-size: 1.6rem; }
  .kid-ring { width: 72px; height: 72px; }
  .kid-ring-coach { width: 88px; height: 88px; }
  .kid-coach { width: 66px; height: 72px; }
  #kid-count { top: auto; bottom: 150px; left: 14px; }
}
