:root {
	--topbar-height: 64px;
	--drawer-width: min(300px, 85vw);
}

html {
	background-color: black;
	color: white;
}

body {
	min-height: 100vh;
	min-height: 100dvh;
}

/* page doesn't scroll behind the open navigation (mainly for phones) */
html.nav_open {
	overflow: hidden;
}

#topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	height: var(--topbar-height);
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0 12px;
	background-color: black;
	border-bottom: 1px solid #222;
}

#burger_button {
	width: 48px;
	height: 48px;
	display: grid;
	place-items: center;
	padding: 0;
	border: none;
	border-radius: 12px;
	background: none;
	cursor: pointer;
}

#burger_button:hover,
#burger_button:focus-visible {
	background-color: #1a1a1a;
}

#burger_button svg {
	width: 32px;
	height: 32px;
	color: var(--light-blue); /* the sprite's icons use currentColor */
}

#site_title {
	font-size: 1.5rem;
	font-weight: bold;
}

#nav_backdrop {
	position: fixed;
	inset: 0;
	z-index: 20;
	background-color: rgba(0, 0, 0, 0.6);
}

#nav_drawer {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	z-index: 30;
	width: var(--drawer-width);
	display: flex;
	flex-direction: column;
	gap: 24px;
	padding: 24px 16px;
	box-sizing: border-box;
	overflow-y: auto;
	background-color: #111;
	border-right: 1px solid #222;
	transform: translateX(-100%);
	transition: transform 0.2s ease;
}

#nav_drawer.open {
	transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
	#nav_drawer {
		transition: none;
	}
}

#nav_user {
	color: #aaa;
	overflow-wrap: anywhere;
}

#nav_user strong {
	color: white;
}

#nav_links {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

#nav_links button,
#nav_links a,
#logout_button {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	box-sizing: border-box;
	padding: 14px 16px;
	border-radius: 12px;
	font-family: inherit;
	font-size: 1.25rem;
	text-align: left;
	color: white;
	text-decoration: none;
	border: none;
	background: none;
	cursor: pointer;
}

#nav_links button:hover,
#nav_links button:focus-visible,
#nav_links a:hover,
#nav_links a:focus-visible {
	background-color: #222;
}

/* thin line between everyone's items and the admin-only ones (admins only) */
#nav_links .nav_separator {
	height: 1px;
	margin: 6px 16px;
	background-color: #333;
}

#nav_links button[aria-current="page"] {
	color: var(--light-blue);
}

#logout_button {
	margin-top: auto;
	border: 1px solid #333;
}

#logout_button:hover,
#logout_button:focus-visible {
	background-color: #222;
}

#content {
	padding: 24px 16px;
	overflow-wrap: anywhere;
}

#content section[hidden] {
	display: none;
}

#content h1 {
	margin: 0;
	font-size: clamp(1.5rem, 5vw, 2.5rem);
}

/* ---- Users view ---- */

#content h2 {
	margin: 0 0 12px;
	font-size: 1.25rem;
}

.admin_view,
#view_home {
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-width: 640px;
}

.panel,
.list_item {
	padding: 16px;
	border: 1px solid #333;
	border-radius: 16px;
	background-color: #111;
}

.panel {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	color: #aaa;
}

.field input,
.password_form input {
	min-width: 0;
	padding: 12px 14px;
	font-family: inherit;
	font-size: 1rem;
	color: white;
	border: 1px solid #444;
	border-radius: 12px;
	background-color: black;
}

.field input:focus-visible,
.password_form input:focus-visible {
	outline: 2px solid var(--light-blue);
	outline-offset: 1px;
}

.primary_button,
.secondary_button,
.danger_button {
	padding: 12px 18px;
	font-family: inherit;
	font-size: 1rem;
	border-radius: 12px;
	cursor: pointer;
}

.primary_button {
	color: black;
	font-weight: bold;
	border: none;
	background-color: var(--light-blue);
}

.secondary_button {
	color: white;
	border: 1px solid #444;
	background: none;
}

.danger_button {
	color: #ff6b6b;
	border: 1px solid #ff6b6b;
	background: none;
}

.secondary_button:hover,
.danger_button:hover {
	background-color: #222;
}

[role="status"]:empty {
	display: none;
}

.message_ok {
	color: #7bd88f;
}

.message_error {
	color: #ff6b6b;
}

.item_list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

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

.item_header {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.item_name {
	font-size: 1.15rem;
	overflow-wrap: anywhere;
}

.role_badge {
	padding: 2px 10px;
	font-size: 0.85rem;
	color: black;
	border-radius: 999px;
	background-color: var(--light-blue);
}

.item_actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.password_form {
	flex-basis: 100%;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.password_form[hidden] {
	display: none;
}

.password_form input {
	flex: 1 1 180px;
}

/* phones: buttons take the full width so they are easy to tap */
@media (max-width: 480px) {
	.item_actions,
	.item_actions button,
	.password_form button {
		flex: 1 1 auto;
	}
	.item_actions {
		width: 100%;
	}
}

.item_detail {
	color: #aaa;
}

.empty_hint {
	color: #aaa;
}


/* ---- Setup view: teams and groups ---- */

#view_setup {
	max-width: 960px;
}

.field select {
	padding: 12px 14px;
	font-family: inherit;
	font-size: 1rem;
	color: white;
	border: 1px solid #444;
	border-radius: 12px;
	background-color: black;
}

.hint {
	margin: 0;
	color: #aaa;
}

.team_names_form {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.team_grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
	gap: 10px;
}

.team_field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	color: #aaa;
	font-size: 0.9rem;
}

.team_field input {
	padding: 10px 12px;
	font-family: inherit;
	font-size: 1rem;
	color: white;
	border: 1px solid #444;
	border-radius: 10px;
	background-color: black;
}

/* the name field with its explanation button beside it */
.team_field_row {
	display: flex;
	gap: 6px;
}

.team_field_row input {
	flex: 1;
	min-width: 0;
}

/* grey: no explanation yet; blue: the team has one */
.description_button {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	padding: 0;
	color: #666;
	border: 1px solid #444;
	border-radius: 10px;
	background: none;
	cursor: pointer;
}

.description_button svg {
	width: 22px;
	height: 22px;
}

.description_button.has_description {
	color: var(--light-blue);
	border-color: var(--light-blue);
}

.description_button:hover {
	background-color: #222;
}

.description_button:focus-visible {
	outline: 2px solid var(--light-blue);
	outline-offset: 1px;
}

/* the explanation in its pop-up; grows by dragging its corner */
.team_description {
	padding: 8px 12px;
	font-family: inherit;
	font-size: 0.9rem;
	color: white;
	border: 1px solid #333;
	border-radius: 10px;
	background-color: black;
	resize: vertical;
}

.team_description:focus-visible,
.team_field input:focus-visible,
.field select:focus-visible {
	outline: 2px solid var(--light-blue);
	outline-offset: 1px;
}

#draw_button {
	align-self: flex-start;
}

.tournament_actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.tournament_actions [hidden] {
	display: none;
}

/* a panel heading with a button on the right */
.panel_head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 8px 12px;
}

.panel_head h2 {
	margin: 0;
}

/* Tournaments: each entry is a button that opens its pop-up */
.tournament_item {
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	font: inherit;
	color: inherit;
	text-align: left;
	border: 1px solid #333;
	border-radius: 16px;
	background-color: #111;
	cursor: pointer;
}

.tournament_item:hover {
	border-color: #555;
}

.tournament_item:focus-visible {
	outline: 2px solid var(--light-blue);
	outline-offset: 1px;
}

.tournament_year {
	color: #aaa;
}

.group_grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
	gap: 10px;
}

.group_grid .empty_hint {
	margin: 0;
}

.group_card {
	padding: 12px 14px;
	border: 1px solid #333;
	border-radius: 12px;
	background-color: black;
}

.group_card h3 {
	margin: 0 0 8px;
	font-size: 1rem;
	color: var(--light-blue);
}

.group_card ol {
	margin: 0;
	padding-left: 1.4em;
	display: flex;
	flex-direction: column;
	gap: 4px;
	overflow-wrap: anywhere;
}

/* ---- Live match (Home) ---- */

.match_meta {
	color: #aaa;
	font-size: 0.95rem;
}

.vote_buttons {
	margin-top: 12px;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
	gap: 12px;
}

.vote_button {
	min-height: 96px;
	padding: 16px;
	font-family: inherit;
	font-size: 1.2rem;
	font-weight: bold;
	color: white;
	overflow-wrap: anywhere;
	border: 2px solid #444;
	border-radius: 16px;
	background-color: black;
	cursor: pointer;
}

.vote_button:hover,
.vote_button:focus-visible {
	border-color: var(--light-blue);
}

.vote_button[aria-pressed="true"] {
	color: black;
	border-color: var(--light-blue);
	background-color: var(--light-blue);
}


/* ---- Groups view ---- */

.wide_view {
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-width: 1200px;
}

.group_tables {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
	gap: 16px;
}

.group_panel h2 {
	color: var(--light-blue);
}

.group_table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}

.group_table th,
.group_table td {
	padding: 6px 4px;
	border-bottom: 1px solid #222;
}

.group_table th {
	color: #aaa;
	font-weight: normal;
	text-align: right;
}

.group_table th:nth-child(2),
.group_table .team_cell {
	text-align: left;
}

.group_table .num {
	text-align: right;
	white-space: nowrap;
}

.group_table .team_cell {
	overflow-wrap: anywhere;
}

.group_table .points {
	font-weight: bold;
	color: var(--light-blue);
}

.group_matches {
	list-style: none;
	margin: 12px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 0.9rem;
}

.group_matches li {
	display: grid;
	grid-template-columns: 2.2em 1fr auto 1fr;
	gap: 8px;
	align-items: baseline;
	color: #aaa;
}

.group_matches .match_team {
	overflow-wrap: anywhere;
}

.group_matches .match_team:last-child {
	text-align: right;
}

.group_matches .match_score {
	white-space: nowrap;
}

.group_matches .match_finished {
	color: white;
}

.group_matches .match_live .match_score {
	color: var(--light-blue);
	font-weight: bold;
}

/* phones: the vote-for/against columns are already left out; tighten the rest */
@media (max-width: 480px) {
	.group_table {
		font-size: 0.85rem;
	}
}

/* ---- Control: live match ---- */

#control_live {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
}

/* Control: more room between "x of y matches played" and the match below */
.played_count {
	/* full width, for the bar below the line */
	align-self: stretch;
	margin-bottom: 14px;
}

.played_line {
	display: grid;
	justify-content: start; /* keep the columns together on the left */
	grid-template-columns: auto auto auto auto;
	column-gap: 12px;
	row-gap: 2px;
	align-items: baseline;
	font-variant-numeric: tabular-nums;
}

/* the progress bar under the line, across the whole width */
.played_bar {
	margin-top: 6px;
}

.played_numbers,
.played_percent {
	text-align: right;
}

.played_percent {
	color: white;
}

/* Control: Start and End have the same size, so nothing shifts between them
   (the danger button's 1px border is matched by a transparent one on Start) */
.match_button {
	min-width: 120px;
	margin-bottom: 10px; /* room before the LIVE/NEXT line */
	border: 1px solid transparent;
}

.danger_button.match_button {
	border-color: #ff6b6b;
}

/* Control: LIVE badge, match and timer in one line */
.control_live_head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 10px;
}

/* NEXT and LIVE badges on Control: same size, so the match beside them
   doesn't move when it starts (NEXT a quiet grey pill, LIVE the red one) */
.control_badge {
	box-sizing: border-box;
	min-width: 4.2em;
	padding: 2px 10px;
	text-align: center;
	font-weight: bold;
	border: 1px solid transparent;
	border-radius: 999px;
}

.next_badge {
	border-color: #555;
}

/* Control: the last finished match, above the reopen button */
.control_last_result {
	align-self: stretch;
	margin-top: 10px;
	padding-top: 12px;
	border-top: 1px solid #333;
}

.control_last_result .label {
	color: #aaa;
	font-weight: bold;
}

.control_live_head .live_timer {
	font-size: 0.95rem;
}

.live_badge {
	padding: 2px 10px;
	font-weight: bold;
	color: black;
	border-radius: 999px;
	background-color: #ff6b6b;
}

.versus {
	font-size: 1.15rem;
	font-weight: bold;
	overflow-wrap: anywhere;
}

/* Control's live and next match: each team on its own line, "vs" small in between */
.versus.stacked {
	margin-top: 8px; /* room below the NEXT/LIVE line with the match info */
}

.versus.stacked .vs {
	margin: 2px 0;
	font-size: 0.8rem;
	font-weight: normal;
	color: #777;
}

.vote_log {
	align-self: stretch;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.vote_events {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 320px;
	overflow-y: auto;
	border: 1px solid #222;
	border-radius: 12px;
}

.vote_event {
	display: grid;
	grid-template-columns: auto 1fr auto;
	gap: 12px;
	padding: 8px 12px;
	border-bottom: 1px solid #222;
}

.vote_event:last-child {
	border-bottom: none;
}

.event_time {
	color: #aaa;
	font-variant-numeric: tabular-nums;
}

.event_user {
	overflow-wrap: anywhere;
}

/* the vote of each user that currently counts */
.vote_event.counts {
	background-color: rgba(74, 183, 221, 0.15);
	box-shadow: inset 3px 0 0 var(--light-blue);
}

.vote_event.counts .event_user,
.vote_event.counts .event_action {
	color: var(--light-blue);
	font-weight: bold;
}

/* votes that were retracted later, and the retractions themselves */
.vote_event.cast:not(.counts) {
	color: #888;
}

.vote_event.retracted .event_action {
	color: #ff6b6b;
}

.vote_events .empty_hint {
	padding: 8px 12px;
}

/* ---- Log view ---- */

#view_log {
	max-width: 900px;
}

.log_list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.log_entry {
	padding: 10px 14px;
	border: 1px solid #333;
	border-left: 3px solid #555;
	border-radius: 12px;
	background-color: #111;
}

.log_header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 12px;
	font-size: 0.9rem;
}

.log_action {
	font-weight: bold;
	color: var(--light-blue);
}

.log_user {
	color: white;
}

.log_filter {
	max-width: 280px;
}

.log_filters {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.log_filters[hidden] {
	display: none;
}

.log_filters .log_filter {
	flex: 1 1 200px;
}

.log_filter input[type="datetime-local"] {
	padding: 10px 12px;
	font-family: inherit;
	font-size: 1rem;
	color: white;
	color-scheme: dark;
	border: 1px solid #444;
	border-radius: 12px;
	background-color: black;
}

/* user activity is quieter than admin actions */
.log_login .log_action,
.log_logout .log_action,
.log_vote_cast .log_action,
.log_vote_changed .log_action,
.log_vote_retracted .log_action {
	color: #aaa;
}

.log_login_failed,
.log_login_locked {
	border-left-color: #ffb74d;
}

.log_login_failed .log_action,
.log_login_locked .log_action {
	color: #ffb74d;
}

.locked_badge {
	padding: 2px 10px;
	font-size: 0.85rem;
	color: black;
	border-radius: 999px;
	background-color: #ffb74d;
}

.log_time {
	margin-left: auto;
	color: #888;
	font-variant-numeric: tabular-nums;
}

.log_details {
	margin-top: 4px;
	color: #ccc;
	overflow-wrap: anywhere;
}

/* removals stand out */
.log_user_removed,
.log_tournament_removed,
.log_tournament_reset,
.log_backup_restored,
.log_backup_deleted {
	border-left-color: #ff6b6b;
}

.log_user_removed .log_action,
.log_tournament_removed .log_action,
.log_tournament_reset .log_action,
.log_backup_restored .log_action,
.log_backup_deleted .log_action {
	color: #ff6b6b;
}

#log_more_button {
	align-self: flex-start;
}

/* ---- Setup: resets ---- */

.reset_box {
	margin-top: 8px;
	padding-top: 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	border-top: 1px solid #333;
}

.reset_box[hidden] {
	display: none;
}

.podium_box {
	margin-top: 8px;
	padding-top: 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	border-top: 1px solid #333;
}

.podium_box h3 {
	margin: 0;
	font-size: 1rem;
}

.podium_box .hint {
	margin: 0;
}

.reset_box h3 {
	margin: 0;
	font-size: 1rem;
	color: #ff6b6b;
}

.reset_option {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 12px;
}

.reset_option .danger_button {
	flex: 0 0 auto;
	min-width: 230px;
}

.reset_option .hint {
	flex: 1 1 220px;
	font-size: 0.9rem;
}

@media (max-width: 480px) {
	.reset_option .danger_button {
		flex: 1 1 100%;
	}
}

/* ---- Teams view ---- */

.team_table_box {
	max-width: 900px;
	overflow-x: auto;
}

/* the team number and group columns are narrow; the name takes the rest */
.team_table td:nth-child(3),
.team_table th:nth-child(3) {
	text-align: center;
}

/* ---- Settings view ---- */

.setting_item {
	align-items: flex-start;
}

.setting_info {
	flex: 1 1 260px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.setting_label {
	font-weight: bold;
}

.setting_form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.setting_form input[type="number"],
.setting_form input[type="text"] {
	width: 160px;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 1rem;
	color: white;
	border: 1px solid #444;
	border-radius: 10px;
	background-color: black;
}

.setting_form input[type="checkbox"] {
	width: 24px;
	height: 24px;
}

/* automatic mode: countdown until the live match ends */
/* Control: how long the live match has been live */
.live_timer {
	font-size: 1.1rem;
	font-weight: bold;
	font-variant-numeric: tabular-nums;
}

.countdown {
	margin-top: 12px;
	padding: 8px 14px;
	font-weight: bold;
	color: black;
	border-radius: 12px;
	background-color: #ffd54f;
	font-variant-numeric: tabular-nums;
}

#control_live .countdown {
	margin-top: 0;
}

#backup_button {
	align-self: flex-start;
}

/* total of counting votes in the live match (never per team) */
.vote_total {
	margin-top: 6px;
	color: var(--light-blue);
	font-weight: bold;
}

/* a match an admin reopened: no countdown, an admin ends it */
.reopened_note {
	margin-top: 8px;
	padding: 8px 14px;
	color: black;
	border-radius: 12px;
	background-color: #ffb74d;
}

#control_live .reopened_note {
	margin-top: 0;
}

/* ---- My votes view ---- */

#myvotes_summary[hidden] {
	display: none;
}

.myvotes_headline {
	font-weight: bold;
	font-size: 1.1rem;
}

.myvotes_stats {
	display: grid;
	grid-template-columns: auto auto 1fr;
	column-gap: 12px;
	row-gap: 2px;
	font-variant-numeric: tabular-nums;
}

.myvotes_stat_label {
	color: #aaa;
}

.myvotes_stat_value,
.myvotes_stat_share {
	text-align: right;
}

.myvotes_stat_share {
	justify-self: start;
	min-width: 3.5em;
	color: #aaa;
}

.myvote {
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
}

.myvote_head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 4px 12px;
	font-size: 0.9rem;
	color: #aaa;
}

.myvote_outcome {
	font-weight: bold;
	color: white;
}

.myvote.won .myvote_outcome { color: #7bd88f; }
.myvote.lost .myvote_outcome { color: #ff6b6b; }
.myvote.not_voted { opacity: 0.6; }

.myvote_teams {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.myvote_team {
	display: grid;
	grid-template-columns: 2em 1fr;
	gap: 8px;
	color: #ccc;
}

.myvote_team.picked {
	color: var(--light-blue);
	font-weight: bold;
}

.myvote_count {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.myvote_name {
	overflow-wrap: anywhere;
}

/* navigation icons: follow the text color, so the active item's icon is blue too */
.nav_icon {
	flex: none;
	width: 24px;
	height: 24px;
}

/* Teams table: sortable column headers (look like headers, work like buttons) */
.team_table .sort_button,
.match_table .sort_button {
	padding: 0;
	font: inherit;
	color: inherit;
	text-align: inherit;
	border: none;
	background: none;
	cursor: pointer;
	white-space: nowrap;
}

.team_table .sort_button:hover,
.team_table .sort_button:focus-visible,
.team_table .sort_button.active,
.match_table .sort_button:hover,
.match_table .sort_button:focus-visible,
.match_table .sort_button.active {
	color: var(--light-blue);
}

.team_table .sort_arrow,
.match_table .sort_arrow {
	margin-left: 3px;
	font-size: 0.7em;
}

/* home: the next match while nothing is live */
.up_next {
	margin-top: 8px;
	padding: 10px 14px;
	border: 1px solid #333;
	border-radius: 12px;
	background-color: black;
}

.up_next .label {
	color: #aaa;
	font-size: 0.85rem;
}

.up_next_teams {
	margin: 10px 0 4px;
	font-weight: bold;
	overflow-wrap: anywhere;
}

.up_next_teams .vs {
	margin: 2px 0;
	font-size: 0.8rem;
	font-weight: normal;
	color: #777;
}

/* Groups: the group with the live match, its two teams and the match */
.group_panel.has_live {
	border-color: var(--light-blue);
	box-shadow: 0 0 0 1px var(--light-blue);
}

.group_live_badge {
	margin-left: 10px;
	font-size: 0.75rem;
	vertical-align: middle;
}

.group_table tr.live_team td {
	background-color: rgba(74, 183, 221, 0.15);
}

.group_table tr.live_team .team_cell {
	color: var(--light-blue);
	font-weight: bold;
}

.group_matches .match_live {
	color: white;
	font-weight: bold;
}

/* live box: one vote icon per expected player, blue for each counting vote */
.vote_dots {
	margin-top: 8px;
	display: flex;
	flex-wrap: wrap;
	justify-content: center; /* centred over the vote buttons */
	gap: 4px;
}

.vote_dot {
	width: 24px;
	height: 24px;
	color: #555;
	transition: color 0.2s;
}

.vote_dot.cast {
	color: var(--light-blue);
}

/* a vote (or retraction) on its way: pulses until the server confirms; only
   then is the button solid blue (or back to normal) */
.vote_button.sending {
	border-color: var(--light-blue);
	animation: vote_sending 0.7s ease-in-out infinite alternate;
}

.vote_button[aria-pressed="true"].sending {
	color: white;
	background-color: rgba(74, 183, 221, 0.35);
}

@keyframes vote_sending {
	from { box-shadow: 0 0 0 0 rgba(74, 183, 221, 0.7); }
	to { box-shadow: 0 0 0 7px rgba(74, 183, 221, 0); }
}

@media (prefers-reduced-motion: reduce) {
	.vote_button.sending {
		animation: none;
		box-shadow: 0 0 0 3px rgba(74, 183, 221, 0.5);
	}
}

/* Teams: team names open the team's matches */
.team_table .team_link {
	padding: 0;
	font: inherit;
	color: inherit;
	text-align: left;
	border: none;
	background: none;
	cursor: pointer;
	overflow-wrap: anywhere;
}

.team_table .team_link:hover,
.team_table .team_link:focus-visible {
	color: var(--light-blue);
	text-decoration: underline;
}

/* the pop-up with a team's matches */
.team_dialog {
	width: min(560px, calc(100vw - 24px));
	max-height: min(80vh, 720px);
	padding: 0;
	color: white;
	border: 1px solid #333;
	border-radius: 16px;
	background-color: #111;
}

.team_dialog::backdrop {
	background-color: rgba(0, 0, 0, 0.7);
}

.team_dialog_head {
	position: sticky;
	top: 0;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 12px;
	padding: 16px 16px 12px;
	border-bottom: 1px solid #333;
	background-color: #111;
}

/* a team's explanation (from Setup); line breaks are kept */
.team_dialog_description {
	margin: 10px 0 0;
	white-space: pre-line;
	overflow-wrap: anywhere;
	color: #ddd;
}

.team_dialog_head h2 {
	margin: 0 0 4px;
	font-size: 1.2rem;
	overflow-wrap: anywhere;
}

/* the tournament pop-ups: creating one, and the actions for one (team pop-up's frame) */
.dialog_form,
.dialog_body {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
}

.dialog_form .primary_button {
	align-self: flex-start;
}

.team_matches {
	list-style: none;
	margin: 0;
	padding: 8px 16px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

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

.team_match_outcome {
	font-weight: bold;
	white-space: nowrap;
}

.team_match.won .team_match_outcome { color: #7bd88f; }
.team_match.lost .team_match_outcome { color: #ff6b6b; }
.team_match.live .team_match_outcome { color: var(--light-blue); }
.team_match.upcoming { opacity: 0.6; }

.team_match_opponent {
	overflow-wrap: anywhere;
}

/* Champions: one card per tournament with its podium */
.champions_card {
	flex-direction: column;
	align-items: stretch;
	gap: 10px;
}

.podium {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.podium li {
	display: flex;
	align-items: baseline;
	gap: 10px;
}

.podium_medal {
	flex: none;
	width: 1.6em;
	text-align: center;
}

.podium_team {
	overflow-wrap: anywhere;
}

.podium .first .podium_team {
	font-size: 1.15rem;
	font-weight: bold;
	color: var(--light-blue);
}

.podium .undecided .podium_team {
	color: #888;
	font-style: italic;
}

/* Matches: every match of the current tournament as a table, in playing order */
.match_table_box {
	max-width: 900px;
	overflow-x: auto;
}

.match_table th:nth-child(2),
.match_table td:nth-child(2) {
	text-align: left;
	white-space: nowrap;
}

/* team numbers: A right-aligned towards the score, B left-aligned away from it */
.match_table .team_a {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.match_table .team_b {
	text-align: left;
	font-variant-numeric: tabular-nums;
}

/* a row opens/closes the line with the team names below it */
/* they work like buttons, so a (double) tap doesn't select their text */
.match_table tr.match_row,
.match_table tr.match_detail {
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
}

.match_table tr.match_row:hover td {
	background-color: #1a1a1a;
}

.match_table tr.match_row:focus-visible {
	outline: 2px solid var(--light-blue);
	outline-offset: -2px;
}

/* an open row and its names line share a slightly lighter background */
.match_table tr.match_row[aria-expanded="true"] td {
	/* thin blue line between the match and its names */
	border-bottom-color: rgba(74, 183, 221, 0.6);
	background-color: #1b1f24;
}

.match_table tr.match_detail td {
	background-color: #1b1f24;
	padding: 18px 4px 16px;
	line-height: 1.4;
	text-align: center;
	color: #ccc;
	overflow-wrap: anywhere;
}

/* each team on its own line, "vs" small in between */
.match_table tr.match_detail span {
	display: block;
}

.match_table tr.match_detail .match_detail_vs {
	margin: 6px 0;
	font-size: 0.8rem;
	color: #777;
}

.match_table th.score,
.match_table td.score {
	text-align: center;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.match_table .winner {
	font-weight: bold;
	color: var(--light-blue);
}

.match_table .time {
	font-variant-numeric: tabular-nums;
}

.match_table tr.upcoming td {
	color: #777;
}

.match_table tr.live td {
	background-color: rgba(74, 183, 221, 0.15);
}

.match_table tr.live .score,
.match_table tr.live .time {
	font-weight: bold;
	color: var(--light-blue);
}

/* Statistics: one panel per phase, side by side where there is room */
.stats_grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
	gap: 16px;
}

.stats_grid h2 {
	margin: 0;
	color: var(--light-blue);
}

.stats_list {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.stats_list dt {
	color: #aaa;
	font-size: 0.95rem;
}

.stats_list dd {
	margin: 2px 0 0;
}

.stats_value {
	font-size: 1.3rem;
	font-weight: bold;
	font-variant-numeric: tabular-nums;
}

.stats_detail {
	display: block;
	color: #aaa;
	font-size: 0.9rem;
	overflow-wrap: anywhere;
}

/* a view's heading with a button on the right (e.g. Elimination → big screen) */
.view_head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 8px 16px;
}

.view_head h1 {
	margin: 0;
}

a.secondary_button {
	display: inline-block;
	text-decoration: none;
}

/* Elimination: tabs for the bracket and the round */
.round_tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.round_tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	font: inherit;
	color: white;
	border: 1px solid #444;
	border-radius: 999px;
	background: none;
	cursor: pointer;
}

.round_tab:hover {
	background-color: #222;
}

.round_tab:focus-visible {
	outline: 2px solid var(--light-blue);
	outline-offset: 1px;
}

.round_tab.selected {
	color: black;
	font-weight: bold;
	border-color: var(--light-blue);
	background-color: var(--light-blue);
}

/* the round (or bracket) where a match is live */
.round_tab_live {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background-color: #ff6b6b;
}

.bracket_round_title {
	color: var(--light-blue);
	font-weight: bold;
}

/* a match card: head line, then one line per team */
.bracket_card {
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
}

.bracket_card.live {
	border-color: var(--light-blue);
}

.bracket_card.upcoming .bracket_team {
	color: #bbb;
}

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

.bracket_team {
	display: grid;
	grid-template-columns: 2.2em 1fr auto 1.2em;
	align-items: baseline;
	gap: 8px;
}

.bracket_team_number {
	color: #888;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.bracket_team_name {
	overflow-wrap: anywhere;
}

.bracket_team_name.from {
	color: #888;
	font-style: italic;
}

.bracket_team_votes {
	font-weight: bold;
	font-variant-numeric: tabular-nums;
}

.bracket_team.won .bracket_team_name,
.bracket_team_check {
	font-weight: bold;
	color: #7bd88f;
}

.bracket_team.lost {
	opacity: 0.6;
}

/* ---- Home: tournament progress, live match header, last result ---- */

.progress_box {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.progress_text {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 2px 12px;
	color: #aaa;
	font-size: 0.95rem;
}

.progress_text strong {
	color: white;
}

.progress_bar {
	height: 6px;
	border-radius: 999px;
	background-color: #222;
	overflow: hidden;
}

.progress_bar span {
	display: block;
	height: 100%;
	border-radius: inherit;
	background-color: var(--light-blue);
}

/* LIVE badge, round and timer in one line */
.live_head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 12px;
}

.live_head .live_timer {
	margin-left: auto;
	font-size: 1rem;
	color: #aaa;
}

.live_badge.pulse {
	animation: live_pulse 1.6s ease-in-out infinite;
}

@keyframes live_pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.6); }
	50% { box-shadow: 0 0 0 6px rgba(255, 107, 107, 0); }
}

@media (prefers-reduced-motion: reduce) {
	.live_badge.pulse {
		animation: none;
	}
}

/* the two teams, large, with "VS" between them */
.versus_big {
	margin: 18px 0 14px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	text-align: center;
}

.versus_big .team {
	font-size: 1.5rem;
	font-weight: bold;
	overflow-wrap: anywhere;
}

.versus_big .vs {
	font-size: 0.85rem;
	font-weight: bold;
	letter-spacing: 0.1em;
	color: var(--light-blue);
}

/* last result as a small scoreboard */
.scoreboard {
	margin-top: 10px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.score_row {
	display: grid;
	grid-template-columns: 1fr auto 1.2em;
	align-items: baseline;
	gap: 10px;
	font-size: 1.15rem;
}

.score_row .name {
	overflow-wrap: anywhere;
}

.score_row .votes {
	font-weight: bold;
	font-variant-numeric: tabular-nums;
}

.score_row.won .name,
.score_row .check {
	font-weight: bold;
	color: #7bd88f;
}

.score_row.lost {
	opacity: 0.6;
}

/* how the votes were split: team A's share on the left, team B's on the right;
   the winner's share green, the loser's grey, a tie blue (empty if no votes) */
.split_bar {
	margin-top: 4px;
	height: 8px;
	display: flex;
	border-radius: 999px;
	background-color: #333;
	overflow: hidden;
}

.split_bar span.won {
	background-color: #7bd88f;
}

.split_bar span.lost {
	background-color: #555;
}

.split_bar span.tie {
	background-color: var(--light-blue);
}

/* a thin gap between the two shares */
.split_bar span + span {
	border-left: 2px solid #111;
}

.score_note {
	color: #aaa;
	font-size: 0.9rem;
}

/* Statistics: group balance table (group name left, numbers right) */
.balance_table th:first-child {
	text-align: left;
}

.balance_table th:nth-child(2) {
	text-align: right;
}
