/* ===== Simple dark theme for /server UI ===== */

/* Theme tokens */
:root {
	--bg: #06070a;
	--card: #0b1118;
	--card-2: #0a0f16;
	--muted: #8b94a5;
	--line: #1b2432;
	--line-2: #141d29;
	--panel: #0b1118;
	--panel-line: #1b2432;
	--text: #e6edf6;
	--text-soft: #b6c0cf;
	--brand: #2f7cf6;
	--brand-2: #1f5ccc;
	--accent: #10b981;
	--danger: #ef4444;
	--shadow: 0 14px 36px rgba(0,0,0,.55);
	--radius: 12px;
	--font-sans: "Manrope", "Segoe UI", sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Layout */
html, body { height: 100%; }
/* Override global stable gutter to avoid reserved horizontal space on this page */
html { scrollbar-gutter: auto; }
body { background: var(--bg); color: var(--text); font-family: var(--font-sans); }
#app { display: flex; flex-direction: row; height: 100vh; }

.panel {
	width: 360px;
	padding: 14px 14px 18px;
	background: var(--panel);
	border-right: 1px solid var(--panel-line);
	display: flex; flex-direction: column; gap: .4rem;
	position: relative; z-index: 2200;
	transition: transform .25s ease-in-out; will-change: transform; overflow: hidden;
}
.panel::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(255,255,255,.03), transparent 35%);
	pointer-events: none;
	opacity: .6;
}
.panel > * { position: relative; z-index: 1; }
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:.5rem; padding-bottom:.35rem; border-bottom:1px solid var(--panel-line); }
.panel-head h2 { margin:0; font-size:1.02rem; letter-spacing:.08em; text-transform: uppercase; font-weight: 600; }
.panel-head-actions { display:flex; gap:.5rem; align-items:center }

button.small { font-size:.7rem; padding:.28rem .6rem; border-radius:8px; background:#0e141d; color:var(--text); border:1px solid var(--line); cursor:pointer }
button.small:hover { background:#111826; }
button.full-width { width:100%; }

.hint { font-size:.72rem; opacity:.8; }
.status { display:inline-block; margin-top:.25rem; font-size:.65rem; background: #0a1118; padding:2px 8px; border:1px solid var(--panel-line); border-radius:999px; color: var(--text-soft); }

.stats-summary {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: .55rem .65rem;
	margin: .25rem 0 .9rem;
	background: var(--card-2);
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: .65rem .75rem .7rem;
}
.stats-summary.hidden { display: none; }
.stats-summary[hidden] { display: none !important; }
.stats-summary .summary-grid { display: contents; }
.stats-summary .summary-item { display: flex; flex-direction: column; gap: .18rem; }
.stats-summary .summary-item.summary-wide { grid-column: 1 / -1; }
.stats-summary .summary-label {
	font-size: .68rem;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--text-soft);
}
.stats-summary .summary-value { font-size: 1rem; font-weight: 600; color: var(--text); }
.stats-summary.dimmed .summary-value { color: var(--muted); }
.stats-summary .summary-value time,
.stats-summary time.summary-value { font-style: normal; }
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.panel-footer { margin-top:auto; padding-top:.6rem; display:flex; flex-direction:column; gap:.5rem; }
.with-footer { margin-bottom:.75rem; }

.searchbar { position:sticky; top:0; z-index:2; background:transparent; padding-bottom:.5rem; }
.searchbar input { width:100%; padding:.6rem .7rem; background:#0a1118; color:var(--text); border:1px solid var(--line); border-radius:10px; font-size:.92rem; outline:none }
.searchbar input:focus { border-color:rgba(47,124,246,.8); box-shadow:0 0 0 3px rgba(47,124,246,.18) }
.searchbar .search-actions { margin-top:.45rem; display:flex; gap:.45rem; }

/* Active filters badge */
#filtersCount.count-badge {
	display: inline-block;
	min-width: 16px;
	padding: 0 6px;
	margin-left: 6px;
	font-size: 12px;
	line-height: 18px;
	text-align: center;
	color: #fff;
	background: #e04848;
	border-radius: 10px;
}
#filtersCount.hidden { display: none; }

/* Highlight Filters button when filters are active */
#filtersOpenBtn.active {
	background: #f59e0b;
	border-color: #f59e0b;
	color: #111827;
}
#filtersOpenBtn.active:hover {
	background: #fbbf24;
	border-color: #fbbf24;
}

/* Smoothly transition Filters button color when filters toggle */
#filtersOpenBtn {
	transition: background-color 600ms ease, border-color 600ms ease, color 600ms ease;
}
@media (prefers-reduced-motion: reduce) {
	#filtersOpenBtn { transition: none; }
}

/* Filters bar */
.filters { margin-top:.45rem; display:flex; flex-direction:column; gap:.45rem; }
.filters .row { display:flex; gap:.5rem; flex-wrap:wrap; }
.filters .section { border:1px solid var(--line); border-radius:10px; padding:.75rem; background:#0a1118; }
.filters .section-title { font-size:.82rem; color:#9aa4b2; margin-bottom:.5rem; letter-spacing:.02em; }
.filters .chips { display:flex; flex-wrap:wrap; gap:.5rem; }
.filters .grid { display:grid; gap:.5rem; }
.filters .grid.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 520px) { .filters .grid.grid-2 { grid-template-columns: 1fr; } }
.filters .inline { color:var(--text-soft); font-size:.8rem; display:flex; flex-direction:column; align-items:flex-start; gap:.3rem; width:100% }

.filters .inline{ position: relative; }
/* Select wrapper for consistent, centered custom chevron */
.filters .select-wrap{ position:relative; display:block; width:100%; }
/* Disable wrapper overlay */
.filters .select-wrap::before,
.filters .select-wrap::after{ display:none; }

.filters select {
	width:100%; min-height:36px;
	background:#0a1118; color:var(--text); border:1px solid var(--line); border-radius:8px; padding:.4rem .65rem; background-clip:border-box;
	color-scheme: dark; accent-color: var(--brand);
	outline: none; overflow:hidden; position:relative; z-index:0; line-height:1.2;
	appearance:none !important; -webkit-appearance:none !important; -moz-appearance:none !important;
	background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 8l5 5 5-5' stroke='%23cfd3da' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat:no-repeat; background-position:right .55rem center; background-size:14px; padding-right:2rem;
}
.filters select:hover,
.filters select:focus {
	background-color:#0a1118; outline:none;
	border-color:#26344a;
}
select::-ms-expand{display:none}
.filters select:focus { outline:2px solid rgba(47,124,246,.35); outline-offset:1px; border-color:#33507d; box-shadow:0 0 0 2px rgba(47,124,246,.12) inset; }
.filters .chip input { vertical-align:middle }
.filters .chip { display:inline-flex; align-items:center; gap:.35rem; background:#0a1118; border:1px solid var(--line); color:var(--text); padding:.25rem .55rem; border-radius:999px; font-size:.78rem; cursor:pointer; user-select:none }
.filters .chip input { accent-color: var(--brand); }

#lobbyList { list-style:none; padding:0; margin:.55rem 0; flex:1 1 auto; min-height:0; overflow-y:auto; overflow-x:hidden; width:100%; }

/* Custom scrollbar */
#lobbyList::-webkit-scrollbar { width: 10px; }
#lobbyList::-webkit-scrollbar-thumb { background:#1f2b41; border-radius:10px; border:2px solid #0b1220; }
#lobbyList::-webkit-scrollbar-track { background: transparent; }

/* Lobby item card */
.lobby-item {
	background: #0b1118;
	padding:.65rem .75rem .75rem; margin-bottom:8px;
	border:1px solid var(--line); border-radius:12px; font-size:.8rem;
	display:flex; flex-direction:column; position:relative; width:100%; min-width:0;
	transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
	box-shadow: 0 0 0 rgba(0,0,0,0);
}
.lobby-item:hover { transform: translateY(-1px); border-color:#2a3950; box-shadow:0 6px 18px rgba(0,0,0,.35); }
.lobby-item.active { border-color: var(--brand); box-shadow:0 0 0 2px rgba(47,124,246,.22) inset; background: #0c1420; }
.lobby-item.highlight { animation:pulse 1s ease; }
@keyframes pulse { 0% { box-shadow:0 0 0 0 rgba(47,124,246,.5); } 70% { box-shadow:0 0 0 12px rgba(47,124,246,0); } 100% { box-shadow:0 0 0 0 rgba(47,124,246,0); } }
.lobby-item .summary { display:flex; flex-direction:column; gap:6px; cursor:pointer; user-select:none; -webkit-user-select:none; min-width:0; }
.lobby-item .top { display:flex; justify-content:space-between; font-weight:600; letter-spacing:.01em; min-width:0; }
.lobby-item .meta { display:flex; align-items:center; gap:8px; opacity:.85; font-family: var(--font-mono); font-size:.78rem; min-width:0; }
.lobby-item .meta .addr { flex:0 0 auto; white-space:nowrap; color: var(--text-soft) }
.lobby-item .meta .region { flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:right; color: var(--text-soft) }

/* Pack the shield and players together on the right to prevent overlap */
.lobby-item .top .right-pack { display:inline-flex; align-items:center; gap:10px; }
.lobby-item .top .right-pack .players { display:inline-block; }

.lobby-item .details { margin-top:.55rem; padding:.55rem .6rem .6rem; background:#0a1118; border:1px solid #142033; border-radius:10px; font-size:.75rem; line-height:1.35; user-select:text; -webkit-user-select:text; }
.lobby-item .details.hidden { display:none; }
.lobby-item .details .row { display:flex; gap:.45rem; margin-bottom:6px; }
.lobby-item .details .row:last-child { margin-bottom:0; }
.lobby-item .details .label { width:74px; opacity:.7; text-align:right; }
.lobby-item .details .val { flex:1; word-break:break-word; color: var(--text); }
.lobby-item .details .row-pastebin .val { display:flex; flex-direction:column; }
.lobby-item .details .pastebin-preview-btn { background: #111b33; border:1px solid #1b2840; color: var(--text); border-radius:8px; padding:.25rem .6rem; font-weight:600; cursor:pointer; text-align:left; }
.lobby-item .details .pastebin-preview-btn:hover { filter:brightness(1.05); }
.lobby-item .details .pastebin-preview-btn:disabled { opacity:.6; cursor:default; }
.lobby-item .details .pastebin-id-btn { font-family: var(--font-mono); font-size:.72rem; }
.lobby-item .details .row-pastebin-preview .label { align-self:flex-start; }
.lobby-item .details .pastebin-preview {
	margin: 0;
	padding: .45rem .5rem;
	background: rgba(255,255,255,0.04);
	border: 1px solid #1b2840;
	border-radius: 6px;
	font-family: var(--font-mono);
	font-size: .72rem;
	line-height: 1.35;
	max-height: 140px;
	overflow: auto;
	white-space: pre-wrap;
}
.hidden { display: none !important; }

/* Pastebin preview modal */
.pastebin-dialog { width: min(92vw, 980px); }
.pastebin-dialog .pastebin-preview {
	width: 100%;
	height: min(65vh, 520px);
	border: 1px solid #1b2840;
	border-radius: 8px;
	background: #0b1020;
	padding: .6rem .7rem;
	white-space: pre-wrap;
	overflow: auto;
}
.pastebin-dialog .pastebin-preview a { color: #9cc3ff; text-decoration: underline; }
.pastebin-dialog .pastebin-preview a.tm-link-disabled { opacity: .65; pointer-events: none; text-decoration: none; }
.pastebin-dialog .pastebin-preview .tm-align { display: block; }
.pastebin-dialog .pastebin-preview .tm-align-center { text-align: center; }
.pastebin-dialog .pastebin-preview .tm-align-right { text-align: right; }
.pastebin-dialog .pastebin-preview .tm-align-justified { text-align: justify; }
.pastebin-dialog .pastebin-preview .tm-page-break { display: block; margin: 10px 0; border-top: 1px solid #1b2840; }
/* Actions area inside details */
.lobby-item .details .actions { margin-top:.55rem; display:flex; justify-content:center; align-items:center; }
.lobby-item .details .actions .join-btn { margin: 0 auto; }
.lobby-item .details .actions .join-btn { background: var(--brand); border:1px solid var(--brand-2); color:#fff; border-radius:8px; padding:.4rem .7rem; font-weight:600; cursor:pointer }
.lobby-item .details .actions .join-btn:hover { filter:brightness(1.05); }

/* Official badge (white shield) */
.lobby-item > .badge-official {
	position: absolute;
	top: 8px;
	right: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	border-radius: 6px;
	background: rgba(255,255,255,0.1);
	color: #fff;
	border: 1px solid rgba(255,255,255,0.35);
	box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
@media (max-width: 520px) {
	.lobby-item > .badge-official { top: 6px; right: 6px; width: 18px; height: 18px; }
}
/* Inline badge style when packed next to players */
.lobby-item .right-pack .badge-official {
	position: static;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: #fff;
	box-shadow: none;
}
.lobby-item .right-pack .badge-official svg { width: 20px; height: 20px; }

/* Map panel */
#map { flex:1; position:relative; }
.leaflet-container { background:#000; }
.map-overlay { position:absolute; top:14px; left:50%; transform:translateX(-50%); z-index:10000; display:none; pointer-events:none; }
.map-overlay button { background:#0a1118; border:1px solid var(--panel-line); color:var(--text); pointer-events:auto; padding:.55rem .9rem; border-radius:999px; box-shadow: var(--shadow); }

/* Statistics modal */
.stats-overlay { position:fixed; inset:0; background:rgba(2,6,14,.75); display:flex; align-items:flex-start; justify-content:center; padding:5vh 2vw; z-index:5000; }
.stats-overlay.hidden { display:none; }
.stats-overlay#joinOverlay { align-items: center; }
.stats-dialog { background: var(--card); border:1px solid var(--line-2); border-radius:14px; width:min(860px,100%); max-height:92vh; display:flex; flex-direction:column; padding:1rem; box-shadow:0 22px 60px rgba(0,0,0,.65); }
.stats-head { display:flex; justify-content:space-between; gap:.75rem; align-items:center; margin-bottom:.75rem; flex-wrap:wrap; }
.stats-head select { background:#0a1118; color:var(--text); border:1px solid var(--line); border-radius:8px; padding:.25rem .4rem; }
.stats-table-wrap { overflow:auto; flex:1; border:1px solid var(--line-2); border-radius:10px; background:#0b1020; }
.stats-table { width:100%; border-collapse:collapse; font-size:.78rem; }
.stats-table th, .stats-table td { text-align:right; padding:6px 8px; border-bottom:1px solid #0f1628; }
.stats-table th { position:sticky; top:0; background:#0f1628; }
.stats-table th:first-child, .stats-table td:first-child { text-align:left; }
.stats-table tbody tr:hover { background:#0d1527; }
.stats-footer { margin-top:.7rem; font-size:.68rem; opacity:.78; }
.stat-info { position:relative; display:inline-flex; align-items:center; justify-content:center; margin-left:4px; width:16px; height:16px; font-size:11px; line-height:1; border:1px solid var(--line); background:#182235; color:var(--text-soft); border-radius:50%; cursor:pointer; padding:0; }
.stats-table th .stat-info:first-child { margin-left:0; margin-right:4px; }
.stat-info:hover, .stat-info:focus { outline:none; background:#1f2e4a; color:#fff; border-color:#33507d; }

/* Floating tooltip portal variant */
.floating-tooltip { position:fixed; top:0; left:0; max-width:260px; font-size:11px; line-height:1.35; background:#ffffff; color:#111827; border:1px solid #d5dbe5; border-radius:8px; padding:7px 9px 8px; box-shadow:0 8px 28px rgba(0,0,0,.2), 0 2px 6px rgba(0,0,0,.15); pointer-events:none; font-weight:500; opacity:0; transform:scale(.98); transition:opacity .18s ease, transform .22s cubic-bezier(.4,.12,.2,1); will-change:opacity, transform; }
.floating-tooltip.show { opacity:1; transform:scale(1); }
.floating-tooltip.fading { opacity:0; transform:scale(.98); }
@media (prefers-color-scheme: dark) {
	.floating-tooltip { background:#0f172a; color:var(--text); border:1px solid #1d2a3f; box-shadow:0 10px 32px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4); }
}

/* When portal is present, hide pseudo tooltips (JS manages display) */
#tooltipPortal ~ .floating-tooltip, #tooltipPortal ~ .stats-overlay .stat-info[data-tooltip]::after, #tooltipPortal ~ .stats-overlay .stat-info[data-tooltip]::before { display:none !important; }
.stat-info:focus-visible { box-shadow:0 0 0 3px rgba(47,124,246,.4); }
.head-actions { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; }
.map-frozen #map { filter:brightness(.42) blur(1px); }
.map-frozen .leaflet-container { pointer-events:none !important; }

/* Welcome modal */
#welcomeOverlay { align-items: center; }

.welcome-dialog {
	background: var(--card);
	border: 1px solid var(--line-2);
	border-radius: 14px;
	width: min(520px, 94%);
	display: flex;
	flex-direction: column;
	padding: 1.2rem 1.1rem 1rem;
	box-shadow: 0 22px 70px rgba(0,0,0,.65);
}
.welcome-body { text-align:center; padding:0 .25rem; }
.welcome-body h3 { margin:.25rem 0 .7rem; font-size:1.25rem; letter-spacing:.02em; }
.welcome-text { color: var(--text-soft); font-size:.9rem; margin:.25rem 0 .65rem; }
.welcome-tips { text-align:left; margin:.2rem auto .4rem; padding-left:1.1rem; max-width: 38ch; color: var(--text-soft); font-size:.9rem; }
.welcome-tips li { margin:.25rem 0; }
.welcome-note { color:#9aa8bd; font-size:.82rem; opacity:.9; margin:.5rem 0 .2rem; }
.welcome-meta { margin-top:.4rem; font-size:.82rem; color: var(--text-soft); }
.welcome-meta a { color:#93c5fd; text-decoration:none; }
.welcome-meta a:hover { text-decoration:underline; }
.welcome-actions { display:flex; gap:.6rem; justify-content:center; align-items:center; margin-top:.6rem; }
.welcome-actions .primary { background: var(--brand); border:1px solid var(--brand-2); color:#fff; border-radius:10px; padding:.55rem .95rem; font-weight:700; min-width: 140px; }
.welcome-actions .primary:hover { filter: brightness(1.06); }
.welcome-actions .ghost { background: transparent; border:1px solid var(--line); color: var(--text-soft); border-radius:10px; padding:.55rem .95rem; font-weight:600; }
.welcome-actions .ghost:hover { background:#0e1628; color: var(--text); }

/* Join modal footer: center the primary action */
.join-footer { display:flex; justify-content:center; align-items:center; padding-top:.7rem; }
.join-footer .small {
	margin: 0 auto;
	min-width: 240px;
	padding: .7rem 1.1rem;
	font-size: .95rem;
	border-radius: 10px;
}
@media (max-width: 520px) {
	.join-footer .small { width: 100%; max-width: 100%; }
}
.join-footer .small { background: var(--brand); border:1px solid var(--brand-2); color:#fff; border-radius:10px; padding:.5rem .9rem; font-weight:700 }

/* Buttons */
.panel-footer button, .head-actions button { background: var(--brand); border:1px solid var(--brand-2); color:#fff; border-radius:10px; padding:.5rem .8rem; font-weight:600 }
.panel-footer button.small { font-weight:600 }
.panel-footer button:hover { filter: brightness(1.05); }
/* Make cancel in modal header red */
.head-actions .danger { background: var(--danger); border-color: #b91c1c; }
.head-actions .danger:hover { filter: brightness(1.05); }

/* Responsive */
@media (max-width: 980px) {
	#app { flex-direction: column; }
	.panel { width: 100%; border-right: none; border-bottom: 1px solid var(--panel-line); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); }
	#map { height: 100%; }
	.panel-hidden .map-overlay { display:block; }
}

/* Site footer disclaimer */
.site-footer {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 1800;
	padding: 6px 10px;
	text-align: center;
	font-size: 12px;
	color: #8f9bb0;
	background: rgba(6, 9, 14, 0.94);
	border-top: 1px solid var(--panel-line);
	backdrop-filter: blur(2px);
}

.panel {
	animation: panel-in 420ms cubic-bezier(.2,.7,.25,1);
}
@keyframes panel-in {
	0% { opacity: 0; transform: translateX(-10px); }
	100% { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
	.panel { animation: none; }
}
@media (max-width: 520px) {
	.site-footer { font-size: 11px; padding: 6px 8px; }
}

/* Hidden panel mode as bottom sheet on mobile */
.panel-hidden #app { position: relative; }
.panel-hidden .panel { position: absolute; top: 0; left: 0; bottom: 0; width: 360px; transform: translateX(-102%); z-index: 3000; }
.dock-bottom.panel-hidden .panel { position: absolute; left: 0; right: 0; bottom: 0; top: auto; width: auto; transform: translateY(102%); }
.panel-hidden .map-overlay { display: block; }
