:root {
	color-scheme: dark;
}

body {
	margin: 0;
	font: 14px/1.4 system-ui, sans-serif;
	background: #0a0a0a;
	color: #e5e5e5;
}

header,
main {
	max-width: 1100px;
	margin: 0 auto;
	padding: 16px;
}

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

select,
button,
.button {
	background: #111;
	color: #e5e5e5;
	border: 1px solid #333;
	border-radius: 12px;
	padding: 8px 12px;
	text-decoration: none;
	cursor: pointer;
}

button[disabled] {
	opacity: .6;
	cursor: not-allowed;
}

.panel {
	background: #0f0f0f;
	border: 1px solid #222;
	border-radius: 16px;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.panel>h2 {
	margin: 0 0 8px 0;
	font-size: 16px;
}

.panel--warning {
	background: #3b2b0a;
	border-color: #5b451a;
}

video {
	width: 100%;
	border-radius: 12px;
	background: #000;
	aspect-ratio: 16/9;
}

ol.results {
	list-style: none;
	padding: 0;
	margin: 0;
	display: grid;
	gap: 6px;
}

ol.results li {
	display: flex;
	gap: 8px;
	align-items: center;
	background: #141414;
	border: 1px solid #242424;
	border-radius: 12px;
	padding: 8px 10px;
}

.mono {
	font-variant-numeric: tabular-nums;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.muted {
	color: #9aa0a6;
}

p {
	margin: 0 0 8px 0;
}

/* Welcome / empty state */
.welcome {
	display: grid;
	gap: 14px;
	align-items: start;
	grid-template-columns: 1.1fr .9fr;
}

.welcome>div {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.welcome h1 {
	font-size: 22px;
	margin: 0;
}

.welcome h3 {
	font-size: 16px;
	margin: 0;
}

.welcome .lead {
	color: #cfcfcf;
	font-size: 16px;
	font-weight: bold;
	margin: 4px 0 10px 0;
}

.welcome .steps {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 8px;
}

.welcome .steps li {
	background: #111;
	border: 1px solid #222;
	border-radius: 12px;
	padding: 8px 10px;
}

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

.welcome .chip {
	font-size: 12px;
	background: #1f2937;
	border: 1px solid #2b3647;
	padding: 4px 8px;
	border-radius: 999px;
	color: #c9d1d9;
}

.welcome .aside {
	background: #0f0f0f;
	border: 1px solid #1f1f1f;
	border-radius: 14px;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.welcome .aside ul {
	margin: 0;
	padding-left: 18px;
	color: #9aa0a6;
}

.welcome .cta {
	display: flex;
	gap: 10px;
	align-items: center;
}

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 8px;
}

.icon-btn:hover {
	filter: brightness(1.12);
}

/* Buttons: semantic variants */
.btn--primary {
	background: #0f3a15;
	border-color: #1f5e2a;
	color: #eaffea;
}

.btn--primary:hover {
	filter: brightness(1.12);
}

.btn--danger {
	background: #3b0a0a;
	border-color: #5a1a1a;
	color: #ffd7d7;
}

.btn--danger:hover {
	filter: brightness(1.12);
}

/* Utility */
.spacer {
	flex: 10 0 0;
}

/* Main view */
.main-view {
	flex: 1 1 640px;
	min-width: 360px;
}

#camera {
	max-width: 240px;
}

.capture-view {
	flex: 1 1 320px;
	min-width: 320px;
}

/* Scoreboard */
table.score th,
table.score td {
	border: 1px solid #242424;
	padding: 6px 8px;
	text-align: center;
}

table.score thead th {
	background: #141414;
	position: sticky;
	top: 0;
}

table.score .team-icon {
	font-size: 22px;
}

table.score .player {
	text-align: left;
}

table.score .place {
	color: #7388c7;
}

table.score .place-1 {
	color: #f5c542;
}

table.score .place-2 {
	color: #b8c2cc;
}

table.score .place-3 {
	color: #b56b2c;
}

table.score tbody tr:nth-child(2n) {
	background: #33333320;
}

table.score tbody:not(.team-mode) tr:nth-child(n+7) td {
	background: #80000020;
}

table.score tbody td.rank-1 {
	background: #f5c54220;
}

table.score tbody td.rank-2 {
	background: #b8c2cc20;
}

table.score tbody td.rank-3 {
	background: #b56b2c20;
}

.gallery a {
	display: block;
	background: #141414;
	border: 1px solid #242424;
	border-radius: 12px;
	overflow: hidden;
	text-decoration: none;
	color: inherit;
}

.gallery img {
	width: 100%;
	display: block;
	aspect-ratio: 16/9;
	object-fit: cover;
}

.gallery .cap {
	padding: 6px 8px;
	font-size: 12px;
	color: #9aa0a6;
}

/* Modal */
dialog {
	border: none;
	border-radius: 16px;
	padding: 0;
	background: #101010;
	color: #e5e5e5;
}

dialog::backdrop {
	background: rgba(0, 0, 0, .6);
}

.modal {
	padding: 16px;
	min-width: 520px;
}

.modal>h3 {
	margin: 0 0 12px 0;
	font-size: 16px;
}

.grid {
	display: grid;
	gap: 8px;
	grid-template-columns: 80px 1fr 200px;
	align-items: center;
}

.modal footer {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 12px;
}

.badge {
	background: #1f2937;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 12px;
}

textarea {
	width: 100%;
	min-height: 150px;
	box-sizing: border-box;
	background: #0b0b0b;
	color: #e5e5e5;
	border: 1px solid #222;
	border-radius: 8px;
	padding: 8px;
	resize: none;
}

/* Edit roster dialog */
.editroster-container {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.editroster-container:has(>.grid:only-child) {
	grid-template-columns: 1fr;
}

.editroster-container>.grid {
	border: 1px solid #22222280;
	border-radius: 8px;
	padding: 4px;
}

.editroster-container>.grid:only-child {
	border: 0;
	padding: 0;
}

/* Edit race dialog */
.editrace-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.editrace-list label {
	display: flex;
	gap: 8px;
	align-items: center;
	cursor: pointer;
	background: #1f1f1f;
	border: 1px solid #2b2b2b;
	border-radius: 8px;
	padding: 4px;
}

.editrace-list label:has(input:checked) {
	background: #0e1a2a;
	outline: 2px solid #2a3a55;
}

.editrace-list label .place {
	font-size: 12px;
	background: #1f2937;
	border: 1px solid #2b3647;
	padding: 4px 8px;
	border-radius: 999px;
	color: #c9d1d9;
}

.race-screenshot img {
	width: 100%;
	height: auto;
	max-height: 80vh;
	object-fit: contain;
	border-radius: 8px;
	border: 1px solid #333;
}

/* Export scores dialog */
.export-format-toggle {
	display: flex;
	margin-bottom: 8px;
	align-items: center;
}

.export-format-toggle label {
	background: #111;
	color: #e5e5e5;
	border: 1px solid #333;
	border-left-width: 0;
	padding: 8px 12px;
	cursor: pointer;
}

.export-format-toggle label:has(input:checked) {
	background: #0e1a2a;
	border-color: #2a3a55;
}

.export-format-toggle input {
	display: none;
}

.export-format-toggle label:first-of-type {
	border-top-left-radius: 12px;
	border-bottom-left-radius: 12px;
	border-left-width: 1px;
	margin-left: 8px;
}

.export-format-toggle label:last-of-type {
	border-top-right-radius: 12px;
	border-bottom-right-radius: 12px;
}

/* Toasts */
.toasts[popover] {
	position: fixed;
	inset: unset;
	bottom: 0;
	left: 0;
	margin: 12px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	border: 0;
	background: transparent;
	padding: 16px 0 0;
	z-index: auto;
}

.toast {
	min-width: 260px;
	max-width: 380px;
	background: #111;
	border: 1px solid #222;
	color: #e5e5e5;
	padding: 10px 12px;
	border-radius: 12px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
	display: flex;
	align-items: flex-start;
	gap: 10px;
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity .2s ease, transform .2s ease;
}

.toasts:popover-open .toast {
	opacity: 1;
	transform: translateY(0);
}

.toast .msg {
	flex: 1 1 auto;
}

.toast--info {
	background: #0e1a2a;
	border-color: #2a3a55;
}

.toast--success {
	background: #0f3a15;
	border-color: #1f5e2a;
}

.toast--warning {
	background: #3a340f;
	border-color: #5e5a1f;
}

.toast--error {
	background: #3b0a0a;
	border-color: #5a1a1a;
}