/* General Mayhem — shared styles (login, menu, lobby, error pages) */

:root {
	--bg: #12150f;
	--bg-2: #1b2016;
	--panel: rgba(28, 33, 23, 0.94);
	--panel-edge: #4a5534;
	--panel-edge-light: #7d8a55;
	--text: #e8e6d6;
	--muted: #9aa086;
	--brass: #f5b81c;
	--brass-dark: #a86a00;
	--red: #d9381e;
	--red-dark: #8a1b0b;
	--green: #6fbf3b;
	--steel: #5f6f86;
	--danger: #e5533b;
	--radius: 4px;
	--font-head: Impact, Haettenschweiler, 'Arial Narrow Bold', 'Franklin Gothic Bold', sans-serif;
	--font-body: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--font-mono: 'Cascadia Mono', Consolas, 'Liberation Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	min-height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: 15px;
	line-height: 1.45;
}

a { color: var(--brass); }

[hidden] { display: none !important; }

/* Animated camo-ish backdrop built from gradients (no image assets needed). */
.backdrop {
	position: fixed;
	inset: 0;
	z-index: -1;
	background:
		radial-gradient(ellipse at 20% 15%, rgba(245, 184, 28, 0.10), transparent 45%),
		radial-gradient(ellipse at 85% 80%, rgba(217, 56, 30, 0.12), transparent 50%),
		repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 14px),
		linear-gradient(160deg, #1a2013 0%, #10130c 60%, #0b0d08 100%);
}

.backdrop::after {
	content: '';
	position: absolute;
	inset: 0;
	background:
		linear-gradient(transparent 0 97%, rgba(125, 138, 85, 0.07) 97% 100%) 0 0 / 100% 48px,
		linear-gradient(90deg, transparent 0 97%, rgba(125, 138, 85, 0.07) 97% 100%) 0 0 / 48px 100%;
}

/* ---------------------------------------------------------------- panels */

.panel {
	background: var(--panel);
	border: 2px solid var(--panel-edge);
	border-radius: var(--radius);
	box-shadow: 0 0 0 1px #0007, inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 12px 32px rgba(0, 0, 0, 0.45);
	padding: 18px 20px 20px;
	position: relative;
}

.panel-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: -18px -20px 16px;
	padding: 8px 16px;
	background:
		repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.25) 0 10px, transparent 10px 20px),
		linear-gradient(180deg, #3a4428, #2a3120);
	border-bottom: 2px solid var(--panel-edge);
}

.stencil {
	font-family: var(--font-head);
	text-transform: uppercase;
	letter-spacing: 3px;
	font-size: 18px;
	color: var(--brass);
	text-shadow: 2px 2px 0 #000;
}

.subhead {
	font-family: var(--font-head);
	text-transform: uppercase;
	letter-spacing: 2px;
	font-weight: normal;
	color: var(--muted);
	font-size: 14px;
	margin: 18px 0 8px;
}

.muted { color: var(--muted); }
.hint { color: var(--muted); font-style: italic; min-height: 1.4em; }
.fine-print { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }

.tip {
	color: var(--muted);
	font-size: 13px;
	font-style: italic;
	border-left: 3px solid var(--brass-dark);
	padding-left: 10px;
	margin-top: 18px;
}

/* ---------------------------------------------------------------- forms */

.form-stack { display: flex; flex-direction: column; gap: 14px; }

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

.field span {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 1.5px;
	color: var(--muted);
}

input[type='text'], input[type='password'], .select {
	background: #0d100a;
	border: 1px solid var(--panel-edge);
	border-radius: var(--radius);
	color: var(--text);
	padding: 10px 12px;
	font-size: 15px;
	font-family: inherit;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

input[type='text']:focus, input[type='password']:focus, .select:focus {
	border-color: var(--brass);
	box-shadow: 0 0 0 2px rgba(245, 184, 28, 0.25);
}

.select { padding: 6px 8px; font-size: 14px; cursor: pointer; }
.select:disabled { opacity: 0.75; cursor: default; }

.form-error {
	color: #ffb4a3;
	background: rgba(217, 56, 30, 0.15);
	border: 1px solid rgba(217, 56, 30, 0.5);
	padding: 8px 12px;
	border-radius: var(--radius);
	margin: 0;
}

/* ---------------------------------------------------------------- buttons */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-family: var(--font-head);
	text-transform: uppercase;
	letter-spacing: 2px;
	font-size: 16px;
	padding: 10px 18px;
	border-radius: var(--radius);
	border: 2px solid #000;
	cursor: pointer;
	text-decoration: none;
	color: #1a1205;
	transition: transform 0.05s, filter 0.15s, box-shadow 0.15s;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 3px 0 #000;
	user-select: none;
}

.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #000; }
.btn:disabled { filter: grayscale(0.8) brightness(0.7); cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.btn-primary { background: linear-gradient(180deg, #ffd768, var(--brass) 55%, #c98b06); }
.btn-secondary { background: linear-gradient(180deg, #a3b07a, #6f7c48 60%, #56613a); color: #0f130a; }
.btn-danger { background: linear-gradient(180deg, #ff7a5c, var(--red) 60%, var(--red-dark)); color: #fff3ec; }
.btn-ghost { background: linear-gradient(180deg, #3a4130, #262b1f); color: var(--text); border-color: #000; }
.btn-large { font-size: 20px; padding: 14px 22px; }
.btn-small { font-size: 13px; padding: 5px 10px; letter-spacing: 1px; }
.btn-icon { font-family: var(--font-body); font-size: 0.95em; }

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

/* ---------------------------------------------------------------- top bar */

.topbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 24px;
	background: linear-gradient(180deg, rgba(36, 42, 28, 0.95), rgba(20, 24, 15, 0.95));
	border-bottom: 2px solid var(--panel-edge);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.topbar-logo img { height: 46px; display: block; }

.topbar-user { display: flex; align-items: center; gap: 12px; }

.rank-badge {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, #ffe28a, var(--brass) 60%, var(--brass-dark));
	color: #5a3a00;
	border: 2px solid #000;
	font-size: 15px;
}

/* ---------------------------------------------------------------- login */

.login-shell {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 32px 16px;
	gap: 22px;
}

.login-brand { text-align: center; }
.logo-large { width: min(520px, 90vw); filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6)); }
.logo-medium { width: min(360px, 80vw); }
.tagline { color: var(--muted); margin: 6px 0 0; font-size: 16px; }
.tagline em { color: var(--brass); font-style: normal; }
.login-panel { width: min(420px, 100%); }
.login-panel .button-row .btn { flex: 1; }
.login-footer { color: var(--muted); font-size: 13px; letter-spacing: 1px; }

/* ---------------------------------------------------------------- menu */

.menu-shell {
	max-width: 1080px;
	margin: 40px auto;
	padding: 0 20px;
	display: grid;
	grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
	gap: 24px;
	align-items: start;
}

.menu-actions { display: flex; flex-direction: column; gap: 14px; }
.menu-actions .btn-large { justify-content: flex-start; }

.join-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px;
	background: rgba(0, 0, 0, 0.25);
	border: 1px dashed var(--panel-edge-light);
	border-radius: var(--radius);
}

.join-form input { font-family: var(--font-mono); font-size: 14px; }

.rejoin-box {
	margin-bottom: 16px;
	padding: 12px 14px;
	border: 1px solid var(--brass-dark);
	background: rgba(245, 184, 28, 0.08);
	border-radius: var(--radius);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.rejoin-box p { margin: 0; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.stat {
	background: rgba(0, 0, 0, 0.3);
	border: 1px solid var(--panel-edge);
	border-radius: var(--radius);
	padding: 10px;
	text-align: center;
	display: flex;
	flex-direction: column;
}

.stat-value { font-family: var(--font-head); font-size: 28px; color: var(--brass); letter-spacing: 1px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }

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

.recent-list li {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	padding: 7px 10px;
	background: rgba(0, 0, 0, 0.25);
	border-left: 3px solid var(--panel-edge);
	font-size: 13.5px;
}

.recent-list li.win { border-left-color: var(--green); }
.recent-list li.loss { border-left-color: var(--red); }
.outcome-tag { font-family: var(--font-head); letter-spacing: 1px; text-transform: uppercase; }
.outcome-tag.win { color: var(--green); }
.outcome-tag.loss { color: #ff8c75; }

/* ---------------------------------------------------------------- lobby */

.lobby-shell {
	max-width: 1220px;
	margin: 28px auto;
	padding: 0 20px;
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: 22px;
	align-items: start;
}

.lobby-side { display: flex; flex-direction: column; gap: 22px; }

.conn-status { font-size: 12px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.conn-status.online { color: var(--green); }
.conn-status.offline { color: #ff8c75; }

.invite-box {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 14px;
	margin-bottom: 18px;
	background: rgba(0, 0, 0, 0.35);
	border: 1px dashed var(--brass-dark);
	border-radius: var(--radius);
}

.invite-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 4px; }
.invite-code { font-family: var(--font-mono); font-size: 17px; color: var(--brass); word-break: break-all; user-select: all; }

.slot-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.slot-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-weight: normal; padding: 0 10px; }
.slot-table td { background: rgba(0, 0, 0, 0.3); padding: 10px; vertical-align: middle; }
.slot-table td:first-child { border-radius: var(--radius) 0 0 var(--radius); border-left: 6px solid var(--slot-color, #555); }
.slot-table td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.slot-table tr.is-me td { background: rgba(245, 184, 28, 0.08); }
.slot-table tr.empty td { opacity: 0.65; }

.slot-number { font-family: var(--font-head); font-size: 20px; color: var(--slot-color, #ccc); text-shadow: 1px 1px 0 #000; }
.slot-color-name { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.commander-name { font-weight: 600; }
.host-tag { margin-left: 6px; font-size: 11px; background: var(--brass); color: #1a1205; border-radius: 3px; padding: 1px 6px; font-weight: 700; letter-spacing: 1px; }
.offline-tag { margin-left: 6px; font-size: 11px; color: #ff8c75; }
.status-ready { color: var(--green); font-weight: 700; letter-spacing: 1px; }
.status-waiting { color: var(--muted); }
.faction-title { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.lobby-buttons { justify-content: flex-end; margin-top: 10px; }

#map-select { width: 100%; margin-bottom: 12px; }

#map-preview {
	width: 100%;
	aspect-ratio: 1;
	image-rendering: pixelated;
	border: 2px solid #000;
	border-radius: var(--radius);
	background: #0b0d08;
}

.chat-log {
	list-style: none;
	margin: 0 0 10px;
	padding: 8px;
	height: 190px;
	overflow-y: auto;
	background: rgba(0, 0, 0, 0.35);
	border-radius: var(--radius);
	font-size: 13.5px;
}

.chat-log li { margin-bottom: 4px; word-wrap: break-word; }
.chat-log .from { color: var(--brass); font-weight: 600; }
.chat-log .system { color: var(--muted); font-style: italic; }

.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; padding: 6px 10px; font-size: 14px; }

/* ---------------------------------------------------------------- error page */

.error-shell {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 22px;
	padding: 20px;
}

.error-panel { max-width: 520px; width: 100%; }

/* ---------------------------------------------------------------- toast */

.toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	background: #262d1c;
	border: 2px solid var(--brass);
	color: var(--text);
	padding: 10px 18px;
	border-radius: var(--radius);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
	z-index: 1000;
	animation: toast-in 0.2s ease-out;
}

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (max-width: 860px) {
	.menu-shell, .lobby-shell { grid-template-columns: 1fr; }
	.slot-table th:nth-child(4), .slot-table td:nth-child(4) { display: none; }
}
