:root {
  --bg: #0a0a0a;
  --ink: #e4dcc8;
  --muted: #8d877a;
  --accent: #e8b44a;
  --panel: #161512;
  --line: rgba(255, 255, 255, 0.12);
  --groovy: "Shrikhand", "Cooper Black", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html, body { height: 100dvh; }
body {
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
button { touch-action: manipulation; }

.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;
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- psychedelic backdrop ---------- */
.trip-bg {
  position: fixed; inset: -50%; z-index: 0; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    #ff3d7f 0deg 9deg, #ffb400 9deg 18deg, #3dffb4 18deg 27deg,
    #3d8bff 27deg 36deg, #b43dff 36deg 45deg);
}
.trip-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(10,10,10,0.15) 0, rgba(10,10,10,0.55) 22%, rgba(10,10,10,0.92) 45%);
}
.trip .trip-bg { opacity: 0.55; animation: spin 26s linear infinite, hue 5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes hue { to { filter: hue-rotate(360deg); } }

/* WebGL fluid backdrop (fluid.js) */
#fluid { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; transition: opacity 0.6s; }
#fluid.off { display: none; }
:is(.style-print, .style-riso, .style-cut) #fluid { opacity: 0.75; }
.style-neon #fluid { opacity: 0.6; }
@media (pointer: coarse) { :is(.style-print, .style-riso, .style-cut) #fluid { opacity: 0.95; } .style-neon #fluid { opacity: 0.85; } }
/* tessellation bursts (tess.js): behind the fluid, only drawn while one is showing */
#tess { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0; transition: opacity 0.25s linear; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

/* ---------- stage ---------- */
#stage {
  position: fixed; inset: 0; z-index: 2;
  touch-action: none; user-select: none; -webkit-user-select: none;
}

#dudeWrap {
  /* lifted a little so his sandals stay on screen */
  position: absolute; bottom: max(14px, 2vh); right: 3vw;
  height: min(93vh, 150vw); aspect-ratio: 1 / 2;
}
.portrait #dudeWrap {
  /* phones: he stands on the moves row instead of behind it */
  right: auto; left: 50%; transform: translateX(-50%);
  bottom: calc(58px + var(--sab));
  height: min(54vh, 120vw);
}
#dude {
  display: block; width: 100%; height: 100%;
  transform-origin: 50% 100%; overflow: visible;
  pointer-events: none;
}

#drips, #letters { position: absolute; inset: 0; pointer-events: none; }
#drips { filter: url(#gooSmall); }
.goo #letters { filter: url(#goo); }
.goo .L .in { text-shadow: none !important; }
#letters { visibility: hidden; }
.ready #letters { visibility: visible; }

.L {
  position: absolute; left: 0; top: 0;
  pointer-events: auto; cursor: grab;
  font-family: var(--groovy); line-height: 1; white-space: pre;
  will-change: transform; touch-action: none;
}
.L.held { cursor: grabbing; z-index: 2; }
.L .in {
  display: inline-block; padding: 0 0.04em;
  color: var(--ink);
  transform-origin: 50% 100%;
  transition: color 0.4s, text-shadow 0.4s;
}
.L .in.lit {
  color: hsl(var(--h) 95% 66%);
  text-shadow: 0 0 0.12em hsl(var(--h) 100% 60%), 0 0 0.45em hsl(var(--h) 100% 50% / 0.7);
}
.L .in.warming { animation: warm 0.75s ease-in forwards; }
@keyframes warm {
  0% { color: var(--ink); transform: none; }
  30% { transform: translate(-1px, 1px) scale(1.02, 0.99); }
  60% { transform: translate(1px, 0) scale(1.04, 0.98); }
  100% { color: #ff7a2e; text-shadow: 0 0 0.3em #ff5a1f; transform: translate(-1px, 1px) scale(1.07, 0.95); }
}
.L .in.melted {
  animation: melt 1.4s cubic-bezier(0.5, 0, 0.6, 1) forwards;
  filter: url(#melt);
}
@keyframes melt {
  0% { transform: none; }
  40% { transform: scale(1.05, 0.8) skewX(-4deg); }
  100% { transform: scale(1.55, 0.3) skewX(-8deg); }
}
.L .in.reform { animation: reform 0.7s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes reform {
  0% { transform: scale(1.55, 0.3); }
  60% { transform: scale(0.85, 1.2); }
  100% { transform: none; }
}
.L .in.flash { animation: flash 0.45s ease-out; }
@keyframes flash {
  0% { filter: brightness(2.6) drop-shadow(0 0 0.15em #fff); transform: scale(1.15); }
  100% { filter: none; transform: none; }
}
.trip .L .in:not(.melted):not(.warming):not(.flash):not(.reform) {
  animation: tripHue 2.6s linear infinite;
  animation-delay: calc(var(--i) * -0.2s);
}
@keyframes tripHue {
  0%, 100% { color: #ff4d8d; text-shadow: 0 0 0.25em #ff4d8d; }
  25% { color: #ffd23d; text-shadow: 0 0 0.25em #ffd23d; }
  50% { color: #3dffa8; text-shadow: 0 0 0.25em #3dffa8; }
  75% { color: #4da3ff; text-shadow: 0 0 0.25em #4da3ff; }
}

.milk {
  position: absolute; left: 0; top: 0; border-radius: 50%;
  background: #f4f1e8; pointer-events: none;
}
.ball {
  position: absolute; left: 0; top: 0; border-radius: 50%;
  pointer-events: auto; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 35% 30%, #6b7be0, #24308a 55%, #0b0e2e);
  box-shadow: inset -0.6em -0.8em 1.2em rgba(0, 0, 0, 0.5);
}
.ball::before, .ball::after {
  content: ""; position: absolute; border-radius: 50%; background: #05061a;
  width: 0.75em; height: 0.75em;
}
.ball::before { left: 2.4em; top: 1.3em; box-shadow: 1.1em 0.4em 0 #05061a; }
.ball::after { left: 2.9em; top: 2.5em; width: 0.9em; height: 0.9em; }
.pin {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: grab; touch-action: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 72'%3E%3Cpath fill='%23f6f2e8' stroke='%23b9b2a2' stroke-width='1' d='M13 1C8.5 1 7 5 7 10c0 4.6 2 7.6 2 11.4 0 4.6-6.5 12-6.5 24.6 0 11 3 19.4 5.4 25h12.2c2.4-5.6 5.4-14 5.4-25 0-12.6-6.5-20-6.5-24.6 0-3.8 2-6.8 2-11.4 0-5-1.5-9-6-9z'/%3E%3Cpath fill='%23d8402f' d='M8.6 16.2h8.8l-.4 2.6H9zM8.9 21.3h8.2l.2 2.6H8.7z'/%3E%3Cpath fill='%23fff' opacity='.7' d='M10 4.5c-1 1.8-1 4-.6 6 .6-2 1.2-3.8 2.4-5.4z M6.2 38c-.8 6-.2 13 1.8 19.5-.2-7 .2-13.5 1.6-19.5z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}
.drip { position: absolute; left: 0; top: 0; border-radius: 50%; }

/* ---------- the Dude's moves ---------- */
#sleeves, #beard, #hairBack, #hairFront, #carton, #head, #shades, #ppFig .pants, #brows path, #smile {
  transform-box: fill-box;
}
#sleeves.swish { animation: sleeve 1.1s ease-in-out; transform-origin: 50% 0; }
@keyframes swish {
  0%, 100% { transform: none; }
  20% { transform: skewX(-4deg); }
  50% { transform: skewX(3deg); }
  75% { transform: skewX(-1.5deg); }
}
@keyframes sleeve {
  0%, 100% { transform: none; }
  25% { transform: scale(1.06, 1) rotate(-2deg); }
  55% { transform: scale(0.97, 1) rotate(1.5deg); }
}
#beard.stroke { animation: beard 0.9s ease-in-out; transform-origin: 50% 0; }
@keyframes beard {
  0%, 100% { transform: none; }
  20% { transform: rotate(-7deg); }
  40% { transform: rotate(6deg); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(2deg); }
}
#hairBack.frizz, #hairFront.frizz { animation: frizz 1.3s cubic-bezier(0.3, 1.6, 0.5, 1); transform-origin: 50% 40%; }
@keyframes frizz {
  0% { transform: none; }
  25% { transform: scale(1.24, 1.12) rotate(2deg); }
  55% { transform: scale(1.1, 1.05) rotate(-2deg); }
  100% { transform: none; }
}
#carton { transform-origin: 50% 50%; }
#carton.sip { animation: sip 1.3s ease-in-out; }
@keyframes sip {
  0%, 100% { transform: none; }
  30%, 70% { transform: rotate(-14deg); }
}
#carton.spill { animation: spill 3.2s ease-in-out; }
@keyframes spill {
  0% { transform: none; }
  18%, 78% { transform: rotate(-115deg); }
  100% { transform: none; }
}
#ppFig .pants { transform-origin: 50% 0; }
.disco #ppFig .pants { filter: url(#hueSpin); animation: boogie 0.45s ease-in-out infinite alternate; transform-origin: 50% 0; }
@keyframes boogie { from { transform: skewX(-3deg); } to { transform: skewX(3deg); } }
#shades { transition: transform 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); transform-origin: 50% 50%; }
.trip #shades { transform: translateY(-38px) rotate(-8deg); }
#eyes { opacity: 0; transition: opacity 0.3s; }
.trip #eyes { opacity: 1; }
.trip #hairBack, .trip #hairFront { filter: url(#hueSpin); }
#head.nod { animation: nod 0.6s ease-in-out; transform-origin: 50% 100%; }
@keyframes nod {
  0%, 100% { transform: none; }
  35% { transform: rotate(4deg) translateY(3px); }
  70% { transform: rotate(-2deg); }
}

/* ---------- speech + text effects ---------- */
#bubble {
  position: fixed; left: 0; top: 0; z-index: 9;
  max-width: min(260px, 70vw);
  padding: 0.5rem 0.85rem;
  background: rgba(243, 236, 216, 0.82); color: #1b1a17;
  font-family: var(--groovy); font-size: 17px; line-height: 1.25;
  border-radius: 16px;
  opacity: 0; transform: scale(0.8) translateY(6px); transform-origin: 85% 100%;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
  pointer-events: none;
}
#bubble::after {
  content: ""; position: absolute; bottom: -10px; right: 22px;
  border: 10px solid transparent; border-top-color: rgba(243, 236, 216, 0.82); border-bottom: 0;
}
#bubble.center { transform-origin: 50% 100%; }
#bubble.center::after { right: auto; left: calc(50% - 10px); }
#bubble.side::after { display: none; }
#bubble.show { opacity: 1; transform: none; }

#strike {
  position: fixed; left: 50%; top: 42%; z-index: 8;
  font-family: var(--groovy); font-size: clamp(56px, 14vw, 190px);
  color: #ffd23d; text-shadow: 0 0 0.12em #ff7a2e, 0 0.06em 0 #b4291f;
  transform: translate(-50%, -50%) scale(0); opacity: 0; pointer-events: none;
  white-space: nowrap;
}
#strike.go { animation: strike 1.7s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes strike {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-12deg); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1.1) rotate(-4deg); opacity: 1; }
  75% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1.2) rotate(-4deg); opacity: 0; }
}

/* ---------- UI ---------- */
#counter {
  position: fixed; top: calc(14px + var(--sat)); left: calc(14px + var(--sal)); z-index: 10;
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.85rem; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: var(--ink);
  border: 1px solid var(--line);
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer; backdrop-filter: blur(6px);
}
#counter:hover { background: rgba(255, 255, 255, 0.1); }
#counter span[aria-hidden] { color: var(--accent); }
#counter.pop { animation: pop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

#panel {
  position: fixed; top: calc(58px + var(--sat)); left: calc(14px + var(--sal));
  touch-action: pan-y; overscroll-behavior: contain; user-select: text; -webkit-user-select: text; z-index: 11;
  width: min(360px, calc(100vw - 28px));
  max-height: calc(100dvh - 130px); overflow: auto;
  padding: 1rem 1.1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
#panel[hidden] { display: none; }
#panel h2 { margin: 0 0 0.2rem; font-family: var(--groovy); font-weight: 400; font-size: 1.4rem; color: var(--accent); }
#panel .sub { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.85rem; }
#list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
#list li { font-size: 0.9rem; line-height: 1.35; padding: 0.45rem 0.6rem; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
#list li b { display: block; font-weight: 600; }
#list li.got b { color: var(--accent); }
#list li.got span { color: var(--ink); opacity: 0.8; }
#list li:not(.got) b { color: var(--muted); letter-spacing: 0.15em; }
#list li:not(.got) span { color: var(--muted); font-style: italic; }
/* today's verse (days.js), at the foot of the discoveries list */
#verse { margin: 0.9rem 0 0; padding: 0.7rem 0.75rem; border-left: 2px solid var(--accent); background: rgba(232, 180, 74, 0.06); border-radius: 0 8px 8px 0; }
#verse b { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
#verse span { display: block; margin: 0.3rem 0 0.25rem; font-family: var(--groovy); font-size: 1rem; line-height: 1.3; color: var(--ink); }
#verse small { color: var(--muted); font-size: 0.78rem; }
/* special days (days.js puts day-<id> on <html>): a light touch on the Classic lettering */
.day-halloween body:not([class*="style-"]) .L .in:not(.lit) { color: #f2902e; }
.day-winter body:not([class*="style-"]) .L .in:not(.lit) { color: #dbe8f2; }
.day-summer body:not([class*="style-"]) .L .in:not(.lit) { color: #f6dd92; }
#panel .row { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.9rem; }
#panel .row button {
  padding: 0.45rem 0.8rem; border-radius: 999px; cursor: pointer;
  font: 500 13px/1 system-ui, sans-serif;
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
#panel .row button:hover { background: rgba(255, 255, 255, 0.08); }

#toast {
  position: fixed; top: calc(14px + var(--sat)); left: 50%; z-index: 12;
  transform: translate(-50%, -140%); opacity: 0;
  padding: 0.55rem 1rem; border-radius: 999px;
  background: #f3ecd8; color: #1b1a17;
  font: 600 14px/1.2 system-ui, sans-serif; white-space: nowrap;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.25s;
  pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast small { font-weight: 400; color: #6b6556; margin-left: 0.4rem; white-space: nowrap; }
@media (max-width: 360px) { #toast { font-size: 13px; white-space: nowrap !important; } }
@media (max-width: 560px) { #toast { top: calc(60px + var(--sat)); max-width: calc(100vw - 24px); white-space: normal; text-align: center; } }

#hint {
  position: fixed; left: 50%; bottom: calc(64px + var(--sab)); z-index: 10;
  transform: translateX(-50%); opacity: 0;
  padding: 0.35rem 0.8rem; border-radius: 999px; background: rgba(10, 10, 10, 0.72);
  color: #b4ae9f; font-size: 14px; letter-spacing: 0.04em; white-space: nowrap;
  transition: opacity 1s; pointer-events: none;
}
#hint.show { opacity: 1; animation: breathe 3s ease-in-out infinite; }
/* phones: the bottom belongs to the Dude and the moves row, so the hint sits under the top buttons */
.portrait #hint { bottom: auto; top: calc(72px + var(--sat)); font-size: 13px; }
@keyframes breathe { 50% { opacity: 0.45; } }

/* reset, style and outfit live in the top right corner, the yin-yang furthest right */
footer {
  position: fixed; right: calc(14px + var(--sar)); top: calc(14px + var(--sat)); z-index: 10;
  display: flex; flex-direction: row-reverse; align-items: center; gap: 0.6rem;
  color: var(--muted); font-size: 12px; letter-spacing: 0.03em;
  pointer-events: none;
}
footer > * { pointer-events: auto; }
#abide {
  width: 34px; height: 34px; padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 50%; transition: transform 0.6s ease;
}
#abide svg { width: 100%; height: 100%; display: block; }
#abide:focus-visible { transform: rotate(180deg); }
@media (hover: hover) { #abide:hover { transform: rotate(180deg); } }
.portrait footer span { display: none; }

button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .trip .trip-bg { animation: none; }
  #hint.show { animation: none; }
}

/* ---------- zen, wardrobe, bowling buddy ---------- */
#aura, #rug, #mat { opacity: 0; transition: opacity 0.8s ease; pointer-events: none; }
#phones { display: none; }
.lying #phones { display: inline; }
.lying #mat { opacity: 1; }
.lying #carton { visibility: hidden; }
.note { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; font: 700 30px/1 system-ui, sans-serif; color: #ffe08a; text-shadow: 0 2px 0 rgba(0,0,0,.4); animation: noteUp 2.4s ease-out forwards; }
@keyframes noteUp { 0% { opacity: 0; transform: translate(var(--x), var(--y)) scale(.6); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) - 110px)) rotate(var(--r)) scale(1.1); } }
.zen #aura, .zen #rug { opacity: 1; }
#aura { transform-box: fill-box; transform-origin: 50% 50%; }
.zen #aura { animation: auraPulse 3.2s ease-in-out infinite; }
@keyframes auraPulse { 50% { transform: scale(1.08); } }
#shirt { cursor: pointer; }

#buddy {
  position: fixed; left: 64px; bottom: 0; z-index: 8;
  width: min(210px, 36vw); aspect-ratio: 220 / 260;
  transform: translateY(110%) rotate(-6deg);
  transition: transform 0.55s cubic-bezier(0.3, 1.5, 0.5, 1);
  pointer-events: none; cursor: pointer;
}
#buddy svg { width: 100%; height: 100%; display: block; overflow: visible; }
#buddy.up { transform: translateY(8%) rotate(3deg); pointer-events: auto; }
#buddy.pump { animation: pump 0.5s ease-in-out 2; }
@keyframes pump { 50% { transform: translateY(2%) rotate(-3deg) scale(1.04); } }
#buddyBubble {
  position: absolute; left: 62%; bottom: 100%; margin-bottom: 4px;
  width: max-content; max-width: min(240px, 60vw);
  padding: 0.45rem 0.8rem; border-radius: 14px;
  background: #ffe9a8; color: #1b1a17;
  font-family: var(--groovy); font-size: 16px; line-height: 1.25;
  opacity: 0; transform: scale(0.8); transform-origin: 0 100%;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}
#buddyBubble::after {
  content: ""; position: absolute; bottom: -9px; left: 16px;
  border: 10px solid transparent; border-top-color: #ffe9a8; border-bottom: 0;
}
#buddyBubble.show { opacity: 1; transform: none; }

/* ---------- cube-figure look ---------- */
#ppFig .cb { display: none; }
.cube-on #ppFig .rd { display: none; }
.cube-on #ppFig .cb { display: inline; }

/* ---------- marionette ---------- */
#puppet { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#ppStrings line:nth-child(n+4) { opacity: 0; transition: opacity 0.4s; }
.puppet #ppStrings line { opacity: 1; }
#ppStrings line:nth-child(-n+3) { stroke-opacity: .35; }
.puppet #ppStrings line { stroke-opacity: .7; }
#ppStrings line { transition: opacity 0.4s; }
.cut-strings #ppStrings line { opacity: 0 !important; }
#ppFig .seg { pointer-events: visiblePainted; cursor: grab; }
#ppFig .seg:active { cursor: grabbing; }
/* the control bar and strings still steer the rig, but stay invisible: he just moves */
#ppBar, #ppStrings { display: none; }
/* #dudeWrap only marks where he stands; the rig draws him */
#dudeWrap { opacity: 0; pointer-events: none; }
#ppFArmR .prop-ball, #ppFArmR .prop-glass, #ppFArmR .prop-joint, #ppFArmR .hand-pinch { display: none; }
#ppFArmR.hold-ball .prop-ball, #ppFArmR.hold-glass .prop-glass, #ppFArmR.hold-joint .prop-joint, #ppFArmR.hold-joint .hand-pinch { display: inline; }
#ppFArmR.hold-ball #carton, #ppFArmR.hold-glass #carton, #ppFArmR.hold-joint #carton, #ppFArmR.hold-joint .hand-fist { display: none; }
#ember { animation: ember 0.7s ease-in-out infinite alternate; }
@keyframes ember { to { opacity: 0.55; } }
/* expressions */
#brows path, #smile { transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.2s; transform-origin: 50% 50%; }
.ex-wow #browL, .ex-wow #browR { transform: translateY(-8px); }
.ex-wow #smile { opacity: 0; }
.ex-bliss #browL { transform: translateY(-3px) rotate(-6deg); }
.ex-bliss #browR { transform: translateY(-3px) rotate(6deg); }
.ex-bliss #smile { transform: scale(1.3, 1.5); }
.ex-grumpy #browL { transform: translateY(3px) rotate(16deg); }
.ex-grumpy #browR { transform: translateY(3px) rotate(-16deg); }
.ex-grumpy #smile { transform: scaleY(-1); }
.trip #ppFig .cloth { filter: url(#hueSpin); }

#poses {
  position: fixed; left: 50%; bottom: calc(14px + var(--sab)); z-index: 10;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  width: max-content; max-width: calc(100vw - 24px);
  transform: translate(-50%, 0);
}
body:not(.puppet) #poses [data-pose="done"] { display: none; }
#poses button {
  padding: 0.45rem 0.75rem; border-radius: 999px; cursor: pointer;
  font: 600 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: color-mix(in srgb, var(--bg) 84%, transparent); color: var(--ink); border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
@media (hover: hover) { #poses button:hover { background: color-mix(in srgb, var(--bg) 85%, var(--ink)); } }
/* phones (portrait): one swipeable row across the whole bottom */
.portrait #poses {
  left: calc(8px + var(--sal)); right: calc(8px + var(--sar)); bottom: calc(12px + var(--sab));
  width: auto; max-width: none; flex-wrap: nowrap; justify-content: flex-start;
  overflow-x: auto; scrollbar-width: none; touch-action: pan-x; overscroll-behavior: contain;
  padding: 2px 24px 2px 2px; transform: none;
  -webkit-mask-image: linear-gradient(to right, #000 80%, transparent); mask-image: linear-gradient(to right, #000 80%, transparent);
}
.portrait #poses::-webkit-scrollbar { display: none; }
.portrait #poses button { flex: none; padding: 0.45rem 0.6rem; }
.portrait #poses { gap: 5px; }
/* short landscape phones: stack the moves down the right edge */
@media (max-height: 500px) and (orientation: landscape) {
  :is(.portrait, body) #poses {
    left: auto; right: calc(10px + var(--sar)); top: calc(60px + var(--sat)); bottom: calc(8px + var(--sab)); width: max-content;
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start; gap: 5px; padding: 0;
    overflow-y: auto; touch-action: pan-y; -webkit-mask-image: none; mask-image: none; transform: none;
  }
  :is(.portrait, body) #poses button { min-height: 34px !important; padding: 0 0.75rem; font-size: 13px; }
}
@media (pointer: coarse) {
  #poses button { min-height: 40px; padding: 0 0.9rem; font-size: 14px; }
  #abide { width: 42px; height: 42px; }
  #styleBtn, #fitBtn { height: 42px; }
  #muteBtn, #boardBtn { width: 42px; height: 42px; }
  #counter { min-height: 38px; }
  #panel .row button { min-height: 40px; }
  /* one glow instead of two: much cheaper to repaint on phones */
  .style-neon #buddy svg { filter: drop-shadow(0 0 5px #ff4fd8); }
  .style-neon .L .in { text-shadow: 0 0 0.25em #4dd8ff; }
  #counter, #poses button { backdrop-filter: none; }
}
#poses button.on { border-color: var(--accent); color: var(--accent); }
.puppet #hint, footer .tag { display: none; }

/* ---------- art styles ---------- */
#styleBtn, #fitBtn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 34px; padding: 0 0.7rem 0 0.35rem; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); color: var(--ink); border: 1px solid var(--line);
  font: 600 12px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#styleBtn svg, #fitBtn svg { width: 24px; height: 24px; }
#muteBtn, #boardBtn {
  width: 34px; height: 34px; padding: 0; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
}
#muteBtn svg, #boardBtn svg { width: 22px; height: 22px; }
#muteBtn .x, #muteBtn.muted .waves { display: none; }
#muteBtn.muted .x { display: inline; }
#muteBtn.muted svg { opacity: 0.6; }
.bowling footer #muteBtn { visibility: visible; }
.portrait :is(#styleName, #fitName) { display: none; }
.portrait :is(#styleBtn, #fitBtn) { padding: 0 0.35rem; }

body { transition: background-color 0.5s; }
.style-print { --bg: #f3e3cc; --ink: #2b2d6e; --muted: #7a5a4a; --line: rgba(43, 45, 110, 0.25); --accent: #d8402f;
  background: repeating-conic-gradient(from 0deg at 78% 38%, rgba(232, 120, 60, 0.16) 0deg 6deg, transparent 6deg 12deg), #f3e3cc; }
.style-print #ppFig, .style-print #buddy svg { filter: url(#fxPrint); }
.style-print .L .in { text-shadow: 0.05em 0.05em 0 #d8402f; }

.style-riso { --bg: #5d8fd6; --ink: #fff3e0; --muted: #e8eefa; --line: rgba(255, 255, 255, 0.35); --accent: #ffd23d;
  background: radial-gradient(rgba(255, 255, 255, 0.13) 1px, transparent 1.6px) 0 0 / 7px 7px, #5d8fd6; }
.style-riso #ppFig, .style-riso #buddy svg { filter: url(#fxRiso); }
.style-riso .L .in { text-shadow: 0.045em 0.045em 0 #e8452c; }

.style-cut { --bg: #d4cf93; --ink: #141414; --muted: #4a4630; --line: rgba(0, 0, 0, 0.2); --accent: #c41e1e;
  background: linear-gradient(to bottom, #d4cf93 0 74%, #c41e1e 74% 100%); }
.style-cut #puppet, .style-cut #buddy svg { filter: contrast(1.1) saturate(1.05); }
.style-cut .L .in { text-shadow: 0.035em 0.035em 0 #fffbe8; }
/* phones: SVG filters run on the CPU every frame (Safari especially), so use GPU-friendly CSS filters instead */
@media (pointer: coarse) {
  #puppet { will-change: transform; }
  .style-print #ppFig, .style-print #buddy svg { filter: none; }
  .style-riso #ppFig, .style-riso #buddy svg { filter: none; }
  .style-print #puppet, .style-print #buddy svg { filter: grayscale(1) contrast(1.35) sepia(1) hue-rotate(-38deg) saturate(3.4) brightness(0.92); }
  .style-riso #puppet, .style-riso #buddy svg { filter: saturate(1.9) contrast(1.15) hue-rotate(-8deg) drop-shadow(3px 2px 0 rgba(232, 69, 44, 0.55)); }
}

.style-neon { --bg: #07040f; --ink: #4dd8ff; --accent: #ff4fd8;
  background: linear-gradient(rgba(255, 79, 216, 0.07) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, rgba(77, 216, 255, 0.07) 1px, transparent 1px) 0 0 / 48px 48px, #07040f; }
.style-neon #ppFig :is(path, rect, ellipse, circle),
.style-neon #buddy svg :is(path, rect, ellipse, circle) {
  fill: transparent !important; stroke: var(--neon, #ff4fd8) !important; stroke-width: 2.6px !important; stroke-opacity: 1 !important;
  stroke: color-mix(in srgb, var(--neon, #ff4fd8) 55%, #fff) !important; stroke-linecap: round; stroke-linejoin: round;
}
.style-neon #ppFig .hit { stroke: none !important; }
.style-neon #buddy svg { filter: drop-shadow(0 0 4px #ff4fd8) drop-shadow(0 0 10px rgba(77, 216, 255, 0.6)); }
.style-neon #ppFig { filter: url(#fxNeon); }
/* phones: the tubes already carry their own glow twins, so one cheap GPU halo is plenty */
@media (pointer: coarse) {
  .style-neon #ppFig { filter: none; }
  .style-neon #puppet { filter: drop-shadow(0 0 4px rgba(255, 120, 220, 0.5)); }
}
.style-neon :is(#hairBack, #hairFront, #ppHair) { --neon: #ffc43a; }
.style-neon #head { --neon: #ffa53d; }
.style-neon #beard { --neon: #ff9a3a; }
.style-neon #shades { --neon: #ff4fd8; }
.style-neon :is(.pants, #ppThighL, #ppThighR, #ppShinL, #ppShinR) { --neon: #ff3fa4; }
.style-neon #shirt { --neon: #ffffff; }
.style-neon #carton { --neon: #c9a7ff; }
.style-neon :is(#robe, #robeFront, #sleeves, #ppUArmR, #ppFArmL, #ppFArmR) { --neon: #2ee6a8; }
.style-neon .L .in { color: transparent; -webkit-text-stroke: 0.03em #4dd8ff; text-shadow: 0 0 0.18em #4dd8ff, 0 0 0.5em rgba(255, 79, 216, 0.6); }
.style-neon .L .in.lit { -webkit-text-stroke-color: hsl(var(--h) 100% 65%); }

/* ---------- wardrobe: four outfits drawn into the same rig ---------- */
#ppFig .w:not(.w-robe) { display: none; }
:is(.fit-card, .fit-bowl, .fit-vest, .fit-v) #ppFig .w { display: none; }
.fit-card #ppFig .w.w-card, .fit-bowl #ppFig .w.w-bowl, .fit-vest #ppFig .w.w-vest, .fit-v #ppFig .w.w-v { display: inline; }
.fit-bowl #ppFig .pl { fill: #cbb68c; }
.fit-vest #ppFig .pl { fill: #5a7ca3; }
.fit-card #ppFig .cb .pl { fill: #b9a477; }
.fit-card #ppFig .cb .cloth { fill: url(#knit); }
.fit-bowl #ppFig .cb .cloth { fill: #2f6f7c; }
.fit-vest #ppFig .cb .cloth { fill: url(#argyle); }
#ppFig.changing { animation: quickChange 0.5s ease-in-out; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes quickChange { 50% { transform: scaleX(0.04); } }
@media (prefers-reduced-motion: reduce) { #ppFig.changing { animation: none; } }
.style-neon :is(.w-card, .w-bowl, .w-vest) { --neon: #ffa53d; }

/* ---------- Dude Lab: ragdolls evolving a walk ---------- */
/* ---------- Dude Lanes (bowl.js) ---------- */
.bowling :is(#letters, #drips, #poses, footer, #counter, #hint, #buddy, #strike, .ball, .pin) { visibility: hidden; }
.bowling #carton { visibility: hidden; }
.bowling #dudeWrap { right: 5vw; height: min(76vh, 118vw); }
.bowling.portrait #dudeWrap { left: auto; right: -9vw; transform: none; height: min(44vh, 96vw); }
#bowl { color: #efe6cf; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#bowl .bw-sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0; transition: opacity 0.45s ease; background: #0b0908; }
#bowl .bw-sky.on { opacity: 0.94; }
#bowl .bw-tag {
  position: fixed; z-index: 4; left: 0; right: 0; top: calc(92px + var(--sat)); text-align: center; pointer-events: none;
  font: 500 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 0.08em; text-transform: lowercase;
  color: rgba(239, 230, 207, 0.85); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); opacity: 0; transition: opacity 0.8s ease;
}
#bowl .bw-tag.show { opacity: 1; }
#bowl .bw-lane { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
#bowl .bw-touch { position: fixed; inset: 0; z-index: 3; touch-action: none; cursor: grab; }
#bowl .bw-touch:active { cursor: grabbing; }
#bowl .bw-top {
  position: fixed; z-index: 4; top: calc(10px + var(--sat)); left: calc(10px + var(--sal)); right: calc(10px + var(--sar));
  display: flex; align-items: flex-start; justify-content: center; gap: 8px; pointer-events: none;
}
#bowl .bw-card { display: flex; border: 1px solid rgba(239, 230, 207, 0.35); border-radius: 8px; overflow: hidden; background: rgba(16, 12, 10, 0.78); }
#bowl .bw-card .f { width: 44px; border-left: 1px solid rgba(239, 230, 207, 0.22); text-align: center; }
#bowl .bw-card .f:first-child { border-left: 0; }
#bowl .bw-card .f:last-child { width: 58px; }
#bowl .bw-card .f.on { background: rgba(255, 207, 61, 0.16); }
#bowl .bw-card b { display: block; font-size: 10px; font-weight: 600; color: rgba(239, 230, 207, 0.55); padding-top: 2px; }
#bowl .bw-card span { display: flex; justify-content: flex-end; }
#bowl .bw-card i { font-style: normal; font-weight: 700; font-size: 13px; width: 18px; height: 18px; line-height: 18px; border-left: 1px solid rgba(239, 230, 207, 0.18); border-bottom: 1px solid rgba(239, 230, 207, 0.18); }
#bowl .bw-card i.x { color: #ffcf3d; }
#bowl .bw-card i.s { color: #7fd6c8; }
#bowl .bw-card em { display: block; font-style: normal; font-weight: 700; font-size: 15px; height: 22px; line-height: 22px; }
#bowl .bw-x {
  pointer-events: auto; flex: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: rgba(16, 12, 10, 0.78); color: #efe6cf; border: 1px solid rgba(239, 230, 207, 0.35); font-size: 16px;
}
#bowl .bw-banner {
  position: fixed; z-index: 4; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none;
  font-family: var(--groovy); font-size: clamp(34px, 9vw, 110px); line-height: 1; color: #efe6cf; opacity: 0;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
#bowl .bw-banner.strike { color: #ffcf3d; text-shadow: 0 0 24px rgba(255, 140, 40, 0.7), 0 5px 0 #8a3b12; }
#bowl .bw-banner.spare { color: #7fd6c8; text-shadow: 0 5px 0 #1d5c55; }
#bowl .bw-banner.meh { font-size: clamp(26px, 6vw, 60px); }
#bowl .bw-banner.show { animation: bwPop 1.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
@keyframes bwPop { 0% { opacity: 0; transform: scale(0.4) rotate(-6deg); } 18% { opacity: 1; transform: scale(1.08) rotate(-3deg); } 70% { opacity: 1; transform: scale(1) rotate(-3deg); } 100% { opacity: 0; transform: scale(1) translateY(-20px) rotate(-3deg); } }
#bowl .bw-hint {
  position: fixed; z-index: 4; left: 50%; bottom: calc(16px + var(--sab)); transform: translateX(-50%); pointer-events: none;
  padding: 0.4rem 0.9rem; border-radius: 999px; background: rgba(10, 10, 10, 0.72); font-size: 14px; white-space: nowrap;
  transition: opacity 0.5s;
}
#bowl .bw-hint.dim { opacity: 0.55; }
#bowl .bw-hint.gone { opacity: 0; }
#bowl .bw-end {
  position: fixed; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center;
  padding: 1.2rem 1.6rem; border-radius: 16px; background: rgba(16, 12, 10, 0.9); border: 1px solid rgba(239, 230, 207, 0.3);
}
#bowl .bw-end[hidden] { display: none; }
#bowl .bw-final { margin: 0 0 0.8rem; }
#bowl .bw-final b { display: block; font-family: var(--groovy); font-weight: 400; font-size: 64px; line-height: 1; color: #ffcf3d; }
#bowl .bw-final span { font-size: 14px; color: rgba(239, 230, 207, 0.7); }
#bowl .bw-end div { display: flex; gap: 8px; justify-content: center; }
#bowl .bw-end button { white-space: nowrap;
  min-height: 40px; padding: 0 1rem; border-radius: 999px; cursor: pointer; font: 600 14px/1 system-ui, -apple-system, sans-serif;
  background: rgba(255, 255, 255, 0.08); color: #efe6cf; border: 1px solid rgba(239, 230, 207, 0.3);
}
#bowl .bw-end button[data-act=again] { border-color: #ffcf3d; color: #ffcf3d; }
@media (max-width: 560px) {
  #bowl .bw-card .f { width: 29px; }
  #bowl .bw-card .f:last-child { width: 40px; }
  #bowl .bw-card i { width: 13px; height: 15px; line-height: 15px; font-size: 11px; }
  #bowl .bw-card em { font-size: 12px; height: 18px; line-height: 18px; }
  #bowl .bw-top { justify-content: flex-start; }
  #bowl .bw-x { margin-left: auto; width: 36px; height: 36px; }
  /* the mute button would sit on the scorecard: tuck it under the close button */
  .bowling footer #muteBtn { position: fixed; right: calc(10px + var(--sar)); top: calc(54px + var(--sat)); width: 36px; height: 36px; }
  #bowl .bw-hint { font-size: 12px; }
}

/* ---------- felt cutout: flat construction-paper shapes, no shading, a paper shadow ---------- */
.style-felt { --bg: #3f7a4a; --ink: #fff6e0; --muted: #dcebd6; --line: rgba(255, 246, 224, 0.3); --accent: #ffcf3d;
  background: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.5px) 0 0 / 5px 5px,
    radial-gradient(rgba(0, 0, 0, 0.06) 1px, transparent 1.5px) 2px 3px / 6px 6px, #3f7a4a; }
.style-felt #ppFig .rd :is(path, ellipse)[fill="#000"],
.style-felt #ppFig .rd :is(path, ellipse)[fill="#fff"],
.style-felt #ppFig .rd [fill="url(#legShade)"],
.style-felt #ppFig .rd :is(g, path)[fill="none"][opacity] { display: none; }
.style-felt #ppFig .rd [fill="url(#robeGrad)"], .style-felt #ppFig .rd [fill="url(#sleeveGrad)"] { fill: #7f7c46; }
.style-felt #ppFig .rd [fill="url(#hairGrad)"] { fill: #b98f2c; }
.style-felt #ppFig .rd [fill="url(#skinGrad)"] { fill: #eab38b; }
.style-felt #puppet { filter: saturate(1.25); }
.style-felt .L .in { text-shadow: 0.05em 0.06em 0 rgba(0, 0, 0, 0.3); }

/* ---------- 8-bit: the blocky figure, hard pixel edges, chunky letter shadows ---------- */
.style-pixel { --bg: #79a7f2; --ink: #fffbe8; --muted: #e8f0ff; --line: rgba(255, 255, 255, 0.35); --accent: #fcd000;
  background: linear-gradient(to bottom, transparent 0 82%, #b5652b 82% 84%, #3fa34d 84% 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 50%, transparent 50%) 0 0 / 16px 16px, #79a7f2; }
.style-pixel #ppFig .rd { display: none; }
.style-pixel #ppFig .cb { display: inline; }
.style-pixel #puppet { shape-rendering: crispEdges; }
/* the 8-bit Dude is drawn as real blocks on a coarse canvas; the vector figure stays (invisible) for grabbing */
#pixDude { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; display: none;
  image-rendering: -webkit-optimize-contrast; image-rendering: pixelated; }
.style-pixel.pix-ready #pixDude { display: block; }
.style-pixel.pix-ready #ppFig { opacity: 0; }
.style-pixel .L .in { text-shadow: 0.07em 0 0 #000, 0 0.07em 0 #000, 0.07em 0.07em 0 #000, 0.14em 0.14em 0 rgba(0, 0, 0, 0.35); }

/* ---------- letters dressed for each art style (fonts only download when their style is picked) ---------- */
:root {
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1.3 0 0 0 -.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --fibre: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.6 .7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0 0 0 -.22'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
}
/* screen print: a heavy slab face, red ink printed a little off register */
.style-print .L { font-family: "Alfa Slab One", var(--groovy); }
.style-print .L .in { text-shadow: 0.06em 0.045em 0 #d8402f, -0.015em -0.01em 0 rgba(255, 196, 64, 0.8); }
/* riso: fat rounded letters in fluoro inks, grainy, layers misregistered */
.style-riso .L { font-family: "Bowlby One", var(--groovy); }
.style-riso .L .in { --c1: #ff6a2b; --c2: #ff3fa4; }
.style-riso .L:nth-child(4n+2) .in { --c1: #ffe14a; --c2: #ff6a2b; }
.style-riso .L:nth-child(4n+3) .in { --c1: #ff3fa4; --c2: #2d55c9; }
.style-riso .L:nth-child(4n+4) .in { --c1: #fff3e0; --c2: #ff3fa4; }
.style-riso .L .in {
  color: transparent; background: var(--grain), var(--c1);
  -webkit-background-clip: text; background-clip: text;
  text-shadow: 0.055em 0.045em 0 var(--c2);
}
/* cut paper: white card letters, leaning a little, each with a coloured folded edge */
.style-cut .L { font-family: "Anton", var(--groovy); }
.style-cut .L .in { --c: #ff2d8a; }
.style-cut .L:nth-child(7n+2) .in { --c: #1e90ff; }
.style-cut .L:nth-child(7n+3) .in { --c: #8fd400; }
.style-cut .L:nth-child(7n+4) .in { --c: #ff7a00; }
.style-cut .L:nth-child(7n+5) .in { --c: #8e44ff; }
.style-cut .L:nth-child(7n+6) .in { --c: #00b8a0; }
.style-cut .L:nth-child(7n+7) .in { --c: #e8262b; }
.style-cut .L { filter: drop-shadow(0.03em 0.05em 0.03em rgba(0, 0, 0, 0.3)); }
.style-cut .L .in {
  color: #fff;
  text-shadow: 0.02em 0.025em 0 var(--c), 0.04em 0.05em 0 var(--c), 0.06em 0.075em 0 var(--c);
  transform: skewX(-7deg) rotate(-2deg);
}
.style-cut .L:nth-child(even) .in { transform: skewX(-7deg) rotate(2.5deg); }
/* felt: soft rounded rainbow letters with a fuzzy fibre surface */
.style-felt .L { font-family: "Fredoka", var(--groovy); font-weight: 700; }
.style-felt .L { filter: drop-shadow(0.035em 0.055em 0.02em rgba(0, 0, 0, 0.3)); }
.style-felt .L .in {
  --fc: hsl(calc(var(--i) * 27) 78% 56%);
  color: transparent; background: var(--fibre), var(--fc);
  -webkit-background-clip: text; background-clip: text;
  text-shadow: none;
}
/* 8-bit: chunky pixel letters, outlined, extruded like an arcade title */
.style-pixel .L { font-family: "Silkscreen", var(--groovy); font-weight: 700; -webkit-font-smoothing: none; }
.style-pixel .L .in {
  color: #1d1b3f; -webkit-text-stroke: 0.035em #ffb000;
  text-shadow: 0.03em 0.03em 0 #ffb000, 0.06em 0.06em 0 #d98a00, 0.09em 0.09em 0 #b06e00, 0.12em 0.12em 0 #7a4b00, 0.16em 0.16em 0 rgba(0, 0, 0, 0.3);
}
/* lit, tripping or goo: drop the paper and paint back to plain glowing colour */
:is(.style-print, .style-riso, .style-cut, .style-felt, .style-pixel) .L .in.lit,
:is(.style-riso, .style-cut, .style-felt).trip .L .in, :is(.style-riso, .style-felt).trip .L .in {
  background: none; -webkit-text-stroke: 0; color: hsl(var(--h) 95% 66%);
  text-shadow: 0 0 0.12em hsl(var(--h) 100% 60%), 0 0 0.45em hsl(var(--h) 100% 50% / 0.7);
}
:is(.style-riso, .style-cut, .style-felt).goo .L .in { background: none; color: var(--ink); }

/* ---------- depth & texture (depth.js): every solid piece gets a shadow twin below and a grain twin above ---------- */
#ppFig .dsh, #ppFig .dtx { pointer-events: none; }
#ppFig .dso { display: none; }
/* classic: layered felt-paper, soft dark shadows, fine fibres and a faint stitch along each edge */
#ppFig .dsh { fill: rgba(0, 0, 0, 0.34); stroke: none; transform: translate(2.5px, 4px); }
#ppFig .dtx { fill: url(#tx-classic); stroke: rgba(255, 246, 224, 0.16); stroke-width: 1.2px; stroke-dasharray: 3 3; }
/* screen print: pressed paper pieces, a light cut edge, a warm low shadow */
.style-print #ppFig .dsh { fill: rgba(70, 12, 12, 0.3); transform: translate(2px, 3.5px); }
.style-print #ppFig .dtx { fill: url(#tx-print); stroke: rgba(255, 238, 220, 0.32); stroke-width: 1.3px; stroke-dasharray: none; }
/* crayon riso: waxy grain, crinkles, a broken crayon edge, crumpled scraps casting a cool shadow */
.style-riso #ppFig .dsh { fill: rgba(16, 30, 90, 0.3); transform: translate(2px, 3.5px); }
.style-riso #ppFig .dtx { fill: url(#tx-riso); stroke: rgba(255, 255, 255, 0.34); stroke-width: 1.8px; stroke-dasharray: 7 3 2 4; stroke-linecap: round; }
/* cut paper: thick black paper shadows under every layer, a pale cut edge */
.style-cut #ppFig .dsh { fill: rgba(16, 16, 10, 0.88); transform: translate(5px, 6px); }
.style-cut #ppFig .dtx { fill: url(#tx-cut); stroke: rgba(255, 252, 232, 0.4); stroke-width: 1.2px; stroke-dasharray: none; }
/* felt: fuzzy fibres on top and fuzz around the edges, puffy shadows */
.style-felt #ppFig .dsh { fill: rgba(0, 0, 0, 0.3); transform: translate(3px, 5px); }
.style-felt #ppFig .dtx { fill: url(#tx-felt); stroke: rgba(255, 250, 235, 0.3); stroke-width: 2.2px; stroke-dasharray: 0.6 2.4; stroke-linecap: round; }
/* neon: no paper here; the twins underneath become each tube's own coloured glow */
.style-neon #ppFig .dtx { display: none; }
.style-neon #ppFig .dsh, .style-neon #ppFig .dso {
  display: inline; transform: none;
  fill: none !important; stroke: var(--neon, #ff4fd8) !important; stroke-width: 8px !important; stroke-opacity: 0.22 !important; stroke-dasharray: none !important;
}
/* cut paper's own paper stock: olive and orange hair, pink skin, a forest-green league shirt, slate jeans */
.style-cut #ppFig .rd [fill="url(#hairGrad)"], .style-cut #ppFig .rd [fill="#b48d30"] { fill: #a9a23a; }
.style-cut #ppFig .rd [fill="#c9a144"] { fill: #e39a35; }
.style-cut #ppFig .rd [fill="url(#skinGrad)"], .style-cut #ppFig .rd [fill="#e3aa82"] { fill: #f1a99a; }
.style-cut #ppFig .rd :is([fill="#dfa47c"], [fill="#d99c74"], [fill="#cf9871"], [fill="#d39d77"]) { fill: #dc8f82; }
.style-cut #ppFig .rd [fill="#a07520"] { fill: #c9822a; }
.style-cut.fit-bowl #ppFig .rd .cloth[fill="#2f6f7c"] { fill: #1f5e4a; }
.style-cut.fit-vest #ppFig .rd .pl { fill: #5d6497; }

/* ---------- 5 November only (fifth.js adds .fifth): mask on, every bowling ball a lit cartoon bomb ---------- */
.gf-on { display: none; }
.fifth .gf-on { display: inline; }
.fifth .gf-off { display: none; }
#gfMask { pointer-events: none; }
.style-pixel #gfMask path:first-child { stroke: #111; stroke-width: 4; }
.fifth .ball { background: none; box-shadow: none; }
.fifth .ball::before {
  left: -30%; top: -30%; width: 160%; height: 160%; border-radius: 0; box-shadow: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Ccircle cx='80' cy='80' r='50' fill='%231d1d1f' stroke='%23050505' stroke-width='4'/%3E%3Cpath fill='%23000' opacity='.45' d='M50 44 C30 64 32 104 60 122 C46 118 34 104 32 84 C30 66 38 52 50 44 Z'/%3E%3Cpath fill='%233a3a3e' d='M62 40 C82 32 108 40 120 62 C104 48 84 42 62 40 Z' opacity='.8'/%3E%3Cg transform='translate%28112 48%29 rotate%2845%29'%3E%3Crect x='-15' y='-9' width='30' height='17' rx='3' fill='%232a2a2c' stroke='%23050505' stroke-width='3.5'/%3E%3C/g%3E%3Cpath fill='none' stroke='%23050505' stroke-width='10' stroke-linecap='round' d='M118 40 C121 30 127 26 134 22'/%3E%3Cpath fill='none' stroke='%23d8b27a' stroke-width='6' stroke-linecap='round' d='M118 40 C121 30 127 26 134 22'/%3E%3Cpath fill='none' stroke='%237a5a30' stroke-width='1.6' d='M117 36 l5 1 M120 30 l4 3 M125 26 l3 4 M130 23 l2 4'/%3E%3Cellipse cx='102' cy='94' rx='10' ry='12' fill='%23f2f2f2' transform='rotate%28-20 102 94%29'/%3E%3Cellipse cx='96' cy='117' rx='7' ry='5.5' fill='%23f2f2f2'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  filter: drop-shadow(0 0.15em 0.2em rgba(0, 0, 0, 0.4));
}
.fifth .ball::after {
  left: 84%; top: -32%; width: 44%; height: 44%; border-radius: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36'%3E%3Cpath fill='%23d7261e' stroke='%237a1010' stroke-width='1.5' stroke-linejoin='round' d='M18.0 0.5 L20.4 11.4 L29.2 4.6 L24.1 14.5 L35.2 15.0 L24.9 19.2 L33.2 26.7 L22.5 23.4 L24.0 34.4 L18.0 25.0 L12.0 34.4 L13.5 23.4 L2.8 26.8 L11.1 19.2 L0.8 15.0 L11.9 14.5 L6.8 4.6 L15.6 11.4 Z'/%3E%3Cpath fill='%23ffd21f' d='M19.9 7.2 L20.5 13.7 L26.4 10.9 L22.7 16.3 L29.0 18.0 L22.7 19.7 L26.5 25.0 L20.5 22.3 L20.0 28.8 L17.2 22.9 L12.5 27.6 L14.2 21.2 L7.7 21.8 L13.0 18.0 L7.6 14.3 L14.2 14.8 L12.5 8.5 L17.1 13.1 Z'/%3E%3Ccircle cx='18' cy='18' r='4' fill='%23fff8d0'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  animation: gfSpark 0.18s steps(2) infinite alternate;
}
.fifth .gf-spark { transform-box: fill-box; transform-origin: center; animation: gfSpark 0.18s steps(2) infinite alternate; }
@keyframes gfSpark { from { transform: scale(0.82) rotate(0deg); } to { transform: scale(1.12) rotate(18deg); } }
@media (prefers-reduced-motion: reduce) { .fifth .ball::after, .fifth .gf-spark { animation: none; } }
#boom { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 7; pointer-events: none; }

/* V (5 November only): long dark hair, black gloves, a dark figure in pixel style */
.fit-v #ppFig .rd :is(#hairBack, #hairFront) [fill="url(#hairGrad)"] { fill: #1e1916; }
.fit-v #ppFig .rd :is(#hairBack, #hairFront) [fill="#c9a144"] { fill: #2a221d; }
.fit-v #ppFig .rd :is(#hairBack, #hairFront) :is([fill="#b48d30"], [fill="#9c7524"]) { fill: #241d19; }
.fit-v #ppFig .rd :is(#hairBack, #hairFront) g { stroke: #0f0c0a; }
.fit-v #ppFArmL .rd [fill="#e3aa82"], .fit-v #ppFArmR .rd [fill="#e3aa82"] { fill: #26262a; }
.fit-v #ppFArmL .rd [stroke="#b9805a"], .fit-v #ppFArmR .rd [stroke="#b9805a"] { stroke: #0e0e10; }
.fit-v #ppFig .cb .cloth { fill: #2b2b31; }
.fit-v #ppFig .cb .pl { fill: #26262b; }
.fit-v #ppFig .cb [fill="#a8822a"], .fit-v #ppFig .cb [fill="#b48d30"], .fit-v #ppFig .cb [fill="#c29a38"] { fill: #241d19; }
.fit-v #ppFig .cb [fill="#f0b98e"] { fill: #26262a; }
.style-neon .w-v { --neon: #ff3d5a; }
.fit-v #ppTorso .cb [fill="#ecdfa4"] { fill: #2b2b31; }

/* ---------- the league board (board.js): an overhead alley monitor ---------- */
#board {
  position: fixed; z-index: 11; top: calc(62px + var(--sat)); right: calc(14px + var(--sar));
  width: min(380px, calc(100vw - 28px)); max-height: calc(100dvh - 140px); overflow: auto;
  overscroll-behavior: contain; touch-action: pan-y; outline: none;
  padding: 10px; border-radius: 16px;
  background: linear-gradient(#2a2622, #141210); border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  animation: bdIn 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}
#board[hidden] { display: none; }
@keyframes bdIn { from { opacity: 0; transform: translateY(-10px) scale(0.97); } }
#board .bd-screen {
  padding: 14px 16px 16px; border-radius: 10px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 50% 0%, #1b2f5c, #0b1430 70%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
  color: #ffcf3d; font: 600 13px/1.35 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  text-shadow: 0 0 6px rgba(255, 207, 61, 0.55);
}
#board .bd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#board h2 { margin: 0; font-family: var(--groovy); font-weight: 400; font-size: 1.5rem; letter-spacing: 0.02em; color: #ffcf3d; }
#board .bd-x {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; flex: none;
  background: rgba(255, 255, 255, 0.06); color: #ffcf3d; border: 1px solid rgba(255, 207, 61, 0.35); font-size: 14px;
}
#board .bd-sub { margin: 2px 0 12px; color: rgba(255, 207, 61, 0.6); text-transform: lowercase; letter-spacing: 0.06em; font-size: 12px; }
#board h3 { margin: 16px 0 8px; font: inherit; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: #7fd6c8; text-shadow: 0 0 6px rgba(127, 214, 200, 0.5); }
#board ol, #board ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#board li { display: flex; align-items: baseline; gap: 10px; padding: 7px 9px; border-radius: 6px; background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 207, 61, 0.12); }
#board .bd-n { flex: none; min-width: 2ch; font-weight: 700; color: #ffcf3d; }
#board .bd-t { display: grid; gap: 2px; min-width: 0; }
#board li.shut { opacity: 0.55; }
#board li.shut .bd-t { text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; }
#board .bd-name {
  justify-self: start; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: #fff1c2; text-decoration: none; text-shadow: inherit; text-align: left;
}
#board .bd-name::after { content: ' →'; color: #ffcf3d; }
@media (hover: hover) { #board .bd-name:hover { color: #ffffff; } }
#board .bd-name:focus-visible, #board .bd-x:focus-visible { outline: 2px solid #7fd6c8; outline-offset: 2px; }
#board small { font-weight: 400; font-size: 12px; color: rgba(255, 241, 194, 0.7); text-shadow: none; }
#board li.open { animation: bdBlink 0.6s steps(2) 1; }
@keyframes bdBlink { 50% { opacity: 0.4; } }
.portrait #board { left: calc(14px + var(--sal)); right: calc(14px + var(--sar)); width: auto; }
@media (prefers-reduced-motion: reduce) { #board, #board li.open { animation: none; } }
/* very narrow phones: six things share the top row */
@media (max-width: 360px) {
  footer { gap: 0.25rem; right: calc(10px + var(--sar)); }
  #counter { padding: 0.4rem 0.6rem; left: calc(10px + var(--sal)); }
  #muteBtn, #boardBtn, #abide { width: 36px; height: 36px; }
  #styleBtn, #fitBtn { height: 36px; }
}

/* ---------- the guestbook on the rug (rug.js) ---------- */
#rugbook {
  position: fixed; z-index: 11; top: calc(62px + var(--sat)); right: calc(14px + var(--sar));
  width: min(400px, calc(100vw - 28px)); max-height: calc(100dvh - 140px); overflow: auto;
  overscroll-behavior: contain; touch-action: pan-y;
  padding: 10px 0; border-radius: 6px;
  /* fringe top and bottom */
  background:
    repeating-linear-gradient(90deg, #efe1bf 0 2px, transparent 2px 7px) top / 100% 10px no-repeat,
    repeating-linear-gradient(90deg, #efe1bf 0 2px, transparent 2px 7px) bottom / 100% 10px no-repeat;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.6));
  animation: bdIn 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}
#rugbook[hidden] { display: none; }
#rugbook .rg-weave {
  padding: 18px 18px 16px; color: #f6ead0;
  background:
    linear-gradient(#7a2a1c, #7a2a1c) padding-box,
    repeating-linear-gradient(45deg, #d29a45 0 6px, #3b5a6b 6px 12px) border-box;
  border: 8px solid transparent;
  box-shadow: inset 0 0 0 2px #d29a45, inset 0 0 0 7px #7a2a1c, inset 0 0 0 9px #3b5a6b;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#rugbook .rg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#rugbook h2 { margin: 0; font-family: var(--groovy); font-weight: 400; font-size: 1.5rem; color: #ffd27a; }
#rugbook .rg-x { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; flex: none; background: rgba(0, 0, 0, 0.2); color: #ffd27a; border: 1px solid rgba(255, 210, 122, 0.45); font-size: 14px; }
#rugbook .rg-sub { margin: 4px 0 12px; color: rgba(246, 234, 208, 0.8); font-size: 13px; }
#rugbook form { display: grid; gap: 8px; }
#rugbook label { display: grid; gap: 3px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: #ffd27a; }
#rugbook input, #rugbook textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255, 210, 122, 0.35);
  background: rgba(0, 0, 0, 0.25); color: #fff6e0; font: 16px/1.35 system-ui, -apple-system, sans-serif; resize: vertical;
}
#rugbook input:focus-visible, #rugbook textarea:focus-visible, #rugbook button:focus-visible { outline: 2px solid #ffd27a; outline-offset: 1px; }
#rugbook .rg-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#rugbook .rg-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#rugbook .rg-count { font-size: 12px; color: rgba(246, 234, 208, 0.6); }
#rugbook button[type=submit] {
  padding: 0.55rem 1rem; border-radius: 999px; cursor: pointer; border: 0;
  background: #ffd27a; color: #3a140c; font: 700 14px/1 system-ui, -apple-system, sans-serif;
}
#rugbook button[type=submit]:disabled { opacity: 0.5; cursor: progress; }
#rugbook .rg-msg { margin: 0; min-height: 1.2em; font-size: 13px; color: #ffb4a0; }
#rugbook .rg-msg.ok { color: #c9f2d8; }
#rugbook .rg-notes { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px dashed rgba(255, 210, 122, 0.35); display: grid; gap: 8px; }
#rugbook .rg-notes li { padding: 8px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.18); }
#rugbook .rg-notes p { margin: 0 0 3px; font-family: var(--groovy); font-size: 15px; line-height: 1.3; color: #fff6e0; overflow-wrap: anywhere; }
#rugbook .rg-notes small { color: rgba(246, 234, 208, 0.65); font-size: 12px; }
#rugbook .rg-notes .rg-empty { background: none; color: rgba(246, 234, 208, 0.7); font-style: italic; }
.portrait #rugbook { left: calc(14px + var(--sal)); right: calc(14px + var(--sar)); width: auto; }
@media (prefers-reduced-motion: reduce) { #rugbook { animation: none; } }
