:root {
	--bg: #071019;
	--card: rgba(255, 255, 255, 0.06);
	--stroke: rgba(255, 255, 255, 0.12);
	--text: rgba(255, 255, 255, 0.92);
	--muted: rgba(255, 255, 255, 0.68);

	--a: #22c55e;
	--b: #fb7185;
	--accent: #0ea5e9;

	--shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
	--radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
	margin: 0;
	font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji",
		"Segoe UI Emoji";
	color: var(--text);
	background:
		radial-gradient(1200px 800px at 20% 10%, rgba(14, 165, 233, 0.20), transparent 45%),
		radial-gradient(900px 700px at 80% 20%, rgba(34, 197, 94, 0.14), transparent 50%),
		radial-gradient(900px 700px at 70% 85%, rgba(251, 113, 133, 0.12), transparent 55%),
		linear-gradient(180deg, #050b12, var(--bg));
	-webkit-tap-highlight-color: transparent;
}

.app {
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
	gap: 12px;
	max-width: 980px;
	margin: 0 auto;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	border: 1px solid var(--stroke);
	border-radius: var(--radius);
	background: var(--card);
	box-shadow: var(--shadow);
	backdrop-filter: blur(10px);
}

.brand { display: flex; gap: 10px; align-items: center; }

.brand__logo {
	width: 38px;
	height: 38px;
	border-radius: 12px;
	display: grid;
	place-items: center;
	background: rgba(14, 165, 233, 0.18);
	border: 1px solid rgba(14, 165, 233, 0.28);
}

.brand__title { font-weight: 800; letter-spacing: 0.2px; }

.brand__subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.main {
	flex: 1;
	display: grid;
	align-content: stretch;
	gap: 12px;
}

.card {
	border: 1px solid var(--stroke);
	border-radius: var(--radius);
	background: var(--card);
	box-shadow: var(--shadow);
	backdrop-filter: blur(10px);
	padding: 14px;
	min-height: 0;
}

.hidden { display: none !important; }

.h1 { margin: 0 0 12px; font-size: 18px; }
.h1--tight { margin-bottom: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 720px) {
	.grid2 { grid-template-columns: 1fr; }
}

.field { display: grid; gap: 6px; }

.label { font-size: 13px; color: var(--muted); }

.input {
	width: 100%;
	padding: 12px 12px;
	border-radius: 14px;
	border: 1px solid var(--stroke);
	background: rgba(0, 0, 0, 0.25);
	color: var(--text);
	font-size: 16px;
	outline: none;
}

.input--center { text-align: center; }

.input:focus {
	border-color: rgba(14, 165, 233, 0.6);
	box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
}

.select {
	width: 100%;
	border: 1px solid var(--stroke);
	background: rgba(0, 0, 0, 0.25);
	color: var(--text);
	padding: 10px 12px;
	border-radius: 14px;
	font-weight: 800;
	outline: none;
	line-height: 1.2;
}

.select:focus {
	border-color: rgba(14, 165, 233, 0.6);
	box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
}

.hint { font-size: 12px; color: var(--muted); }
.hint--center { text-align: center; margin-top: 10px; }

.row { margin-top: 10px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.row--left { justify-content: flex-start; }

.btn {
	border: 1px solid var(--stroke);
	background: rgba(255, 255, 255, 0.06);
	color: var(--text);
	padding: 12px 14px;
	border-radius: 14px;
	font-weight: 800;
	cursor: pointer;
	user-select: none;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.08s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:active { transform: translateY(1px) scale(0.99); }

.btn--primary {
	background: rgba(14, 165, 233, 0.22);
	border-color: rgba(14, 165, 233, 0.35);
}

.btn--primary:hover { background: rgba(14, 165, 233, 0.28); }

.btn--ghost:hover { background: rgba(255, 255, 255, 0.10); }

/**
 * Setup
 */
.teamSetup {
	border: 1px solid rgba(255, 255, 255, 0.10);
	background: rgba(0, 0, 0, 0.10);
	border-radius: 18px;
	padding: 12px;
}

.teamSetup__head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 8px;
}

.teamSetup__badge {
	width: 10px;
	height: 10px;
	border-radius: 50%;
}

.teamSetup__badge--a {
	background: var(--a);
	box-shadow: 0 0 18px rgba(34, 197, 94, 0.55);
}

.teamSetup__badge--b {
	background: var(--b);
	box-shadow: 0 0 18px rgba(251, 113, 133, 0.55);
}

.teamSetup__title {
	font-weight: 1000;
	color: var(--muted);
}

.stepper {
	display: grid;
	grid-template-columns: 56px 1fr 56px;
	gap: 8px;
	align-items: center;
}

.stepper__btn {
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(255, 255, 255, 0.08);
	color: var(--text);
	height: 48px;
	border-radius: 16px;
	font-weight: 1000;
	font-size: 22px;
	cursor: pointer;
	user-select: none;
}

.stepper__btn:active {
	transform: translateY(1px) scale(0.99);
}

.presetRow {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
}

.pill {
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(0, 0, 0, 0.20);
	color: rgba(255, 255, 255, 0.92);
	padding: 8px 10px;
	border-radius: 999px;
	font-weight: 1000;
	cursor: pointer;
}

.pill:active { transform: translateY(1px) scale(0.99); }

/**
 * Game
 */
.gameHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.score { display: flex; gap: 10px; flex-wrap: wrap; }

.chip {
	padding: 8px 10px;
	border-radius: 999px;
	font-weight: 1000;
	border: 1px solid var(--stroke);
	background: rgba(0, 0, 0, 0.18);
}

.chip--a { border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.12); }
.chip--b { border-color: rgba(251, 113, 133, 0.35); background: rgba(251, 113, 133, 0.10); }

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }

.arenaWrap { position: relative; min-height: 0; }

.arena {
	position: relative;
	display: grid;
	grid-template-columns: 1fr 280px 1fr;
	gap: 14px;
	align-items: start;
	min-height: 0;
}

@media (max-width: 900px) {
	.arena { grid-template-columns: 1fr; }
}

.team__title {
	font-weight: 1000;
	color: var(--muted);
	margin-bottom: 10px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.team--a .team__title::before {
	content: "";
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--a);
	box-shadow: 0 0 18px rgba(34, 197, 94, 0.55);
}

.team--b .team__title::before {
	content: "";
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--b);
	box-shadow: 0 0 18px rgba(251, 113, 133, 0.55);
}

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }

@media (max-width: 520px) {
	.grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.unit {
	position: relative;
	height: 72px;
	border-radius: 18px;

	/* No “squares”: no backgrounds/borders */
	border: none;
	background: transparent;

	overflow: hidden;
	display: grid;
	place-items: center;
	isolation: isolate;
	cursor: pointer;

	/* Reserve space for HP indicator (so it doesn't cover the character) */
	padding-bottom: 18px;
}

.unit:active { transform: translateY(1px) scale(0.99); }

.unit__bg {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 18px; /* matches reserved HP indicator height */
	background-position: center;
	background-repeat: no-repeat;
	filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
	pointer-events: none;
}

/* Icons: keep full sprite visible */
.unit--icon .unit__bg { background-size: contain; }

/* Photos: fill nicely */
.unit--photo .unit__bg { background-size: cover; }


.unit__hpBar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 18px;
	border-top: 1px solid rgba(255, 255, 255, 0.14);
	background: rgba(0, 0, 0, 0.35);
	overflow: hidden;
	z-index: 4;
	display: grid;
	place-items: center;
}

.unit__hpFill {
	position: absolute;
	inset: 0;
	transform-origin: left center;
	transform: scaleX(1);
	opacity: 0.85;
}

.unit__hpLabel {
	position: relative;
	z-index: 5;
	font-size: 12px;
	font-weight: 1000;
	letter-spacing: 0.2px;
	color: rgba(255, 255, 255, 0.92);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
	pointer-events: none;

	/* Improve readability on bright fills */
	padding: 1px 8px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.22);
	border: 1px solid rgba(255, 255, 255, 0.12);
}



.unit--dead { opacity: 0.35; filter: grayscale(1); }

.unit--shooter {
	outline: 3px solid rgba(14, 165, 233, 0.75);
	border-radius: 18px;
	box-shadow: 0 0 0 6px rgba(14, 165, 233, 0.18), 0 20px 45px rgba(0, 0, 0, 0.30);
	animation: pop 0.25s ease;
}

@keyframes pop {
	0% { transform: scale(1); }
	50% { transform: scale(1.04); }
	100% { transform: scale(1); }
}

.unit--hit { animation: hit 0.35s ease; }

@keyframes hit {
	0% { transform: translateX(0); }
	20% { transform: translateX(-4px); }
	40% { transform: translateX(4px); }
	60% { transform: translateX(-3px); }
	80% { transform: translateX(3px); }
	100% { transform: translateX(0); }
}

.vs { display: grid; gap: 10px; align-content: start; }

.log {
	border: 1px solid var(--stroke);
	border-radius: 16px;
	padding: 12px;
	background: rgba(0, 0, 0, 0.18);
	min-height: unset;
	height: auto;
}

.log__title { font-weight: 1000; color: var(--muted); margin-bottom: 8px; }

.log__line { font-weight: 900; line-height: 1.35; }

.log__line small {
	display: block;
	color: var(--muted);
	font-weight: 800;
	margin-top: 6px;
}

.fxLayer { position: absolute; inset: 0; pointer-events: none; overflow: visible; }

#shotLine {
	stroke: rgba(14, 165, 233, 0.95);
	stroke-width: 1.2;
	stroke-linecap: round;
	filter: drop-shadow(0 0 6px rgba(14, 165, 233, 0.75));
	opacity: 0;
}

body.weapon-laser #shotLine { stroke-width: 1.2; stroke-dasharray: none; }
body.weapon-cannon #shotLine { stroke-width: 2.6; stroke-dasharray: none; }
body.weapon-rocket #shotLine { stroke-width: 1.8; stroke-dasharray: 2.2 2.4; }

.lineOn { animation: line 0.32s ease forwards; }

@keyframes line {
	0% { opacity: 0; }
	10% { opacity: 1; }
	70% { opacity: 1; }
	100% { opacity: 0; }
}

.explosionLayer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.explosion {
	position: absolute;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	transform: translate(-50%, -50%) scale(1);
	filter: drop-shadow(0 0 10px rgba(255, 180, 60, 0.35));
	background:
		radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(255, 200, 80, 0.95) 30%, rgba(255, 110, 60, 0.90) 55%, rgba(255, 60, 60, 0.0) 72%);
	animation: boom 0.45s ease-out forwards;
}

.explosion::after {
	content: "";
	position: absolute;
	inset: -12px;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(255, 210, 120, 0.35) 0%, rgba(255, 120, 60, 0.0) 60%);
	animation: ring 0.45s ease-out forwards;
}

@keyframes boom {
	0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
	15% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
	55% { opacity: 0.9; transform: translate(-50%, -50%) scale(2.8); }
	100% { opacity: 0; transform: translate(-50%, -50%) scale(3.4); }
}

@keyframes ring {
	0% { opacity: 0; transform: scale(0.4); }
	25% { opacity: 1; transform: scale(1); }
	100% { opacity: 0; transform: scale(1.8); }
}

.winner {
	margin-top: 12px;
	display: grid;
	gap: 10px;
	justify-items: center;
	padding: 14px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 18px;
	background: rgba(0, 0, 0, 0.18);
}

.winner__title { font-size: 18px; font-weight: 1000; }

/**
 * Stats
 */
.statsHeader {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.statsHeader__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.statsList {
	display: grid;
	gap: 10px;
}

.statsItem {
	border: 1px solid rgba(255, 255, 255, 0.10);
	background: rgba(0, 0, 0, 0.12);
	border-radius: 18px;
	padding: 12px;
	display: grid;
	gap: 10px;
}

.statsItem__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.statsItem__name {
	font-weight: 1000;
	font-size: 16px;
}

.statsItem__meta {
	color: var(--muted);
	font-weight: 900;
	font-size: 12px;
}

.statsItem__actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.footer { opacity: 0.7; text-align: center; font-size: 12px; padding-bottom: 2px; }

@media (max-width: 520px) {
	.brand__logo {
		width: 32px;
		height: 32px;
		border-radius: 10px;
	}

	.brand__title {
		font-size: 14px;
	}

	.brand__subtitle {
		font-size: 11px;
	}
}
