/* ==========================================================
   Match Stats – design spec
   Widget: 590px wide x 365px high, Helvetica, bold
   Titles 17px (Shots/Corners) | Home/Away 14px | Numbers 16px
   Small titles 14px (Offsides, Fouls, Yellow Cards, Red Cards)
   ========================================================== */

.ms-stat,
.ms-all {
	--ms-home: #ca2128;
	--ms-away: #727272;
	--ms-label-color: #000;
	--ms-label-bar: 17px;
	--ms-label-box: 14px;
	font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
	font-weight: 700;
	color: #000;
	text-align: left;
	box-sizing: border-box;
}
.ms-stat *,
.ms-all *,
.ms-stat *::before,
.ms-stat *::after {
	box-sizing: border-box;
	font-family: inherit;
	margin: 0;
}

/* ---------- Card used by [match_stats] (590 x 365) ---------- */
.ms-all {
	width: 100%;
	max-width: 590px;
	min-height: 365px;
	margin: 0 auto;
	padding: 38px 40px 40px;
	background: #fff;
	border: 1px solid #dcdcdc;
}

/* ---------- Single stat blocks ---------- */
.ms-stat {
	margin: 0 0 26px;
	max-width: 590px;
}
.ms-stat--bar {
	width: 100%;
}
.ms-stat--box {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	margin: 0 0 20px;
}

/* ---------- Titles ---------- */
.ms-stat .ms-title {
	font-weight: 700;
	text-transform: uppercase;
	line-height: 1.2;
	color: var(--ms-label-color);
	letter-spacing: 0;
}
.ms-stat .ms-title--bar {
	font-size: var(--ms-label-bar);
	margin-bottom: 8px;
}
.ms-stat .ms-title--box {
	font-size: var(--ms-label-box);
	margin-bottom: 11px;
	text-align: center;
	white-space: nowrap;
}

/* ---------- Home / Away names ---------- */
.ms-stat .ms-teams {
	display: flex;
	justify-content: space-between;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--ms-label-color);
	margin-bottom: 10px;
	gap: 12px;
}
.ms-stat .ms-teams span:last-child {
	text-align: right;
}

/* ---------- Horizontal bar (one box, red fill + white remainder) ---------- */
.ms-stat .ms-bar {
	display: flex;
	height: 24px;
	border: 1px solid var(--ms-away);
	background: #fff;
}
.ms-stat .ms-bar-home,
.ms-stat .ms-bar-away {
	flex: 1 1 0;
	flex-grow: var(--v, 1);
	min-width: 34px;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	padding: 0 10px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1;
	transition: flex-grow 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.ms-stat .ms-bar-home {
	background: var(--ms-home);
	color: #fff;
}
.ms-stat .ms-bar-away {
	background: #fff;
	color: #000;
	border-left: 1px solid var(--ms-away);
}

/* ---------- Small boxes (Offsides, Fouls, Yellow, Red) ---------- */
.ms-stat .ms-boxes {
	display: inline-flex;
	gap: 6px;
}
.ms-stat .ms-box {
	width: 35px;
	min-width: 35px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	font-weight: 700;
	line-height: 1;
	border: 1px solid var(--ms-away);
	transition: opacity 0.6s ease, transform 0.6s ease;
}
.ms-stat .ms-box-home {
	background: var(--ms-home);
	border-color: var(--ms-home);
	color: #fff;
}
.ms-stat .ms-box-away {
	background: #fff;
	color: #000;
	transition-delay: 0.12s;
}

/* Away team "filled" option */
.ms-away-filled .ms-bar-away,
.ms-away-filled .ms-box-away {
	background: var(--ms-away);
	color: #fff;
}

/* ---------- Combined layout [match_stats] ---------- */
.ms-all .ms-stat--bar {
	margin-bottom: 26px;
	max-width: none;
}
.ms-all .ms-box-row {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: flex-start;
	gap: 20px 24px;
	margin-top: 33px;
}
.ms-all .ms-box-row .ms-stat {
	margin: 0;
}

/* ---------- Animation (JS adds .ms-animate, then .ms-is-visible) ---------- */
.ms-stat.ms-animate:not(.ms-is-visible) .ms-bar-home,
.ms-stat.ms-animate:not(.ms-is-visible) .ms-bar-away {
	flex-grow: 0.001;
}
.ms-stat.ms-animate:not(.ms-is-visible) .ms-box {
	opacity: 0;
	transform: translateY(8px);
}

/* ---------- Small screens: 2 x 2 grid for the small boxes ----------
   Offsides | Fouls
   Yellow Cards | Red Cards                                          */
@media (max-width: 520px) {
	.ms-all {
		min-height: 0;
		padding: 28px 20px 30px;
	}
	.ms-all .ms-box-row {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 24px 16px;
		justify-content: stretch;
		align-items: stretch;
		margin-top: 28px;
	}
	.ms-all .ms-box-row .ms-stat {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		height: 100%;
	}
	.ms-all .ms-box-row .ms-title--box {
		text-align: left;
		white-space: normal;
	}
	/* keep the boxes level even if a title wraps to two lines */
	.ms-all .ms-box-row .ms-boxes {
		margin-top: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ms-stat .ms-bar-home,
	.ms-stat .ms-bar-away,
	.ms-stat .ms-box { transition: none !important; }
}
