/*
 * MeroScore phone design. Loaded only for (max-width: 899px) (see inc/Assets.php), so desktop is never touched.
 * A light, scores-first app look: white cards with a hairline border, red only for live and active, tabular scores.
 * Colours come from tokens.css only; sizes follow the rules in AGENTS.md (44px targets, 16px fields).
 *
 * Contents: 1 shell and page rhythm, 2 bottom bar, 3 slim footer, 4 headings and section heads, 5 segmented tabs,
 * 6 data tables, 7 cards and rows (shared), then one section per screen below.
 */

/* ---------- 1. Shell and page rhythm ---------- */

:root {
	--ms-gutter: 16px;
	--ms-card-gap: 12px;
	--ms-section-gap: 24px;
}

html body .ms-main {
	padding: 16px var(--ms-gutter) 28px;
}

/* ---------- 2. Bottom bar: Home, Live, Fixtures, News, More ---------- */

.ms-tabbar__more {
	appearance: none;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}

.ms-tabbar .ms-nav__link {
	color: var(--muted);
}

.ms-tabbar .ms-nav__link svg {
	width: 24px;
	height: 24px;
}

/* ---------- 3. Slim footer: the bar and the menu already hold every link, so the footer keeps only the legal row ---------- */

.ms-footer__groups {
	display: flex;
	flex-direction: column-reverse;
	gap: 12px;
	padding-block: 20px 8px;
}

.ms-footer__nav:not(:has(a[href*="/terms"])) {
	display: none;
}

.ms-footer__nav:has(a[href*="/terms"]) .ms-footer__title {
	display: none;
}

.ms-footer__nav:has(a[href*="/terms"]) ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0 20px;
}

.ms-footer__nav:has(a[href*="/terms"]) li:has(a[href*="hall-of-fame"]) {
	display: none;
}

.ms-footer__nav:has(a[href*="/terms"]) a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--muted);
	font-size: 13px;
}

.ms-footer__brand {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 16px;
}

.ms-footer__brand .ms-footer__note {
	order: 3;
	flex-basis: 100%;
	margin: 0;
	font-size: 12px;
	line-height: 18px;
}

.ms-footer__brand .ms-tz {
	margin: 0;
}

/* ---------- 4. Headings and section heads ---------- */

html body .ms-main :is(h1, .mse__h1) {
	font-size: 24px;
	line-height: 30px;
	font-weight: 800;
	letter-spacing: -0.01em;
}

html body .ms-main :is(.ms-section__title, .mse__h2) {
	font-size: 18px;
	line-height: 24px;
	font-weight: 700;
}

html body .ms-main .ms-section__head {
	align-items: center;
	margin: 0 0 12px;
}

html body .ms-main .ms-section__head .ms-more,
html body .ms-main .ms-section__head a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font-size: 14px;
	font-weight: 600;
}

/* ---------- 5. Segmented tabs: one scrolling row, the selected tab in view, a fade where more is hidden ---------- */

.ms-tabs__list,
.ms-fx__tablist,
.ms-th__tablist,
.ms-news__filters,
.ms-search__filters,
.ms-band__chips {
	display: flex;
	flex-wrap: nowrap;
	gap: 8px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	margin-inline: calc(var(--ms-gutter) * -1);
	padding-inline: var(--ms-gutter);
}

.ms-tabs__list::-webkit-scrollbar,
.ms-fx__tablist::-webkit-scrollbar,
.ms-th__tablist::-webkit-scrollbar,
.ms-news__filters::-webkit-scrollbar,
.ms-search__filters::-webkit-scrollbar,
.ms-band__chips::-webkit-scrollbar {
	display: none;
}

.ms-tabs__list > li,
.ms-fx__tablist > li,
.ms-th__tablist > li {
	flex: none;
	scroll-snap-align: center;
}

.ms-tabs__tab,
.ms-fx__tab,
.ms-th__tab,
.ms-news__filter,
.ms-search__chip,
.ms-band__chips .ms-chip {
	flex: none;
	white-space: nowrap;
}

.has-more-right {
	-webkit-mask-image: linear-gradient(to right, var(--ink) calc(100% - 36px), transparent);
	mask-image: linear-gradient(to right, var(--ink) calc(100% - 36px), transparent);
}

.has-more-left {
	-webkit-mask-image: linear-gradient(to left, var(--ink) calc(100% - 36px), transparent);
	mask-image: linear-gradient(to left, var(--ink) calc(100% - 36px), transparent);
}

.has-more-left.has-more-right {
	-webkit-mask-image: linear-gradient(to right, transparent, var(--ink) 36px, var(--ink) calc(100% - 36px), transparent);
	mask-image: linear-gradient(to right, transparent, var(--ink) 36px, var(--ink) calc(100% - 36px), transparent);
}

/* ---------- 6. Data tables: the first column stays put while the rest scroll, so no figure is ever cut off ---------- */

.ms-tablewrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-inline: calc(var(--ms-gutter) * -1);
	padding-inline: var(--ms-gutter);
}

/* ---------- 7. Cards and rows, shared ---------- */

html body .ms-main :is(.mse-card, .mse-match) {
	padding: 14px 16px;
	border-radius: var(--radius-md);
}

/* ---------- Home: scores first ---------- */

/* The Fixtures tab is in the bottom bar, so the "Full fixtures" link above the cards is not needed. */
.ms-band__head .ms-band__all,
html body .ms-band__all {
	display: none !important;
}

.ms-band__head {
	margin-bottom: 4px;
}

/* Score cards: a swipe row of 272px cards, a status line on top, two team lines, the result or countdown below. */
.ms-band__list {
	gap: 12px;
	padding-inline: var(--ms-gutter);
	margin-inline: calc(var(--ms-gutter) * -1);
	scroll-padding-inline: var(--ms-gutter);
}

.ms-band__list .ms-strip__item {
	flex: 0 0 272px;
}

html body .ms-match--card {
	display: flex;
	flex-direction: column;
	gap: 10px;
	height: 100%;
	padding: 14px 16px;
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
	background: var(--surface);
}

html body .ms-match--card .ms-match__tag {
	font-size: 11px;
	line-height: 16px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--muted);
}

html body .ms-match--card.is-live .ms-match__tag {
	color: var(--accent-text);
}

html body .ms-match--card .ms-match__line {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

html body .ms-match--card .ms-team__name {
	font-size: 15px;
	font-weight: 600;
}

html body .ms-match--card .ms-match__count,
html body .ms-match--card .ms-match__note {
	margin-top: auto;
	padding-top: 10px;
	border-top: 1px solid var(--line);
	color: var(--muted);
	font-size: 13px;
	line-height: 18px;
}

/* The featured match: two sides, the time, one head-to-head line, one wide button. */
.ms-home__row {
	gap: 16px;
}

html body .ms-hero2 {
	padding: 16px;
}

html body .ms-hero2__head {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-bottom: 12px;
}

html body .ms-hero2__ctx {
	font-size: 13px;
	line-height: 18px;
	color: var(--muted);
}

html body .ms-hero2__teams {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
}

html body .ms-hero2__side {
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 4px 8px 12px;
	text-align: center;
}

html body .ms-hero2__side + .ms-hero2__side {
	border-left: 1px solid var(--line);
}

html body .ms-hero2__name {
	font-size: 15px;
	line-height: 20px;
	font-weight: 700;
}

html body .ms-hero2__line {
	display: none;
}

html body .ms-hero2__when {
	margin: 0;
	text-align: center;
	font-size: 14px;
	color: var(--muted);
}

html body .ms-hero2 .ms-match__count {
	display: block;
	margin: 6px 0 0;
	text-align: center;
	font-size: 15px;
	font-weight: 700;
}

html body .ms-h2h {
	margin-top: 16px;
	padding-top: 16px;
}

html body .ms-h2h__sub,
html body .ms-h2h__item:nth-child(n+2) {
	display: none;
}

html body .ms-hero2__foot {
	margin-top: 16px;
}

html body .ms-hero2__open {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
}

/* News: one big story, then a compact list. */
html body .ms-lead__title {
	font-size: 22px;
	line-height: 28px;
	font-weight: 800;
}

html body .ms-news__list li {
	padding-block: 12px;
}

/* Points table on the home page: title, season and "Full table" sit on two tight lines. */
html body .ms-ptable .ms-section__head {
	gap: 0 12px;
	margin-bottom: 8px;
}

html body .ms-ptable__season {
	font-size: 13px;
}

/* ---------- Live and Fixtures: day headers that stay in view, and one compact row per match ---------- */

html body .ms-fx__group {
	margin-bottom: 20px;
}

html body .ms-fx__date {
	position: sticky;
	top: calc(var(--ms-header-h) + var(--ms-safe-top));
	z-index: 5;
	margin: 0;
	padding: 10px 0 8px;
	background: var(--bg);
	font-size: 16px;
	line-height: 22px;
	font-weight: 700;
}

html body .ms-fx__venue {
	margin: 0 0 8px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--muted);
	font-size: 12px;
	line-height: 16px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: none;
}

html body .ms-fx__rows {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
}

html body .ms-match--row {
	display: grid;
	/* Teams use the whole card width; the status, result and time sit on a line under them, so a name is never squeezed. */
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas: 'teams teams' 'meta when';
	align-items: center;
	gap: 6px 12px;
	min-height: 76px;
	padding: 12px 14px;
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
	background: var(--surface);
}

html body .ms-match--row .ms-match__when {
	grid-area: when;
	align-self: center;
	text-align: right;
	white-space: nowrap;
	color: var(--muted);
	font-size: 13px;
	line-height: 16px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

html body .ms-match--row .ms-match__teams {
	grid-area: teams;
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
}

html body .ms-match--row .ms-match__team {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

html body .ms-match--row .ms-crest--md {
	width: 28px;
	height: 28px;
	flex: none;
}

html body .ms-match--row .ms-match__score {
	margin-left: auto;
	flex: none;
	white-space: nowrap;
	text-align: right;
}

html body .ms-match--row .ms-match__name {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 15px;
	line-height: 20px;
	font-weight: 600;
	white-space: normal;
	overflow-wrap: anywhere;
}

html body .ms-match--row .ms-match__meta {
	grid-area: meta;
	align-self: center;
	justify-self: start;
	min-width: 0;
	max-width: 100%;
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 8px;
	text-align: left;
}

html body .ms-match--row .ms-match__text {
	max-width: 100%;
	overflow-wrap: anywhere;
}

html body .ms-match--row:active {
	background: var(--surface-2);
}

/* ---------- Match centre ---------- */

/* The score header: status line, big score, result. While you scroll it shrinks to a single line (class set by mobile.js). */
html body .ms-cm__head {
	padding: 14px 16px;
}

html body .ms-cm__top {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 10px;
	margin-bottom: 6px;
}

html body .ms-cm__facts {
	display: inline;
	font-size: 12px;
	line-height: 16px;
	color: var(--muted);
}

html body .ms-cm__score {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 8px;
	margin: 0;
}

html body .ms-cm__runs {
	font-size: 34px;
	line-height: 38px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

html body .ms-cm__need {
	margin: 4px 0 0;
	font-size: 14px;
	line-height: 20px;
	font-weight: 600;
}

/* The score card scrolls away with the page; once it has, a one-line bar (made by mobile.js) takes its place under the site header.
   The bar is fixed, so showing or hiding it never changes the page height, whatever the amount of content. */
html body .ms-cm__head {
	position: static;
}

.ms-scorebar {
	position: fixed;
	z-index: 15;
	top: calc(var(--ms-header-h) + var(--ms-safe-top));
	left: 0;
	right: 0;
	display: none;
	padding: 8px 16px;
	border-bottom: 1px solid var(--line);
	background: var(--surface);
}

.ms-scorebar.is-on {
	display: block;
}

.ms-scorebar .ms-cm__score {
	margin: 0;
}

.ms-scorebar .ms-cm__runs {
	font-size: 22px;
	line-height: 28px;
}

.ms-scorebar .ms-cm__team {
	font-size: 14px;
}

/* The side cards (at the crease, bowling, match info...) stack below the content at full width instead of a swipe row of 86% cards. */
html body .ms-cm__side {
	flex-direction: column;
	overflow: visible;
	scroll-snap-type: none;
}

html body .ms-cm__sec {
	flex: none;
	width: 100%;
}

/* The tab row, and the panel title that only repeats the selected tab. */
html body .ms-cm__tabs {
	margin-block: 0;
}

html body .ms-cm__main > :is(h2, h3):first-child {
	display: none;
}

/* Scorecard and bowling tables: the player column stays while the figures scroll, with tight cells so most fit at once. */
html body .ms-mx__scroll {
	margin-inline: 0;
	padding-inline: 0;
}

html body .ms-mx__table :is(th, td) {
	padding-inline: 6px;
	white-space: nowrap;
}

html body .ms-mx__table :is(th, td):first-child {
	position: sticky;
	left: 0;
	z-index: 1;
	min-width: 132px;
	max-width: 160px;
	padding-inline-start: 12px;
	background: var(--surface);
	white-space: normal;
}

html body .ms-mx__table thead :is(th):first-child {
	background: var(--surface);
}

html body .ms-mc__panel > .ms-live__heading:first-child {
	display: none;
}

/* ---------- Team, tournament and season pages: match cards become short rows ---------- */

html body .mse-match {
	display: grid;
	gap: 8px;
	padding: 12px 14px;
}

html body .mse-match > .mse-badge {
	justify-self: start;
}

html body .mse-match__sides {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

html body .mse-match__team {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

html body .mse-match__team .ms-team__code {
	display: none;
}

html body .mse-match__team .ms-team__name {
	font-size: 15px;
	font-weight: 600;
}

html body .mse-match__score {
	font-size: 16px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

html body .mse-match__result {
	font-size: 14px;
	line-height: 20px;
	font-weight: 600;
}

html body .mse-match__meta {
	overflow: hidden;
	color: var(--muted);
	font-size: 12px;
	line-height: 16px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

html body .ms-fx__extra {
	margin: 0 0 4px;
	text-align: right;
}

html body .ms-fx__extra .ms-more {
	min-height: 44px;
	font-size: 13px;
}

html body .mse-list {
	gap: 10px;
}

/* ---------- 44px tap targets for links that sit alone on a line ---------- */

html body .ms-squad__player {
	min-height: 48px;
}

html body .ms-squad__name {
	display: flex;
	flex: 1;
	align-items: center;
	min-height: 48px;
}

html body a.mse-chip {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding-inline: 14px;
}

html body :is(.ms-hof__label, .ms-hof__sub) a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
}
