body, div, p, canvas {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

:root {
	--bc-text: #e8eeff;
	--bc-soft-text: #9ea9d1;
	--bc-panel: rgba(20, 29, 56, 0.75);
	--bc-border: rgba(120, 157, 255, 0.35);
}

body {
	background:
		radial-gradient(120% 120% at 10% 10%, #243a7a 0%, rgba(36, 58, 122, 0) 45%),
		radial-gradient(100% 120% at 90% 90%, #42246e 0%, rgba(66, 36, 110, 0) 50%),
		linear-gradient(160deg, #090c1a 0%, #10162b 45%, #0a0f1f 100%);
	color: var(--bc-text);
	font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-tap-highlight-color: transparent;
	overflow-x: hidden;
	min-height: 100vh;
}

a:link { color: #cfe0ff; text-decoration: underline; }
a:visited { color: #a9b8ff; text-decoration: underline; }
a:hover { color: #ffffff; text-decoration: underline; }

/* Встраивание: корневой блок на всю ширину родителя (сайт / iframe) */
.battle-city-root {
	width: 100%;
	max-width: 58rem;
	margin-left: auto;
	margin-right: auto;
	position: relative;
	padding: 0.9rem 0.9rem 1.2rem;
	border-radius: 1rem;
	background: linear-gradient(160deg, rgba(25, 37, 72, 0.68), rgba(14, 20, 40, 0.78));
	border: 1px solid var(--bc-border);
	box-shadow: 0 18px 42px rgba(5, 9, 20, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.bc-header {
	text-align: center;
	margin-bottom: 0.55rem;
}

.bc-header h1 {
	font-size: clamp(1.15rem, 4.5vw, 2rem);
	margin: 0;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #f4f7ff;
	text-shadow: 0 0 20px rgba(122, 170, 255, 0.45), 0 2px 0 rgba(0, 0, 0, 0.4);
}

.bc-layout {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: center;
	gap: 0.75rem 1rem;
}

.bc-canvas-column {
	flex: 0 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
}

/* Логическое поле 512×448, масштабируется по ширине колонки */
.bc-canvas-wrap {
	position: relative;
	width: min(100vw - 1.5rem, 512px);
	max-width: 100%;
	aspect-ratio: 512 / 448;
	background: linear-gradient(160deg, #060a15, #0a1022);
	touch-action: none;
	border-radius: 0.9rem;
	overflow: hidden;
	border: 1px solid rgba(132, 168, 255, 0.4);
	box-shadow: 0 14px 34px rgba(1, 5, 16, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
	/* Пост-обработка: Bloom и цветокоррекция */
	filter: saturate(1.2) contrast(1.1) brightness(1.05);
}

.bc-canvas-wrap canvas {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	display: block;
	/* Легкое свечение для всех элементов канваса */
	filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.1));
}

.bc-code-overlay {
	position: absolute;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 30;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	padding: 1rem;
	background: linear-gradient(180deg, rgba(4, 8, 20, 0.78), rgba(6, 10, 24, 0.9));
	backdrop-filter: blur(2px);
	text-align: center;
	cursor: pointer;
	touch-action: manipulation;
}

.bc-code-overlay[hidden] {
	display: none !important;
}

.bc-code-line {
	margin: 0;
	font-size: clamp(1.75rem, 9vw, 3.25rem);
	font-weight: 900;
	color: #eaf1ff;
	text-shadow: 0 0 18px rgba(140, 181, 255, 0.75), 0 2px 0 rgba(0, 0, 0, 0.5);
	line-height: 1.2;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.bc-code-hint {
	margin: 0;
	font-size: clamp(0.8rem, 3.5vw, 1rem);
	color: var(--bc-soft-text);
	max-width: 18em;
	line-height: 1.35;
}

#srcImg {
	display: none;
}

.bc-sidebar {
	flex: 1 1 220px;
	max-width: 240px;
	min-width: 170px;
	font-size: 0.85rem;
	line-height: 1.4;
	padding: 0.7rem 0.75rem;
	border-radius: 0.8rem;
	background: var(--bc-panel);
	border: 1px solid rgba(137, 170, 255, 0.28);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.bc-help {
	list-style: none;
	margin: 0 0 0.75rem;
	padding: 0;
	text-align: left;
	color: #d8e2ff;
}

.bc-help-title {
	font-weight: 800;
	margin-bottom: 0.35rem;
	color: #f2f6ff;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

#fast-mode {
	font-size: 0.8rem;
	margin-top: 0.5rem;
	min-height: 1.2em;
	color: var(--bc-soft-text);
}

/* Панель управления под полем */
.bc-touch-bar {
	width: min(100vw - 1.5rem, 512px);
	max-width: 100%;
	margin-top: 0.5rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.bc-panel {
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.5rem 1.25rem;
	user-select: none;
	touch-action: manipulation;
	background: rgba(255, 255, 255, 0.03);
	border-radius: 1rem;
	border: 1px solid rgba(255, 255, 255, 0.05);
}

.bc-panel-visible {
	display: flex;
}

.bc-panel-play {
    justify-content: space-between;
}

.bc-joystick {
	position: relative;
	width: 7.5rem;
	height: 7.5rem;
	flex-shrink: 0;
	touch-action: none;
}

.bc-joystick-base {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 6.5rem;
	height: 6.5rem;
	margin-left: -3.25rem;
	margin-top: -3.25rem;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, #3a3a55, #151528 55%, #0a0a18);
	box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.12), 0 4px 12px rgba(0, 0, 0, 0.45);
	border: 2px solid rgba(255, 153, 102, 0.35);
}

.bc-joystick-knob {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 2.5rem;
	height: 2.5rem;
	margin-left: -1.25rem;
	margin-top: -1.25rem;
	border-radius: 50%;
	background: radial-gradient(circle at 30% 25%, #ffcc99, #cc6633 60%, #442211);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
	transform: translate(0, 0);
	pointer-events: none;
}

.bc-fire {
	flex-shrink: 0;
	align-self: center;
	min-width: 5.5rem;
	min-height: 3.25rem;
	padding: 0 1.25rem;
	border-radius: 0.65rem;
	border: 3px solid #cc6633;
	background: linear-gradient(180deg, #553322, #331100);
	color: #ffddbb;
	font-size: 1.05rem;
	font-weight: 700;
	cursor: pointer;
	touch-action: manipulation;
	box-shadow: 0 4px 0 #221100, 0 6px 12px rgba(0, 0, 0, 0.4);
}

.bc-fire:active {
	transform: translateY(2px);
	box-shadow: 0 2px 0 #221100, 0 3px 8px rgba(0, 0, 0, 0.35);
}

.bc-astar {
	display: none;
}

/* Режим встраивания: компактный вид */
.battle-city-root.bc-embed {
	max-width: 100%;
	padding: 0.25rem;
}

.bc-embed-body .bc-header,
.bc-embed-body .bc-sidebar {
	display: none;
}

.bc-embed-body .bc-layout {
	display: block;
}

.bc-embed-body .bc-canvas-column {
	width: 100%;
}

.bc-embed-body .bc-canvas-wrap,
.bc-embed-body .bc-touch-bar {
	width: 100%;
}

/* Крупнее рычаги на очень узких экранах */
@media (max-width: 380px) {
	.bc-joystick {
		width: 6.75rem;
		height: 6.75rem;
	}
	.bc-joystick-base {
		width: 5.75rem;
		height: 5.75rem;
		margin-left: -2.875rem;
		margin-top: -2.875rem;
	}
}

/* На широком экране подсказки справа от поля */
@media (min-width: 640px) {
	.bc-layout {
		flex-wrap: nowrap;
		justify-content: center;
	}
	.bc-sidebar {
		padding-top: 0.25rem;
	}
}
