:root {
	--compare-top: 200px;
	--compare-bottom: 110px;
	--compare-side: 60px;
	--compare-panel-width: 440px;
	--compare-gap: 40px;
	--compare-row-height: 78px;
	--compare-name-width: 210px;
	--compare-value-width: 130px;
	--compare-delay: 0.6s; /* panels in first, then the stat rows */
}

/* Header (same placement as lineup) */
.page-header {
	position: absolute;
	top: 45px;
	left: var(--compare-side);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.15em;
	font-size: 60px;
	line-height: 1;
	color: var(--light-text-color);
}
.page-title:before {
	text-shadow: 0 2px rgba(var(--black-rgb), 0.4);
}
.compare-filter {
	font-size: 26px;
	line-height: 40px;
	padding: 0 0.5em;
	background-color: var(--primary-color);
	color: var(--text-color);
	font-weight: 500;
}
.compare-filter:empty {
	display: none;
}

/* Layout: panel | stats | panel */
.compare {
	position: absolute;
	top: var(--compare-top);
	bottom: var(--compare-bottom);
	left: var(--compare-side);
	right: var(--compare-side);
	display: grid;
	grid-template-columns: var(--compare-panel-width) 1fr var(--compare-panel-width);
	column-gap: var(--compare-gap);
	align-items: stretch;
	color: var(--light-text-color);
}
.compare.no-players {
	display: none;
}

/* Player panels */
.compare-player {
	position: relative;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	border-bottom: 12px solid var(--primary-color);
	background-color: rgba(var(--dark-color-rgb), 0.9);
	transition: opacity 0.5s, transform 0.5s;
}
.compare-player:after {
	content: '';
	position: absolute;
	inset: 0;
	opacity: 0.6;
	background: no-repeat center top / auto 990px;
	background-image: url('../img/bg/prism_bw6.jpg');
	z-index: 0;
}
.theme-cs2 .compare-player:after { background-image: url('../img/bg/prism_cs6.jpg'); }
.theme-lol .compare-player:after { background-image: url('../img/bg/prism_lol4.jpg'); }
.theme-val .compare-player:after { background-image: url('../img/bg/prism_val7.jpg'); }
.player-a:after { background-position: left 25%; }
.player-b:after { background-position: right 25%; }

.compare-player .player-photo {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	top: 40px;
	background: no-repeat center bottom / 90% auto;
	z-index: 1;
}
.player-a.no-photo .player-photo { background-image: url('../img/silhouette_ct.png') !important; }
.player-b.no-photo .player-photo { background-image: url('../img/silhouette_t.png') !important; }

.compare-player .player-data {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	text-align: center;
	padding: 60px 0 0;
	background: linear-gradient(to bottom, rgba(var(--dark-color-rgb), 0) 0%, rgba(var(--dark-color-rgb), 0.85) 45%);
}
.team-info {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.4em;
	font-size: 26px;
	line-height: 50px;
	padding: 0 0.5em;
	color: var(--light-color);
	font-weight: 500;
}
.compare-player:not(.has-team) .team-info {
	display: none;
}
.team-info .team-logo {
	width: 50px;
	height: 50px;
	flex-shrink: 0;
	background: no-repeat center / contain;
}
.team-info .team-name {
	max-width: calc(100% - 60px);
	white-space: nowrap;
}
.player-info {
	display: flex;
	flex-direction: column;
	padding: 0.15em 0.4em 0.25em;
	background-color: var(--primary-color);
	color: var(--text-color);
}
.player-info .nickname {
	font-size: 64px;
	line-height: 1.1;
	font-weight: 700;
	white-space: nowrap;
	width: 100%;
}
.player-info .realname {
	font-family: var(--text-font);
	font-size: 22px;
	line-height: 1.3;
	font-weight: 500;
	text-transform: none;
}
.player-info .realname.hide {
	display: none;
}
.maps-played {
	font-family: var(--text-font);
	font-size: 22px;
	line-height: 40px;
	color: var(--light-text-color);
	background-color: rgba(var(--black-rgb), 0.55);
}
.compare-player.no-stats .maps-played {
	color: var(--light-color);
}
.compare-player.no-stats .player-photo {
	filter: saturate(0.1) brightness(0.6);
}

/* Corner decoration (lineup style) */
.player-corners {
	position: absolute;
	inset: 0;
	z-index: 3;
	font-size: 25px;
	color: var(--primary-color);
	pointer-events: none;
}
.corners:before,
.corners:after {
	content: '';
	position: absolute;
	top: 0;
	border: 2px solid;
	border-bottom-width: 0;
	width: 1em;
	height: 1em;
}
.corners:before { left: 0; border-right-width: 0; }
.corners:after { right: 0; border-left-width: 0; }

/* Centre column */
.compare-center {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: stretch;
	gap: 24px;
	min-width: 0;
}
.compare-versus {
	align-self: center;
	font-size: 48px;
	line-height: 70px;
	width: 110px;
	text-align: center;
	color: var(--text-color);
	background-color: var(--primary-color);
	font-weight: 700;
	transition: opacity 0.4s, transform 0.4s;
}
.compare-stats {
	display: flex;
	flex-direction: column;
	gap: 12px;
	font-family: var(--text-font);
}
.compare:not(.has-stats) .compare-stats:before {
	content: 'No stats for this selection';
	text-align: center;
	font-size: 30px;
	color: var(--light-color);
}

/* One stat row: value | bar | name | bar | value - bars grow outward from the name */
.compare-stat {
	display: grid;
	grid-template-columns: var(--compare-value-width) 1fr var(--compare-name-width) 1fr var(--compare-value-width);
	align-items: center;
	height: var(--compare-row-height);
	padding: 0 18px;
	background-color: rgba(var(--dark-color-rgb), 0.8);
	border-bottom: 2px solid var(--secondary-color);
	transition: opacity 0.4s, transform 0.4s;
	transition-delay: calc(var(--compare-delay) + (var(--row, 0) * 0.12s));
}
.compare-stat .stat-name {
	text-align: center;
	font-size: 24px;
	font-weight: 500;
	color: var(--light-color);
	white-space: nowrap;
}
.compare-stat .stat-value {
	font-size: 46px;
	font-weight: 700;
	line-height: 1;
	color: var(--light-text-color);
}
.compare-stat .value-a { text-align: left; }
.compare-stat .value-b { text-align: right; }
.compare-stat .stat-value.worse { color: rgba(var(--light-text-color-rgb), 0.6); }
.compare-stat .stat-value.missing { color: var(--light-color); }
.compare-stat .stat-value.better {
	color: var(--primary-color);
	text-shadow: 0 2px rgba(var(--black-rgb), 0.6);
}

.stat-bar {
	position: relative;
	height: 14px;
	margin: 0 14px;
	background-color: rgba(var(--white-rgb), 0.1);
	overflow: hidden;
}
.stat-bar-fill {
	position: absolute;
	top: 0;
	bottom: 0;
	width: var(--fill, 0%);
	background-color: rgba(var(--white-rgb), 0.4);
	transition: width 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
	transition-delay: calc(var(--compare-delay) + 0.2s + (var(--row, 0) * 0.12s));
}
.bar-a .stat-bar-fill { right: 0; }
.bar-b .stat-bar-fill { left: 0; }
.stat-bar.better .stat-bar-fill { background-color: var(--primary-color); }
.stat-bar.equal .stat-bar-fill { background-color: var(--light-color); }

/* Averages note (lineup .avg-stats) */
.avg-stats {
	position: absolute;
	left: 50%;
	bottom: 50px;
	transform: translateX(-50%);
	font-size: 25px;
	line-height: 40px;
	padding: 0 12px;
	font-weight: 500;
	color: var(--text-color);
	background-color: var(--primary-color);
	opacity: 0;
	transition: opacity 0.4s;
}

/* In / out - follows the preview/program tally (js/_overlay_state.js):
 *  preview:  body.preview.show  - always shown, plays the in-animation on load/data changes
 *  program:  body.show          - on air: in-animation (panels, then rows, then bars)
 *            body.hide          - taken off air: quick out-animation, no stagger
 *            neither            - never shown yet: hidden without animating
 *  scene cuts (preview <-> program) get body.no-anim, which kills all transitions (_general.css) */
.page-header {
	transition: opacity 0.4s;
}
body:not(.show) .page-header { opacity: 0; }
body:not(.show) .player-a { opacity: 0; transform: translateX(-40px); }
body:not(.show) .player-b { opacity: 0; transform: translateX(40px); }
body:not(.show) .compare-versus { opacity: 0; transform: scale(0.6); }
body:not(.show) .compare-stat { opacity: 0; transform: translateY(12px); }
body:not(.show) .stat-bar-fill { width: 0; }
body.show .compare-versus { transition-delay: 0.3s; }
body.show .compare.stats-are-avg ~ .avg-stats {
	opacity: 1;
	transition: opacity 0.6s 1.5s;
}

/* Out: everything leaves together and fast */
body.hide .page-header,
body.hide .compare-player,
body.hide .compare-versus,
body.hide .compare-stat,
body.hide .stat-bar-fill,
body.hide .avg-stats {
	transition-duration: 0.3s;
	transition-delay: 0s;
}

/* Rows rebuilt while shown (js adds .entering for one frame): start hidden, then animate in */
.compare-stats.entering .compare-stat {
	opacity: 0;
	transform: translateY(12px);
	transition: none;
}
.compare-stats.entering .stat-bar-fill {
	width: 0;
	transition: none;
}

/* New selection while on air (program): fade the old values out before re-rendering */
.compare.data-swap .compare-stat,
.compare.data-swap .compare-player .player-data,
.compare.data-swap .compare-player .player-photo {
	opacity: 0;
	transition: opacity 0.35s;
	transition-delay: 0s;
}
.compare-player .player-data,
.compare-player .player-photo {
	transition: opacity 0.35s;
}

.debug .compare-stat,
.debug .stat-bar-fill {
	transition-delay: 0s !important;
}
@media (prefers-reduced-motion: reduce) {
	.compare-player, .compare-stat, .stat-bar-fill, .compare-versus {
		transition: none !important;
	}
}
