/* ================= Effects layer ================= */
.hte-layer {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 999990;
	overflow: hidden;
}

/* ---- falling icons ---- */
.hte-fall { position: absolute; inset: 0; }
.hte-item {
	position: absolute;
	top: -50px;
	will-change: transform;
	user-select: none;
	filter: drop-shadow(0 0 3px rgba(255, 140, 0, 0.5));
	animation: hte-fall linear infinite;
}
@keyframes hte-fall {
	0%   { transform: translateY(-10vh) translateX(0) rotate(0deg); }
	50%  { transform: translateY(50vh) translateX(20px) rotate(180deg); }
	100% { transform: translateY(110vh) translateX(-20px) rotate(360deg); }
}

/* ---- flying bats ---- */
.hte-bat {
	position: absolute;
	left: 0;
	will-change: transform;
	filter: drop-shadow(0 0 6px rgba(160, 80, 255, 0.7));
	animation-timing-function: linear;
	animation-fill-mode: forwards;
}
@keyframes hte-fly-ltr {
	0%   { transform: translate(-80px, 0) scaleX(-1) rotate(-6deg); }
	25%  { transform: translate(25vw, -40px) scaleX(-1) rotate(6deg); }
	50%  { transform: translate(50vw, 30px) scaleX(-1) rotate(-6deg); }
	75%  { transform: translate(75vw, -30px) scaleX(-1) rotate(6deg); }
	100% { transform: translate(110vw, 20px) scaleX(-1) rotate(-6deg); }
}
@keyframes hte-fly-rtl {
	0%   { transform: translate(110vw, 0) rotate(6deg); }
	25%  { transform: translate(75vw, -40px) rotate(-6deg); }
	50%  { transform: translate(50vw, 30px) rotate(6deg); }
	75%  { transform: translate(25vw, -30px) rotate(-6deg); }
	100% { transform: translate(-80px, 20px) rotate(6deg); }
}

/* ---- hanging spiders ---- */
.hte-spider {
	position: absolute;
	top: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	transform-origin: top center;
	animation: hte-dangle ease-in-out infinite;
}
.hte-thread {
	display: block;
	width: 1px;
	height: 14vh;
	background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.75));
}
.hte-spider-body {
	display: block;
	font-size: 28px;
	line-height: 1;
	margin-top: -4px;
	filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.7));
}
@keyframes hte-dangle {
	0%, 100% { transform: translateY(-9vh) rotate(-3deg); }
	45%      { transform: translateY(8vh) rotate(3deg); }
	60%      { transform: translateY(8vh) rotate(-2deg); }
}

/* ---- cobwebs ---- */
.hte-web {
	position: absolute;
	top: 0;
	width: clamp(90px, 16vw, 200px);
	height: clamp(90px, 16vw, 200px);
	color: rgba(255, 255, 255, 0.55);
	filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.6));
}
.hte-web svg { width: 100%; height: 100%; display: block; }
.hte-web-l { left: 0; }
.hte-web-r { right: 0; transform: scaleX(-1); }

/* ---- fog ---- */
.hte-fog {
	position: absolute;
	left: -50%;
	width: 200%;
	bottom: 0;
	height: 26vh;
	background:
		radial-gradient(ellipse 18% 55% at 10% 80%, rgba(210, 200, 230, 0.20), transparent 70%),
		radial-gradient(ellipse 22% 60% at 35% 90%, rgba(210, 200, 230, 0.22), transparent 70%),
		radial-gradient(ellipse 20% 50% at 62% 85%, rgba(210, 200, 230, 0.18), transparent 70%),
		radial-gradient(ellipse 24% 60% at 88% 90%, rgba(210, 200, 230, 0.22), transparent 70%);
	animation: hte-drift 55s linear infinite;
}
.hte-fog-2 {
	height: 20vh;
	opacity: 0.8;
	animation-duration: 80s;
	animation-direction: reverse;
}
@keyframes hte-drift {
	from { transform: translateX(0); }
	to   { transform: translateX(25%); }
}

/* ---- moon ---- */
.hte-moon {
	position: absolute;
	top: 5vh;
	right: 9vw;
	width: clamp(54px, 8vw, 100px);
	height: clamp(54px, 8vw, 100px);
	border-radius: 50%;
	background: radial-gradient(circle at 35% 35%, #fffbe6 0%, #ffe9a8 45%, #f0c868 100%);
	box-shadow: 0 0 40px 12px rgba(255, 220, 130, 0.45), 0 0 120px 40px rgba(255, 190, 80, 0.2);
	opacity: 0.85;
	animation: hte-moon-glow 6s ease-in-out infinite;
}
.hte-moon::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background:
		radial-gradient(circle at 30% 40%, rgba(160, 120, 40, 0.25) 0 8%, transparent 9%),
		radial-gradient(circle at 62% 30%, rgba(160, 120, 40, 0.2) 0 6%, transparent 7%),
		radial-gradient(circle at 55% 68%, rgba(160, 120, 40, 0.22) 0 10%, transparent 11%);
}
@keyframes hte-moon-glow {
	0%, 100% { box-shadow: 0 0 40px 12px rgba(255, 220, 130, 0.45), 0 0 120px 40px rgba(255, 190, 80, 0.2); }
	50%      { box-shadow: 0 0 55px 18px rgba(255, 220, 130, 0.6), 0 0 150px 55px rgba(255, 190, 80, 0.28); }
}

/* ---- lightning ---- */
.hte-lightning {
	position: absolute;
	inset: 0;
	background: rgba(220, 225, 255, 0.9);
	opacity: 0;
}
.hte-lightning.hte-strike { animation: hte-flash 1.3s ease-out 1; }
@keyframes hte-flash {
	0%   { opacity: 0; }
	4%   { opacity: 0.35; }
	8%   { opacity: 0.05; }
	14%  { opacity: 0.5; }
	40%  { opacity: 0.08; }
	100% { opacity: 0; }
}

/* ---- sound button ---- */
.hte-sound-btn {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: 1000001;
	width: 48px;
	height: 48px;
	padding: 0;
	font-size: 22px;
	line-height: 1;
	color: #fff;
	background: radial-gradient(circle at 50% 30%, #3b1a5a, #1a0b2e);
	border: 2px solid #ff7a00;
	border-radius: 50%;
	cursor: pointer;
	box-shadow: 0 0 14px rgba(255, 122, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.5);
	transition: transform 0.2s ease;
}
.hte-sound-btn:hover { transform: scale(1.1); }
.hte-sound-btn.hte-need-tap { animation: hte-pulse 1.6s ease-in-out infinite; }
@keyframes hte-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 0, 0.7), 0 4px 14px rgba(0, 0, 0, 0.5); }
	50%      { box-shadow: 0 0 0 14px rgba(255, 122, 0, 0), 0 4px 14px rgba(0, 0, 0, 0.5); }
}

/* ================= Popup (big, with cartoon monsters) ================= */
.hte-popup-backdrop {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	display: flex;
	padding: 16px;
	box-sizing: border-box;
	overflow-y: auto;
	background: radial-gradient(circle at 50% 40%, rgba(40, 14, 70, 0.8), rgba(5, 2, 12, 0.94));
	opacity: 0;
	transition: opacity 0.9s ease;
}
.hte-popup-backdrop.hte-open { opacity: 1; }
/* red "boo" vignette flash every time a new monster appears */
.hte-popup-backdrop::after {
	content: '';
	position: fixed;
	inset: 0;
	pointer-events: none;
	background: radial-gradient(circle at 50% 50%, transparent 35%, rgba(190, 0, 20, 0.65) 100%);
	opacity: 0;
}
.hte-popup-backdrop.hte-boo::after { animation: hte-boo 1.3s ease-out 0.4s 1; }
@keyframes hte-boo { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }

.hte-popup {
	position: relative;
	margin: auto;
	width: 100%;
	max-width: 860px;
	box-sizing: border-box;
	padding: 36px 40px 34px;
	color: #fff;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background:
		radial-gradient(circle at 25% 0%, rgba(255, 122, 0, 0.2) 0%, transparent 55%),
		radial-gradient(circle at 50% 0%, #432066 0%, #1a0b2e 80%);
	border: 2px solid #ff7a00;
	border-radius: 26px;
	box-shadow: 0 0 30px rgba(255, 122, 0, 0.5), 0 0 100px rgba(150, 60, 255, 0.35), 0 20px 60px rgba(0, 0, 0, 0.75);
	opacity: 0;
	transform: scale(0.8) translateY(40px);
	transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 1s ease;
	animation: hte-border-glow 4s ease-in-out infinite;
}
.hte-open .hte-popup { opacity: 1; transform: scale(1) translateY(0); }
.hte-open .hte-popup.hte-swap { opacity: 0; transform: scale(0.94) translateY(14px); transition-duration: 0.7s, 0.7s; }

@keyframes hte-border-glow {
	0%, 100% { box-shadow: 0 0 22px rgba(255, 122, 0, 0.45), 0 0 80px rgba(150, 60, 255, 0.3), 0 20px 60px rgba(0, 0, 0, 0.75); }
	50%      { box-shadow: 0 0 40px rgba(255, 122, 0, 0.75), 0 0 120px rgba(150, 60, 255, 0.5), 0 20px 60px rgba(0, 0, 0, 0.75); }
}

.hte-popup-body {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: 34px;
}

/* ---- the monster ---- */
.hte-char-stage {
	position: relative;
	flex: 0 0 44%;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	margin-top: -70px;     /* pokes out above the card */
	min-height: 340px;
}
.hte-char-glow {
	position: absolute;
	left: 50%;
	bottom: 8%;
	width: 120%;
	aspect-ratio: 1;
	transform: translateX(-50%);
	background: radial-gradient(circle, rgba(255, 122, 0, 0.45) 0%, rgba(150, 60, 255, 0.25) 45%, transparent 70%);
	animation: hte-glow-pulse 3s ease-in-out infinite;
}
.hte-popup-body[class*="hte-enter"] .hte-char-glow { opacity: 1; }
.hte-char {
	position: relative;
	width: 100%;
	max-width: 340px;
	filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6));
}
.hte-char svg { display: block; width: 100%; height: auto; overflow: visible; }
.hte-char-emoji { font-size: 150px; line-height: 1; text-align: center; filter: drop-shadow(0 0 18px rgba(255, 140, 0, 0.9)); }
.hte-char-fog {
	position: absolute;
	left: -10%;
	right: -10%;
	bottom: -14px;
	height: 60px;
	background: radial-gradient(ellipse at 50% 60%, rgba(220, 210, 240, 0.55), transparent 70%);
	filter: blur(6px);
	animation: hte-fog-breathe 5s ease-in-out infinite;
}

/* jump-scare entrance: lunges at the screen, then settles & floats */
.hte-enter .hte-char { animation: hte-lunge 1.5s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
.hte-enter .hte-char svg, .hte-enter .hte-char-emoji { animation: hte-hover 4s 1.6s ease-in-out infinite; }
.hte-enter .hte-char-glow { animation: hte-glow-pulse 3s ease-in-out infinite; }
@keyframes hte-lunge {
	0%   { opacity: 0; transform: translateY(90px) scale(0.35) rotate(-14deg); }
	45%  { opacity: 1; transform: translateY(-10px) scale(1.22) rotate(5deg); }
	62%  { transform: translateY(0) scale(1.1) rotate(-3deg); }
	80%  { transform: scale(0.98) rotate(1deg); }
	100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes hte-hover {
	0%, 100% { transform: translateY(0) rotate(-2deg); }
	50%      { transform: translateY(-12px) rotate(2deg); }
}
@keyframes hte-glow-pulse {
	0%, 100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
	50%      { opacity: 1;   transform: translateX(-50%) scale(1.08); }
}
@keyframes hte-fog-breathe {
	0%, 100% { opacity: 0.6; transform: scaleX(1); }
	50%      { opacity: 1;   transform: scaleX(1.08); }
}

/* glowing eyes flicker */
.hte-eye { animation: hte-eye-glow 2.2s ease-in-out infinite; filter: drop-shadow(0 0 5px currentColor); }
@keyframes hte-eye-glow {
	0%, 100% { opacity: 1; }
	45%      { opacity: 0.55; }
	50%      { opacity: 1; }
	92%      { opacity: 1; }
	94%      { opacity: 0.2; }
	96%      { opacity: 1; }
}

/* ---- text column ---- */
.hte-popup-content { flex: 1; text-align: left; min-width: 0; }
.hte-enter .hte-popup-title   { animation: hte-rise 1.1s 0.7s both ease-out, hte-flicker 4s 2.2s infinite; }
.hte-enter .hte-popup-message { animation: hte-rise 1.1s 1s both ease-out; }
.hte-enter .hte-popup-btn     { animation: hte-rise 1.1s 1.3s both ease-out; }
@keyframes hte-rise {
	from { opacity: 0; transform: translateY(18px); }
	to   { opacity: 1; transform: translateY(0); }
}

.hte-popup-title {
	margin: 0 0 14px;
	padding: 0;
	font-size: 40px;
	line-height: 1.1;
	font-weight: 900;
	letter-spacing: 0.3px;
	background: linear-gradient(180deg, #ffd08a, #ff8a1f);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	filter: drop-shadow(0 0 12px rgba(255, 122, 0, 0.6));
}
.hte-popup-message p {
	margin: 0 0 10px;
	font-size: 19px;
	line-height: 1.55;
	color: #f1e6ff;
}
.hte-popup-btn {
	margin-top: 18px;
	padding: 14px 34px;
	font-size: 17px;
	font-weight: 800;
	color: #1a0b2e;
	background: linear-gradient(180deg, #ffbf5e, #ff7a00);
	border: none;
	border-radius: 999px;
	cursor: pointer;
	box-shadow: 0 4px 18px rgba(255, 122, 0, 0.6);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hte-popup-btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 26px rgba(255, 122, 0, 0.75); }

.hte-popup-close {
	position: absolute;
	z-index: 3;
	top: 12px;
	right: 14px;
	width: 36px;
	height: 36px;
	padding: 0;
	line-height: 1;
	font-size: 17px;
	color: #fff;
	background: rgba(255, 255, 255, 0.06);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	opacity: 0.7;
	transition: opacity 0.2s, background 0.2s;
}
.hte-popup-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.18); }

/* step dots */
.hte-popup-dots { position: relative; z-index: 1; display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.hte-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); transition: all 0.6s ease; }
.hte-dot-on { width: 26px; border-radius: 6px; background: #ff9a2e; box-shadow: 0 0 8px rgba(255, 140, 0, 0.8); }

/* auto-advance progress */
.hte-popup-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; border-radius: 0 0 24px 24px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.hte-popup-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff7a00, #ffbf5e); }

/* floating decorations */
.hte-popup-deco { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 24px; }
.hte-deco { position: absolute; opacity: 0.3; font-size: 24px; }
.hte-deco-1 { top: 10%;  left: 3%;    animation: hte-float 5s ease-in-out infinite; }
.hte-deco-2 { top: 8%;   right: 12%;  font-size: 34px; animation: hte-float 6.5s ease-in-out infinite 1s; }
.hte-deco-3 { bottom: 12%; left: 46%; animation: hte-twinkle 3s ease-in-out infinite; }
.hte-deco-4 { bottom: 10%; right: 5%; font-size: 30px; animation: hte-float 5.5s ease-in-out infinite 0.5s; }
.hte-deco-5 { top: 48%;  right: 3%;   font-size: 20px; animation: hte-float 7s ease-in-out infinite 2s; }
@keyframes hte-float { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
@keyframes hte-twinkle { 0%, 100% { opacity: 0.12; transform: scale(0.8); } 50% { opacity: 0.7; transform: scale(1.2); } }
@keyframes hte-flicker { 0%, 18%, 22%, 62%, 64%, 100% { opacity: 1; } 20%, 63% { opacity: 0.6; } }

/* ---- tablets / phones: monster on top, text below ---- */
@media (max-width: 760px) {
	.hte-popup { padding: 22px 20px 26px; margin-top: 70px; }
	.hte-popup-body { flex-direction: column; gap: 6px; }
	.hte-char-stage { flex: none; width: 100%; min-height: 0; margin-top: -90px; }
	.hte-char { max-width: 230px; }
	.hte-char-emoji { font-size: 110px; }
	.hte-popup-content { text-align: center; }
	.hte-popup-title { font-size: 30px; }
	.hte-popup-message p { font-size: 16.5px; }
}
@media (max-width: 480px) {
	.hte-char { max-width: 190px; }
	.hte-popup-title { font-size: 26px; }
	.hte-sound-btn { left: 10px; bottom: 10px; width: 44px; height: 44px; }
}
@media (max-height: 560px) and (min-width: 761px) {
	.hte-char-stage { min-height: 240px; }
	.hte-char { max-width: 250px; }
}

@media (prefers-reduced-motion: reduce) {
	.hte-popup, .hte-popup-backdrop { transition: none; }
	.hte-popup, .hte-eye, .hte-deco, .hte-moon, .hte-fog, .hte-spider, .hte-sound-btn, .hte-char-glow, .hte-char-fog { animation: none !important; }
	.hte-enter * { animation: none !important; }
	.hte-popup-backdrop::after { display: none; }
	.hte-item { animation-duration: 20s !important; }
}
