/* Get Cracking — styles
   Visual language: chunky dark outlines, flat warm fills, toy-like buttons
   with an offset "3D" shadow, hand-lettered caps for labels. */

@font-face { font-family: 'Fredoka'; src: url('../fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Patrick Hand SC'; src: url('../fonts/patrick-hand-sc.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --out: #3b2224;
  --cream: #fdf3e4;
  --paper: #efe7da;
  --teal: #62b5c5;
  --teal-dk: #4b9bab;
  --gold: #e0a43c;
  --ink: #4a3418;
  --clay: #d98a64;
  --clay-dk: #b8694a;
  --leaf: #a9d36b;
  --leaf-dk: #7fb04a;
  --berry: #c9483f;
  --scene-bg: #5e6f55;
  --hold: 1.5s;
  --hand: 'Patrick Hand SC', 'Fredoka', 'Chalkboard SE', 'Comic Sans MS', system-ui, sans-serif;
  --round: 'Fredoka', ui-rounded, 'Nunito', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--scene-bg);
  color: var(--out);
  font-family: var(--round);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  transition: background-color .6s;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------------------------------------------------------------- pills */
.pill {
  font-family: var(--hand);
  background: #e9e4dc;
  border: 5px solid var(--out);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--out);
  padding: .25em 1.1em .3em;
  letter-spacing: .04em;
  text-align: center;
  line-height: 1.05;
}

/* =============================================================== SETUP */
#setup { overflow: hidden; }
.setup-bg { position: absolute; inset: -20px; width: calc(100% + 40px); height: calc(100% + 40px); filter: blur(2px) saturate(.85); }
.setup-scrim { position: absolute; inset: 0; background: rgba(70, 62, 60, .42); }
.setup-inner {
  position: absolute; left: 50%; top: 0;
  width: min(92vw, 420px);
  transform-origin: 50% 0;
  transform: translateX(-50%) scale(var(--fit, 1));
  display: flex; flex-direction: column; align-items: center;
  padding: calc(18px + var(--safe-t)) 0 calc(14px + var(--safe-b));
  gap: 14px;
}
.title-pill { font-size: 28px; margin: 0; max-width: 100%; }

.timer-box {
  position: relative;
  width: 100%;
  background: var(--teal);
  border: 6px solid var(--out);
  border-radius: 32px;
  box-shadow: 0 8px 0 var(--out), inset 0 -12px 0 var(--teal-dk);
  padding: 14px 14px 26px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}

/* the egg-timer dial: twist the ring, or use − / + in the corners */
.dial-wrap { position: relative; width: 100%; aspect-ratio: 1; }
.dial { display: block; width: 100%; height: 100%; overflow: visible; touch-action: none; cursor: grab; border-radius: 50%; }
.dial.dragging { cursor: grabbing; }
.dial:focus-visible { outline-offset: -2px; }
.dial-fill { transition: stroke-dasharray .12s ease-out; }
.dial-knob { transition: transform .12s ease-out; filter: drop-shadow(0 4px 0 rgba(59, 34, 36, .35)); }
.dial.dragging .dial-fill, .dial.dragging .dial-knob { transition: none; }
.dial-time {
  font-family: var(--round); font-weight: 700; font-size: 60px; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; fill: var(--ink); pointer-events: none;
  transform-box: fill-box; transform-origin: center;
}
.step-btn {
  position: absolute; bottom: 0; width: 56px; height: 56px; border-radius: 50%; padding: 0;
  background: var(--cream); border: 4px solid var(--out); box-shadow: 0 5px 0 var(--out);
  display: grid; place-items: center; touch-action: none;
  transition: transform .08s, box-shadow .08s, opacity .15s;
}
.step-btn svg { width: 34px; height: 34px; display: block; }
.step-minus { left: 0; } .step-plus { right: 0; }
.step-btn:disabled { opacity: .45; cursor: default; }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 92%; height: 22px; border-radius: 99px;
  border: 5px solid var(--out);
  background: linear-gradient(90deg, var(--berry) 0 var(--p, 10%), #5a2a2c var(--p, 10%) 100%);
  margin: 4px 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 46px; border-radius: 10px;
  background: #8a5a3b; border: 5px solid var(--out); box-shadow: inset 0 -6px 0 #6b4430, 0 3px 0 var(--out); cursor: grab;
}
input[type=range]::-moz-range-thumb { width: 22px; height: 38px; border-radius: 10px; background: #8a5a3b; border: 5px solid var(--out); cursor: grab; }

.presets { display: flex; gap: 6px; width: 100%; }
.presets button {
  flex: 1; min-width: 0; height: 50px; padding: 0 0 2px; border-radius: 16px;
  font-family: var(--round); font-weight: 700; font-size: 21px; color: var(--ink);
  background: var(--cream); border: 4px solid var(--out); box-shadow: 0 5px 0 var(--out);
  transition: transform .08s, box-shadow .08s, background-color .15s;
}
.presets button.on { background: var(--gold); }

/* every chunky button sinks onto its shadow when pressed */
.presets button:active, .icon-btn:active, .start-btn:active, .round-btn:active, .opt:active, .step-btn:not(:disabled):active,
.tray-btns button:active, .scene-card:active, .sheet-close:active, .tray-close:active, .icon-row button:active, .photo-add:active {
  transform: translateY(3px); box-shadow: 0 1px 0 var(--out);
}

.start-btn {
  width: 100%; height: 88px; margin-top: 4px; padding: 0 0 8px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: var(--leaf); border: 6px solid var(--out); border-radius: 30px;
  box-shadow: 0 8px 0 var(--out), inset 0 -10px 0 var(--leaf-dk);
  transition: transform .08s, box-shadow .08s;
}
.start-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--out), inset 0 -10px 0 var(--leaf-dk); }
.start-ico { width: 44px; height: 44px; flex: none; }
.start-ico path { fill: var(--cream); stroke: var(--out); stroke-width: 4.5; stroke-linejoin: round; }
.start-label { font-family: var(--hand); font-size: 46px; letter-spacing: .1em; line-height: 1; }

.toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.setup-toggle { min-height: 44px; margin-top: 2px; }
.switch { position: relative; width: 70px; height: 36px; border-radius: 99px; background: #8d8784; border: 4px solid var(--out); flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: var(--cream); border: 4px solid var(--out); transition: transform .2s cubic-bezier(.4,1.6,.6,1); }
input:checked + .switch { background: var(--leaf-dk); }
input:checked + .switch::after { transform: translateX(34px); }
input:focus-visible + .switch { outline: 4px solid #fff; outline-offset: 3px; }
.toggle-text { font-family: var(--hand); font-size: 22px; color: var(--cream); text-shadow: 0 2px 0 var(--out), 0 -1px 0 var(--out), 2px 0 0 var(--out), -2px 0 0 var(--out); }

.quick-icons { display: flex; gap: 10px; width: 100%; }
.icon-btn {
  flex: 1; min-width: 0; height: 76px; border-radius: 20px; background: var(--cream); border: 4px solid var(--out); box-shadow: 0 5px 0 var(--out);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 0;
  transition: transform .08s, box-shadow .08s;
}
.icon-btn .ico { width: 38px; height: 38px; margin-bottom: 1px; }
.icon-btn .ico svg { width: 100%; height: 100%; display: block; }
.icon-btn small { font-family: var(--hand); font-size: 16px; }

/* short, wide screens: dial on the left, everything else beside it */
@media (orientation: landscape) and (max-height: 620px) {
  .setup-inner {
    width: 700px; display: grid; grid-template-columns: 340px 1fr; column-gap: 30px; row-gap: 14px;
    align-items: center; justify-items: center;
  }
  .timer-box { grid-column: 1; grid-row: 1 / span 4; }
  .title-pill, .start-btn, .setup-toggle, .quick-icons { grid-column: 2; }
}

/* drawn icons (js/icons.js) */
.gc-ico { overflow: visible; }

/* =============================================================== TIMER */
#timer { background: var(--scene-bg); }
.stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.hatch-pill {
  position: absolute; top: calc(18px + var(--safe-t)); left: 50%; transform: translate(-50%, -160%) scale(.6);
  font-size: clamp(28px, 7vw, 44px); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: transform .5s cubic-bezier(.3,1.6,.5,1), opacity .3s;
}
.hatch-pill.show { transform: translate(-50%, 0) scale(1); opacity: 1; }
/* the clock: big, centred at the top. `translate` (not transform) centres it, so the
   bump animation in adjust() can scale it without knocking it off centre */
.time-pill {
  position: absolute; top: calc(14px + var(--safe-t)); left: 50%; translate: -50% 0;
  font-family: var(--round); font-weight: 700; font-size: clamp(56px, 17vw, 100px); letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; line-height: 1;
  padding: .1em .45em .12em; border-width: 6px; box-shadow: 0 7px 0 var(--out); background: var(--cream); color: var(--ink);
  pointer-events: none; white-space: nowrap;
}
.time-pill.hide { display: none; }
.time-pill.paused { animation: pill-paused 1.8s ease-in-out infinite; }
@keyframes pill-paused { 50% { opacity: .5; } }
.tap-hint { position: absolute; left: 0; top: 0; width: 64px; height: 64px; pointer-events: none; opacity: 0; filter: drop-shadow(0 3px 0 var(--out)); }
.tap-hint svg { width: 100%; height: 100%; }
.tap-hint.show { opacity: 1; animation: tap-bob 1.1s ease-in-out infinite; }
@keyframes tap-bob { 50% { transform: translate(0, -14px) rotate(-8deg); } }

.lock-btn, .hold-btn {
  position: absolute; border: 4px solid var(--out); background: rgba(253, 243, 228, .78); box-shadow: 0 4px 0 var(--out);
  display: grid; place-items: center; padding: 0;
}
.lock-btn { left: 16px; bottom: calc(16px + var(--safe-b)); width: 58px; height: 58px; border-radius: 50%; opacity: .55; touch-action: none; }
.lock-ico svg { width: 32px; height: 32px; display: block; }
.lock-btn.holding, .lock-btn:focus-visible { opacity: 1; }
.hold-ring { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); transform: rotate(-90deg); pointer-events: none; }
.hold-ring circle { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 0 1; opacity: 0; transition: stroke-dasharray .2s, opacity .2s; }
.holding .hold-ring circle { opacity: 1; stroke-dasharray: 1 1; transition: stroke-dasharray var(--hold) linear; }
.lock-tip {
  /* sits above the lock so it never hides behind the on-screen − / + / pause buttons */
  position: absolute; left: 14px; bottom: calc(88px + var(--safe-b)); font-family: var(--hand); font-size: 19px; color: var(--cream);
  background: rgba(59, 34, 36, .88); padding: 5px 13px 6px; border-radius: 12px; opacity: 0; transform: translateY(8px); transition: .25s; pointer-events: none;
}
.lock-tip.show { opacity: 1; transform: none; }

.kid-controls { position: absolute; right: 16px; bottom: calc(16px + var(--safe-b)); display: flex; gap: 10px; }
.round-btn { width: 62px; height: 62px; border-radius: 50%; background: var(--cream); border: 4px solid var(--out); box-shadow: 0 4px 0 var(--out); font-weight: 700; font-size: 21px; padding: 0; display: grid; place-items: center; transition: transform .08s, box-shadow .08s; }
.round-btn svg { width: 30px; height: 30px; }
.kid-controls .hidden { display: none; }

.hold-btn {
  left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%) translateY(140%);
  height: 60px; border-radius: 999px; padding: 0 22px 0 16px; display: flex; gap: 10px; align-items: center; width: max-content; white-space: nowrap;
  font-family: var(--hand); font-size: 20px; transition: transform .45s cubic-bezier(.3,1.4,.5,1); touch-action: none;
}
.hold-btn > span svg { width: 34px; height: 34px; display: block; }
.hold-btn::after { content: ''; position: absolute; left: 0; bottom: 0; height: 6px; width: 0; background: var(--gold); border-radius: 99px; transition: width .2s; }
.hold-btn.holding::after { width: 100%; transition: width var(--hold) linear; }
.hold-btn.show { transform: translateX(-50%) translateY(0); }

.next-card {
  position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 30px) scale(.8); opacity: 0;
  display: flex; align-items: center; gap: 14px; padding: 10px 22px 10px 12px;
  background: var(--cream); border: 5px solid var(--out); border-radius: 22px; box-shadow: 0 6px 0 var(--out);
  transition: .5s cubic-bezier(.3,1.5,.5,1); pointer-events: none; width: max-content; max-width: 92vw;
}
.next-card.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.next-icon { width: 64px; height: 64px; border-radius: 16px; background: #e9e4dc; border: 4px solid var(--out); display: grid; place-items: center; overflow: hidden; flex: none; }
.next-icon svg { width: 46px; height: 46px; }
.next-icon img { width: 100%; height: 100%; object-fit: cover; }
.next-card small { display: block; font-family: var(--hand); font-size: 16px; opacity: .7; }
.next-card strong { font-family: var(--hand); font-size: 28px; font-weight: 400; line-height: 1; }

.tray {
  position: absolute; left: 50%; bottom: calc(12px + var(--safe-b)); width: min(94vw, 560px);
  transform: translate(-50%, 130%); transition: transform .35s cubic-bezier(.3,1.2,.5,1);
  background: var(--paper); border: 5px solid var(--out); border-radius: 26px; box-shadow: 0 7px 0 var(--out);
  padding: 14px 16px 18px; z-index: 5;
}
.tray.show { transform: translate(-50%, 0); }
.tray-title { font-family: var(--hand); font-size: 22px; text-align: center; margin: 4px 0 14px; }
.tray-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tray-btns button {
  height: 74px; border-radius: 16px; background: var(--cream); border: 4px solid var(--out); box-shadow: 0 4px 0 var(--out);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--hand); font-size: 17px; line-height: 1;
  transition: transform .08s, box-shadow .08s;
}
.tray-btns button span { font-family: var(--round); font-weight: 700; font-size: 24px; margin-bottom: 4px; height: 30px; display: grid; place-items: center; }
.tray-btns button span svg { width: 30px; height: 30px; display: block; }
.tray-btns button.danger { background: #f6c9bd; }
.tray-btns button[hidden] { display: none; }
.tray-close { position: absolute; right: 8px; top: 6px; width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--out); box-shadow: 0 3px 0 var(--out); background: var(--cream); padding: 0; display: grid; place-items: center; }
.tray-close svg, .sheet-close svg { width: 60%; height: 60%; }

/* =============================================================== SHEETS */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(40, 30, 30, .5); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 10; }
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: min(100vw, 620px); height: 92vh; height: 92dvh;
  transform: translate(-50%, 105%); transition: transform .38s cubic-bezier(.3,1.1,.5,1);
  background: var(--paper); border: 5px solid var(--out); border-bottom: none; border-radius: 30px 30px 0 0;
  z-index: 11; display: flex; flex-direction: column; -webkit-user-select: text; user-select: text;
}
.sheet.show { transform: translate(-50%, 0); }
/* the white focus ring disappears on the paper-coloured sheet and tray */
.sheet :focus-visible, .tray :focus-visible { outline-color: var(--teal-dk); }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.sheet h2 { font-family: var(--hand); font-weight: 400; font-size: 32px; margin: 0; }
.sheet-close { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 4px solid var(--out); background: var(--cream); box-shadow: 0 3px 0 var(--out); padding: 0; display: grid; place-items: center; }
.sheet-body { overflow-y: auto; padding: 0 20px calc(30px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.sec { margin: 14px 0 24px; }
.sec h3 { font-family: var(--hand); font-weight: 400; font-size: 24px; margin: 0 0 4px; }
.sec p.hint { margin: 0 0 10px; font-size: 14px; opacity: .75; line-height: 1.35; }
.gc-ico.inline { width: 1.35em; height: 1.35em; vertical-align: -.3em; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px; border-radius: 14px;
  background: var(--cream); border: 4px solid var(--out); box-shadow: 0 4px 0 var(--out); font-weight: 600; font-size: 15px;
  transition: transform .08s, box-shadow .08s;
}
.opt.on { background: var(--gold); }
.opt svg { width: 26px; height: 26px; flex: none; margin-left: -4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px dashed rgba(59,34,36,.18); }
.row:last-child { border-bottom: none; }
.row label { font-weight: 600; }
.row .sub { display: block; font-weight: 400; font-size: 13px; opacity: .7; }
.row .toggle-row { margin: 0; }
.sheet input[type=range] { width: 160px; height: 18px; border-width: 4px; }
.sheet input[type=text] { font: inherit; font-size: 17px; padding: 8px 12px; border: 4px solid var(--out); border-radius: 12px; background: var(--cream); width: 100%; }

.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.scene-card { transition: transform .08s, box-shadow .08s; padding: 0; border: 4px solid var(--out); border-radius: 16px; overflow: hidden; background: var(--cream); box-shadow: 0 4px 0 var(--out); text-align: center; }
.scene-card svg { display: block; width: 100%; aspect-ratio: 5 / 5; }
.scene-card span { display: block; font-family: var(--hand); font-size: 15px; padding: 2px 4px 5px; }
.scene-card.on { outline: 5px solid var(--gold); outline-offset: 2px; }
.scene-card .rand { display: grid; place-items: center; aspect-ratio: 1; background: repeating-conic-gradient(#e9e4dc 0 25%, #f6efe4 0 50%) 50% / 28px 28px; }
.scene-card .rand svg { width: 52%; height: 52%; }

.style-preview { display: block; width: 100%; max-width: 360px; margin: 12px auto 0; background: #9fcdc4; border: 4px solid var(--out); border-radius: 18px; cursor: pointer; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.photo { position: relative; width: 78px; height: 78px; border-radius: 50%; border: 4px solid var(--out); background: #ddd; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.photo button::after { content: ''; position: absolute; inset: -9px; }
.photo button { position: absolute; right: -10px; top: -10px; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--out); background: #fff; padding: 0; display: grid; place-items: center; }
.photo button svg { width: 70%; height: 70%; }
.photo-add { width: 78px; height: 78px; border-radius: 50%; border: 4px dashed var(--out); background: transparent; display: grid; place-items: center; }
.photo-add svg { width: 34px; height: 34px; }

.icon-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.icon-row button { width: 48px; height: 48px; border-radius: 12px; border: 3px solid var(--out); background: var(--cream); padding: 0; display: grid; place-items: center; }
.icon-row button svg { width: 34px; height: 34px; }
.icon-row button.on { background: var(--gold); }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.book-card { background: var(--cream); border: 4px solid var(--out); border-radius: 16px; text-align: center; padding: 4px 2px 6px; box-shadow: 0 4px 0 var(--out); position: relative; }
.book-card svg { width: 100%; aspect-ratio: 1; display: block; }
.book-card span { font-family: var(--hand); font-size: 15px; display: block; line-height: 1; }
.book-card.unseen svg { filter: brightness(0) opacity(.18); }
.book-card.unseen span { opacity: .45; }
.book-card b { position: absolute; top: 4px; right: 6px; font-size: 12px; background: var(--gold); border: 2px solid var(--out); border-radius: 99px; padding: 0 6px; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; color: #fff; font-size: 20px; }

/* ====================================================== SVG: egg */
.egg-wobble, .egg-squash, .friend-anim, .critter, .c-squash { transform-box: view-box; transform-origin: 0 0; }
.egg-wobble[data-level="0"] { animation: egg-breathe 3.2s ease-in-out infinite; }
.egg-wobble[data-level="1"] { animation: egg-wobble 4.5s ease-in-out infinite; }
.egg-wobble[data-level="2"] { animation: egg-wobble2 2.8s ease-in-out infinite; }
.egg-wobble[data-level="3"] { animation: egg-hop 1.6s ease-in-out infinite; }
.ready .egg-wobble { animation: egg-ready 1.3s ease-in-out infinite !important; }
.paused .egg-wobble { animation-play-state: paused !important; }
@keyframes egg-breathe { 50% { transform: scale(1.025, .975); } }
@keyframes egg-wobble { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-4deg); } 84% { transform: rotate(3.5deg); } 92% { transform: rotate(-1.5deg); } }
@keyframes egg-wobble2 { 0%, 55%, 100% { transform: rotate(0); } 62% { transform: rotate(-7deg); } 72% { transform: rotate(6deg); } 82% { transform: rotate(-4deg); } 90% { transform: rotate(2deg); } }
@keyframes egg-hop { 0%, 40%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(0) scale(1.08, .92); } 62% { transform: translateY(-22px) rotate(-5deg) scale(.96, 1.05); } 74% { transform: translateY(0) rotate(4deg) scale(1.06, .94); } 86% { transform: rotate(-2deg); } }
@keyframes egg-ready { 0%, 100% { transform: rotate(0) scale(1); } 15% { transform: rotate(-8deg) scale(1.03, .97); } 30% { transform: rotate(7deg); } 45% { transform: rotate(-5deg) translateY(-8px); } 60% { transform: rotate(3deg); } 75% { transform: rotate(0) scale(1.05, .95); } }

/* cracks: each step runs them further and draws them wider (--crack-w is set per step in egg.js) */
.crack-main, .crack-branch { fill: none; stroke: var(--out); stroke-linecap: round; stroke-linejoin: round; }
.crack-main { stroke-width: var(--crack-w, 3); stroke-dasharray: 0 2; transition: stroke-dasharray .35s cubic-bezier(.2,1.4,.5,1), stroke-width .5s ease-out; }
.crack-branch { stroke-width: var(--branch-w, 2.4); stroke-dasharray: 0 2; transition: stroke-dasharray .3s ease-out, stroke-width .5s ease-out; }
.crack-branch.on { stroke-dasharray: 1 2; }
.hatched .egg-cracks, .hatched .egg-halo, .hatched .egg-shadow { display: none; }
.egg-halo { opacity: 0; transition: opacity .6s; }
.ready .egg-halo { animation: halo 1.3s ease-in-out infinite; }
@keyframes halo { 50% { opacity: .75; } 0%, 100% { opacity: .35; } }
.egg-rays { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(.2); transition: opacity .6s, transform 1s cubic-bezier(.3,1.5,.5,1); pointer-events: none; }
.hatched .egg-rays { opacity: .32; transform: scale(1); }
.egg-rays-spin { animation: spin 30s linear infinite; transform-box: view-box; transform-origin: 0 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.egg-root { cursor: pointer; }
.zz { font-family: var(--round); font-weight: 700; fill: var(--cream); stroke: var(--out); stroke-width: 5px; paint-order: stroke; animation: zz 2.4s ease-in-out infinite; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(24px, -40px); } }

/* hatched friend: idle hop / blink / wave / wag loop */
.idle .c-squash { animation: critter-hop 2.6s ease-in-out infinite; }
.idle .c-shadow { transform-box: fill-box; transform-origin: center; animation: shadow-pulse 2.6s ease-in-out infinite; }
@keyframes critter-hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  10% { transform: translateY(0) scale(1.08, .92); }
  25% { transform: translateY(-26px) scale(.95, 1.06); }
  40% { transform: translateY(0) scale(1.08, .92); }
  50% { transform: translateY(0) scale(1, 1); }
  70% { transform: translateY(0) rotate(-3deg); }
  85% { transform: translateY(0) rotate(3deg); }
}
@keyframes shadow-pulse { 25% { transform: scale(.75); opacity: .1; } }
.c-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.2s infinite; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.idle .c-arm-r { transform-box: fill-box; transform-origin: 30% 20%; animation: wave 2.6s ease-in-out infinite; }
.idle .c-arm-l { transform-box: fill-box; transform-origin: 70% 20%; animation: wave-l 2.6s ease-in-out infinite; }
@keyframes wave { 55%, 100% { transform: rotate(0); } 62% { transform: rotate(-40deg); } 70% { transform: rotate(-10deg); } 78% { transform: rotate(-40deg); } 86% { transform: rotate(0); } }
@keyframes wave-l { 0%, 20%, 50%, 100% { transform: rotate(0); } 30% { transform: rotate(20deg); } }
.idle .c-ears { transform-box: fill-box; transform-origin: 50% 100%; animation: ears 2.6s ease-in-out infinite; }
@keyframes ears { 0%, 60%, 100% { transform: rotate(0); } 66% { transform: rotate(-4deg); } 74% { transform: rotate(4deg); } }
.idle .c-tail { transform-box: fill-box; transform-origin: 0% 100%; animation: wag .9s ease-in-out infinite alternate; }
@keyframes wag { to { transform: rotate(-12deg); } }

/* ====================================================== SVG: scenes */
.sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sway var(--sd, 6s) ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-1.2deg); } 50% { transform: rotate(1.2deg); } }
.sea-sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sea-sway var(--sd, 4s) ease-in-out infinite; }
@keyframes sea-sway { 0%, 100% { transform: skewX(-7deg); } 50% { transform: skewX(7deg); } }
.bob { animation: bob var(--bd, 3s) ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.flicker { animation: flicker 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes flicker { 0%, 100% { opacity: 1; transform: scale(1); } 30% { opacity: .75; transform: scale(.92, 1.05); } 60% { opacity: .95; transform: scale(1.05, .95); } }
.glow-pulse { animation: glow-pulse 3s ease-in-out infinite; }
@keyframes glow-pulse { 50% { opacity: .65; } }
.twinkle { animation: twinkle var(--td, 3s) ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .2; } }
.drift { animation: drift var(--dd, 60s) ease-in-out infinite alternate; }
@keyframes drift { to { transform: translateX(60px); } }
.sun-pulse { transform-box: fill-box; transform-origin: center; animation: sun 5s ease-in-out infinite; }
@keyframes sun { 50% { transform: scale(1.06); } }
.moon-glow { transform-box: fill-box; transform-origin: center; animation: sun 4s ease-in-out infinite; }
.ripple { transform-box: fill-box; transform-origin: center; animation: ripple 3s ease-out infinite; }
@keyframes ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
.wave { stroke-dasharray: 20 14; animation: wave-dash 3s linear infinite; }
@keyframes wave-dash { to { stroke-dashoffset: -68; } }
.water-top { animation: glow-pulse 4s ease-in-out infinite; }
.swim { animation: swim var(--sd, 6s) ease-in-out infinite alternate; }
@keyframes swim { to { transform: translateX(var(--sx, 30px)); } }
.scuttle { animation: scuttle 4s ease-in-out infinite; }
@keyframes scuttle { 0%, 40%, 100% { transform: translateX(0); } 50%, 90% { transform: translateX(8px); } }
.glide { animation: glide 9s ease-in-out infinite alternate; }
@keyframes glide { to { transform: translate(-40px, 10px); } }
.blink { transform-box: fill-box; transform-origin: center; animation: blink 3.8s infinite; }
.burrow-critter:nth-child(2n) .blink { animation-delay: -1.7s; animation-duration: 5.1s; }
.flutter { animation: flutter 12s ease-in-out infinite; }
@keyframes flutter {
  0% { transform: translate(var(--fx), var(--fy)); }
  25% { transform: translate(calc(var(--fx) + 60px), calc(var(--fy) - 30px)); }
  50% { transform: translate(calc(var(--fx) + 20px), calc(var(--fy) - 60px)); }
  75% { transform: translate(calc(var(--fx) - 40px), calc(var(--fy) - 20px)); }
  100% { transform: translate(var(--fx), var(--fy)); }
}
.flap { transform-box: fill-box; transform-origin: center; animation: flap .25s ease-in-out infinite alternate; }
@keyframes flap { to { transform: scaleX(.3); } }

.p-firefly { animation: firefly var(--dur) ease-in-out infinite; }
@keyframes firefly {
  0%, 100% { transform: translate(0, 0); opacity: .1; }
  25% { transform: translate(calc(var(--dx) * .6), -18px); opacity: 1; }
  50% { transform: translate(var(--dx), 6px); opacity: .3; }
  75% { transform: translate(calc(var(--dx) * .2), -26px); opacity: 1; }
}
.p-rise { animation: rise var(--dur) linear infinite; }
@keyframes rise { from { transform: translate(0, 0); opacity: 0; } 15% { opacity: 1; } to { transform: translate(var(--dx), -380px); opacity: 0; } }
.p-fall { animation: fall var(--dur) linear infinite; }
@keyframes fall { from { transform: translate(0, 0) rotate(0); } to { transform: translate(var(--dx), 760px) rotate(540deg); } }

.scene-dark .egg-shadow { opacity: .35; }

@media (prefers-reduced-motion: reduce) {
  .particles, .tap-hint.show { animation: none !important; }
  .time-pill.paused { animation: none; opacity: .6; }
  .dial-fill, .dial-knob { transition: none; }
  .particles { display: none; }
  .sway, .sea-sway, .bob, .drift, .swim, .flutter, .glide, .scuttle, .idle .c-squash, .egg-wobble { animation: none !important; }
}
