:root{
  color-scheme:light;
  --sky:#dcecf0;
  --paper:#fbfdf8;
  --ink:#22331f;
  --muted:#5c6b52;
  --water:#5aa79b;
  --reed:#4f7a3f;
  --sun:#e0a33c;
  --line:#cddfd2;
  --focus:#1f6f8b;
  font-family:ui-rounded,"Avenir Next",system-ui,-apple-system,sans-serif;
  color:var(--ink);
  background:var(--sky);
}
*{box-sizing:border-box}
/* A strict viewport still needs the page held still: no rubber-band, and no
   iOS text inflation. */
html{-webkit-text-size-adjust:100%;overscroll-behavior:none}
body{margin:0;min-width:320px;background:linear-gradient(180deg,#dcecf0,#eef7f1 55%,#f6f1e2);overscroll-behavior:none}
/* The Sandpit shell pads the body to clear its fixed back link. This toy reads
   the same inset itself (below), so cancel the shell padding on its own page
   and count the pill once. The variable is the documented interface; the
   fallback keeps standalone hosting at a normal 22px. */
html body:has(.sandpit-back){padding-top:0}
button,input{font:inherit}
button{
  border:1px solid #b9cfc0;border-radius:12px;padding:12px 16px;min-height:48px;
  background:#fbfdf8;color:var(--ink);cursor:pointer;font-weight:650;
  touch-action:manipulation;transition:background .15s,transform .15s;
}
button:hover{background:#eef7ef}
button:active{transform:scale(.97)}
button:disabled{cursor:default;opacity:.5}
button:focus-visible,input:focus-visible{outline:3px solid var(--focus);outline-offset:3px}
input[type=checkbox]{accent-color:var(--reed);width:18px;height:18px}
.pond{
  width:min(1220px,100%);margin:auto;
  padding:calc(max(20px,env(safe-area-inset-top)) + var(--sandpit-inset-top,0px)) max(20px,env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));
}
.header{display:flex;justify-content:space-between;align-items:center;gap:14px;margin-bottom:16px}
/* Rule 7: a compact name beside a drawing, no slogan and no intro in the
   child's view. The explanation lives in the footer's grown-ups note. */
.brand{display:flex;align-items:center;gap:12px;min-width:0;margin:0}
.brand-mark{width:58px;height:45px;flex:none}
.brand-name{font:500 27px/1.05 Georgia,serif;letter-spacing:0}
.eyebrow{font-size:12px;font-weight:750;text-transform:uppercase;letter-spacing:.12em;color:#3f6a44;margin:0 0 7px}
.guide-button{display:flex;align-items:center;gap:9px;font-size:14px;white-space:nowrap}
.guide-button>span:first-child{font-size:20px;color:var(--reed)}
.count{border-radius:30px;background:#dfeee0;padding:5px 10px;color:#2f5a34;font-size:12px}

.pond-layout{display:block}
.scene-column{min-width:0}
.scene-bar{
  display:flex;justify-content:space-between;align-items:center;gap:14px;font-size:13px;
  background:#e7f2ea;border:1px solid var(--line);border-bottom:0;border-radius:16px 16px 0 0;padding:12px 16px;
}
.depth-label{font-weight:700;display:flex;align-items:center;gap:8px}
.depth-label i{width:8px;height:8px;border-radius:50%;background:var(--water);flex:none}
.tip{color:var(--muted);text-align:right}

.viewport{
  position:relative;height:clamp(330px,52vh,540px);overflow:hidden;
  border:1px solid var(--line);border-top:0;border-bottom:0;background:#8fd0c0;
  /* Capture is scoped to the pond only; the page around it still scrolls. */
  touch-action:none;cursor:grab;
  /* No text selection and no long-press callout under a small hand. */
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
}
.viewport.is-dragging{cursor:grabbing}
#scene{display:block;width:100%;height:100%;pointer-events:none}
.creature-targets{position:absolute;inset:0;pointer-events:none}
.creature-target{
  position:absolute;pointer-events:auto;border:0;background:transparent!important;box-shadow:none;
  border-radius:30%;padding:0;min-width:48px;min-height:48px;touch-action:none;
}
/* Stick with the Safari precedent: a generic button:hover rule must never
   paint a pale rectangle over a creature on a touch device with sticky hover. */
.creature-target:hover,.creature-target:active{background:transparent!important;transform:none}
.creature-target:focus-visible{outline:3px dashed #10321f;outline-offset:2px;background:rgba(255,255,255,.16)!important}
.creature-target .creature-label{
  position:absolute;left:50%;top:-22px;transform:translateX(-50%);
  background:rgba(251,253,248,.93);border-radius:30px;padding:4px 10px;font-size:12px;
  white-space:nowrap;color:#22402a;box-shadow:0 3px 8px rgba(20,50,30,.16);
}
.creature-target:not(.is-known) .creature-label{font-size:13px;min-width:26px;padding:3px 8px}

.primary{background:var(--reed);border-color:var(--reed);color:#fff}
.primary:hover{background:#3f6633}
.sighting{
  position:absolute;top:14px;left:50%;transform:translateX(-50%);margin:0;padding:8px 15px;
  background:rgba(251,253,248,.9);border:1px solid var(--line);border-radius:30px;font-size:12px;
  pointer-events:none;white-space:nowrap;
}

.control-bar{
  display:flex;flex-wrap:wrap;align-items:center;gap:12px 18px;
  padding:14px 16px;background:#f6fbf4;border:1px solid var(--line);border-radius:0 0 16px 16px;
}
.depth-controls{display:flex;gap:8px;flex:1 1 auto}
.depth-controls button{flex:1;min-height:52px;font-size:15px}
.play-controls{display:flex;gap:8px;flex:1 1 auto;justify-content:flex-end}
.play-controls .primary{min-width:132px;min-height:54px;font-size:16px}
#restart{min-height:52px}
.sound-toggle{min-width:118px;min-height:52px;background:transparent;border-color:#c4d6c8}
.sound-toggle[aria-pressed=false]{color:#4c6350}

.encounter{
  display:none;margin-top:16px;background:var(--paper);border:1px solid var(--line);border-radius:16px;
  padding:14px 16px;gap:14px;grid-template-columns:112px minmax(0,1fr);align-items:start;
}
.encounter.is-open{display:grid}
.portrait{position:relative;width:112px;height:112px;border-radius:12px;background:#e6f2e8;display:grid;place-items:center;overflow:hidden}
.portrait canvas{width:112px;height:112px}
.badge{position:absolute;bottom:6px;left:50%;transform:translateX(-50%);padding:3px 9px;background:#fff6d8;border-radius:20px;font-size:11px;font-weight:750;color:#5c5a28;white-space:nowrap}
.notes{min-width:0}
.notes h2{font:500 24px Georgia,serif;margin:0 0 6px;letter-spacing:0;overflow-wrap:anywhere}
/* Everything a child does not need is folded away: the fact, the sound
   disclaimer and the optional name/chime repeats live here for a grown-up,
   out of the first tap. */
.encounter-detail{font-size:13px;color:var(--muted)}
.encounter-detail summary{cursor:pointer;font-weight:700;color:#35603c;min-height:34px;display:flex;align-items:center;gap:6px}
.encounter-detail p{font-size:13px;color:var(--muted);line-height:1.5;margin:6px 0 0;max-width:48ch}
.encounter-detail .sound-description{color:#35603c}
.encounter-detail .speech-status{color:#35603c;font-weight:650}
.encounter-extras{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.encounter-extras button{flex:1 1 150px;min-height:44px;font-size:13.5px}
.encounter-actions{grid-column:1/-1;display:flex;gap:8px}
.encounter-actions button{flex:1 1 auto;min-height:52px;font-size:15px}

.lifecycle{
  margin-top:20px;background:var(--paper);border:1px solid var(--line);border-radius:16px;
  padding:18px;display:grid;gap:14px;
}
.lifecycle h2{font:500 24px Georgia,serif;margin:0 0 8px;letter-spacing:0}
.lifecycle p{font-size:14px;color:var(--muted);margin:0;line-height:1.55;max-width:52ch}
#lifecycle-canvas{width:100%;height:auto;aspect-ratio:620/220;border-radius:12px}

.guide{margin-top:20px;background:#f7fbf5;border:1px solid var(--line);border-radius:16px;padding:18px}
.guide-heading{display:flex;justify-content:space-between;align-items:center;gap:14px;margin-bottom:16px}
.guide-heading h2{font:500 24px Georgia,serif;margin:0;letter-spacing:0}
.guide-heading>p{font-size:13px;color:var(--muted)}
.guide-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}
.guide-card{
  display:flex;flex-direction:column;align-items:center;gap:4px;background:#ecf4ea;
  border:1px solid #d8e6d6;border-radius:12px;padding:8px 8px 12px;min-height:150px;
}
.guide-card:disabled{cursor:default;opacity:1}
.guide-card canvas{width:96px;height:96px;max-width:100%}
.guide-card .unknown-mark{display:grid;place-items:center;height:96px;color:#7d9a7d;font:40px Georgia,serif}
.guide-name{font-size:13px;font-weight:700}
.guide-subtitle{font-size:12.5px;font-weight:400;color:#4f6150;text-align:center}

.footer{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:flex-start;gap:12px;padding:18px 4px 0;color:#5b6c58;font-size:12px}
.footer-copy{flex:1 1 320px;min-width:0}
.credits{margin:0;max-width:70ch;line-height:1.55}
.credits strong{color:#2f5a34}
.grown-ups{margin:8px 0 0;max-width:70ch;line-height:1.55}
.grown-ups summary{cursor:pointer;font-weight:700;color:#35603c}
.grown-ups p{margin:6px 0 0;line-height:1.55}
.motion-setting{display:flex;align-items:center;gap:7px;min-height:44px;white-space:nowrap}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
[hidden]{display:none!important}

/* Portrait phone: the card appears below the pond once something is found. */
@media (max-width:759px){
  .pond{padding-left:max(14px,env(safe-area-inset-left));padding-right:max(14px,env(safe-area-inset-right))}
  .header{flex-direction:column;align-items:flex-start;gap:12px;margin-bottom:16px}
  .brand-name{font-size:23px}
  .brand-mark{width:48px;height:38px}
  .guide-button{align-self:stretch;justify-content:center}
  .viewport{height:clamp(300px,46vh,420px)}
  .tip{max-width:46%;font-size:12px}
  .depth-controls button{font-size:14px;padding:10px 8px}
  .play-controls{justify-content:stretch}
  .play-controls .primary{flex:1;min-width:0}
  #restart,.sound-toggle{flex:1;min-width:0}
  .encounter{grid-template-columns:104px minmax(0,1fr);padding:14px;gap:12px}
  .portrait{width:104px;height:120px}
  .portrait canvas{width:106px;height:106px}
  .notes h2{font-size:23px}
  .guide-grid{grid-template-columns:repeat(2,1fr)}
  .guide-card{min-height:138px}
  .guide-card canvas{width:88px;height:88px}
}

/* Tablet and up: larger targets and readable notes. */
@media (min-width:760px) and (pointer:coarse){
  .depth-controls button{min-height:56px;font-size:16px}
  .play-controls .primary{min-height:56px;font-size:17px}
  #restart,.sound-toggle{min-height:56px;font-size:15px}
  .notes p{font-size:15px}
  .guide-grid{grid-template-columns:repeat(4,1fr)}
}

/* Tablet and up: once something is found, the discovery card sits beside the
   pond instead of below it. This is what keeps the page exactly one viewport
   tall in portrait (768x1024) as well as landscape: the card can never push
   the return control or the depth buttons past the fold. Before a discovery
   the pond keeps the full width, so the first screen has no empty column. */
@media (min-width:760px){
  .pond.is-selected .pond-layout{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:18px;align-items:start}
  .encounter.is-open{display:grid;margin-top:0;grid-template-columns:minmax(0,1fr);align-content:start;gap:12px}
  .portrait{width:100%;height:132px}
  .portrait canvas{width:132px;height:132px}
  .notes h2{font-size:24px}
  .encounter-actions button{flex:1 1 100%}
}

/* Landscape tablet: the window is the frame. The scene has to leave room for
   the header, the controls, the footer and the card inside 100dvh. Measured
   chrome above and below the scene is 440px at this breakpoint; without the
   cap the page grew to 781px in a 720px window. */
@media (min-width:900px) and (orientation:landscape){
  /* The window is the frame: the shell's back-link cushion is counted once in
     .pond's own padding. */
  .viewport{height:clamp(240px,min(54vh,calc(100dvh - 440px)),560px)}
  .lifecycle{grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:center}
}

/* With the card sharing the row the controls can wrap to two rows, so the
   chrome above and below the scene grows from 440px to about 462px. Leave room
   for that, or the return control and the depth buttons fall past the fold. */
@media (min-width:900px) and (orientation:landscape){
  .pond.is-selected .viewport{height:clamp(200px,min(52vh,calc(100dvh - 462px)),560px)}
}

/* Short landscape tablets: hide nothing important, just tighten the pond. */
@media (min-width:900px) and (max-height:700px) and (orientation:landscape){
  .viewport{height:clamp(200px,min(44vh,calc(100dvh - 440px)),360px)}
  .pond{padding-top:calc(max(14px,env(safe-area-inset-top)) + var(--sandpit-inset-top,0px));padding-bottom:12px}
}

@media (prefers-reduced-motion:reduce){*{transition:none!important}}
