/* Horror Crypt Escape - Styles */
.hce-widget-wrapper {
	position: relative;
	width: 100%;
}

.hce-container {
	position: relative;
	width: 100%;
	height: 80vh;
	overflow: hidden;
	background: #000;
	border-radius: 4px;
	touch-action: none;
	cursor: grab;
}

.hce-container:active { cursor: grabbing; }

.hce-sizing-px .hce-container { height: 600px; }
.hce-sizing-vh .hce-container { height: 80vh; }
.hce-sizing-aspect .hce-container { height: auto; }
.hce-aspect-16-9 .hce-container { aspect-ratio: 16 / 9; }
.hce-aspect-4-3  .hce-container { aspect-ratio: 4 / 3; }
.hce-aspect-1-1  .hce-container { aspect-ratio: 1 / 1; }
.hce-aspect-21-9 .hce-container { aspect-ratio: 21 / 9; }

.hce-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

/* Loading */
.hce-loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	color: #a8a2a0;
	font-family: Georgia, 'Times New Roman', serif;
	letter-spacing: 1px;
	background: radial-gradient(circle at center, #1a1717 0%, #050404 100%);
	z-index: 5;
	transition: opacity 0.6s ease;
}

.hce-loading.hce-hidden { opacity: 0; pointer-events: none; }

.hce-loading-skull {
	width: 50px;
	height: 50px;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 35%, #d8d0c8, #706860 70%, #2a2622 100%);
	box-shadow: 0 0 22px rgba(255, 157, 60, 0.35);
	animation: hce-skull-pulse 1.6s ease-in-out infinite;
}

@keyframes hce-skull-pulse {
	0%, 100% { transform: scale(1); opacity: 0.9; }
	50% { transform: scale(1.12); opacity: 1; }
}

/* Hint bar */
.hce-hint {
	position: absolute;
	bottom: 10px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 18px;
	padding: 6px 16px;
	background: rgba(10, 8, 8, 0.6);
	border: 1px solid rgba(255, 157, 60, 0.25);
	border-radius: 30px;
	color: #c9b89a;
	font-size: 12px;
	font-family: Georgia, serif;
	z-index: 4;
	pointer-events: none;
	opacity: 0.9;
	transition: opacity 3s ease 2s;
}

.hce-hint.hce-fade { opacity: 0; }

/* Puzzle HUD */
.hce-puzzle-status {
	position: absolute;
	top: 12px;
	left: 12px;
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	padding: 6px 12px;
	background: rgba(10, 8, 8, 0.65);
	border: 1px solid rgba(255, 157, 60, 0.3);
	border-radius: 20px;
	color: #ff9d3c;
	font-family: Georgia, serif;
	font-size: 13px;
	z-index: 4;
	pointer-events: none;
	max-width: 80%;
}

.hce-puzzle-status.hce-puzzle-complete {
	border-color: #ff9d3c;
	box-shadow: 0 0 20px rgba(255, 157, 60, 0.6);
	animation: hce-hud-pulse 2s ease-in-out infinite;
}

.hce-puzzle-mistakes.hce-danger { color: #ff4444; }

@keyframes hce-hud-pulse {
	0%, 100% { box-shadow: 0 0 12px rgba(255,157,60,0.3); }
	50% { box-shadow: 0 0 28px rgba(255,157,60,0.7); }
}

/* Screen flash (jump scare) */
.hce-screenflash {
	position: absolute;
	inset: 0;
	background: #fff;
	opacity: 0;
	pointer-events: none;
	z-index: 7;
}

.hce-screenflash.hce-flash-active {
	animation: hce-flash 0.35s ease-out;
}

@keyframes hce-flash {
	0% { opacity: 0.9; }
	100% { opacity: 0; }
}

.hce-shake {
	animation: hce-camera-shake 0.4s ease-in-out;
}

@keyframes hce-camera-shake {
	0%, 100% { transform: translate(0,0); }
	20% { transform: translate(-6px, 4px); }
	40% { transform: translate(6px, -4px); }
	60% { transform: translate(-4px, -6px); }
	80% { transform: translate(4px, 6px); }
}

/* WebGL Fallback */
.hce-webgl-fallback {
	position: absolute;
	inset: 0;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	background: #0c0a0a;
	color: #c9b89a;
	text-align: center;
	padding: 24px;
	font-family: Georgia, serif;
	z-index: 6;
}

.hce-webgl-fallback.hce-show { display: flex; }

.hce-webgl-fallback img {
	max-width: 100%;
	max-height: 70%;
	border-radius: 4px;
	box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

/* ===================== LIGHTBOX ===================== */
.hce-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	perspective: 1600px;
}

.hce-lightbox.hce-open { display: flex; }

.hce-lightbox-backdrop {
	position: absolute;
	inset: 0;
	background: radial-gradient(circle at center, rgba(20,15,15,0.92) 0%, rgba(2,1,1,0.98) 100%);
	opacity: 0;
	transition: opacity 0.5s ease;
}

.hce-lightbox.hce-open .hce-lightbox-backdrop { opacity: 1; }

.hce-lightbox-inner {
	position: relative;
	width: min(90vw, 900px);
	max-height: 90vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hce-lightbox-glow {
	position: absolute;
	inset: -40px;
	border-radius: 12px;
	background: radial-gradient(circle, rgba(255,157,60,0.15) 0%, transparent 70%);
	opacity: 0;
	transition: opacity 0.8s ease 0.3s;
	pointer-events: none;
}

.hce-lightbox.hce-open .hce-lightbox-glow.hce-glow {
	opacity: 1;
	animation: hce-glow-pulse 3s ease-in-out infinite;
}

@keyframes hce-glow-pulse {
	0%, 100% { box-shadow: 0 0 30px 6px rgba(255,157,60,0.12) inset; }
	50% { box-shadow: 0 0 60px 14px rgba(255,157,60,0.3) inset; }
}

.hce-lightbox-lid {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 52%;
	background: linear-gradient(135deg, #4a3a2a 0%, #241a10 45%, #4a3a2a 100%);
	box-shadow: 0 0 40px rgba(0,0,0,0.7);
	z-index: 3;
	transform-origin: center;
}

.hce-lightbox-lid::before {
	content: '';
	position: absolute;
	inset: 12px;
	border: 2px solid rgba(10,8,6,0.6);
	background-image: repeating-linear-gradient(45deg, rgba(10,8,6,0.2) 0 6px, transparent 6px 14px);
}

.hce-lightbox-lid-left { left: 0; }
.hce-lightbox-lid-right { right: 0; }

.hce-lightbox.hce-open .hce-lightbox-lid-left.hce-animate {
	animation: hce-lid-open-left 1.1s cubic-bezier(0.65,0,0.35,1) forwards;
}
.hce-lightbox.hce-open .hce-lightbox-lid-right.hce-animate {
	animation: hce-lid-open-right 1.1s cubic-bezier(0.65,0,0.35,1) forwards;
}
.hce-lightbox.hce-closing .hce-lightbox-lid-left.hce-animate {
	animation: hce-lid-close-left 0.9s cubic-bezier(0.65,0,0.35,1) forwards;
}
.hce-lightbox.hce-closing .hce-lightbox-lid-right.hce-animate {
	animation: hce-lid-close-right 0.9s cubic-bezier(0.65,0,0.35,1) forwards;
}

@keyframes hce-lid-open-left { 0% { transform: translateX(0) rotateY(0); opacity: 1; } 100% { transform: translateX(-100%) rotateY(-95deg); opacity: 0; } }
@keyframes hce-lid-open-right { 0% { transform: translateX(0) rotateY(0); opacity: 1; } 100% { transform: translateX(100%) rotateY(95deg); opacity: 0; } }
@keyframes hce-lid-close-left { 0% { transform: translateX(-100%) rotateY(-95deg); opacity: 0; } 100% { transform: translateX(0) rotateY(0); opacity: 1; } }
@keyframes hce-lid-close-right { 0% { transform: translateX(100%) rotateY(95deg); opacity: 0; } 100% { transform: translateX(0) rotateY(0); opacity: 1; } }

.hce-lightbox-frame {
	position: relative;
	max-width: 100%;
	max-height: 80vh;
	padding: 18px;
	background: linear-gradient(145deg, #3a2f26, #1c1610);
	border-radius: 8px;
	box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 0 2px rgba(255,157,60,0.25) inset;
	opacity: 0;
	transform: scale(0.85);
	transition: opacity 0.6s ease 0.6s, transform 0.6s ease 0.6s;
}

.hce-lightbox-frame.hce-chain-border {
	border: 6px solid transparent;
	border-image: repeating-linear-gradient(90deg, #6b6b6b 0 8px, #2a2a2a 8px 16px, #6b6b6b 16px 24px) 6;
}

.hce-lightbox.hce-open .hce-lightbox-frame { opacity: 1; transform: scale(1); }

.hce-lightbox-image {
	display: block;
	max-width: 100%;
	max-height: 70vh;
	border-radius: 4px;
	background: #111;
}

.hce-lightbox-caption {
	margin-top: 10px;
	text-align: center;
	color: #e0c9a0;
	font-family: Georgia, serif;
	font-weight: bold;
	letter-spacing: 1px;
}

.hce-lightbox-close {
	position: absolute;
	top: -46px;
	right: -6px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 2px solid #ff9d3c;
	background: rgba(10, 8, 8, 0.7);
	color: #ff9d3c;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	z-index: 5;
	transition: background 0.2s ease, transform 0.2s ease;
}

.hce-lightbox-close:hover {
	background: rgba(255, 157, 60, 0.3);
	transform: rotate(90deg);
}

/* Responsive */
@media (max-width: 767px) {
	.hce-hint { font-size: 10px; gap: 10px; padding: 5px 10px; }
	.hce-lightbox-inner { width: 94vw; }
	.hce-lightbox-lid { width: 55%; }
	.hce-sizing-vh .hce-container { height: 65vh; }
	.hce-puzzle-status { font-size: 11px; gap: 8px; }
}
