/*
 * Calm, natural palette (Montessori classrooms favor earthy, uncluttered rooms).
 * Motion is slow and soft: fades, gentle slides, nothing flashing.
 */
:root {
  --paper: #F6F1E6;
  --card: #FBF8F1;
  --ink: #4A4036;
  --ink-soft: #9A8C7C;
  --line: #DDD3C2;
  --ground: #AEB792;
  --ground-edge: #9DA883;
  --hill-far: #D9DCC6;
  --hill-near: #C5CCAA;
  --fern: #849870;
  --fern-dark: #6B7F57;
  --sun: #F2DFB8;
  --moss: #6F8F5E;
  --shadow: 0 1.2vh 4vh rgba(74, 64, 54, .10), 0 .2vh .6vh rgba(74, 64, 54, .06);
  --letter-font: "Futura", "Century Gothic", "Avenir Next", "Trebuchet MS", sans-serif;
  --ui-font: "Avenir Next", "Avenir", "Segoe UI", system-ui, sans-serif;
  /* the stage unit: what creatures are sized in. 1vh on a computer or any landscape screen; on a tall portrait
     screen (a phone, an iPad held upright) a share of the width instead, so creatures never fill it */
  --su: min(1vh, calc(100vw / 90));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;          /* no "copy / look up" bubble on a long press */
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
/* touch screens: no scrolling, zooming or double-tap zoom while he plays */
html[data-touch=yes] #app { touch-action: none; }

/* ---------- scene ---------- */
#app { position: fixed; inset: 0; overflow: hidden; }

.sky { position: absolute; inset: 0; }
.sky-day   { background: linear-gradient(#E3ECE8 0%, #EEF0E6 45%, #F6F0E2 75%); }
.sky-dusk  { background: linear-gradient(#E3C3AA 0%, #EED3B8 45%, #F5E4CB 75%); opacity: 0; transition: opacity var(--dusk-dur, 110s) linear; }
.sky-night { background: linear-gradient(#1D2536 0%, #27324A 55%, #34405A 80%); opacity: 0; transition: opacity 8s ease; }
body.dusk .sky-dusk { opacity: 1; }
body.night .sky-night { opacity: 1; }

#sun {
  position: absolute; top: 9vh; right: 9vw;
  width: 13vh; height: 13vh; border-radius: 50%;
  background: var(--sun); opacity: .75;
  transition: background 20s, opacity 8s, box-shadow 8s;
}
body.dusk #sun { background: #EDB98E; }
body.night #sun { background: #E9E5D8; opacity: .9; box-shadow: 0 0 6vh rgba(233, 229, 216, .25); }

#stars { position: absolute; inset: 0; }
.star {
  position: absolute; width: .6vh; height: .6vh; border-radius: 50%;
  background: #F3EED9; opacity: 0; transition: opacity 3s;
}
.star.on { opacity: .55; }
.star.tw { animation: twinkle 2.4s ease-in-out both; }
@keyframes twinkle { 0% { opacity: 0; scale: .5; } 30% { opacity: 1; scale: 2.2; } 100% { opacity: .55; scale: 1; } }

/* layers, back to front: sky, sun, stars, scenery-back, ground, buddy-layer, herd (creatures), scenery-front, stage, strip, mouse */
#scenery-back { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
#ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 24vh; z-index: 2;
  background: linear-gradient(var(--ground-edge), var(--ground) 30%);
}
#scenery-front { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#scenery-back, #ground, #scenery-front { transition: filter 8s ease; }
body.night #scenery-back, body.night #ground, body.night #scenery-front { filter: brightness(.42) saturate(.7); }
/* the arrow-key friend walks on the ground strip, but in its own layer so it's lit like the other creatures */
#buddy-layer { position: absolute; left: 0; right: 0; bottom: 0; height: 24vh; z-index: 2; pointer-events: none; }
/* at night the creatures are moonlit too, so they sit in the scene instead of glowing on top of it
   (a firefly keeps its own light) */
:is(.critter, .flyer, #buddy) { color: var(--cc); }   /* each creature's color, set by js/app.js */
:is(.critter, .flyer, #buddy) .dino-svg { transition: filter 8s ease; }
body.night :is(.critter, .flyer, #buddy) .dino-svg:not(:has(.glow)) { filter: brightness(.76) saturate(.78); }

.fern {
  position: absolute; bottom: calc(100% - 2vh);
  transform: translateX(-50%); transform-origin: 50% 100%;
  color: var(--fern);
}
.fern svg { height: 100%; width: auto; display: block; }
.fern.front { bottom: -4vh; height: 26vh; color: var(--fern-dark); z-index: 2; }
.fern.sway { animation: sway 1.5s ease-in-out; }
@keyframes sway { 0% { rotate: 0deg; } 25% { rotate: 4deg; } 60% { rotate: -3deg; } 100% { rotate: 0deg; } }
.fern-svg { fill: currentColor; }
.fern-svg .stem { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

#tracks { position: absolute; left: 0; right: 0; bottom: 1vh; height: 10vh; }
.track {
  position: absolute; width: calc(4.6 * var(--su)); height: calc(5.5 * var(--su)); color: #6E7856;
  opacity: 0; transform: translate(-50%, -50%) rotate(90deg) scale(1.3);
  transition: opacity .35s ease, transform .35s ease-out;
}
.track.on { opacity: .55; transform: translate(-50%, -50%) rotate(90deg) scale(1); }
.track.off { opacity: 0; transition-duration: .6s; }
.print-svg { width: 100%; height: 100%; display: block; fill: currentColor; }

#buddy {
  position: absolute; bottom: 9vh; left: 22%;
  width: calc(17 * var(--su)); transform: translateX(-50%);
  transition: left .5s ease-in-out; z-index: 1;
}
.buddy-bob, .buddy-face { transform-origin: 50% 100%; }
.buddy-face { transition: scale .25s ease, --flip .25s ease; }
.buddy-face.left { scale: -1 1; }
.buddy-face svg { width: 100%; display: block; }
.buddy-bob { transition: scale .8s ease, translate .8s ease; }
.buddy-bob.walk { animation: walk .5s ease-in-out; }
.buddy-bob.hop  { animation: hop .55s cubic-bezier(.3, .7, .4, 1); }
.buddy-bob.duck { animation: duck .7s ease; }
.buddy-bob.bump { animation: bump .3s ease; }
.buddy-bob.asleep { scale: 1 .82; translate: 0 1vh; }
@keyframes walk { 0%, 50%, 100% { translate: 0 0; } 25%, 75% { translate: 0 -.8vh; } }
@keyframes hop  { 0% { translate: 0 0; } 40% { translate: 0 -6vh; } 100% { translate: 0 0; } }
@keyframes duck { 0%, 100% { scale: 1 1; } 30%, 70% { scale: 1.06 .82; } }
@keyframes bump { 0%, 100% { translate: 0 0; } 50% { translate: .8vh 0; } }

/* ---------- typing line (looks like a grown-up's document) ---------- */
#strip {
  position: absolute; top: 3.2vh; left: 50%; transform: translateX(-50%);
  width: min(70vw, 120vh); height: 8vh; padding: 0 2.4vh;
  display: flex; align-items: center;
  background: rgba(251, 248, 241, .75); border-radius: 2vh; box-shadow: var(--shadow);
  font-family: var(--letter-font); font-size: 4.6vh; color: var(--ink);
  white-space: pre; z-index: 6;
  transition: background 8s, color 8s;
}
#strip-text { display: flex; min-width: 0; overflow: hidden; justify-content: flex-end; }
.ch { display: inline-block; animation: chIn .25s ease-out; transition: opacity .2s, transform .5s ease-in; }
.ch.gone { opacity: 0; transform: translateY(.6vh); }
.ch.sent { opacity: 0; transform: translateY(-4vh); }
@keyframes chIn { from { opacity: 0; transform: translateY(.8vh); } }
#caret {
  flex: none; width: .35vh; height: 5vh; margin-left: .3vh;
  background: var(--ink-soft); border-radius: .2vh;
  animation: caret 1.8s ease-in-out infinite;
}
@keyframes caret { 0%, 100% { opacity: .75; } 50% { opacity: .15; } }
body.night #strip { background: rgba(52, 64, 90, .6); color: #E7E2D4; }

/* ---------- the big card ---------- */
#stage {
  position: absolute; left: 0; right: 0; top: 13vh; bottom: 25vh;
  display: grid; place-items: center; z-index: 5; pointer-events: none;
}
.card {
  grid-area: 1 / 1; position: relative;
  background: var(--card); color: var(--ink);
  border-radius: 4vh; box-shadow: var(--shadow); padding: 3vh 5vh;
  opacity: 0; transform: translateY(2vh) scale(.98);
  transition: opacity .5s ease, transform .7s cubic-bezier(.2, .8, .2, 1), background 8s, color 8s;
}
.card.in { opacity: 1; transform: none; }
.card.out { opacity: 0; transform: scale(.985); transition-duration: .35s; }
body.night .card { background: #313C55; color: #E7E2D4; box-shadow: none; }

.letter-card, .number-card {
  display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 5vh;
}
.glyph {
  font-family: var(--letter-font); font-weight: 500;
  font-size: min(25vh, 18vw); line-height: 1; color: var(--ct, var(--c));
}
.glyph .lower { font-size: .55em; margin-left: .12em; opacity: .7; }
.pic { width: min(50vh, 40vw); color: var(--c); }
.pic.small { width: min(34vh, 28vw); }
.pic svg { width: 100%; height: auto; display: block; overflow: visible; }
.card.in .pic { animation: walkIn .9s cubic-bezier(.2, .8, .2, 1) both, breathe 5s ease-in-out .9s infinite; }
.pic.nod { animation: nod .6s ease-in-out !important; }
@keyframes walkIn { from { opacity: 0; translate: 5vh 0; } to { opacity: 1; translate: 0 0; } }
@keyframes breathe { 0%, 100% { scale: 1; } 50% { scale: 1.012; } }
@keyframes nod { 0%, 100% { translate: 0 0; } 40% { translate: 0 -1.2vh; } }

.label {
  grid-column: 1 / -1; text-align: center; margin-top: 1.5vh;
  font-family: var(--letter-font); font-size: min(5.6vh, 4.4vw); letter-spacing: .02em;
}
.label .first { color: var(--ct, var(--c)); }

/* dinosaur illustrations (structure in js/art.js) */
.dino-svg {
  --edge: color-mix(in srgb, currentColor 42%, #20180F);
  --deep: color-mix(in srgb, currentColor 70%, #20180F);
}
.dino-svg .s-dark  { stop-color: color-mix(in srgb, currentColor 74%, #20180F); }
.dino-svg .s-base  { stop-color: currentColor; }
.dino-svg .s-light { stop-color: color-mix(in srgb, currentColor 58%, #F6EEDC); }
.dino-svg .edge > * { fill: var(--edge); stroke: var(--edge); stroke-width: 2.6; stroke-linejoin: round; }
.dino-svg .far > * { fill: var(--deep); stroke: var(--edge); stroke-width: 1.3; stroke-linejoin: round; }
.dino-svg .ground { opacity: .2; }   /* its fill is a soft gradient (js/art.js): */
.dino-svg .sh-a { stop-color: #3B3128; stop-opacity: 1; }
.dino-svg .sh-b { stop-color: #3B3128; stop-opacity: .72; }
.dino-svg .sh-c { stop-color: #3B3128; stop-opacity: 0; }
.dino-svg .side-shade { opacity: 0; }   /* the side away from a low sun (css/sky.css) */
.dino-svg .ss-a { stop-color: #1E1610; stop-opacity: 0; }
.dino-svg .ss-b { stop-color: #1E1610; stop-opacity: .6; }
.dino-svg .tex { opacity: .16; }
.dino-svg pattern * { fill: var(--edge); }
.dino-svg .stripe { fill: var(--edge); opacity: .2; }
.dino-svg .mark { fill: var(--edge); opacity: .25; }
.dino-svg .ln { fill: none; stroke: var(--edge); stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; opacity: .5; }
.dino-svg .ln.strong { opacity: .8; stroke-width: 1.3; }
.dino-svg .dot { fill: var(--edge); opacity: .75; }
.dino-svg .ivory { fill: #EFE7D3; stroke: #9C8D72; stroke-width: 1; stroke-linejoin: round; }
.dino-svg .far-ivory { fill: #D6CBB3; }
.dino-svg .beak { fill: color-mix(in srgb, currentColor 30%, #3B3129); stroke: var(--edge); stroke-width: .8; }
.dino-svg .plate { fill: color-mix(in srgb, currentColor 72%, #F1E3C4); stroke: var(--edge); stroke-width: 1.2; stroke-linejoin: round; }
.dino-svg .far-plate { fill: var(--deep); }
.dino-svg .feather { fill: var(--deep); stroke: var(--edge); stroke-width: 1; stroke-linejoin: round; }
.dino-svg .scute { fill: var(--deep); stroke: var(--edge); stroke-width: .9; }
.dino-svg .scute-hl { fill: #F6EEDC; opacity: .28; }
.dino-svg .membrane { fill: color-mix(in srgb, currentColor 72%, #F6EEDC); stroke: var(--edge); stroke-width: 1.2; stroke-linejoin: round; }
.dino-svg .far-membrane { fill: var(--deep); }
.dino-svg .bone { fill: none; stroke: var(--deep); stroke-width: 2.4; stroke-linecap: round; }
.dino-svg .limbline { fill: none; stroke: var(--deep); stroke-width: 2.6; stroke-linecap: round; }
.dino-svg .rim { fill: color-mix(in srgb, currentColor 45%, #FFF6E2); opacity: .85; }
.dino-svg .underside > * { fill: color-mix(in srgb, currentColor 62%, #20180F); }
.dino-svg .scales { opacity: .14; }
.dino-svg .scale-pat path { fill: none; stroke: var(--edge); stroke-width: .6; }
.dino-svg .mouth { fill: #4A302A; stroke: var(--edge); stroke-width: .8; stroke-linejoin: round; }
.dino-svg .tooth { fill: #F4EEDF; stroke: #A3937A; stroke-width: .45; stroke-linejoin: round; }
.dino-svg .ridge { fill: none; stroke: #B3A486; stroke-width: .7; stroke-linecap: round; }
.eye-ring { fill: color-mix(in srgb, currentColor 45%, #20180F); opacity: .9; }
.eye-iris { fill: #8E6230; }
.eye-pupil { fill: #1B140F; }
.eye-glint { fill: #FFF8EA; }
.dino-svg .lid { fill: none; stroke: #241B14; stroke-width: 1.4; stroke-linecap: round; }

/* numbers: eggs in a nest */
.nest-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-height: 26vh; }
.eggs {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  gap: 1.2vh; max-width: 44vh; margin-bottom: -4.5vh; position: relative; z-index: 1;
}
.egg { width: 7.5vh; opacity: 0; transform: translateY(1.5vh) scale(.7); transition: opacity .35s, transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.egg.on { opacity: 1; transform: none; }
.egg-svg .shell, .hatch-svg .shell { fill: #F0E7D5; stroke: #D6C8AE; stroke-width: 2; }
.egg-svg .speck, .hatch-svg .speck { fill: #CDBB9E; }
.egg-svg .egg-hl, .hatch-svg .egg-hl { fill: #FFFDF6; opacity: .55; }
.nest-svg { width: 92%; position: relative; z-index: 2; fill: #8E7250; }
.nest-svg .twig { fill: none; stroke: #6F5A40; stroke-width: 3; stroke-linecap: round; }
/* bugs world: ladybugs land on a leaf */
.leaf-wrap { position: relative; width: min(46vh, 40vw); margin-top: 3vh; }
.leaf-svg { width: 100%; display: block; fill: none; }
.leaf-svg .blade { fill: #86A85A; stroke: #5F7F3E; stroke-width: 2; stroke-linejoin: round; }
.leaf-svg .vein { stroke: #A9C47E; stroke-width: 1.6; stroke-linecap: round; }
.leaf-svg .stalk { stroke: #5F7F3E; stroke-width: 3; stroke-linecap: round; }
.egg.leaf-bug { position: absolute; width: 12.5%; translate: -50% -50%; rotate: var(--tilt, 0deg); }
.count-svg { display: block; width: 100%; }
.count-svg .lb-shell { fill: #C0412E; stroke: #2A221D; stroke-width: 1.6; }
.count-svg .lb-black { fill: #2A221D; }
.count-svg .lb-white { fill: #F4EEE2; }
.count-svg .lb-seam { stroke: #2A221D; stroke-width: 1.4; }
.count-svg .lb-leg { stroke: #2A221D; stroke-width: 2; stroke-linecap: round; fill: none; }
.count-svg .lb-hl { fill: #FFF6EA; opacity: .4; }

/* Enter: an egg hatches */
.hatch-card { padding: 4vh 9vh; }
.hatch-card .pic { width: min(32vh, 30vw); }
.hatch-svg .wob, .hatch-svg .shell-top { transform-box: fill-box; }
.hatch-svg .wob { transform-origin: 50% 100%; }
.hatch-card.wobble .wob { animation: wobble 1.2s ease-in-out; }
@keyframes wobble { 0%, 100% { rotate: 0deg; } 15% { rotate: -5deg; } 35% { rotate: 5deg; } 55% { rotate: -4deg; } 75% { rotate: 3deg; } }
.hatch-svg .crack {
  fill: none; stroke: #8E7C62; stroke-width: 2; stroke-linejoin: round;
  stroke-dasharray: 130; stroke-dashoffset: 130; transition: stroke-dashoffset .35s ease, opacity .4s;
}
.hatch-card.cracked .crack { stroke-dashoffset: 0; }
.hatch-card.open .crack { opacity: 0; }
.hatch-svg .shell-top { transform-origin: 15% 100%; transition: transform .8s cubic-bezier(.2, .8, .2, 1); }
.hatch-card.open .shell-top { transform: translate(-8px, -16px) rotate(-26deg); }
.hatch-svg .baby { transform: translateY(48px); transition: transform 1s cubic-bezier(.2, .8, .2, 1) .15s; }
.hatch-svg .baby-body { fill: var(--c); stroke: color-mix(in srgb, var(--c) 42%, #20180F); stroke-width: 1.3; }
.hatch-card.open .baby { transform: translateY(-8px); }

.welcome-card, .sleep-card { display: grid; justify-items: center; }
.welcome-card .pic, .sleep-card .pic { width: min(48vh, 44vw); }
.zzz { position: absolute; top: 3vh; right: 6vh; font-family: var(--letter-font); font-size: 4vh; color: #C9C3B2; }
.zzz span { display: inline-block; opacity: 0; animation: zzz 4.5s ease-in-out infinite; }
.zzz span:nth-child(2) { animation-delay: 1.5s; font-size: .8em; }
.zzz span:nth-child(3) { animation-delay: 3s; font-size: .6em; }
@keyframes zzz { 0% { opacity: 0; translate: 0 1vh; } 30% { opacity: .9; } 100% { opacity: 0; translate: 1vh -4vh; } }

/* mouse footprints */
#mouse-layer { position: fixed; inset: 0; pointer-events: none; z-index: 7; }
.mprint {
  position: fixed; width: 2.6vh; height: 3.1vh; color: #7D8763; pointer-events: none;
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  animation: mfade 1.8s ease-out forwards;
}
.mprint.big { width: 5vh; height: 6vh; }
@keyframes mfade { from { opacity: .7; } to { opacity: 0; } }

/* grown-up pause progress */
#combo-ring {
  position: fixed; top: 2vh; right: 2vh; width: 6vh; height: 6vh; border-radius: 50%; z-index: 50;
  background: conic-gradient(var(--ink-soft) calc(var(--p, 0) * 1turn), rgba(0, 0, 0, .08) 0);
  -webkit-mask: radial-gradient(circle, transparent 50%, #000 52%);
  mask: radial-gradient(circle, transparent 50%, #000 52%);
}
#combo-ring[hidden] { display: none; }

/* ---------- grown-up screens: the start sheet and the pause panel ----------
   Layout: one frosted sheet over the softly blurred live world. The three worlds are the centerpiece
   (live previews drawn by plate.html); the other choices form a settings list (label | control) with
   Mac-style segmented controls; the grown-up keys sit top right as real keycaps; Start is the only
   filled control. System fonts only (the app runs offline). */
#start-screen, #parent-panel {
  --gu-ink: #1E2420;                     /* text: deep green-black */
  --gu-ink-2: #58615A;                   /* secondary text */
  --gu-ink-3: #8A9289;                   /* placeholders */
  --gu-sheet: rgba(251, 251, 248, .93);
  --gu-line: rgba(30, 36, 32, .1);
  --gu-track: rgba(30, 36, 32, .065);    /* segmented control track, keys box */
  --gu-fern: #2F6A4C;                    /* the one accent: what's chosen, and Start */
  --gu-fern-deep: #24563D;
  --gu-ui: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --gu-round: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI Variable Display", "Segoe UI", sans-serif;
}
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; overflow: auto; -webkit-overflow-scrolling: touch;
  background: rgba(238, 242, 234, .3);
  -webkit-backdrop-filter: blur(14px) saturate(1.05); backdrop-filter: blur(14px) saturate(1.05);
  -webkit-user-select: text; user-select: text;
}
.overlay > * { margin: auto; }          /* centered, and still scrollable when taller than the screen */
/* the blurred world behind the start sheet rests (a moving world under a blur costs every frame) */
body[data-mode=start] #app * { animation-play-state: paused !important; }
/* while paused, creatures may still finish what they were doing: a soft tint instead of a blur */
#parent-panel { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(240, 243, 236, .66); }
.overlay[hidden] { display: none; }
html[data-os=mac] .os-other, html[data-os=other] .os-mac { display: none !important; }

.sheet {
  --gu-gap: clamp(12px, 1.6vw, 20px);    /* the worlds' column gap; the settings and Start share their grid */
  display: grid; gap: clamp(18px, 2.8vh, 28px);
  width: min(1060px, 100%); box-sizing: border-box;
  padding: clamp(22px, 3.2vh, 34px) clamp(22px, 3vw, 38px);
  color: var(--gu-ink); font: 400 15px/1.45 var(--gu-ui); text-wrap: pretty;
  background: var(--gu-sheet); border-radius: 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7), 0 0 0 .5px rgba(30, 36, 32, .14),
    0 2px 6px rgba(30, 36, 32, .06), 0 30px 80px -30px rgba(30, 36, 32, .45);
}
.sheet h1 { margin: 0; font: 700 34px/1.05 var(--gu-round); letter-spacing: -.015em; }
.sheet .gu-label { margin: 0; font-size: 15px; font-weight: 600; }
.sheet .help { margin: 7px 0 0; font-size: 13.5px; color: var(--gu-ink-2); }

/* header: the world's friend and the name; the grown-up keys */
.sheet .sheet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 28px; }
.sheet .brand { display: flex; align-items: center; gap: 16px; }
/* the box takes the cropped drawing's proportions (js/app.js fitHero sets --hero-ar), so every browser
   sizes it the same (Safari doesn't size an SVG's width from its viewBox when only the height is set) */
.sheet .brand .hero { flex: none; height: 74px; aspect-ratio: var(--hero-ar, 1.43); margin: -6px 0 -4px; }
.sheet .brand .hero svg { width: 100%; height: 100%; display: block; overflow: visible; }
.sheet .brand .sub { margin: 5px 0 0; font-size: 15px; color: var(--gu-ink-2); }
.sheet .keys-box { display: grid; gap: 7px; padding: 12px 16px 13px; border-radius: 14px; background: var(--gu-track); }
.sheet .keys-note { margin: 0; font-size: 12.5px; color: var(--gu-ink-2); }
.sheet .keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sheet .keys li { display: grid; grid-template-columns: 8.4em auto; align-items: center; gap: 10px; font-size: 13.5px; }
.sheet .caps { display: inline-flex; gap: 4px; }
.overlay kbd {
  display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 7px; box-sizing: border-box;
  font: 600 12px/1 var(--gu-ui); color: var(--gu-ink);
  background: linear-gradient(#FFFFFF, #F3F4F0); border: 1px solid rgba(30, 36, 32, .16);
  border-bottom-color: rgba(30, 36, 32, .3); border-radius: 6px; box-shadow: 0 1px 0 rgba(30, 36, 32, .07);
}

/* worlds: three live previews */
.sheet .worlds { display: grid; gap: 12px; }
.sheet .tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gu-gap); }
.sheet .tile { display: grid; align-content: start; cursor: pointer; }
.sheet .tile input, .sheet .seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.sheet .shot {
  position: relative; display: block; overflow: hidden; aspect-ratio: 16 / 9; margin-bottom: 10px;
  border-radius: 12px; background: #DCE3D9; box-shadow: 0 0 0 1px var(--gu-line);
  transition: box-shadow .18s ease;
}
/* the miniature is laid out like a laptop screen (four times the tile's width), then scaled down;
   it sits on the tile's bottom edge, so the land shows and some sky is left out */
.sheet .shot iframe {
  position: absolute; left: 0; bottom: 0; width: 400%; height: auto; aspect-ratio: 16 / 10;
  border: 0; transform: scale(.25); transform-origin: 0 100%; pointer-events: none;
}
/* a still picture always shows; the live preview fades in over it once drawn (js/app.js loadPlates) */
.sheet .shot { background: #DCE3D9 center bottom / 100% auto no-repeat; }
.sheet .tile:has(#world-dinos) .shot { background-image: url(img/plate-dinos.webp); }
.sheet .tile:has(#world-animals) .shot { background-image: url(img/plate-animals.webp); }
.sheet .tile:has(#world-bugs) .shot { background-image: url(img/plate-bugs.webp); }
.sheet .shot iframe { opacity: 0; transition: opacity .5s ease; }
.sheet .shot.live iframe { opacity: 1; }
.sheet .tile:hover .shot { box-shadow: 0 0 0 1px rgba(30, 36, 32, .3); }
.sheet .tile:has(input:checked) .shot { box-shadow: 0 0 0 3px var(--gu-fern); }
.sheet .tile:has(input:focus-visible) .shot { outline: 3px solid color-mix(in srgb, var(--gu-fern) 40%, transparent); outline-offset: 3px; }
.sheet .tick {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--gu-fern); box-shadow: 0 0 0 2px #FFF, 0 1px 4px rgba(0, 0, 0, .2);
  opacity: 0; transform: scale(.6); transition: opacity .18s ease, transform .18s ease;
}
.sheet .tick::after {
  content: ''; position: absolute; left: 8.5px; top: 5px; width: 5px; height: 10px;
  border: solid #FFF; border-width: 0 2.2px 2.2px 0; transform: rotate(45deg);
}
.sheet .tile:has(input:checked) .tick { opacity: 1; transform: none; }
.sheet .tile-name { font-size: 16px; font-weight: 600; }
.sheet .tile-desc { font-size: 13.5px; color: var(--gu-ink-2); }

/* the other choices, as a settings list */
.sheet .rows { display: grid; gap: 18px; padding-top: clamp(16px, 2.4vh, 24px); border-top: 1px solid var(--gu-line); }
.sheet .row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 6px var(--gu-gap); }
.sheet .row > :last-child { grid-column: 2 / -1; }          /* controls line up with the second world */
.sheet .row > .gu-label { padding-top: 8px; }
.sheet .seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; background: var(--gu-track); }
.sheet .seg label { cursor: pointer; }
.sheet .seg span {
  display: inline-block; padding: 7px 14px; border-radius: 8px; white-space: nowrap;
  font-size: 14.5px; font-weight: 500; color: var(--gu-ink-2);
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.sheet .seg label:hover span { color: var(--gu-ink); }
.sheet .seg input:checked + span {
  color: var(--gu-ink); font-weight: 600; background: #FFF;
  box-shadow: 0 1px 2px rgba(30, 36, 32, .15), 0 0 0 .5px rgba(30, 36, 32, .1);
}
.sheet .seg input:focus-visible + span { outline: 2px solid var(--gu-fern); outline-offset: 1px; }
/* each choice explains itself: only the chosen one's note shows */
.setup:has(#play-letters:checked) .help-explore, .setup:has(#play-explore:checked) .help-letters,
.setup:has(#m0:checked) .help-timed, .setup:not(:has(#m0:checked)) .help-open { display: none; }
.setup:has(#kb-off:checked) .help-kb-on, .setup:not(:has(#kb-off:checked)) .help-kb-off { display: none; }
#kid-name {
  width: min(320px, 100%); height: 38px; box-sizing: border-box; padding: 0 12px;
  font: 400 15px var(--gu-ui); color: var(--gu-ink);
  background: #FFF; border: 1px solid rgba(30, 36, 32, .18); border-radius: 9px;
  box-shadow: inset 0 1px 1px rgba(30, 36, 32, .04);
}
#kid-name::placeholder { color: var(--gu-ink-3); }
#kid-name:focus { outline: none; border-color: var(--gu-fern); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gu-fern) 22%, transparent); }

/* footer: a tip for the first session, and Start */
.sheet .sheet-foot {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: 14px var(--gu-gap);
  padding-top: clamp(16px, 2.4vh, 22px); border-top: 1px solid var(--gu-line);
}
.sheet .tip { grid-column: 1 / 3; margin: 0; max-width: 62ch; font-size: 13.5px; color: var(--gu-ink-2); }
.sheet .tip b { font-weight: 600; color: var(--gu-ink); }

/* buttons */
.sheet .btn {
  height: 40px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  font: 500 15px/1 var(--gu-ui); color: var(--gu-ink);
  background: #FFF; border: 1px solid rgba(30, 36, 32, .16); box-shadow: 0 1px 1px rgba(30, 36, 32, .05);
}
.sheet .btn:hover { background: #F5F6F2; }
.sheet .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--gu-fern) 40%, transparent); outline-offset: 2px; }
.sheet .btn.primary {
  color: #FFF; font-weight: 600; background: var(--gu-fern); border-color: var(--gu-fern-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 1px 2px rgba(30, 36, 32, .2);
}
.sheet .btn.primary:hover { background: var(--gu-fern-deep); }
.sheet .start { grid-column: 3; width: 100%; height: 48px; padding: 0 28px; font-size: 16px; border-radius: 12px; }  /* as wide as the third world */

/* the pause panel */
#parent-panel .pause { width: min(560px, 100%); gap: 22px; }
#parent-panel h1 { font-size: 28px; }
#parent-panel .time-left { margin: -6px 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 15px; color: var(--gu-ink-2); }
#parent-panel .time-left .num { font: 700 46px/1 var(--gu-round); color: var(--gu-ink); font-variant-numeric: tabular-nums; }
#parent-panel .actions { display: flex; flex-wrap: wrap; gap: 10px; }
#parent-panel .actions .btn { flex: 1 1 auto; height: 44px; white-space: nowrap; }
#parent-panel .actions .primary { flex-grow: 1.6; font-size: 16px; }
#parent-panel .volume {
  display: grid; grid-template-columns: auto 18px minmax(0, 1fr) 18px; align-items: center; gap: 10px;
  padding-top: 18px; border-top: 1px solid var(--gu-line);
}
#parent-panel .volume label { margin-right: 8px; font-weight: 600; }
#parent-panel .volume svg { width: 18px; height: 18px; fill: none; stroke: var(--gu-ink-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#parent-panel input[type=range] { width: 100%; margin: 0; accent-color: var(--gu-fern); }
#parent-panel input[type=range]:focus-visible { outline: 3px solid color-mix(in srgb, var(--gu-fern) 40%, transparent); outline-offset: 4px; }
#parent-panel .quit { margin: -4px 0 0; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--gu-ink-2); }

/* narrower screens (820 px portrait and up) */
@media (max-width: 900px) {
  .sheet .row { grid-template-columns: minmax(0, 1fr); }
  .sheet .row > :last-child { grid-column: auto; }
  .sheet .row > .gu-label { padding-top: 0; }
  .sheet .sheet-head { align-items: flex-start; }
  .sheet .sheet-foot { grid-template-columns: minmax(0, 1fr) auto; }
  .sheet .tip { grid-column: 1; }
  .sheet .start { grid-column: 2; min-width: 200px; }
}
/* shorter laptop screens: a little more compact, so everything fits without scrolling */
@media (max-height: 820px) and (min-width: 901px) {
  .overlay { padding-block: 16px; }
  .sheet { gap: 16px; padding-block: 22px 20px; }
  .sheet .shot { aspect-ratio: 2 / 1; margin-bottom: 8px; }
  .sheet .brand .hero { height: 62px; }
  .sheet h1 { font-size: 30px; }
  .sheet .rows { gap: 14px; padding-top: 16px; }
  .sheet .help { margin-top: 5px; }
  .sheet .sheet-foot { padding-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet .shot, .sheet .tick, .sheet .seg span { transition: none; }
}

/* the session winds down (its last two minutes) and ends (bedtime) with a soft dimming, whatever the real
   time of day outside: an overlay above the creatures and the scenery, below the cards (js/app.js) */
#veil { position: absolute; inset: 0; z-index: 4; pointer-events: none; background: #1E2638; opacity: 0; transition: opacity 6s ease; }
body.winding #veil { opacity: .14; transition-duration: 110s; }
body.resting #veil { opacity: .32; transition-duration: 8s; }
body.night.resting #veil { opacity: .16; }

/* ---------- phones and tablets ----------
   js/device.js tells the page what it runs on: html[data-touch=yes|no] (a touch screen),
   [data-input=touch|keys] (switches to keys when a real keyboard is used), [data-device=phone|tablet|desktop],
   [data-platform=ios|android|mac|windows|other], [data-standalone=yes|no] (opened from the Home Screen). */
html[data-touch=yes] .for-keys, html:not([data-touch=yes]) .for-touch { display: none !important; }
html:not([data-platform=ios]) .on-ios, html:not([data-platform=android]) .on-android { display: none !important; }
html[data-standalone=yes] .not-standalone { display: none !important; }

/* the notch and the home bar stay clear of the grown-up screens */
.overlay {
  padding-top: max(env(safe-area-inset-top), clamp(12px, 4vh, 48px));
  padding-bottom: max(env(safe-area-inset-bottom), clamp(12px, 4vh, 48px));
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
}
html[data-touch=yes] #strip { top: max(3.2vh, calc(env(safe-area-inset-top) + 8px)); }

/* the touch version of the grown-up box: a hold-the-corner picture and a lock */
.sheet .for-touch .keys li { grid-template-columns: 22px auto; }
.sheet .corner-icon, .sheet .lock-icon { width: 22px; height: 22px; background: center / contain no-repeat; }
.sheet .corner-icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Crect x='1.5' y='1.5' width='19' height='19' rx='4' fill='none' stroke='%2358615A' stroke-width='1.4'/%3E%3Ccircle cx='15.5' cy='6.5' r='3.2' fill='%232F6A4C'/%3E%3C/svg%3E"); }
.sheet .lock-icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Crect x='4.5' y='9.5' width='13' height='10' rx='2.2' fill='none' stroke='%2358615A' stroke-width='1.4'/%3E%3Cpath d='M7.5 9.5V7a3.5 3.5 0 0 1 7 0v2.5' fill='none' stroke='%2358615A' stroke-width='1.4'/%3E%3C/svg%3E"); }
.sheet .tip .on-ios { display: block; margin-top: 4px; }
#kid-name { font-size: 16px; }   /* 16 px or more, so iPhone doesn't zoom in when it's tapped */

/* phones: the sheet becomes one column; each world is a row with its picture beside its name */
@media (max-width: 640px) {
  .sheet { padding: 18px 16px; border-radius: 16px; gap: 16px; }
  .sheet h1 { font-size: 28px; }
  .sheet .brand .hero { height: 46px; }
  .sheet .brand .sub { font-size: 14px; }
  .sheet .keys-box { width: 100%; }
  .sheet .tiles { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .sheet .tile { grid-template-columns: minmax(0, 46%) minmax(0, 1fr); column-gap: 14px; align-items: center; }
  .sheet .shot { grid-row: span 2; margin-bottom: 0; border-radius: 10px; }
  .sheet .tile-name { align-self: end; }
  .sheet .tile-desc { align-self: start; }
  .sheet .tick { top: 6px; right: 6px; width: 20px; height: 20px; }
  .sheet .tick::after { left: 7px; top: 4px; width: 4px; height: 8px; }
  .sheet .seg { display: flex; width: 100%; box-sizing: border-box; }      /* equal segments across the width */
  .sheet .seg label { flex: 1 1 0; min-width: 0; }
  .sheet .seg span { display: block; padding: 7px 2px; font-size: 13.5px; text-align: center; }
  #kid-name { width: 100%; }
  .sheet .sheet-foot { grid-template-columns: minmax(0, 1fr); }
  .sheet .tip { grid-column: 1; }
  .sheet .start { grid-column: 1; min-width: 0; }
}

/* the grown-up pause on a touch screen: a faint dot in the top-right corner; hold it until the ring fills */
#grownup-corner {
  display: none; position: fixed; top: 0; right: 0; z-index: 60; touch-action: none;
  width: calc(78px + env(safe-area-inset-right)); height: calc(78px + env(safe-area-inset-top));
}
html[data-touch=yes] body:is([data-mode=play], [data-mode=sleep]) #grownup-corner { display: block; }
#grownup-corner span {
  position: absolute; top: calc(18px + env(safe-area-inset-top)); right: calc(18px + env(safe-area-inset-right));
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(74, 64, 54, .2);
}
body.night #grownup-corner span { border-color: rgba(231, 226, 212, .22); }
html[data-touch=yes] #combo-ring {
  top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); width: 38px; height: 38px;
}

/* the on-screen keyboard: touch screens, Letters & numbers, laid out like a real keyboard */
html[data-input=touch] {
  --key: clamp(22px, min(calc((100vw - 20px) / 12.75), 7.6vh), 62px);   /* the top row (10 keys + Backspace) always fits */
  --kb-h: calc(var(--key) * 5.06 + env(safe-area-inset-bottom));
}
#softkeys { display: none; }
html[data-input=touch] body:not([data-softkeys=off]):is([data-mode=play], [data-mode=sleep], [data-mode=paused]) #softkeys { display: grid; }
/* ...and the world sits above it, so creatures stand on the grass instead of behind the keys */
html[data-input=touch] body:not([data-softkeys=off]):is([data-mode=play], [data-mode=sleep], [data-mode=paused]) #app { bottom: var(--kb-h); }
/* the creatures are sized to the world that's left above the keys */
html[data-input=touch] body:not([data-softkeys=off]):is([data-mode=play], [data-mode=sleep], [data-mode=paused]) { --su: min(calc((100vh - var(--kb-h)) / 100), calc(100vw / 90)); }
#softkeys {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; touch-action: none;
  align-content: start; gap: calc(var(--key) * .12);
  padding: calc(var(--key) * .22) max(10px, env(safe-area-inset-right)) calc(var(--key) * .26 + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: rgba(241, 238, 228, .94); border-top: 1px solid rgba(74, 64, 54, .1);
}
.sk-row { display: flex; justify-content: center; gap: calc(var(--key) * .12); }
.sk {
  display: grid; place-items: center; width: var(--key); height: calc(var(--key) * .82);
  font: 500 calc(var(--key) * .42) / 1 var(--letter-font); color: var(--ink);
  background: #FFFDF8; border-radius: calc(var(--key) * .16);
  box-shadow: 0 2px 0 rgba(74, 64, 54, .2), 0 1px 3px rgba(74, 64, 54, .1);
  transition: translate .08s ease, box-shadow .08s ease, background-color .08s ease;
}
.sk.wide { width: calc(var(--key) * 1.55); font-family: var(--ui-font); font-size: calc(var(--key) * .38); }
.sk.space { width: calc(var(--key) * 6.2); }
.sk.down { translate: 0 2px; background: #EEE8DA; box-shadow: 0 0 0 rgba(74, 64, 54, .2), 0 1px 2px rgba(74, 64, 54, .1); }
body.night #softkeys { background: rgba(38, 46, 64, .9); border-top-color: rgba(255, 255, 255, .06); }
body.night .sk { background: #3A4560; color: #E7E2D4; box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
/* with the keys on screen the world is shorter: the cards use all of it, and get a little smaller */
html[data-input=touch] body:not([data-softkeys=off]) #stage { top: max(10vh, calc(env(safe-area-inset-top) + 8vh)); bottom: 2vh; }
html[data-input=touch] body:not([data-softkeys=off]) #stage .card { scale: .8; }
@media (max-height: 560px) { html[data-input=touch] body:not([data-softkeys=off]) #stage .card { scale: .5; } }
@media (prefers-reduced-motion: reduce) { .sk { transition: none; } }
/* shorter laptop screens keep the start sheet's tighter margins, so it fits without scrolling */
@media (max-height: 820px) and (min-width: 901px) {
  .overlay { padding-top: max(env(safe-area-inset-top), 16px); padding-bottom: max(env(safe-area-inset-bottom), 16px); }
}

/* the typing line (Letters & numbers) stays out of sight behind the start screen */
body[data-mode=start] #strip { visibility: hidden; }

/* while paused, the stage card (hello, a letter, goodnight) steps back so it doesn't collide with the panel */
body[data-mode=paused] #stage { visibility: hidden; }
/* after bedtime the world behind stays dark, and the page glows like a lamp-lit card */
body.night #parent-panel { background: rgba(18, 24, 34, .45); }

/* ---------- Explore: the key tag each creature wears (js/app.js) ----------
   A small keycap with the letter over the creature's head while it's here. It sits inside the
   creature's travel wrapper (.b-go), so it walks, hops and flies along; it turns with the creature
   so it never reads backwards, nods when the key is pressed again and fades as the creature leaves. */
.key-tag {
  position: absolute; translate: -50% 0; z-index: 2; pointer-events: none;
  font-family: var(--letter-font); font-weight: 500; line-height: 1;
  transition: scale .35s ease, opacity .6s ease;
}
.c-face.left .key-tag { scale: -1 1; }
.key-tag span {
  display: block; min-width: 1.42em; padding: .18em .3em .2em; text-align: center; border-radius: .26em;
  color: color-mix(in srgb, var(--c) 40%, #2C241D);
  background: #FBF8F1;
  box-shadow: 0 .12em 0 color-mix(in srgb, var(--c) 80%, #6B5E4E), 0 .24em .5em rgba(60, 48, 36, .16);
  opacity: 0; translate: 0 .4em;
  animation: keyTagIn .5s cubic-bezier(.2, .8, .2, 1) .05s forwards;
}
@keyframes keyTagIn { to { opacity: .95; translate: 0 0; } }
.key-tag.out { opacity: 0; }
body.dusk .key-tag span { background: #F4EADA; }
body.night .key-tag:not(.out) { opacity: .7; }   /* (everyone goes home at bedtime; this is for previews) */
@media (prefers-reduced-motion: reduce) {
  .key-tag span { translate: 0 0; animation-name: keyTagFade; }
}
@keyframes keyTagFade { to { opacity: .95; } }

/* eyes */
.eye-mammal { fill: #22180F; }
.eye-bird { fill: #6B4A26; }
.eye-owl { fill: #E2B23E; }
.eye-bug { fill: #241D18; }
.dino-svg .eye-ring-light { fill: #F2EBDD; }

/* hatchlings */
.hatch-svg .chick, .hatch-svg .chick-fluff { fill: #EFCB52; }
.hatch-svg .chick-beak { fill: #E08A35; }
.hatch-svg .cat-baby { fill: #93B65A; }
.hatch-svg .cat-stripe { fill: none; stroke: #7A9A48; stroke-width: 1.2; }
.hatch-svg .antenna { fill: none; stroke: #2A211B; stroke-width: 1.4; stroke-linecap: round; }

.dino-svg .gloss { fill: #FFFFFF; opacity: .3; }

.dino-svg .fur { opacity: .2; }
.dino-svg .fur-pat path { fill: none; stroke: var(--edge); stroke-width: .5; stroke-linecap: round; }

/* previews jump straight to a time of day */
body.instant, body.instant *, body.instant *::before, body.instant *::after { transition: none !important; }
/* a freshly built scene shows its look at once (js/app.js snapStyles) */
#app.snap, #app.snap *, #app.snap *::before, #app.snap *::after { transition: none !important; }
