:root {
	--crt-purple: #3f0077;
	--crt-magenta: #be0076;
	--crt-phosphor: #ff3ea0;
	--crt-phosphor-dim: #be0076;
	--crt-amber: #ff7ad1;
	--crt-bg: #14002a;
	--crt-bg-deep: #0a0014;
	--crt-bezel: #1a0033;
	--crt-bezel-edge: #0a0014;
	--crt-glow: 0 0 6px rgba(190, 0, 118, 0.9), 0 0 14px rgba(63, 0, 119, 0.55);
	--crt-glow-soft: 0 0 4px rgba(190, 0, 118, 0.7);
}

html, body {
	height: 100%;
}

body.crt-body {
	margin: 0;
	min-height: 100vh;
	font-family: "VT323", "Press Start 2P", "Courier New", Courier, monospace;
	color: var(--crt-phosphor);
	background:
		radial-gradient(ellipse at center, #1a0033 0%, #0a0014 70%, #000 100%),
		#000;
	background-attachment: fixed;
	overflow-x: hidden;
	letter-spacing: 0.5px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

body.crt-body::before {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	background-image: radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
	background-size: 3px 3px;
	mix-blend-mode: overlay;
	z-index: 0;
}

.crt-shell {
	position: relative;
	width: min(1200px, 100%);
	display: flex;
	flex-direction: column;
	gap: 14px;
	z-index: 1;
}

.crt-bezel {
	position: relative;
	background: linear-gradient(180deg, #4a0089 0%, #3f0077 50%, #1f003a 100%);
	padding: 22px;
	border-radius: 28px;
	box-shadow:
		0 0 0 2px #0a0014,
		0 0 0 4px #3f0077,
		0 30px 80px rgba(63, 0, 119, 0.6),
		0 0 60px rgba(190, 0, 118, 0.25),
		inset 0 2px 0 rgba(255, 255, 255, 0.08),
		inset 0 -2px 0 rgba(0, 0, 0, 0.6);
}

.crt-bezel::before,
.crt-bezel::after {
	content: "";
	position: absolute;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: radial-gradient(circle, #444 0%, #111 70%);
	bottom: 8px;
	box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
.crt-bezel::before { left: 14px; background: radial-gradient(circle, #5a0099 0%, #1a0033 70%); }
.crt-bezel::after  { right: 14px; background: radial-gradient(circle, #ff3ea0 0%, #3f0077 70%); box-shadow: 0 0 8px rgba(190, 0, 118, 0.85); }

.crt-screen {
	position: relative;
	background: var(--crt-bg-deep);
	border-radius: 18px;
	padding: 18px 18px 12px;
	overflow: hidden;
	box-shadow:
		inset 0 0 60px rgba(0, 0, 0, 0.95),
		inset 0 0 16px rgba(190, 0, 118, 0.18);
	transform: perspective(1200px);
	min-height: 540px;
}

.crt-screen::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 18px;
	background:
		radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.05) 0%, transparent 40%),
		radial-gradient(ellipse at 50% 100%, rgba(0, 0, 0, 0.4) 0%, transparent 50%);
	pointer-events: none;
	z-index: 5;
}

.crt-status-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 4px 8px 10px;
	border-bottom: 1px dashed rgba(190, 0, 118, 0.4);
	margin-bottom: 10px;
	font-size: 14px;
	text-transform: uppercase;
	color: var(--crt-phosphor-dim);
	text-shadow: var(--crt-glow-soft);
	position: relative;
	z-index: 2;
}

.crt-led {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--crt-magenta);
	box-shadow: 0 0 10px var(--crt-magenta), 0 0 18px rgba(190, 0, 118, 0.6), 0 0 4px #fff inset;
	animation: crt-led-pulse 2.4s ease-in-out infinite;
}

@keyframes crt-led-pulse {
	0%, 100% { opacity: 1; }
	50%      { opacity: 0.55; }
}

.crt-title {
	letter-spacing: 3px;
	font-weight: bold;
}

.crt-clock {
	font-variant-numeric: tabular-nums;
}

.wrapper {
	position: relative;
	margin: 0 auto;
	text-align: center;
	width: 100%;
	min-height: 420px;
	height: 60vh;
	max-height: 72vh;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1;
}

.emscripten,
#canvas {
	display: block;
	margin: 0 auto;
	max-width: 100%;
	max-height: 100%;
	background: #000;
	border-radius: 6px;
	image-rendering: pixelated;
	box-shadow:
		0 0 30px rgba(190, 0, 118, 0.25),
		0 0 60px rgba(63, 0, 119, 0.2),
		inset 0 0 0 1px rgba(190, 0, 118, 0.18);
}

#canvas:not([fullscreen]) {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.crt-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
	padding: 6px 4px;
}

.btn.crt-btn {
	--bs-btn-padding-y: 0.55rem;
	--bs-btn-padding-x: 1.15rem;
	background: linear-gradient(180deg, rgba(63, 0, 119, 0.55), rgba(63, 0, 119, 0.25));
	border: 1px solid var(--crt-magenta);
	color: var(--crt-phosphor);
	font-family: inherit;
	font-size: 1rem;
	letter-spacing: 1px;
	text-transform: uppercase;
	border-radius: 4px;
	min-width: 160px;
	text-shadow: var(--crt-glow-soft);
	box-shadow:
		inset 0 0 12px rgba(190, 0, 118, 0.18),
		0 0 10px rgba(190, 0, 118, 0.25);
	transition: all 0.15s ease;
}

.btn.crt-btn i {
	margin-right: 6px;
	color: var(--crt-phosphor);
	text-shadow: var(--crt-glow-soft);
}

.btn.crt-btn:hover,
.btn.crt-btn:focus {
	color: #fff;
	background: linear-gradient(180deg, var(--crt-magenta), var(--crt-purple));
	border-color: var(--crt-phosphor);
	box-shadow:
		0 0 14px rgba(190, 0, 118, 0.85),
		0 0 28px rgba(63, 0, 119, 0.6);
	text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
	outline: none;
}

.btn.crt-btn:hover i,
.btn.crt-btn:focus i {
	color: #fff;
	text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}

.btn.crt-btn:active {
	transform: translateY(1px);
}

.crt-footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 22px;
	font-size: 13px;
	color: var(--crt-phosphor-dim);
	text-transform: uppercase;
	letter-spacing: 2px;
	text-shadow: var(--crt-glow-soft);
	opacity: 0.85;
}

.crt-footer i {
	margin-right: 6px;
}

.crt-overlay {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		linear-gradient(135deg, rgba(63, 0, 119, 0.18) 0%, rgba(190, 0, 118, 0.10) 100%);
	mix-blend-mode: screen;
	z-index: 3;
}

.crt-scanlines {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: repeating-linear-gradient(
		to bottom,
		rgba(0, 0, 0, 0)   0px,
		rgba(0, 0, 0, 0)   2px,
		rgba(0, 0, 0, 0.28) 3px,
		rgba(0, 0, 0, 0.28) 3px
	);
	z-index: 4;
	animation: crt-scan-shift 8s linear infinite;
}

@keyframes crt-scan-shift {
	0%   { background-position: 0 0; }
	100% { background-position: 0 6px; }
}

.crt-vignette {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: radial-gradient(
		ellipse at center,
		transparent 55%,
		rgba(0, 0, 0, 0.45) 90%,
		rgba(0, 0, 0, 0.85) 100%
	);
	z-index: 5;
}

.crt-flicker {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: rgba(190, 0, 118, 0.04);
	mix-blend-mode: overlay;
	animation: crt-flicker 3.3s steps(2, end) infinite;
	z-index: 6;
}

@keyframes crt-flicker {
	0%, 100% { opacity: 0.85; }
	48%      { opacity: 0.85; }
	49%      { opacity: 0.55; }
	50%      { opacity: 0.95; }
	51%      { opacity: 0.7;  }
	52%      { opacity: 0.9;  }
}

.crt-screen { animation: crt-power-on 1.4s ease-out 1; }
@keyframes crt-power-on {
	0%   { filter: brightness(0) contrast(2); transform: scaleY(0.02); }
	35%  { filter: brightness(0.4) contrast(2); transform: scaleY(0.1); }
	60%  { transform: scaleY(1.02); }
	100% { filter: none; transform: scaleY(1); }
}

.glyphicon-spin {
	animation: spin 2000ms infinite linear;
	display: inline-block;
}

@keyframes spin {
	0%   { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

.progress {
	background: rgba(20, 0, 42, 0.7);
	border: 1px solid rgba(190, 0, 118, 0.5);
	border-radius: 0;
	height: 8px;
	overflow: hidden;
}

.progress-bar,
.progress-bar-custom {
	background: linear-gradient(90deg, var(--crt-purple), var(--crt-magenta));
	box-shadow: 0 0 10px rgba(190, 0, 118, 0.85);
}

@media (max-width: 768px) {
	body.crt-body { padding: 8px; }
	.crt-bezel { padding: 12px; border-radius: 18px; }
	.crt-screen { padding: 12px; min-height: 380px; }
	.btn.crt-btn { min-width: 130px; font-size: 0.85rem; }
	.crt-status-bar, .crt-footer { font-size: 11px; letter-spacing: 1px; }
	.crt-footer { gap: 12px; }
}

#canvas:fullscreen {
	width: 100vw;
	height: 100vh;
	max-width: none;
	max-height: none;
}
