:root {
  --spot-ms: 900ms;            /* keep in step with SPOTLIGHT_MS in config.js */
  --big: 80px;
  --small: 56px;
  --spot: 112px;               /* spotlit icon size */
  --poof-ms: 1400ms;           /* keep in step with POOF_MS in config.js */
  --ink: #2a1a10;
  --outline: #fff;
  --wiggle-deg: 4deg;           /* icon tilt each way */
  --wiggle-s: 2s;               /* one left + one right = 2 s, i.e. one pose per second */
  --dance-s: 8.10s;                /* spotlit icon's whole dance; set by tools/build_dance.py */
  --bg-opacity: 0.85;           /* background drawings: 1 = full strength */
  --backdrop: #b9b9b9;          /* shows through the see-through background, and beside it on very wide screens */
  --shadow: 0 6px 14px rgba(0, 0, 0, .5);
  --font: "Fredoka", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;   /* Fredoka: rounded cartoon font (Google Fonts, index.html) */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--backdrop); color: #fff; font-family: var(--font); }
.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; }

/* ---- background and monkey ---- */
/* Background: fills the whole screen on PC (cropped to fit); on phones it fills the height, centred.
   See-through at --bg-opacity over --backdrop, which washes it out a little. */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; pointer-events: none; opacity: var(--bg-opacity); }
body[data-layout="portrait"] #bg { inset: 0 auto auto 50%; translate: -50% 0; width: auto; max-width: none; object-fit: fill; }
/* Layers: background 0, monke 2, speech bubble 3, falling items 4 (in front of both), icons 5, buttons 6.
   The monke's box lets the mouse through; app.js decides per press whether it landed on him (a drawn pixel). */
#monkey-hit { position: fixed; z-index: 2; padding: 0; border: 0; background: transparent; pointer-events: none; -webkit-tap-highlight-color: transparent; }
body.over-monke, body.over-monke * { cursor: pointer !important; }
#monke { display: block; width: 100%; height: 100%; }
#monkey-hit:focus-visible { outline: 3px dashed #fff; }

/* ---- falling things ---- */
#stage { position: fixed; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.fall { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: grab; will-change: transform;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; }
.fall img, .fall a { -webkit-user-drag: none; }
.fall.dragging { cursor: grabbing; z-index: 1; }
.fall.dragging.card { box-shadow: 0 16px 30px rgba(0, 0, 0, .6); }
.fall.pending { visibility: hidden; }
.fall.emerge { animation: emerge .4s cubic-bezier(.2, 1.6, .4, 1); transform-origin: 50% 0; }
@keyframes emerge { from { scale: .15; } to { scale: 1; } }
.fall.poof { animation: poof var(--poof-ms) ease-in-out forwards; pointer-events: none; }
.fall.poof.fast { animation-duration: .4s; }
@keyframes poof {
  0% { scale: 1; opacity: 1; filter: blur(0); }
  60% { scale: 1.06; opacity: .7; filter: blur(.5px); }
  100% { scale: 1.2; opacity: 0; filter: blur(4px); }
}
.puff { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #fff; opacity: .95;
  box-shadow: 0 0 10px rgba(255, 255, 255, .8); animation: puff .9s ease-out forwards; pointer-events: none; }
@keyframes puff { to { translate: var(--dx) var(--dy); scale: .15; opacity: 0; } }

.card { border: 3px solid var(--outline); border-radius: 14px; box-shadow: var(--shadow); }
.chat { max-width: min(300px, 72vw); padding: 8px 12px; background: rgba(24, 18, 36, .92); font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.chat .name { font-weight: 800; }
.chat .emote { height: 1.7em; vertical-align: middle; margin: -.25em 0; }
.video { overflow: hidden; background: #000; border-width: 4px; }
.chat { display: block; color: #fff; text-decoration: none; }
.video iframe, .video .player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.video .shield { position: absolute; inset: 0; z-index: 1; display: block; }

/* ---- speech bubble ---- */
#bubble-wrap { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 3; pointer-events: none; transform-origin: 0 0; opacity: 0;
  transition: left .16s linear, top .16s linear;   /* glides after the monke as his frames change */
  filter: drop-shadow(2.5px 0 0 var(--ink)) drop-shadow(-2.5px 0 0 var(--ink)) drop-shadow(0 2.5px 0 var(--ink)) drop-shadow(0 -2.5px 0 var(--ink)) drop-shadow(0 8px 10px rgba(0, 0, 0, .45)); }
#bubble-wrap.show { animation: pop .34s cubic-bezier(.2, 1.5, .45, 1) forwards; }
#bubble-wrap.hide { animation: unpop .2s ease-in forwards; }
@keyframes pop { from { scale: .15; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes unpop { from { scale: 1; opacity: 1; } to { scale: .3; opacity: 0; } }
#bubble { position: absolute; bottom: 24px; width: max-content; padding: 14px 18px; border-radius: 20px; background: #fff; color: var(--ink);
  font: 600 clamp(16px, 1.3vw, 22px)/1.3 var(--font); }
#bubble .full { visibility: hidden; }
#bubble .typed { position: absolute; inset: 14px 18px; }
#bubble-tail { position: absolute; bottom: 0; background: #fff; }
[data-tail="sw"] #bubble { left: 10px; transform: translateX(var(--shift, 0px)); }
[data-tail="sw"] #bubble-tail { left: 0; width: 56px; height: 30px; clip-path: polygon(0 100%, 40% 0, 100% 0); }
[data-tail="s"] #bubble { left: 0; transform: translateX(calc(-50% + var(--shift, 0px))); }
[data-tail="s"] #bubble-tail { left: -15px; width: 30px; height: 30px; clip-path: polygon(50% 100%, 0 0, 100% 0); }

/* ---- social icons ---- */
#links { position: fixed; z-index: 5; top: 14px; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100% - 140px);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px; }
#spot { position: fixed; z-index: 5; left: 50%; top: calc(14px + var(--big) + 26px); translate: -50% 0; }
.social { position: relative; display: block; text-decoration: none; transform-origin: 0 0; transition: transform var(--spot-ms) cubic-bezier(.25, .9, .3, 1.1); }
.social.big { width: var(--big); height: var(--big); }
.social.small { width: var(--small); height: var(--small); }
.social.is-spot { width: var(--spot); height: var(--spot); }

/* Spit squash-and-stretch is played from app.js (spit()); it pivots near the top so the stretch points down. */
.social.is-spot .badge { transform-origin: 50% 12%; }
/* Burp smoke, drawn just under the spotlit icon. */
.burp { position: absolute; left: 50%; top: 92%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 40% 35%, #fbf8ee 0 40%, rgba(225, 220, 205, .9) 60%, rgba(200, 195, 180, 0) 72%);
  animation: burp var(--d, 900ms) ease-out forwards; }
@keyframes burp {
  0% { translate: 0 0; scale: .3; opacity: 0; }
  15% { opacity: .95; }
  100% { translate: var(--dx) var(--dy); scale: var(--s); opacity: 0; }
}
/* SIMP's hand-drawn icons (assets/icons/, transparent PNGs): no circle behind them, just a soft dark shadow. */
.badge { display: block; width: 100%; height: 100%; transition: scale .15s, filter .3s;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .55)) drop-shadow(0 5px 8px rgba(0, 0, 0, .5)); }
.badge img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.social:hover .badge, .social:focus-visible .badge { scale: 1.08; }
.social:focus-visible { outline: none; }
.social:focus-visible .badge { filter: drop-shadow(0 0 3px #ffd36b) drop-shadow(0 0 6px #ffd36b) drop-shadow(0 5px 8px rgba(0, 0, 0, .5)); }

/* Icons wiggle together at 1 fps (a small tilt left, then right; app.js keeps them in step). The spotlit icon dances
   instead. These sit on the <img> so they don't clash with the spit (which animates .badge). */
.badge img { animation: wiggle var(--wiggle-s) steps(1, end) infinite; transform-origin: 50% 100%; }
@keyframes wiggle { 0% { rotate: calc(var(--wiggle-deg) * -1); } 50% { rotate: var(--wiggle-deg); } }
.social.is-spot .badge img { animation: dance var(--dance-s) ease-in-out infinite; }
/* Reduced motion (the button top right): icons hold still, the LIVE pill stops blinking. The monke still animates. */
body.calm .social .badge img, body.calm.is-live .live-pill { animation: none; }
.live-pill { position: absolute; left: 50%; bottom: -10px; translate: -50% 0; padding: 2px 9px; border: 2px solid #fff; border-radius: 999px; background: #e91916;
  font: 700 13px/1.2 var(--font); letter-spacing: .06em; box-shadow: 0 3px 8px rgba(0, 0, 0, .5); display: none; }
body.is-live .live-pill { display: block; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .75; } }

/* ---- controls, hint, credit ---- */
#controls { position: fixed; z-index: 6; top: 14px; right: 14px; display: flex; gap: 10px; }
#controls button { width: 46px; height: 46px; padding: 0; display: grid; place-items: center; border: 3px solid #fff; border-radius: 50%; background: rgba(0, 0, 0, .5);
  color: #fff; cursor: pointer; box-shadow: var(--shadow); }
#controls button:hover { background: rgba(0, 0, 0, .7); }
#controls svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#controls .spk { fill: currentColor; }
#controls .off { display: none; }
#controls button[aria-pressed="true"] .off { display: inline; }
#btn-mute[aria-pressed="true"] .on { display: none; }
#btn-motion circle { fill: currentColor; }
#sound-hint { position: fixed; z-index: 6; top: 70px; right: 14px; padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, .55); font-size: 13px;
  animation: blink 2s ease-in-out infinite; pointer-events: none; }
#credit { position: fixed; z-index: 6; right: 14px; bottom: 8px; margin: 0; font-size: 13px; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
#credit a { color: #ffd36b; font-weight: 700; }

/* ---- portrait (phones) ---- */
body[data-layout="portrait"] { --big: 60px; --small: 44px; --spot: 84px; }
body[data-layout="portrait"] #links { top: 70px; max-width: calc(100% - 20px); gap: 8px; }
body[data-layout="portrait"] #spot { top: calc(70px + var(--big) + 22px); }
body[data-layout="portrait"] #sound-hint { top: auto; bottom: 34px; right: 50%; translate: 50% 0; }
body[data-layout="portrait"] #credit { font-size: 12px; }

@keyframes dance { /* 8.1 s, made by tools/build_dance.py */
  0.00% { translate: 0px 0px; rotate: 0deg; scale: 1 1; }
  1.85% { translate: -3px -3px; rotate: -9deg; scale: 1 1; }
  3.70% { translate: 0px 0px; rotate: -3.6deg; scale: 1 1; }
  5.56% { translate: 3px -3px; rotate: 9deg; scale: 1 1; }
  7.41% { translate: 0px 0px; rotate: 3.6deg; scale: 1 1; }
  9.26% { translate: -3px -3px; rotate: -9deg; scale: 1 1; }
  11.11% { translate: 0px 0px; rotate: -3.6deg; scale: 1 1; }
  12.96% { translate: 3px -3px; rotate: 9deg; scale: 1 1; }
  14.81% { translate: 0px 0px; rotate: 3.6deg; scale: 1 1; }
  16.67% { translate: -3px -3px; rotate: -9deg; scale: 1 1; }
  18.52% { translate: 0px 0px; rotate: -3.6deg; scale: 1 1; }
  20.37% { translate: 3px -3px; rotate: 9deg; scale: 1 1; }
  22.22% { translate: 0px 0px; rotate: 3.6deg; scale: 1 1; }
  23.70% { translate: 0px 0px; rotate: 0deg; scale: 1 1; }
  25.43% { translate: 0px 0px; rotate: 0deg; scale: 1.12 0.86; }
  27.90% { translate: -11px -30px; rotate: -12deg; scale: 0.9 1.12; }
  30.37% { translate: -22px 0px; rotate: 0deg; scale: 1.25 0.78; }
  31.85% { translate: -22px -2px; rotate: 0deg; scale: 0.94 1.07; }
  33.33% { translate: -22px 0px; rotate: 0deg; scale: 1 1; }
  35.19% { translate: -25px -3px; rotate: -9deg; scale: 1 1; }
  37.04% { translate: -22px 0px; rotate: -3.6deg; scale: 1 1; }
  38.89% { translate: -19px -3px; rotate: 9deg; scale: 1 1; }
  40.74% { translate: -22px 0px; rotate: 3.6deg; scale: 1 1; }
  42.59% { translate: -25px -3px; rotate: -9deg; scale: 1 1; }
  44.44% { translate: -22px 0px; rotate: -3.6deg; scale: 1 1; }
  46.30% { translate: -19px -3px; rotate: 9deg; scale: 1 1; }
  48.15% { translate: -22px 0px; rotate: 3.6deg; scale: 1 1; }
  50.00% { translate: -25px -3px; rotate: -9deg; scale: 1 1; }
  51.85% { translate: -22px 0px; rotate: -3.6deg; scale: 1 1; }
  53.70% { translate: -19px -3px; rotate: 9deg; scale: 1 1; }
  55.56% { translate: -22px 0px; rotate: 3.6deg; scale: 1 1; }
  57.04% { translate: -22px 0px; rotate: 0deg; scale: 1 1; }
  58.77% { translate: -22px 0px; rotate: 0deg; scale: 1.12 0.86; }
  61.23% { translate: 0px -30px; rotate: 12deg; scale: 0.9 1.12; }
  63.70% { translate: 22px 0px; rotate: 0deg; scale: 1.25 0.78; }
  65.19% { translate: 22px -2px; rotate: 0deg; scale: 0.94 1.07; }
  66.67% { translate: 22px 0px; rotate: 0deg; scale: 1 1; }
  68.52% { translate: 19px -3px; rotate: -9deg; scale: 1 1; }
  70.37% { translate: 22px 0px; rotate: -3.6deg; scale: 1 1; }
  72.22% { translate: 25px -3px; rotate: 9deg; scale: 1 1; }
  74.07% { translate: 22px 0px; rotate: 3.6deg; scale: 1 1; }
  75.93% { translate: 19px -3px; rotate: -9deg; scale: 1 1; }
  77.78% { translate: 22px 0px; rotate: -3.6deg; scale: 1 1; }
  79.63% { translate: 25px -3px; rotate: 9deg; scale: 1 1; }
  81.48% { translate: 22px 0px; rotate: 3.6deg; scale: 1 1; }
  83.33% { translate: 19px -3px; rotate: -9deg; scale: 1 1; }
  85.19% { translate: 22px 0px; rotate: -3.6deg; scale: 1 1; }
  87.04% { translate: 25px -3px; rotate: 9deg; scale: 1 1; }
  88.89% { translate: 22px 0px; rotate: 3.6deg; scale: 1 1; }
  90.37% { translate: 22px 0px; rotate: 0deg; scale: 1 1; }
  92.10% { translate: 22px 0px; rotate: 0deg; scale: 1.12 0.86; }
  94.57% { translate: 11px -30px; rotate: -12deg; scale: 0.9 1.12; }
  97.04% { translate: 0px 0px; rotate: 0deg; scale: 1.25 0.78; }
  98.52% { translate: 0px -2px; rotate: 0deg; scale: 0.94 1.07; }
  100.00% { translate: 0px 0px; rotate: 0deg; scale: 1 1; }
}
