:root {
	--blue: #93c5fd;
	--pink: #f9a8d4;
	--green: #86efac;
	--cyan: #22d3ee;
	--yellow: #fef08a;
	--red: #ef4444;
	--line: 4px solid #fff;
	font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--blue); color: #000; }
button { font: inherit; cursor: pointer; background: #fff; border: 1px solid #000; padding: 0.2em 0.5em; }
button:hover { background: var(--yellow); }
button:disabled { opacity: 0.3; cursor: default; }
button.pink { background: var(--pink); }
button.yellow { background: var(--yellow); }
button.big { font-size: 1.6rem; font-weight: bold; padding: 0.5em 1.2em; border: 8px double #000; letter-spacing: 0.1em; }
input { font: inherit; background: #fecaca; border: 1px solid #000; padding: 0.2em 0.4em; }
.fine { font-size: 0.8rem; opacity: 0.7; }
.row { display: flex; gap: 0.5em; align-items: center; flex-wrap: wrap; }

/* door */
.door { max-width: 42rem; margin: 0 auto; padding: 2rem 1rem; display: grid; gap: 1.5rem; }
.door h1 { color: #fff; font-family: system-ui, sans-serif; font-size: 4rem; margin: 0; }
.door h1 small { font-size: 1.2rem; letter-spacing: 0.3em; }
.panel { border: 1px solid #000; padding: 1.5rem; }
.panel.green, .green { background: var(--green); }
.door label { display: grid; gap: 0.4em; margin-top: 1em; }
.door-buttons { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }

/* shop */
.shop {
	height: 100dvh;
	display: grid;
	grid-template-columns: 1fr clamp(6rem, 14vw, 11rem);
	grid-template-rows: auto 1fr auto;
	grid-template-areas: "head head" "stage shelf" "line shelf";
	border: var(--line);
}
header { grid-area: head; display: flex; align-items: center; gap: 1rem; padding: 0.5rem 1rem; border-bottom: var(--line); flex-wrap: wrap; }
.logo { color: #fff; font: bold 2rem system-ui, sans-serif; text-decoration: none; }
.status { background: var(--yellow); padding: 0.2em 0.6em; border: 1px solid #000; }
.note { background: var(--red); color: #fff; padding: 0.2em 0.6em; cursor: pointer; font-size: 0.85rem; }
header nav { margin-left: auto; display: flex; gap: 0.3rem; }
header nav button { background: transparent; border: none; }
header nav button:hover { color: var(--pink); background: transparent; }
header nav button.off { text-decoration: line-through; opacity: 0.5; }

.stage {
	grid-area: stage;
	background: var(--cyan);
	display: grid;
	gap: 4px;
	padding: 4px;
	grid-template-columns: repeat(4, 1fr);
	grid-auto-rows: minmax(0, 1fr);
	grid-auto-flow: dense;
	min-height: 0;
	border-right: var(--line);
}
.stage[data-count="1"] { grid-template-columns: 1fr; }
.stage[data-count="1"] .tile.big { grid-column: span 1; grid-row: span 1; }
.stage[data-count="2"] { grid-template-columns: 1fr 1fr; }
.stage[data-count="2"] .tile.big { grid-column: span 1; grid-row: span 1; }
.tile { margin: 0; position: relative; background: #0e7490; overflow: hidden; min-height: 0; }
.tile.big { grid-column: span 2; grid-row: span 2; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.me video { transform: scaleX(-1); }
.tile.away { opacity: 0.4; }
.novideo { position: absolute; inset: 0; display: grid; place-items: center; font: bold 4rem system-ui; color: #fff; }
figcaption { position: absolute; left: 0; bottom: 0; display: flex; gap: 0.4em; align-items: center; padding: 0.2em 0.5em; background: #fffd; font-size: 0.8rem; }
figcaption b { background: var(--pink); padding: 0 0.3em; font-size: 0.7rem; }
figcaption i { background: var(--red); color: #fff; font-style: normal; padding: 0 0.3em; font-size: 0.7rem; }
figcaption em { font-style: normal; opacity: 0.6; }
.empty { grid-column: 1 / -1; display: grid; place-items: center; color: #fff; font-size: 1.5rem; }

.shelf { grid-area: shelf; background: var(--pink); overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 0.5rem; }
.shelf .curate { width: 100%; background: var(--yellow); font-size: 0.75rem; }
.shelf-item { position: relative; }
.shelf-item img { width: 100%; aspect-ratio: 1; display: block; border: 1px solid #000; cursor: pointer; background: var(--yellow); }
.shelf-item .x { position: absolute; top: 0; right: 0; padding: 0 0.3em; line-height: 1.2; }
.cart { margin-top: auto; position: sticky; bottom: 0; width: calc(100% + 1rem); text-align: center; background: var(--green); padding: 1.2rem 0; border-top: var(--line); }

.line { grid-area: line; padding: 0.5rem 1rem; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; background: var(--blue); border-right: var(--line); border-top: var(--line); font-size: 0.85rem; }
.line .label { opacity: 0.7; }
.chip { background: #fff; border: 1px solid #000; padding: 0.1em 0.5em; }
.chip.me { background: var(--yellow); font-weight: bold; }
.chip.away { opacity: 0.4; }

/* host panel */
.hostpanel {
	position: fixed; top: 4rem; left: 1rem; width: min(30rem, 90vw); max-height: calc(100dvh - 6rem); overflow-y: auto;
	background: var(--green); border: 4px double #000; padding: 1rem; display: grid; gap: 0.6rem; font-size: 0.85rem; z-index: 10;
}
.hostpanel h2 { margin: 0; font-size: 1rem; }
.guest { background: #fff; border: 1px solid #000; padding: 0.4rem; display: grid; gap: 0.3rem; }
.guest.onstage { background: var(--yellow); }
.guest.away { opacity: 0.5; }
.guest .ctrl { display: flex; gap: 0.2rem; flex-wrap: wrap; }
.guest .ctrl button { font-size: 0.75rem; padding: 0.1em 0.4em; }
.guest .ctrl button.on { background: var(--red); color: #fff; }
.guest .vol { display: flex; align-items: center; gap: 0.4rem; }
.guest .vol input { flex: 1; background: none; border: 0; }

/* modals */
.modal { position: fixed; inset: 0; background: #155e75cc; display: grid; place-items: center; z-index: 20; padding: 1rem; }
.box { background: var(--green); border: 4px solid var(--pink); padding: 1rem; width: min(52rem, 100%); max-height: 90dvh; overflow-y: auto; display: grid; gap: 0.8rem; }
.box .row input { flex: 1; font-size: 1.1rem; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 0.5rem; }
.result { display: grid; gap: 0.2rem; text-align: left; background: #fff; padding: 0.3rem; font-size: 0.75rem; }
.result img { width: 100%; aspect-ratio: 1; }
.preview { display: grid; gap: 0.5rem; justify-items: start; }
.preview img { width: min(20rem, 100%); aspect-ratio: 1; border: 1px solid #000; }
.preview h3, .product h3 { margin: 0; text-transform: uppercase; font-family: system-ui, sans-serif; }
.product { grid-template-columns: minmax(10rem, 1fr) 1.2fr; }
.product img { width: 100%; aspect-ratio: 1; border: 1px solid #000; }

@media (max-width: 700px) {
	.shop { grid-template-columns: 1fr 5.5rem; }
	.stage { grid-template-columns: 1fr 1fr; }
	.tile.big { grid-column: 1 / -1; }
	.product { grid-template-columns: 1fr; }
}

/* ---------- clouds ---------- */
.tile video.srconly { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
.tile canvas.cloud { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile.me canvas.cloud { transform: scaleX(-1); }

.stage.clouds {
	background:
		radial-gradient(ellipse 30% 12% at 18% 22%, #fff9, transparent 70%),
		radial-gradient(ellipse 25% 10% at 78% 14%, #fff8, transparent 70%),
		radial-gradient(ellipse 35% 14% at 60% 88%, #fff7, transparent 70%),
		linear-gradient(180deg, var(--blue) 0%, #c7d7fe 45%, var(--pink) 100%);
	overflow: hidden;
}
.stage.clouds .tile { background: transparent; overflow: visible; }
.stage.clouds .tile .novideo { color: #fffc; text-shadow: 0 0 30px #fff; }
.tile.floaty canvas.cloud {
	filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 28px #ffffffaa);
	animation: drift 7s ease-in-out infinite;
}
.stage.clouds .tile:nth-child(2n) canvas.cloud { animation-duration: 8.5s; animation-delay: -2s; }
.stage.clouds .tile:nth-child(3n) canvas.cloud { animation-duration: 9.5s; animation-delay: -4s; }
.tile.me.floaty canvas.cloud { animation-name: drift-mirrored; }
@keyframes drift {
	0%, 100% { translate: 0 0; rotate: -0.6deg; }
	50% { translate: 0 -12px; rotate: 0.6deg; }
}
@keyframes drift-mirrored {
	0%, 100% { translate: 0 0; rotate: 0.6deg; }
	50% { translate: 0 -12px; rotate: -0.6deg; }
}
.stage.clouds figcaption { background: #fff8; border-radius: 1em; left: 50%; translate: -50% 0; bottom: 0.4rem; }
.guest .ctrl button.on, .hostpanel button.on { background: var(--red); color: #fff; }

/* ---------- shop: shelf, bag, peeking ---------- */
.shelf-item .tag { position: absolute; left: 0; bottom: 0; background: #000; color: #fff; font-size: 0.6rem; padding: 0 0.3em; }
.shelf-item .noimg { aspect-ratio: 1; background: var(--yellow); border: 1px solid #000; font-size: 0.7rem; padding: 0.3em; cursor: pointer; overflow: hidden; }
.shop .cart { font: inherit; border: 0; border-top: var(--line); cursor: pointer; }
.result.archive { background: #eee; }
.result.soldout { opacity: 0.5; }
.desc { font-size: 0.9rem; }
.desc img { max-width: 100%; }
.variants button { font-weight: bold; }

.bag {
	position: fixed; top: 0; right: 0; bottom: 0; width: min(22rem, 92vw); z-index: 15;
	background: #fecaca; color: #7f1d1d; border-left: 4px double #000; padding: 1rem;
	display: flex; flex-direction: column; gap: 0.6rem; overflow-y: auto;
}
.bag-head { justify-content: space-between; }
.bagline { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.6rem; align-items: start; font-size: 0.85rem; }
.bagline img { width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid currentColor; }
.bagline .row button { padding: 0 0.3em; }
.empty-bag { flex: 1; display: grid; place-items: center; color: var(--red); font-weight: bold; }
.bag-foot { margin-top: auto; text-align: right; display: grid; gap: 0.3rem; justify-items: end; border-top: 1px dashed currentColor; padding-top: 0.6rem; }
.bag .share { display: flex; gap: 0.4em; align-items: center; }
.peek { width: min(30rem, 100%); }
.peek h3 { margin: 0; }

.bagbadge { font-size: 0.7rem; padding: 0 0.4em; border-radius: 1em; background: #fff; }
.paying, .bagbadge.paying, .chip.paying { background: var(--green) !important; animation: pay 1.2s ease-in-out infinite; }
@keyframes pay { 50% { background: var(--yellow); } }
.chip { cursor: default; }
.chip b { font-weight: normal; }
.ticker { background: var(--green); border: 1px solid #000; padding: 0.2em 0.6em; cursor: pointer; animation: pay 1.2s ease-in-out infinite; }

/* ---------- ovals: everyone is a face oval ----------
   Pure CSS, works on the plain camera video (no mask, no sender work).
   Host + 1st in line: big, still, centred (flex centres only in-flow tiles).
   Everyone else: smaller, taken out of the flow, and bounce slowly around the
   stage in front of them. The customer at the counter is a step smaller than the host. Two linear alternating animations (left, top) with
   different lengths give a DVD-logo path that never quite repeats. */
.stage.ovals {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 3vmin;
	position: relative;
	overflow: hidden;
	container-type: size;
}
.stage.ovals .tile { background: transparent; overflow: visible; aspect-ratio: 3 / 4; grid-column: auto; grid-row: auto; }
.stage.ovals .tile video,
.stage.ovals .tile .novideo,
.stage.ovals .tile canvas.cloud { border-radius: 50%; border: var(--line); background: #0e7490; }
.stage.ovals .tile.big { height: min(76cqh, 60cqw); position: relative; z-index: 2; }
.stage.ovals:not(.ovals-me) .tile.big:not(.host) { height: min(58cqh, 46cqw); } /* whoever's at the counter: a step smaller than the host */
.stage.ovals .tile:not(.big) {
	--d: min(30cqh, 24cqw, calc(90cqh / (var(--n, 5) - 1))); /* smaller as more people are on stage */
	position: absolute;
	height: var(--d);
	z-index: 3; /* drifters stay in front: never hidden behind the big ones */
	animation: oval-x 83s linear infinite alternate, oval-y 61s linear infinite alternate;
}
.stage.ovals .tile:not(.big):nth-child(3n) { animation-duration: 97s, 71s; animation-delay: -30s, -11s; }
.stage.ovals .tile:not(.big):nth-child(3n+1) { animation-duration: 74s, 89s; animation-delay: -52s, -40s; }
/* tray.js takes over (balls bouncing off each other and the big ovals); the CSS drift above is the fallback */
.stage.ovals.tray .tile:not(.big) { animation: none; left: 0; top: 0; will-change: transform; }
@keyframes oval-x { from { left: 0; } to { left: calc(100% - var(--d) * 0.75); } }
@keyframes oval-y { from { top: 0; } to { top: calc(100% - var(--d)); } }
.stage.ovals figcaption { background: #fffd; border-radius: 1em; left: 50%; translate: -50% 0; bottom: 4%; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .stage.ovals .tile:not(.big) { animation: none; left: 4%; top: 4%; } }

/* ---------- host: customer carts (reuses .bag) ---------- */
.bag.hostcarts { background: var(--yellow); color: #000; z-index: 16; }
.hostcarts .tabs { flex-wrap: wrap; gap: 0.3rem; }
.hostcarts .tab { border: 1px solid #000; background: #fff; padding: 0.2em 0.6em; }
.hostcarts .tab.on { background: #000; color: #fff; }
.hostcarts .tab.gone { opacity: 0.45; text-decoration: line-through; }
.hostcarts .hcbody { display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }
.hostcarts .to { width: 100%; font: inherit; padding: 0.3em; }
.hostcarts .link { word-break: break-all; opacity: 0.6; text-align: left; }
.hostcarts .bag-foot { justify-items: stretch; text-align: left; }

/* ---------- ovals, host-big variant: the host IS the background ----------
   Everyone else orbits the host's face on a slow ellipse. x and y are the same
   back-and-forth sweep with a sine ease, a quarter-turn apart (that's an
   ellipse), and each person starts a share of the way round (--i of --n). */
.stage.ovals-me { --D: 28s; }
.stage.ovals-me .tile.host { position: absolute; inset: 0; height: auto; aspect-ratio: auto; z-index: 0; }
.stage.ovals-me .tile.host video,
.stage.ovals-me .tile.host .novideo,
.stage.ovals-me .tile.host canvas.cloud { border-radius: 0; border: 0; }
.stage.ovals-me .tile:not(.host) {
	--d: min(24cqh, 19cqw);
	--w: calc(var(--d) * 0.75);
	--rx: calc(50cqw - var(--w) / 2 - 1.5cqw);
	--ry: calc(50cqh - var(--d) / 2 - 1.5cqh);
	position: absolute;
	height: var(--d);
	z-index: 1;
	animation: orbit-x var(--D) cubic-bezier(0.37, 0, 0.63, 1) infinite alternate, orbit-y var(--D) cubic-bezier(0.37, 0, 0.63, 1) infinite alternate;
	animation-delay: calc(var(--D) * -2 * var(--i) / var(--n)), calc(var(--D) * -2 * var(--i) / var(--n) - var(--D) / 2);
}
.stage.ovals-me .tile.big:not(.host) { --d: min(28cqh, 22cqw); } /* whoever's at the counter: just a touch bigger than the rest */
@keyframes orbit-x { from { left: calc(50cqw - var(--rx) - var(--w) / 2); } to { left: calc(50cqw + var(--rx) - var(--w) / 2); } }
@keyframes orbit-y { from { top: calc(50cqh - var(--ry) - var(--d) / 2); } to { top: calc(50cqh + var(--ry) - var(--d) / 2); } }
.stage.ovals-me .tile.host figcaption { left: 0; translate: 0; bottom: 0; border-radius: 0; }
@media (prefers-reduced-motion: reduce) { .stage.ovals-me .tile:not(.host) { animation: none; left: 4%; top: 4%; } }

/* ---------- sales + QR ---------- */
.ticker.sale { background: var(--yellow); font-weight: bold; }
.hostcarts .sales { margin-top: auto; border-top: 1px dashed #000; padding-top: 0.5rem; display: grid; gap: 0.2rem; font-size: 0.8rem; }
.hostcarts .sale-line { gap: 0.6rem; }
.hostcarts .sale-line b { margin-left: auto; }
.qrbox { width: min(30rem, 100%); text-align: center; display: grid; gap: 0.5rem; justify-items: center; }
.qrbox h3 { margin: 0; }
.qr { width: min(24rem, 70vh, 100%); }
.qr svg { width: 100%; height: auto; display: block; border: 4px double #000; border-radius: 1rem; }

/* ---------- /sim: fake visitors ---------- */
.sim { max-width: 56rem; margin: 0 auto; background: var(--green); border: 4px double #000; padding: 1rem; display: grid; gap: 0.8rem; font-size: 0.85rem; }
.sim h2 { margin: 0; }
.sim label { display: grid; gap: 0.2rem; }
.sim input { font: inherit; padding: 0.3em; }
.simtable { width: 100%; border-collapse: collapse; background: #fff; }
.simtable td { padding: 0.3rem 0.5rem; border-bottom: 1px solid #000; }
.simtable tr.gone { opacity: 0.45; }
.simlog { background: #000; color: #86efac; padding: 0.6rem; min-height: 6rem; max-height: 14rem; overflow: auto; margin: 0; font-size: 0.75rem; }

/* mock faces (stand in for video in mock-ups: /sim and "give me a mock face") */
/* (as specific as the ovals rule that uses the background shorthand, and later, so it wins) */
.stage .tile .novideo.face { background-size: cover; background-position: center 30%; background-repeat: no-repeat; }

/* ---------- /embed: the view-only version for the Shopify homepage ---------- */
body.watcher header .joinlink { color: #fff; text-decoration: none; font-weight: bold; }
body.watcher header .joinlink:hover { color: var(--pink); }
body.watcher .shelf-item .x, body.watcher .curate { display: none; }
body.watcher .line .chip { cursor: default; }
