/* Pipe Flow! — "Sunny Waterworks" direction (2026-09-03).
   The lab sticker grammar (ink outlines, hard 4px shadows, Chewy + Sniglet) in this game's OWN
   place: a bright garden — sky above, copper pipes on a dug earth bed, a grass strip and a real
   soil plot down the side where her flowers pile up. Deliberately NOT cream-on-cream like the
   shop/stand: the grounds here are sky blue and soil brown. */
:root {
	--ink: #3b2a2a;
	--sh: 4px 4px 0 var(--ink);
	--sh-sm: 2px 2px 0 var(--ink);

	--sky1: #62c8f5;
	--sky2: #a8e6ff;
	--sky3: #d8f4ff;
	--grass: #7bd94a;
	--grass-d: #59b334;
	--soil: #8a5432;
	--soil-d: #6b3d22;
	--soil-l: #a86b41;

	--copper: #e08a3c;
	--copper-d: #b8622a;
	--water: #37b6f0;
	--water-l: #8fe3ff;

	--pink: #ff5fa2;
	--yellow: #f2c94c;
	--green: #7bd94a;
	--blue: #5bc8ff;
	--purple: #c77dff;
	--orange: #ff9a3c;
	--paper: #fff7e6;
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}
html,
body {
	height: 100%;
	margin: 0;
	overscroll-behavior: none;
}
body {
	font-family: 'Nunito','Trebuchet MS', sans-serif;
	font-weight: 800;
	color: var(--ink);
	background: var(--sky2);
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	overflow: hidden;
}
.f {
	font-family: 'Chewy', 'Arial Black', sans-serif;
	font-weight: 400;
}
.hide {
	display: none !important;
}

#app {
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0)
		env(safe-area-inset-left, 0);
	background:
		radial-gradient(circle at 82% 8%, rgba(255, 233, 120, 0.95) 0 5vmin, rgba(255, 233, 120, 0) 9vmin),
		linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 38%, var(--sky3) 62%, var(--sky3) 100%);
}

/* ---------------- top bar. Left 72px stays clear for the shared 🏠, right 84px for ⛶ ---------- */
#hud {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: clamp(6px, 1.2vw, 12px);
	padding: clamp(6px, 1.2vh, 12px) 84px clamp(4px, 1vh, 10px) 74px;
	min-height: 56px;
}
.chip {
	display: flex;
	align-items: center;
	gap: 6px;
	background: var(--paper);
	border: 3px solid var(--ink);
	border-radius: 999px;
	padding: 4px clamp(9px, 1.4vw, 15px);
	box-shadow: var(--sh-sm);
	font-family: 'Fredoka','Nunito',sans-serif;
	font-size: clamp(13px, 1.9vw, 21px);
	line-height: 1.25;
	white-space: nowrap;
}
.chip.lvl {
	background: var(--yellow);
	transform: rotate(-2deg);
}
.chip.stars {
	background: var(--pink);
	color: #fff;
	-webkit-text-stroke: 0;
	transform: rotate(1.5deg);
}
.chip.streak {
	background: var(--orange);
	transform: rotate(-1deg);
}
.chip.bump {
	animation: bump 0.4s;
}
@keyframes bump {
	40% {
		transform: scale(1.2) rotate(-3deg);
	}
}
#coach {
	flex: 1 1 auto;
	min-width: 0;
	font-family: 'Fredoka','Nunito',sans-serif;
	font-size: clamp(12px, 1.7vw, 19px);
	color: #2c4a63;
	text-align: right;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	opacity: 0.9;
}

/* ---------------- stage: board + garden ---------------------------------------------------- */
#stage {
	flex: 1 1 auto;
	min-height: 0;
	display: grid;
	grid-template-columns: 1fr clamp(190px, 25vw, 320px);
	gap: clamp(6px, 1.2vw, 16px);
	padding: 0 clamp(8px, 1.4vw, 18px) clamp(8px, 1.4vh, 16px);
}

#boardArea {
	position: relative;
	min-width: 0;
	min-height: 0;
	border: 4px solid var(--ink);
	border-radius: 22px;
	box-shadow: var(--sh);
	overflow: hidden;
	background: linear-gradient(180deg, #b9e7ff 0 22%, var(--grass) 22% 30%, var(--soil-l) 30% 100%);
}
#board {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

/* the one optional sticker between levels — she may tap it, she never has to */
#nextBtn {
	position: absolute;
	left: 50%;
	bottom: 12px;
	transform: translateX(-50%) rotate(-2deg);
	background: var(--green);
	border: 4px solid var(--ink);
	border-radius: 16px;
	box-shadow: var(--sh);
	font-family: 'Fredoka','Nunito',sans-serif;
	font-size: clamp(17px, 2.4vw, 26px);
	padding: 9px 22px;
	min-height: 48px;
	cursor: pointer;
	z-index: 6;
}
#nextBtn:active {
	transform: translateX(-50%) translate(3px, 3px) rotate(-2deg);
	box-shadow: 1px 1px 0 var(--ink);
}

/* toast: non-blocking, never needs a tap */
#toast {
	position: absolute;
	left: 50%;
	top: 10px;
	transform: translateX(-50%) rotate(-1deg);
	background: var(--paper);
	border: 3px solid var(--ink);
	border-radius: 14px;
	box-shadow: var(--sh-sm);
	font-family: 'Fredoka','Nunito',sans-serif;
	font-size: clamp(13px, 1.8vw, 20px);
	padding: 6px 16px;
	max-width: 86%;
	text-align: center;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s, transform 0.3s;
	z-index: 7;
}
#toast.show {
	opacity: 1;
	transform: translateX(-50%) translateY(4px) rotate(-1deg);
}

/* ---------------- the forever garden ------------------------------------------------------- */
#garden {
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border: 4px solid var(--ink);
	border-radius: 22px;
	box-shadow: var(--sh);
	overflow: hidden;
	/* all soil under the sign: her plants must stand IN the ground, not float in a sky band */
	background: linear-gradient(180deg, var(--grass-d) 0 6px, var(--soil-l) 6px 14px, var(--soil) 14px 100%);
}
#gardenHead {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	padding: 6px 10px;
	background: repeating-linear-gradient(90deg, var(--copper) 0 18px, #f0a55c 18px 36px);
	border-bottom: 4px solid var(--ink);
	font-family: 'Fredoka','Nunito',sans-serif;
	font-size: clamp(13px, 1.7vw, 19px);
	color: #fff;
	text-shadow: 2px 2px 0 var(--ink);
}
#plotWrap {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	padding: 8px 8px 14px;
}
#plot {
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	justify-content: center;
	gap: 2px 0;
}
.pl {
	width: 20%;
	text-align: center;
	font-size: clamp(20px, 3.4vw, 34px);
	line-height: 1.05;
	filter: drop-shadow(3px 4px 0 rgba(59, 42, 42, 0.28));
	transform-origin: 50% 100%;
	animation: sway 3.4s ease-in-out infinite alternate;
}
.pl:nth-child(3n) {
	animation-duration: 4.2s;
}
.pl:nth-child(3n + 1) {
	animation-delay: -1.6s;
}
@keyframes sway {
	from {
		transform: rotate(-5deg);
	}
	to {
		transform: rotate(5deg);
	}
}
.pl.pop {
	animation: sprout 0.75s cubic-bezier(0.2, 1.7, 0.4, 1);
}
@keyframes sprout {
	0% {
		transform: scale(0) translateY(16px);
	}
	60% {
		transform: scale(1.35) translateY(-6px);
	}
	100% {
		transform: scale(1);
	}
}
#gardenEmpty {
	text-align: center;
	color: #fff3dd;
	text-shadow: 2px 2px 0 rgba(59,42,42,.55);
	font-family: 'Fredoka','Nunito',sans-serif;
	font-size: clamp(12px, 1.6vw, 17px);
	padding: 18px 10px;
	line-height: 1.5;
}
/* a little picket fence along the bottom of the plot */
#fence {
	flex: 0 0 auto;
	height: 22px;
	background:
		repeating-linear-gradient(90deg, #fff7e6 0 14px, transparent 14px 26px),
		linear-gradient(180deg, transparent 0 6px, #fff7e6 6px 12px, transparent 12px 100%);
	border-top: 3px solid var(--ink);
	/* bottom-left ~64px belongs to the shared 🔊 / 📮 — the fence is decorative and untappable */
	pointer-events: none;
}

#fx {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 40;
}
#app.shake {
	animation: shake 0.34s;
}
@keyframes shake {
	20% {
		transform: translate(6px, -4px);
	}
	45% {
		transform: translate(-6px, 3px);
	}
	70% {
		transform: translate(4px, 4px);
	}
}

/* ---------------- portrait + phone: stack, scene on top, garden below ----------------------- */
/* narrow: the coach line would only ellipsize — the same words already arrive as a toast */
@media (max-width: 900px) {
	#coach {
		display: none;
	}
}
@media (orientation: portrait), (max-width: 720px) {
	#stage {
		grid-template-columns: 1fr;
		grid-template-rows: 1fr clamp(150px, 27vh, 300px);
	}
	.pl {
		width: 10%;
	}
	#plot {
		justify-content: flex-start;
		padding-left: 4px;
	}
}
@media (max-width: 720px) and (orientation: portrait) {
	.pl {
		width: 16.6%;
	}
}
/* short landscape phone: keep the garden a narrow column, not a squashed row */
@media (orientation: landscape) and (max-height: 460px) {
	#hud {
		min-height: 44px;
		padding-top: 4px;
		padding-bottom: 2px;
	}
	#stage {
		grid-template-columns: 1fr clamp(150px, 22vw, 230px);
	}
}
