/* =====================================================================
   Konami Tournament Pairings
   Konami brand palette: KONAMI red on white, with black and neutral grays.
   ===================================================================== */

:root {
	--konami-red: #e60012;
	--konami-red-dark: #b8000e;
	--konami-red-tint: #fdecee;
	--black: #111111;
	--charcoal: #222222;
	--gray-700: #444444;
	--gray-500: #767676;
	--gray-300: #cfcfcf;
	--gray-200: #e5e5e5;
	--gray-100: #f4f4f4;
	--white: #ffffff;

	--warning-bg: #fff6e0;
	--warning-border: #f0b429;
	--success-bg: #eaf7ee;
	--success-border: #2f9e55;
	--info-bg: #eef4fb;
	--info-border: #4a7fc1;

	--radius: 6px;
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
	--font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
	--container: 1120px;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--gray-100);
	color: var(--charcoal);
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.5;
}

img {
	max-width: 100%;
	height: auto;
}

a {
	color: var(--konami-red);
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

a:hover {
	color: var(--konami-red-dark);
}

h1, h2, h3, h4 {
	color: var(--black);
	line-height: 1.25;
	margin: 0 0 0.6em;
}

h1 {
	font-size: 1.75rem;
	font-weight: 700;
	padding-bottom: 0.35em;
	border-bottom: 3px solid var(--konami-red);
	display: inline-block;
}

h2 {
	font-size: 1.3rem;
}

h3 {
	font-size: 1.1rem;
}

code {
	font-family: Consolas, "Courier New", monospace;
	background: var(--gray-100);
	padding: 0.1em 0.35em;
	border-radius: 3px;
}

.container {
	max-width: var(--container);
	margin: 0 auto;
	padding: 0 16px;
}

.muted {
	color: var(--gray-500);
}

.preserve-lines {
	white-space: pre-line;
}

.break-all {
	word-break: break-all;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.required {
	color: var(--konami-red);
}

/* ---------------------------------------------------------------------
   Site layout
   --------------------------------------------------------------------- */

.site {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.site-main {
	flex: 1;
	padding: 28px 0 40px;
}

/* Utility bar: white with the red KONAMI wordmark, like konami.com */
.utility-bar {
	background: var(--white);
	border-bottom: 4px solid var(--konami-red);
}

.utility-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 48px;
}

.konami-logo {
	display: inline-flex;
	align-items: center;
}

.konami-logo img {
	display: block;
}

.account-links {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: flex-end;
	font-size: 0.9rem;
}

.account-links .username {
	color: var(--black);
	font-weight: 600;
}

.inline-form {
	display: inline;
	margin: 0;
}

/* Brand bar: TCG logo and app name */
.brand-bar {
	background: var(--white);
}

.brand-inner {
	padding-top: 12px;
	padding-bottom: 12px;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 18px;
	color: var(--black);
	text-decoration: none;
}

.brand:hover {
	color: var(--black);
}

.tcg-logo {
	width: 200px;
	height: auto;
	display: block;
}

.brand-title {
	font-size: 1.6rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	border-left: 3px solid var(--konami-red);
	padding-left: 18px;
}

/* Main navigation: black bar, red active indicator */
.main-nav {
	background: var(--black);
}

.main-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
}

.main-nav a {
	display: block;
	padding: 14px 20px 11px;
	color: var(--white);
	font-weight: 600;
	text-decoration: none;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 0.85rem;
	border-bottom: 3px solid transparent;
}

.main-nav a:hover {
	background: var(--charcoal);
	color: var(--white);
}

.main-nav a.active {
	border-bottom-color: var(--konami-red);
	background: var(--charcoal);
}

/* Admin section menu */
.admin-menu {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 24px;
	padding: 6px;
	background: var(--white);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.admin-menu a {
	padding: 8px 14px;
	border-radius: 4px;
	color: var(--charcoal);
	font-weight: 600;
	text-decoration: none;
	font-size: 0.9rem;
}

.admin-menu a:hover {
	background: var(--gray-100);
	color: var(--black);
}

.admin-menu a.active {
	background: var(--konami-red);
	color: var(--white);
}

/* Footer */
.site-footer {
	background: var(--black);
	color: #a9a9a9;
	font-size: 0.82rem;
	padding: 22px 0;
	border-top: 4px solid var(--konami-red);
}

.footer-links {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 22px;
	margin-bottom: 10px;
}

.footer-links a {
	color: var(--white);
	font-weight: 600;
	text-decoration: none;
}

.footer-links a:hover {
	color: var(--white);
	text-decoration: underline;
}

.copyright {
	margin: 0;
}

/* ---------------------------------------------------------------------
   Cards, tables
   --------------------------------------------------------------------- */

.card {
	background: var(--white);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	margin-bottom: 24px;
	overflow: hidden;
}

.card.highlight {
	outline: 2px solid var(--konami-red);
}

.card-header {
	margin: 0;
	padding: 12px 16px;
	background: var(--black);
	color: var(--white);
	font-size: 1.02rem;
	font-weight: 600;
	border-left: 5px solid var(--konami-red);
	border-bottom: none;
	display: block;
}

.card-subheader {
	margin: 0;
	padding: 10px 16px;
	background: var(--gray-100);
	border-top: 1px solid var(--gray-200);
	border-bottom: 1px solid var(--gray-200);
	font-size: 0.95rem;
}

.card-body {
	padding: 14px 16px;
	margin: 0;
}

.card > p.card-body + .table-scroll,
.card > .card-body + .table-scroll {
	border-top: 1px solid var(--gray-200);
}

.two-column {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
	gap: 0 24px;
	align-items: start;
}

.table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

table {
	border-collapse: collapse;
	width: 100%;
}

/* Label / value tables */
table.details th,
table.details td {
	padding: 10px 16px;
	border-bottom: 1px solid var(--gray-200);
	vertical-align: top;
	text-align: left;
}

table.details th {
	width: 34%;
	min-width: 140px;
	background: var(--gray-100);
	color: var(--gray-700);
	font-weight: 600;
}

table.details th label {
	font-weight: 600;
}

/* List tables */
table.grid th,
table.grid td {
	padding: 10px 14px;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var(--gray-200);
}

table.grid thead th {
	background: var(--charcoal);
	color: var(--white);
	font-size: 0.8rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
}

table.grid tbody tr:nth-child(even) {
	background: #fafafa;
}

table.grid tbody tr:hover {
	background: var(--konami-red-tint);
}

table.grid tr.current-round {
	background: var(--konami-red-tint);
	font-weight: 600;
}

table.grid tr.row-flagged td:first-child {
	box-shadow: inset 4px 0 0 var(--konami-red);
}

table.grid td.actions a + a {
	margin-left: 12px;
}

table[data-sortable] thead th {
	cursor: pointer;
	user-select: none;
}

table[data-sortable] thead th[aria-sort="ascending"]::after {
	content: " \25B2";
	color: var(--konami-red);
}

table[data-sortable] thead th[aria-sort="descending"]::after {
	content: " \25BC";
	color: var(--konami-red);
}

.select-col {
	width: 44px;
	text-align: center !important;
}

/* Admin stats */
.stat-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat {
	padding: 18px 16px;
	border-right: 1px solid var(--gray-200);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.stat:last-child {
	border-right: none;
}

.stat-value {
	font-size: 1.8rem;
	font-weight: 700;
	color: var(--konami-red);
}

.stat-label {
	color: var(--gray-500);
	font-size: 0.85rem;
}

/* Pager */
.pager {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 14px 16px;
	border-top: 1px solid var(--gray-200);
}

.pager a,
.pager span {
	min-width: 36px;
	padding: 6px 10px;
	text-align: center;
	border-radius: 4px;
	text-decoration: none;
	color: var(--charcoal);
	border: 1px solid var(--gray-300);
}

.pager a:hover {
	border-color: var(--konami-red);
	color: var(--konami-red);
}

.pager .current {
	background: var(--konami-red);
	border-color: var(--konami-red);
	color: var(--white);
	font-weight: 600;
}

.pager .ellipsis {
	border: none;
}

/* ---------------------------------------------------------------------
   Forms and buttons
   --------------------------------------------------------------------- */

label {
	font-weight: 600;
	color: var(--charcoal);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
	font: inherit;
	color: var(--charcoal);
	background: var(--white);
	border: 1px solid var(--gray-300);
	border-radius: 4px;
	padding: 8px 10px;
	width: 100%;
	max-width: 360px;
}

input.wide,
textarea.wide,
select.wide {
	max-width: 100%;
}

input.narrow {
	max-width: 120px;
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--konami-red);
	box-shadow: 0 0 0 3px rgba(230, 0, 18, 0.15);
}

input[type="checkbox"] {
	width: 18px;
	height: 18px;
	accent-color: var(--konami-red);
	vertical-align: middle;
}

input[type="file"] {
	font: inherit;
	max-width: 100%;
}

input.invalid,
.invalid input {
	border-color: var(--konami-red);
}

label.checkbox {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 18px;
	border-radius: 4px;
	border: 1px solid transparent;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-small {
	padding: 6px 12px;
	font-size: 0.85rem;
}

.btn-primary {
	background: var(--konami-red);
	color: var(--white);
}

.btn-primary:hover {
	background: var(--konami-red-dark);
	color: var(--white);
}

.btn-secondary {
	background: var(--white);
	border-color: var(--gray-300);
	color: var(--charcoal);
}

.btn-secondary:hover {
	border-color: var(--charcoal);
	color: var(--black);
}

.btn-danger {
	background: var(--white);
	border-color: var(--konami-red);
	color: var(--konami-red);
}

.btn-danger:hover {
	background: var(--konami-red);
	color: var(--white);
}

.btn-ghost {
	background: transparent;
	color: var(--charcoal);
	border-color: var(--gray-300);
}

.btn-ghost:hover {
	border-color: var(--charcoal);
	color: var(--black);
}

.form-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 14px 16px;
	background: var(--gray-100);
	border-top: 1px solid var(--gray-200);
}

.button-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
}

.card-body.button-row {
	margin-top: 0;
}

.inline-options {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin: 0 0 12px;
}

.upload-form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	padding: 14px;
	border: 2px dashed var(--gray-300);
	border-radius: var(--radius);
	background: #fcfcfc;
}

.search-form .field-grid,
.stacked-form .field-grid {
	padding: 14px 16px 0;
}

.field-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 0 20px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	margin-bottom: 14px;
}

.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select {
	max-width: 100%;
}

.field-help {
	font-size: 0.82rem;
}

.stacked-form fieldset {
	border: none;
	margin: 0 0 18px;
	padding: 0;
}

.stacked-form legend {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--black);
	padding: 0 0 4px;
	margin-bottom: 6px;
	border-bottom: 2px solid var(--konami-red);
}

.stacked-form .field-grid {
	padding: 0;
}

.form-buttons {
	margin-top: 16px;
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.validation-summary,
.validation-errors {
	color: var(--konami-red-dark);
	background: var(--konami-red-tint);
	border-left: 4px solid var(--konami-red);
	border-radius: 4px;
	padding: 10px 14px 10px 32px;
	margin: 0 0 16px;
}

.validation-message,
.field-error {
	color: var(--konami-red-dark);
	font-size: 0.85rem;
	font-weight: 600;
}

/* ---------------------------------------------------------------------
   Alerts
   --------------------------------------------------------------------- */

.alert {
	border-radius: 4px;
	padding: 12px 16px;
	margin: 0 0 18px;
	border-left: 4px solid;
}

ul.alert {
	list-style: none;
}

ul.alert li + li {
	margin-top: 4px;
}

.alert-error {
	background: var(--konami-red-tint);
	border-color: var(--konami-red);
	color: #7a0009;
}

.alert-error p {
	margin: 4px 0 0;
}

.alert-warning {
	background: var(--warning-bg);
	border-color: var(--warning-border);
	color: #5c4400;
}

.alert-success {
	background: var(--success-bg);
	border-color: var(--success-border);
	color: #1d5e33;
}

.alert-info {
	background: var(--info-bg);
	border-color: var(--info-border);
	color: #24456e;
}

.error-detail {
	white-space: pre-wrap;
	font-size: 0.8rem;
	max-height: 360px;
	overflow: auto;
	background: var(--white);
	padding: 10px;
	border-radius: 4px;
	margin: 8px 0 0;
}

code.password {
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--black);
}

/* ---------------------------------------------------------------------
   Home and account pages
   --------------------------------------------------------------------- */

.hero {
	background: var(--white);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 32px;
	border-top: 5px solid var(--konami-red);
}

.hero h1 {
	border-bottom: none;
	padding-bottom: 0;
	font-size: 1.6rem;
}

.hero p {
	font-size: 1.05rem;
	max-width: 720px;
}

.hero-actions {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	margin-top: 20px;
}

.auth-layout {
	display: flex;
	justify-content: center;
}

.auth-card {
	width: 100%;
	max-width: 460px;
}

.auth-layout.wide .auth-card {
	max-width: 860px;
}

.auth-card .card-header {
	font-size: 1.15rem;
}

.auth-switch {
	margin: 18px 0 0;
	padding-top: 14px;
	border-top: 1px solid var(--gray-200);
}

/* ---------------------------------------------------------------------
   Player Pairings page (mobile first)
   --------------------------------------------------------------------- */

.player-site {
	background: var(--gray-100);
}

.player-header {
	background: var(--white);
	border-bottom: 4px solid var(--konami-red);
	text-align: center;
	padding: 12px 16px 10px;
}

.player-konami {
	display: block;
	margin: 0 auto 8px;
}

.player-tcg {
	display: block;
	margin: 0 auto;
	width: 180px;
}

.player-title {
	font-size: 1.15rem;
	margin: 6px 0 0;
	border-bottom: none;
	padding-bottom: 0;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.player-main {
	padding: 18px 0 32px;
}

.player-main > * {
	max-width: 720px;
	margin-left: auto;
	margin-right: auto;
	padding-left: 12px;
	padding-right: 12px;
}

.player-content {
	padding: 0 12px;
}

.tournament-name {
	text-align: center;
	font-size: 1.2rem;
}

.lookup-form {
	background: var(--white);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
	margin-bottom: 20px;
}

.lookup-form label {
	display: block;
	margin-bottom: 6px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	font-size: 0.85rem;
}

.lookup-row {
	display: flex;
	gap: 8px;
}

.lookup-row input {
	flex: 1;
	max-width: none !important;
	font-size: 1.15rem !important;
	padding: 10px 12px !important;
}

.lookup-row .btn {
	padding-left: 20px;
	padding-right: 20px;
}

.player-messages {
	list-style: none;
	padding: 0;
	margin: 0 0 18px;
}

.player-messages li {
	background: var(--white);
	border-left: 4px solid var(--konami-red);
	border-radius: 4px;
	padding: 10px 14px;
	margin-bottom: 8px;
	box-shadow: var(--shadow);
}

.player-messages p {
	margin: 4px 0 0;
}

.feedback-link {
	text-align: center;
	margin: 0 0 18px;
	font-weight: 600;
}

.pairings-table td:nth-child(1),
.pairings-table td:nth-child(2) {
	white-space: nowrap;
}

/* ---------------------------------------------------------------------
   QR sign (printable)
   --------------------------------------------------------------------- */

.qr-sheet {
	text-align: center;
	font-family: var(--font);
	padding: 32px 16px;
	font-size: 1.5rem;
	background: var(--white);
	min-height: 100vh;
}

.qr-sheet h1 {
	font-size: 2.6rem;
	display: block;
	border-bottom: none;
	color: var(--konami-red);
}

.qr-url {
	font-family: Verdana, Tahoma, sans-serif;
	font-weight: 700;
	word-break: break-all;
}

@media print {
	.qr-sheet {
		padding: 0;
	}
}

/* ---------------------------------------------------------------------
   Upload "processing" overlay (app.js)
   --------------------------------------------------------------------- */

.processing-overlay {
	position: fixed;
	inset: 0;
	background: rgba(17, 17, 17, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: 16px;
}

.processing-box {
	background: var(--white);
	border-top: 5px solid var(--konami-red);
	border-radius: var(--radius);
	padding: 24px 28px;
	max-width: 420px;
	text-align: center;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.processing-box h2 {
	margin-bottom: 8px;
}

.spinner {
	width: 38px;
	height: 38px;
	border: 4px solid var(--gray-200);
	border-top-color: var(--konami-red);
	border-radius: 50%;
	margin: 0 auto 14px;
	animation: spin 0.9s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---------------------------------------------------------------------
   Small screens
   --------------------------------------------------------------------- */

@media (max-width: 640px) {
	.brand {
		gap: 12px;
	}

	.tcg-logo {
		width: 130px;
	}

	.brand-title {
		font-size: 1.15rem;
		padding-left: 12px;
	}

	.main-nav a {
		padding: 12px 14px 9px;
	}

	h1 {
		font-size: 1.4rem;
	}

	.hero {
		padding: 22px 18px;
	}

	table.details th {
		width: 42%;
		min-width: 0;
	}

	.stat {
		border-right: none;
		border-bottom: 1px solid var(--gray-200);
	}
}
