#erd-tmp-modal,
#erd-leaderboard-modal {
	position:fixed;
	top:0;
	left:0;
	width:100vw;
	height:100vh;
	background:rgba(0,0,0,0.95);
	color:#fff;
	display:none;
	flex-direction:column;
	align-items:center;
	z-index:1000;
}
.rc-toybox-container,
.erd-tmp-leaderboard-container {
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 100vh;
	overflow: hidden;
}
#erd-tmp-rc-toybox-canvas {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1001;
}
.game-container {
	position: relative;
	width: 800px;
	height: 600px;
	background: url(../images/rc-toybox/background.jpg) no-repeat center center;
	border-radius: 10px;
	z-index: 1010;
}

#gameCanvas {
	display: block;
	background: transparent;
	border-radius: 7px;
}

.ui-overlay {
	position: absolute;
	top: 10px;
	left: 10px;
	right: 10px;
	z-index: 10;
	pointer-events: none;
}

.timer {
	background: rgba(0,0,0,0.8);
	color: #fff;
	padding: 8px 12px;
	border-radius: 5px;
	font-family: 'Courier New', monospace;
	font-size: 18px;
	font-weight: bold;
	display: inline-block;
	pointer-events: none;
}

.controls {
	position: absolute;
	bottom: 10px;
	right: 10px;
	z-index: 10;
}

.btn {
	background: #4CAF50;
	color: white;
	border: none;
	padding: 10px 20px;
	border-radius: 5px;
	cursor: pointer;
	font-size: 16px;
	margin-left: 10px;
	transition: background 0.3s;
}

.btn:hover {
	background: #45a049;
}

.btn:disabled {
	background: #ccc;
	cursor: not-allowed;
}

/* Start Screen */
.start-screen {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.8);
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	z-index: 20;
}

.start-screen h1 {
	color: #fff;
	font-size: 48px;
	margin-bottom: 30px;
	text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.start-screen p {
	color: #ccc;
	font-size: 18px;
	margin-bottom: 40px;
	text-align: center;
	max-width: 500px;
}

/* Win Screen */
.win-screen {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.9);
	display: none;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	z-index: 30;
}

.win-screen h2 {
	color: #4CAF50;
	font-size: 36px;
	margin-bottom: 20px;
}

.final-time {
	color: #fff;
	font-size: 24px;
	margin-bottom: 30px;
	font-family: 'Courier New', monospace;
}

.initials-input {
	background: #333;
	color: #fff;
	border: 2px solid #4CAF50;
	padding: 10px;
	font-size: 18px;
	text-align: center;
	width: 100px;
	border-radius: 5px;
	margin-bottom: 20px;
	text-transform: uppercase;
}

/* Touch Controls */
.touch-controls {
	position: absolute;
	bottom: 20px;
	left: 20px;
	z-index: 15;
	display: none;
}

.d-pad {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	grid-template-rows: 1fr 1fr 1fr;
	gap: 5px;
	width: 120px;
	height: 120px;
}

.d-pad-btn {
	background: rgba(255,255,255,0.3);
	border: 2px solid rgba(255,255,255,0.5);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	color: #fff;
	cursor: pointer;
	user-select: none;
	transition: background 0.2s;
}

.d-pad-btn:active {
	background: rgba(255,255,255,0.6);
}

.d-pad-btn.center {
	grid-column: 2;
	grid-row: 2;
}

.d-pad-btn.up {
	grid-column: 2;
	grid-row: 1;
}

.d-pad-btn.down {
	grid-column: 2;
	grid-row: 3;
}

.d-pad-btn.left {
	grid-column: 1;
	grid-row: 2;
}

.d-pad-btn.right {
	grid-column: 3;
	grid-row: 2;
}

/* Responsive Design */
@media (pointer: coarse) {
	.touch-controls {
		display: block;
	}
}

@media (max-width: 850px) {
	.game-container {
		width: 95vw;
		height: 71.25vw; /* Maintain 4:3 aspect ratio */
		max-height: 95vh;
	}

	.touch-controls {
		bottom: 10px;
		left: 10px;
	}

	.d-pad {
		width: 100px;
		height: 100px;
	}
}

/* leaderboard */
.erd-tmp-leaderboard {
	padding: 40px;
	background: url(../images/rc-toybox/background.jpg) no-repeat center center;
	border-radius: 10px;
	color: #000;
	z-index: 1010;
}

#erd-tmp-leaderboard-canvas {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1001;
}

#erd-tmp-leaderboard-close {
	background: #fff;
	border: none;
	border-radius: 10px;
	color: #000;
	cursor: pointer;
	font-size: 16px;
	font-weight: bold;
	padding: 10px;
	position: absolute;
	right: 40px;
	top: 40px;
	z-index: 1020;
}

.erd-tmp-leaderboard h2 {
	color: #fff;
	margin-top: 0;
	position: relative;
	padding-left: 40px;
}
.erd-tmp-leaderboard h2:before {
	content: '';
	display: block;
	width: 30px;
	height: 40.80px;
	background: url(../images/rc-toybox/rc-car.png) no-repeat center center;
	background-size: cover;
	position: absolute;
	top: 0;
	left: 0;
}

.erd-tmp-leaderboard-list {
	display: flex;
	flex-direction: column;
	height: 50vh;
	max-height: 600px;
	max-width: 800px;
	overflow-y: auto;
	width: 50vw;
}

.erd-tmp-leaderboard-item {
	background-color: rgba(0,0,0,0.5);
	box-shadow: inset 0 0 10px 0 rgba(0,0,0,0.75);
	color: rgba(255,255,255,0.5);
	display: flex;
	justify-content: space-between;
	padding: 10px 20px;
	margin-bottom: 10px;
}


.erd-tmp-leaderboard-item:first-child,
.erd-tmp-leaderboard-item:nth-child(2),
.erd-tmp-leaderboard-item:nth-child(3) {
	border-radius: 0;
	box-shadow: none;
	color: #000;
	font-weight: bold;
}
.erd-tmp-leaderboard-item:first-child {
	background-color: rgba(255, 215, 0, 1);
}

.erd-tmp-leaderboard-item:nth-child(2) {
	background-color: rgba(192, 192, 192, 1);
}
.erd-tmp-leaderboard-item:nth-child(3) {
	background-color: rgba(205, 127, 50, 1);
}
.erd-tmp-leaderboard-item:last-child {
	margin-bottom: none;
}
