:root {
	--camera-bg: #10202c;
	--thumb-max: 72px; /* thumb width cap — keeps the 9:16 strip compact (max ~128px tall) */
}

* { box-sizing: border-box; }

#goBack {
	position: fixed;
	top: 14px;
	left: 14px;
	z-index: 5;
	border-radius: 999px;
	padding: 0.5rem 0.85rem;
	font: inherit;
	font-weight: 700;
	font-size: 0.78rem;
	line-height: 1;
	font-family: Fredoka, sans-serif;
	text-decoration: none;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
	background: linear-gradient(180deg, #ff6b6b 0%, #e03131 100%);
	color: #fff;
	border: 2px solid rgba(255, 255, 255, 0.4);
	box-shadow: 0 8px 18px rgba(224, 49, 49, 0.32);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#goBack:active { transform: scale(0.94); }

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
	background: var(--camera-bg);
	touch-action: manipulation;
	-webkit-user-select: none;
	user-select: none;
}

.camera-shell {
	position: fixed;
	inset: 0;
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
}

.camera-view {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transform: scaleX(-1); /* selfie mirror */
	background: #0b151d;
}

.camera-fallback {
	position: absolute;
	left: 50%;
	top: 40%;
	transform: translate(-50%,-50%);
	background: rgba(16, 32, 44, 0.9);
	color: #fff;
	font-family: Fredoka, sans-serif;
	font-size: 1.3rem;
	padding: 1.2rem 1.6rem;
	border-radius: 18px;
	cursor: pointer;
}

.flash-layer {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: #fff;
	opacity: 0;
	transition: opacity 40ms linear;
	z-index: 2;
}

.flash-layer.flashing { opacity: 0.92; }

.privacy-note {
	position: fixed;
	z-index: 3;
	bottom: calc(var(--thumb-max) * 16 / 9 + 124px);
	left: 50%;
	transform: translateX(-50%);
	margin: 0;
	font-family: Fredoka, sans-serif;
	font-size: 1rem;
	color: #e3f2fd;
	background: rgba(16, 32, 44, 0.72);
	padding: 6px 14px;
	border-radius: 14px;
	text-align: center;
	opacity: 0;
	transition: opacity 700ms ease;
	pointer-events: none;
}

.privacy-note.visible { opacity: 1; }
.privacy-note.faded { opacity: 0; }

.shutter-btn {
	position: fixed;
	bottom: calc(var(--thumb-max) * 16 / 9 + 24px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 3;
	justify-self: center;
	margin: 12px 0 16px;
	width: 84px;
	height: 84px;
	border-radius: 50%;
	background: transparent;
	border: 6px solid #ffffff;
	display: grid;
	place-items: center;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.shutter-ring {
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 6px solid #fff;
}

.shutter-core {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: #4ade80;
	transition: transform 90ms ease, background 120ms ease;
}

.shutter-btn:active .shutter-core { transform: scale(0.82); }

.thumb-track {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 3;
	touch-action: none; /* don't let long-press/scroll gestures pointercancel the hold */
	display: flex;
	gap: 8px;
	align-items: flex-end;
	padding: 0 12px 8px;
	overflow: hidden;
	justify-content: center;
}

.thumb {
	-webkit-user-drag: none; /* no image-drag steal mid-hold */
	user-select: none;
	/* 9:16 portrait, filling the viewport width together */
	flex: 1 1 0;
	width: auto;
	min-width: 0;
	max-width: var(--thumb-max);
	height: auto; /* aspect-ratio is set per thumb to match its picture */
	border-radius: 12px;
	border: 3px solid #fff;
	object-fit: cover;
	transition: transform 400ms ease, opacity 400ms ease, margin 400ms ease;
	animation: thumb-slide-in 400ms ease; /* new pictures slide down into the stack at the same pace as the drop-out */
}

@keyframes thumb-slide-in {
	from { transform: translateY(-140%) scale(0.7); opacity: 0; }
	to { transform: translateY(0) scale(1); opacity: 1; }
}

.preview-layer {
	position: fixed;
	inset: 0;
	z-index: 4;
	display: grid;
	place-items: center;
	background: rgba(11, 21, 29, 0.6);
	pointer-events: none; /* hold continues to be tracked on the thumb itself */
	opacity: 0;
	transition: opacity 150ms ease;
}

.preview-layer.show { opacity: 1; }

.preview-img {
	/* Fill the width on phones, but shrink to fit the viewport height on
	   tablets/landscape so the picture is never cropped. */
	width: min(100vw, calc(100dvh * var(--preview-r, 0.5625)));
	height: auto;
	aspect-ratio: var(--preview-r, 0.5625);
	object-fit: cover;
	border-radius: 24px;
	border: 6px solid #fff;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.thumb.deleting {
	transform: translateY(140%) scale(0.7);
	opacity: 0;
	margin-right: calc(-1 * var(--thumb-max) - 8px);
}

@media (max-width: 480px) {
	
	.shutter-btn { margin-bottom: 10px; margin-top: 8px; width: 72px; height: 72px; }
	.shutter-core { width: 52px; height: 52px; }
}
