/*
  The round table on the Tournament page (partials/tournament_round.html): the current round and every past round.
  Everything is scoped under .gt-round, so no other table on the site is touched. Colors come from Bootstrap's theme
  variables (so dark and light follow the page) and from the skin's own color roles: --c-link-text for the link pills
  and --c-button / --c-button-on for the filled buttons, each with a fallback for pages that have no skin colors.
  Below 768px each game becomes a stacked block instead of a table row.
  The round sub-headings at the bottom (.gt-rhead, .gt-rtoggle ...) belong to the same partial but are outside .gt-round.
*/

.gt-round {
	--gtr-accent: var(--c-link-text, #bfa85e);
	--gtr-btn: var(--c-button, #bfa85e);
	--gtr-btn-on: var(--c-button-on, #14110a);
	--gtr-line: var(--bs-border-color, #dee2e6);
	--gtr-soft: color-mix(in srgb, var(--bs-body-color) 5%, transparent);
	width: 100%;
	margin-bottom: 1rem;
	border-collapse: collapse;
}

[data-bs-theme=light] .gt-round { --gtr-accent: var(--c-link-text, #7d6a2a); --gtr-btn: var(--c-button, #9b843a); --gtr-btn-on: var(--c-button-on, #ffffff); }

/* The old phone rules in tournament.css (12px text, 100px minimum cell width) still apply to the other tables that
   share .tournament-round; this table undoes them. */
.tournament-round .gt-round th,
.tournament-round .gt-round td {
	min-width: 0;
	font-size: inherit;
	word-break: normal;
	text-align: left;
	vertical-align: middle;
	background: none;
	box-shadow: none;
}
.tournament-round .gt-round th {
	padding: .4rem .65rem;
	border-bottom: 1px solid var(--gtr-line);
	color: var(--bs-secondary-color);
	font-size: .72rem;
	font-weight: 600;
	letter-spacing: .07em;
	text-transform: uppercase;
}
.tournament-round .gt-round tr.gt-game > td {
	padding: .7rem .65rem;
	border: 0;
	border-top: 1px solid var(--gtr-line);
}
.tournament-round .gt-round tbody > tr.gt-game:first-child > td { border-top: 0; }
.tournament-round .gt-round tr.gt-alt > td { background: color-mix(in srgb, var(--bs-body-color) 3.5%, transparent); }
.tournament-round .gt-round tr.gt-rematch > td { background: color-mix(in srgb, var(--bs-danger) 13%, transparent); }
.tournament-round .gt-round tr.gt-rematch > td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }

.gt-round .gt-map { color: var(--bs-secondary-color); }
.tournament-round .gt-round td.gt-empty { padding: 0; }
.gt-round .gt-none { color: var(--bs-secondary-color); }

/* Game Link and PCS are columns of identical pills, so the header and the pills are centered together. */
.tournament-round .gt-round th.gt-h-link,
.tournament-round .gt-round th.gt-h-pcs,
.tournament-round .gt-round td.gt-gamelink,
.tournament-round .gt-round td.gt-pcs { text-align: center; }

/* Players: the winner gets a green pill with a check, the loser of a two-player game is dimmed. */
.gt-round .gt-pl {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	margin-left: -.65rem;
	padding: .2rem .65rem;
	border: 1px solid transparent;
	border-radius: 999px;
}
/* The same light green as the W-L-T pill of an undefeated player (standings.css), with the name kept in the normal text color
   so it stays easy to read; only the check mark is green. */
.gt-round .gt-pl.gt-win {
	background: rgba(25, 135, 84, .16);
	border-color: rgba(25, 135, 84, .45);
	color: var(--bs-body-color);
	font-weight: 700;
}
.gt-round .gt-pl.gt-lose { color: var(--bs-secondary-color); }
.gt-round .gt-ck { font-size: .8em; color: #146c43; }
html[data-bs-theme=dark] .gt-round .gt-ck { color: #6fe0a8; }

/* Multiplayer: the finishing place as a small chip right after the name. 1st place is filled green. */
.gt-round .gt-rk {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.45em;
	height: 1.45em;
	padding: 0 .3em;
	border: 1px solid var(--gtr-line);
	border-radius: 999px;
	color: var(--bs-secondary-color);
	font-size: .78rem;
	font-weight: 700;
	line-height: 1;
}
.gt-round .gt-rk.gt-rk-w {
	background: var(--bs-success-text-emphasis);
	border-color: transparent;
	color: var(--bs-body-bg);
}

/* Open Game and PCS */
.gt-round a.gt-pill,
.gt-round a.gt-pill:visited {
	display: inline-flex;
	align-items: center;
	padding: .2rem .75rem;
	border: 1px solid var(--gtr-accent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--gtr-accent) 10%, transparent);
	color: var(--gtr-accent) !important;
	font-size: .85rem;
	font-weight: 600;
	text-decoration: none !important;
	white-space: nowrap;
}
.gt-round a.gt-pill:hover { background: color-mix(in srgb, var(--gtr-accent) 22%, transparent); }

/* Report Result / Fix Result / Submit / Cancel */
.tournament-round .gt-round .gt-btn {
	min-width: 0;
	padding: .3rem .85rem;
	border: 1px solid var(--gtr-btn);
	border-radius: 7px;
	background: var(--gtr-btn);
	color: var(--gtr-btn-on);
	font-size: .85rem;
	font-weight: 700;
	white-space: nowrap;
}
.tournament-round .gt-round .gt-btn:hover { background: var(--gtr-btn); color: var(--gtr-btn-on); filter: brightness(1.1); }
.tournament-round .gt-round .gt-btn.gt-ghost { background: transparent; border-color: var(--gtr-line); color: var(--bs-body-color); }
.tournament-round .gt-round .gt-btn.gt-ghost:hover { background: var(--gtr-soft); color: var(--bs-body-color); }
.gt-round .gt-report { width: 1%; white-space: nowrap; text-align: right; }

/* The More Info row and the result form open as a panel under their game. */
.tournament-round .gt-round tr.gt-extra > td { padding: 0 .65rem .9rem; border: 0; }
.gt-round .gt-panel {
	padding: .9rem 1rem;
	border: 1px solid var(--gtr-line);
	border-radius: 10px;
	background: var(--gtr-soft);
	text-align: left;
}
.gt-round .gt-more {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: .9rem 1.5rem;
}
.gt-round .gt-more .gt-gamemeta { grid-column: 1 / -1; }
.gt-round .gt-form .form-select { max-width: 440px; }

/* Phone: each game is a stacked block. */
@media (max-width: 767.98px) {
	.gt-round,
	.gt-round tbody { display: block; }
	.gt-round thead { display: none; }

	.tournament-round .gt-round tr.gt-game {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: .4rem .5rem;
		padding: .8rem .25rem;
		border-top: 1px solid var(--gtr-line);
	}
	.tournament-round .gt-round tbody > tr.gt-game:first-child { border-top: 0; }
	.tournament-round .gt-round tr.gt-game > td,
	.tournament-round .gt-round tbody > tr.gt-game:first-child > td {
		display: block;
		padding: 0;
		border: 0;
		background: none;
		box-shadow: none;
	}
	.tournament-round .gt-round tr.gt-rematch {
		padding: .8rem .85rem;
		background: color-mix(in srgb, var(--bs-danger) 13%, transparent);
		box-shadow: inset 3px 0 0 var(--bs-danger);
	}

	.gt-round .gt-map {
		flex: 0 0 100%;
		font-size: .75rem;
		font-weight: 600;
		letter-spacing: .04em;
		text-transform: uppercase;
	}
	.gt-round .gt-player.gt-empty,
	.gt-round .gt-map.gt-none,
	.gt-round .gt-gamelink.gt-none,
	.gt-round .gt-pcs.gt-none { display: none !important; }
	.gt-round .gt-player { flex: 0 0 100%; }
	.gt-round .gt-player .gt-pl {
		display: flex;
		margin-left: 0;
		padding: .5rem .75rem;
		border-radius: 9px;
		background: var(--gtr-soft);
	}
	.gt-round .gt-player .gt-pl.gt-win { background: rgba(25, 135, 84, .16); }
	.tournament-round .gt-round .gt-report { width: auto; margin-left: auto; text-align: right; }
	.tournament-round .gt-round .gt-report.gt-status { margin-left: 0; }

	.gt-round tr.gt-extra { display: block; padding: 0 .25rem .8rem; }
	.tournament-round .gt-round tr.gt-extra > td { display: block; padding: 0; }
	.gt-round .gt-more { grid-template-columns: 1fr; gap: .8rem; }
	.gt-round .gt-form .form-select { max-width: none; }
	.gt-round .gt-form .gt-btn { flex: 1; padding: .55rem .85rem; }
}

/* Round sub-headings inside the Tournament page panels (Round 1, Round 2, ...), collapsible from the title. */

.tournament-round .gt-rhead {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .4rem 1rem;
	margin: 0 0 .6rem;
}
#TournamentRounds .tournament-round + .tournament-round {
	margin-top: 1.25rem;
	padding-top: 1.1rem;
	border-top: 1px solid var(--bs-border-color);
}
.tournament-round .gt-rtitle {
	margin: 0;
	text-align: left;
	font-family: var(--gt-font-title, 'Lora', Georgia, 'Times New Roman', serif);
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.2;
}
.tournament-round .gt-rtoggle {
	display: inline-flex;
	align-items: center;
	gap: .55rem;
	min-width: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}
.tournament-round .gt-rtoggle:focus-visible { outline: 2px solid var(--c-primary, #bfa85e); outline-offset: 3px; border-radius: 4px; }
.gt-rchev {
	flex: 0 0 auto;
	width: .5rem;
	height: .5rem;
	margin: 0 .15rem;
	border-right: 2px solid var(--bs-secondary-color);
	border-bottom: 2px solid var(--bs-secondary-color);
	transform: translateY(-25%) rotate(45deg);
	transition: transform .15s ease;
}
.gt-rtoggle[aria-expanded="false"] .gt-rchev { transform: translateX(-15%) rotate(-45deg); }
.tournament-round .gt-rmore { margin: 0 0 0 auto; padding-left: 2.5em; font-size: .85rem; }
.tournament-round.gt-rcollapsed .gt-rbody { display: none; }
.tournament-round.gt-rcollapsed .gt-rhead { margin-bottom: 0; }

/* Collapse all / Expand all above the rounds */
.gt-rbar { display: flex; justify-content: flex-end; gap: 1rem; margin: 0 0 .5rem; font-size: .85rem; }
.gt-rbar .gt-rbtn {
	padding: 0;
	border: 0;
	background: none;
	color: var(--c-link-text, var(--bs-link-color));
	text-decoration: underline;
	cursor: pointer;
}

/* The site gives every <button> a blue (or, on hover, gold) fill with !important (base.html and styles.css); these
   plain text controls undo that in every state. */
html[data-bs-theme] .tournament-round .gt-rtoggle,
html[data-bs-theme] .tournament-round .gt-rtoggle:hover,
html[data-bs-theme] .tournament-round .gt-rtoggle:focus,
html[data-bs-theme] .tournament-round .gt-rtoggle:active {
	background: none !important;
	background-color: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	padding: 0 !important;
	color: inherit !important;
	box-shadow: none !important;
}
html[data-bs-theme] .gt-rbar .gt-rbtn,
html[data-bs-theme] .gt-rbar .gt-rbtn:hover,
html[data-bs-theme] .gt-rbar .gt-rbtn:focus,
html[data-bs-theme] .gt-rbar .gt-rbtn:active {
	background: none !important;
	background-color: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	padding: 0 !important;
	color: var(--c-link-text, var(--bs-link-color)) !important;
	box-shadow: none !important;
}

/* Search (rows and rounds that do not match are hidden; a round that does match opens even if it was folded) */
.gt-nomatch,
.tournament-round.gt-rnomatch { display: none !important; }
.tournament-round.gt-rcollapsed.gt-rsearch .gt-rbody { display: block; }
.tournament-round.gt-scollapsed:not(.gt-rsearch) { display: none; }
.gt-searchmsg { margin: 0 0 .75rem; color: var(--bs-secondary-color); font-size: .9rem; }

/* Jump pills (left) and Collapse all / Expand all (right) above the rounds */
.gt-rbar { align-items: center; justify-content: space-between; }
.gt-rbar .gt-rlinks { display: flex; gap: 1rem; margin-left: auto; white-space: nowrap; flex: 0 0 auto; }
.gt-jump { display: flex; flex-wrap: wrap; gap: .4rem; min-width: 0; flex: 1 1 auto; }
.gt-jump:empty { display: none; }
.gt-jump a.gt-jumppill,
.gt-jump a.gt-jumppill:visited {
	padding: .15rem .7rem;
	border: 1px solid var(--bs-border-color);
	border-radius: 999px;
	color: var(--bs-body-color);
	font-size: .8rem;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}
.gt-jump a.gt-jumppill:hover,
.gt-jump a.gt-jumppill:focus-visible { border-color: var(--c-primary, #bfa85e); color: var(--bs-body-color); background: color-mix(in srgb, var(--c-primary, #bfa85e) 14%, transparent); }
.tournament-round[id^="TournamentRound_"] { scroll-margin-top: 5rem; }
.gt-stagehead { scroll-margin-top: 5rem; margin: 1.1rem 0 .6rem; padding-bottom: .35rem; border-bottom: 2px solid var(--c-primary, #bfa85e); }
.gt-stagehead:first-child { margin-top: 0; }
.gt-stagehead .gt-stoggle {
	display: inline-flex;
	align-items: center;
	gap: .55rem;
	font-family: var(--gt-font-title, 'Lora', Georgia, 'Times New Roman', serif);
	font-size: 1.15rem;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
}
html[data-bs-theme] .gt-stagehead .gt-stoggle,
html[data-bs-theme] .gt-stagehead .gt-stoggle:hover,
html[data-bs-theme] .gt-stagehead .gt-stoggle:focus,
html[data-bs-theme] .gt-stagehead .gt-stoggle:active {
	background: none !important;
	background-color: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	padding: 0 !important;
	color: inherit !important;
	box-shadow: none !important;
}
.gt-stoggle[aria-expanded="false"] .gt-rchev { transform: translateX(-15%) rotate(-45deg); }

/* Maps panel, "unique" view: one card per map name, with how many copies are in the pool. */
#TournamentMaps.gt-maps-unique .tournamentMap.gt-mapdup { display: none; }
.gt-mapcount {
	float: right;
	margin: 0 0 0 .4rem;
	padding: 0 .45rem;
	border: 1px solid var(--bs-border-color);
	border-radius: 999px;
	color: var(--bs-secondary-color);
	font-size: .75rem;
	font-weight: 600;
	line-height: 1.5;
}
#TournamentMaps:not(.gt-maps-unique) .gt-mapcount { display: none; }
