/* SphereSB layout tokens */
:root {
	--spheresb-safe-top: env(safe-area-inset-top, 0px);
	--spheresb-safe-right: env(safe-area-inset-right, 0px);
	--spheresb-safe-bottom: env(safe-area-inset-bottom, 0px);
	--spheresb-safe-left: env(safe-area-inset-left, 0px);
	--spheresb-pad: 12px;
	--spheresb-dock-h: 112px;
	--spheresb-bottom-ui: calc(var(--spheresb-pad) + var(--spheresb-safe-bottom));
	--spheresb-ink: #f2ecff;
	--spheresb-muted: rgba(220, 208, 255, 0.72);
	--spheresb-panel: rgba(10, 6, 20, 0.92);
	--spheresb-line: rgba(255, 255, 255, 0.14);
	--spheresb-accent: #c4a4ff;
	--spheresb-font: "Manrope", "Segoe UI", sans-serif;
	--spheresb-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Hide Dynmap clock (top) and compass (top-right) */
.dynmap .largeclock,
.dynmap .clock,
.dynmap .digitalclock,
.dynmap .timeofday,
.dynmap .compass,
.dynmap .compass_N,
.dynmap .compass_E,
.dynmap .compass_S,
.dynmap .compass_W,
.dynmap .compass_NE,
.dynmap .compass_NW,
.dynmap .compass_SE,
.dynmap .compass_SW,
.dynmap .compass_flat,
.dynmap .mobilecompass {
	display: none !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

/* Hide Dynmap left sidebar (map types / players / layers) */
.dynmap .sidebar,
.dynmap .panel,
.dynmap .leaflet-control-layers {
	display: none !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

/* Hide Dynmap chat */
.dynmap .chatbox,
.dynmap .chat,
.dynmap.map-globe-active .chatpanel,
.dynmap .chatpanel,
.dynmap .chatballoon,
.dynmap .chatinput,
.dynmap .messagelist {
	display: none !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

/* Hide share / link button */
.dynmap .dynmap-link {
	display: none !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

/* Town search — flat + globe */
.spheresb-town-search {
	position: fixed;
	z-index: 1101;
	top: calc(var(--spheresb-pad) + var(--spheresb-safe-top));
	left: calc(var(--spheresb-pad) + var(--spheresb-safe-left));
	width: min(320px, calc(100vw - 24px));
	font: 13px/1.35 var(--spheresb-font);
	display: none;
}

.spheresb-town-search.is-visible {
	display: block;
}

.spheresb-town-search input {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(12, 8, 22, 0.9);
	color: #eee;
	outline: none;
	font-size: 16px;
	-webkit-tap-highlight-color: transparent;
}

.spheresb-town-search input:focus {
	border-color: rgba(255, 255, 255, 0.32);
}

.spheresb-town-results {
	margin-top: 4px;
	max-height: min(40vh, 280px);
	overflow: auto;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(12, 8, 22, 0.94);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
	display: none;
}

.spheresb-town-results.is-open {
	display: block;
}

.spheresb-town-results button {
	display: block;
	width: 100%;
	text-align: left;
	border: 0;
	margin: 0;
	padding: 12px 11px;
	background: transparent;
	color: #eee;
	cursor: pointer;
	font: inherit;
	-webkit-tap-highlight-color: transparent;
}

.spheresb-town-results button:hover,
.spheresb-town-results button:focus {
	background: rgba(255, 255, 255, 0.08);
}

.spheresb-town-results .spheresb-town-empty {
	padding: 9px 11px;
	color: rgba(255, 255, 255, 0.55);
	font-size: 12px;
}

/* Town/marker info panel — globe, top-left */
.spheresb-info-panel {
	position: fixed;
	z-index: 1100;
	top: calc(var(--spheresb-pad) + var(--spheresb-safe-top));
	left: calc(var(--spheresb-pad) + var(--spheresb-safe-left));
	right: auto;
	width: min(320px, calc(100vw - 24px));
	min-height: 48px;
	max-height: min(42vh, 360px);
	overflow: auto;
	pointer-events: auto;
	background: rgba(12, 8, 22, 0.88);
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 8px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
	color: #eee;
	font: 13px/1.4 var(--spheresb-font);
	padding: 10px 12px 12px;
	display: none;
}

.spheresb-info-panel.is-open {
	display: block;
}

.spheresb-info-panel .spheresb-info-close {
	float: right;
	color: rgba(255, 255, 255, 0.65);
	text-decoration: none;
	font-size: 18px;
	line-height: 1;
	margin: -2px 0 0 8px;
}

.spheresb-info-panel .spheresb-info-close:hover {
	color: #fff;
}

.spheresb-info-panel .spheresb-info-title {
	font-weight: 700;
	margin-bottom: 6px;
	padding-right: 20px;
}

.spheresb-info-panel .infowindow {
	font-size: 12px;
	line-height: 1.4;
	word-break: break-word;
}

#globe-root {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: none;
	background: #0A0214;
	overflow: hidden;
	pointer-events: auto;
}

#globe-root.is-visible {
	display: block;
}

/* Hide Leaflet map content while globe is active; keep .map box for layout */
.dynmap.map-globe-active > .map > .leaflet-pane,
.dynmap.map-globe-active > .map > .leaflet-control-container {
	visibility: hidden !important;
	pointer-events: none !important;
}

.dynmap.map-globe-active > .map > #globe-root {
	visibility: visible !important;
	pointer-events: auto !important;
}

#globe-root.spheresb-loading::after {
	display: none;
}

/* Hide SphereSB + Dynmap HUD while globe base texture loads */
.dynmap.spheresb-globe-loading .spheresb-view-toggle,
.dynmap.spheresb-globe-loading .spheresb-layer-panel,
.dynmap.spheresb-globe-loading .spheresb-layer-fab,
.dynmap.spheresb-globe-loading .spheresb-layer-backdrop,
.dynmap.spheresb-globe-loading .spheresb-town-search,
.dynmap.spheresb-globe-loading .spheresb-minimap,
.dynmap.spheresb-globe-loading .spheresb-quality,
.dynmap.spheresb-globe-loading .spheresb-info-panel,
.dynmap.spheresb-globe-loading .coord-control,
.dynmap.spheresb-globe-loading .leaflet-control-zoom {
	visibility: hidden !important;
	pointer-events: none !important;
	opacity: 0 !important;
}

.spheresb-load-overlay {
	position: absolute;
	inset: 0;
	z-index: 10;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	background: #0A0214;
	opacity: 1;
	transition: opacity 0.75s ease;
	pointer-events: none;
}

.spheresb-load-overlay.is-fading {
	opacity: 0;
}

.spheresb-load-logo {
	width: min(220px, 55vw);
	height: auto;
	display: block;
	margin-bottom: 4px;
	filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.45));
	user-select: none;
	-webkit-user-drag: none;
}

.spheresb-load-title {
	color: var(--spheresb-ink);
	font: 600 15px/1.4 var(--spheresb-font);
	letter-spacing: 0.01em;
}

.spheresb-load-tip {
	max-width: min(440px, 92vw);
	min-height: 2.8em;
	color: var(--spheresb-muted);
	font: 500 13px/1.5 var(--spheresb-font);
	text-align: center;
	opacity: 1;
	transition: opacity 0.45s ease;
}

.spheresb-load-tip.is-swap {
	opacity: 0;
}

#globe-root canvas {
	display: block;
	width: 100%;
	height: 100%;
}

/* Minimap — bottom-left, cheap blit of already-loaded base canvas */
.spheresb-minimap {
	position: absolute;
	z-index: 20;
	left: calc(var(--spheresb-pad) + var(--spheresb-safe-left));
	bottom: calc(var(--spheresb-pad) + var(--spheresb-safe-bottom));
	width: 148px;
	height: 92px;
	border-radius: 8px;
	border: 1px solid var(--spheresb-line);
	background: rgba(8, 4, 16, 0.92);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
	overflow: hidden;
	cursor: pointer;
	display: none;
	-webkit-tap-highlight-color: transparent;
}

.spheresb-minimap.is-visible {
	display: block;
}

.spheresb-minimap canvas {
	display: block;
	width: 100%;
	height: 100%;
	opacity: 0.95;
}

.spheresb-minimap-view {
	position: absolute;
	border: 1.5px solid rgba(255, 230, 180, 0.9);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
	pointer-events: none;
	border-radius: 2px;
}

/* Globe quality − / + (left middle) */
.spheresb-quality {
	position: absolute;
	z-index: 20;
	left: calc(var(--spheresb-pad) + var(--spheresb-safe-left));
	top: 50%;
	transform: translateY(-50%);
	display: none;
	flex-direction: column;
	align-items: stretch;
	gap: 4px;
	width: 44px;
	padding: 6px;
	border-radius: 10px;
	border: 1px solid var(--spheresb-line);
	background: rgba(8, 4, 16, 0.9);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
	-webkit-tap-highlight-color: transparent;
}

.spheresb-quality.is-visible {
	display: flex;
}

.spheresb-quality-btn {
	height: 36px;
	border: 0;
	border-radius: 7px;
	background: rgba(255, 255, 255, 0.06);
	color: var(--spheresb-ink);
	font: 600 18px/1 var(--spheresb-font);
	cursor: pointer;
}

.spheresb-quality-btn:hover {
	background: rgba(196, 164, 255, 0.22);
	color: #fff;
}

.spheresb-quality-label {
	text-align: center;
	padding: 6px 0 4px;
	color: var(--spheresb-muted);
	font: 600 12px/1.2 var(--spheresb-mono);
}

.spheresb-quality-val {
	color: var(--spheresb-accent);
	font-size: 14px;
}

@media (max-width: 767px) {
	.spheresb-minimap {
		width: 120px;
		height: 74px;
		bottom: calc(var(--spheresb-dock-h) + var(--spheresb-safe-bottom));
	}

	.spheresb-quality {
		top: auto;
		bottom: calc(var(--spheresb-dock-h) + var(--spheresb-safe-bottom) + 86px);
		transform: none;
		width: 40px;
	}
}

.spheresb-view-toggle {
	position: absolute;
	z-index: 1000;
	top: calc(var(--spheresb-pad) + var(--spheresb-safe-top));
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
	border: 0;
	background: transparent;
	box-shadow: none;
	font: 13px/1.2 var(--spheresb-font);
	pointer-events: auto;
}

/* Globe: info panel below search */
.dynmap.spheresb-mode-globe .spheresb-info-panel {
	top: calc(56px + var(--spheresb-safe-top));
}

.spheresb-view-modes {
	display: flex;
	gap: 0;
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 6px;
	overflow: hidden;
	background: rgba(10, 6, 18, 0.85);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.spheresb-view-toggle button {
	appearance: none;
	border: 0;
	margin: 0;
	padding: 8px 16px;
	background: transparent;
	color: rgba(255, 255, 255, 0.7);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

/* Lock under Карта / Глобус — same chrome language */
.spheresb-lock-btn {
	border: 1px solid rgba(255, 255, 255, 0.25) !important;
	border-radius: 6px !important;
	background: rgba(10, 6, 18, 0.85) !important;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
	padding: 7px 14px !important;
	white-space: nowrap;
}

.spheresb-mode-flat .spheresb-lock-btn {
	display: none !important;
}

.spheresb-lock-btn.is-active {
	background: rgba(255, 255, 255, 0.14) !important;
	color: #fff !important;
	font-weight: 600;
}

.spheresb-lock-btn:hover {
	color: #fff;
	background: rgba(255, 255, 255, 0.06) !important;
}

.spheresb-view-toggle button:hover {
	color: #fff;
	background: rgba(255, 255, 255, 0.06);
}

.spheresb-view-toggle button.is-active {
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font-weight: 600;
}

.spheresb-popup {
	position: absolute;
	z-index: 500;
	min-width: 160px;
	max-width: 320px;
	pointer-events: auto;
}

.spheresb-popup .leaflet-popup-content-wrapper {
	position: relative;
	background: rgba(20, 16, 28, 0.95);
	color: #eee;
	border-radius: 6px;
	padding: 10px 28px 10px 12px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.spheresb-popup-title {
	font-weight: 700;
	margin-bottom: 4px;
}

.spheresb-popup-desc {
	font-size: 12px;
	opacity: 0.95;
	word-break: break-word;
	line-height: 1.35;
}

.spheresb-popup-rich .infowindow,
.spheresb-popup-desc .infowindow {
	font-size: 12px;
	line-height: 1.4;
}

.spheresb-popup-close {
	position: absolute;
	right: 8px;
	top: 4px;
	color: rgba(255, 255, 255, 0.7);
	text-decoration: none;
	font-size: 18px;
	line-height: 1;
}

.spheresb-popup-close:hover {
	color: #fff;
}

/* Layer panel — flat + globe */
.spheresb-layer-panel {
	position: fixed;
	z-index: 1102;
	top: calc(var(--spheresb-pad) + var(--spheresb-safe-top));
	right: calc(var(--spheresb-pad) + var(--spheresb-safe-right));
	width: min(240px, calc(100vw - 24px - var(--spheresb-safe-left) - var(--spheresb-safe-right)));
	max-height: min(52vh, 380px);
	overflow: auto;
	display: none;
	padding: 10px 12px 12px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	background: rgba(12, 8, 22, 0.92);
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
	color: #eee;
	font: 13px/1.35 var(--spheresb-font);
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
	-webkit-overflow-scrolling: touch;
}

.spheresb-layer-panel.is-visible {
	display: block;
}

.spheresb-layer-panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 10px;
}

.spheresb-layer-collapse {
	appearance: none;
	border: 0;
	margin: 0;
	padding: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 0;
	text-align: left;
	font: inherit;
}

.spheresb-layer-collapse:hover .spheresb-layer-panel-title {
	color: rgba(242, 236, 255, 0.95);
}

.spheresb-layer-panel-title {
	font-weight: 700;
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: rgba(220, 200, 255, 0.75);
}

.spheresb-layer-chevron {
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid rgba(220, 200, 255, 0.7);
	flex-shrink: 0;
	transition: transform 0.18s ease;
}

.spheresb-layer-panel.is-body-collapsed .spheresb-layer-chevron {
	transform: rotate(-90deg);
}

.spheresb-layer-panel.is-body-collapsed {
	max-height: none;
	overflow: visible;
	padding-bottom: 10px;
}

.spheresb-layer-panel.is-body-collapsed .spheresb-layer-list {
	display: none;
}

.spheresb-layer-panel.is-body-collapsed .spheresb-layer-panel-head {
	margin-bottom: 0;
}

.spheresb-layer-close {
	display: none;
	appearance: none;
	border: 0;
	margin: 0;
	padding: 0;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.08);
	color: rgba(255, 255, 255, 0.85);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.spheresb-layer-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.spheresb-layer-empty {
	color: rgba(255, 255, 255, 0.5);
	font-size: 12px;
	padding: 4px 0;
}

.spheresb-layer-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 8px;
	border-radius: 8px;
	cursor: pointer;
	user-select: none;
	transition: background 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.spheresb-layer-item:hover {
	background: rgba(255, 255, 255, 0.06);
}

.spheresb-layer-item input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.spheresb-layer-check {
	flex: 0 0 20px;
	width: 20px;
	height: 20px;
	border-radius: 5px;
	border: 1.5px solid rgba(255, 255, 255, 0.28);
	background: rgba(0, 0, 0, 0.25);
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
	position: relative;
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.spheresb-layer-check::after {
	content: '';
	position: absolute;
	left: 6px;
	top: 2px;
	width: 5px;
	height: 10px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) scale(0);
	opacity: 0;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.spheresb-layer-item input:checked + .spheresb-layer-check {
	border-color: rgba(180, 140, 255, 0.85);
	background: linear-gradient(145deg, #6e4db8, #4a3288);
	box-shadow: none;
}

.spheresb-layer-item input:checked + .spheresb-layer-check::after {
	transform: rotate(45deg) scale(1);
	opacity: 1;
}

.spheresb-layer-item input:focus-visible + .spheresb-layer-check {
	outline: 2px solid rgba(180, 140, 255, 0.6);
	outline-offset: 2px;
}

.spheresb-layer-label {
	flex: 1;
	line-height: 1.25;
}

/* Layer FAB + backdrop (compact) */
.spheresb-layer-fab {
	display: none;
	position: fixed;
	z-index: 1101;
	right: calc(var(--spheresb-pad) + var(--spheresb-safe-right));
	bottom: calc(var(--spheresb-dock-h) + var(--spheresb-safe-bottom));
	align-items: center;
	gap: 6px;
	padding: 10px 14px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 999px;
	background: rgba(12, 8, 22, 0.94);
	color: #eee;
	font: 600 13px/1 var(--spheresb-font);
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.42);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.spheresb-layer-fab svg {
	width: 18px;
	height: 18px;
	flex: 0 0 18px;
}

.spheresb-layer-fab.is-active {
	border-color: rgba(180, 140, 255, 0.55);
	background: rgba(70, 45, 130, 0.95);
}

.spheresb-layer-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 1101;
	background: rgba(0, 0, 0, 0.45);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.spheresb-layer-backdrop.is-open {
	display: block;
}

/* Flat map: cursor coordinates */
.dynmap.spheresb-mode-flat .coord-control {
	position: fixed !important;
	left: calc(var(--spheresb-pad) + var(--spheresb-safe-left)) !important;
	bottom: var(--spheresb-bottom-ui) !important;
	top: auto !important;
	right: auto !important;
	margin: 0 !important;
	min-width: 132px;
	padding: 8px 12px !important;
	border-radius: 8px !important;
	border: 1px solid rgba(255, 255, 255, 0.14) !important;
	background: rgba(12, 8, 22, 0.9) !important;
	color: rgba(255, 255, 255, 0.72) !important;
	font: 12px/1.45 var(--spheresb-mono) !important;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
	z-index: 1001;
}

.dynmap.spheresb-mode-flat .coord-control .coord-control-label {
	color: rgba(200, 180, 255, 0.65);
	font-size: 10px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.dynmap.spheresb-mode-flat .coord-control .coord-control-value {
	color: #f2ecff !important;
	font-weight: 600;
	font-size: 13px;
}

/* Flat map: zoom buttons — center left */
.dynmap.spheresb-mode-flat .leaflet-control-zoom {
	position: fixed !important;
	left: calc(var(--spheresb-pad) + var(--spheresb-safe-left)) !important;
	top: 50% !important;
	right: auto !important;
	bottom: auto !important;
	margin: 0 !important;
	transform: translateY(-50%) !important;
	border: 0 !important;
	box-shadow: none !important;
	z-index: 1001;
}

.dynmap.spheresb-mode-flat .leaflet-control-zoom a {
	width: 40px !important;
	height: 40px !important;
	line-height: 38px !important;
	border-radius: 8px !important;
	border: 1px solid rgba(255, 255, 255, 0.14) !important;
	background: rgba(12, 8, 22, 0.9) !important;
	color: rgba(255, 255, 255, 0.85) !important;
	font-size: 20px !important;
	font-weight: 600;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.dynmap.spheresb-mode-flat .leaflet-control-zoom a:hover {
	background: rgba(255, 255, 255, 0.12) !important;
	color: #fff !important;
	border-color: rgba(255, 255, 255, 0.28) !important;
}

.dynmap.spheresb-mode-flat .leaflet-control-zoom-in {
	margin-bottom: 6px !important;
	border-bottom: 1px solid rgba(255, 255, 255, 0.14) !important;
}

/* Context menu — flat map */
.spheresb-context-menu {
	position: fixed;
	z-index: 1200;
	min-width: 196px;
	max-width: min(280px, calc(100vw - 24px));
	display: none;
	padding: 6px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	background: rgba(12, 8, 22, 0.96);
	box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
	color: #eee;
	font: 13px/1.35 var(--spheresb-font);
}

.spheresb-context-menu.is-open {
	display: block;
}

.spheresb-context-coords {
	padding: 8px 10px 6px;
	font: 12px/1.4 var(--spheresb-mono);
	color: rgba(220, 200, 255, 0.9);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	margin-bottom: 4px;
	word-break: break-all;
}

.spheresb-context-menu button {
	display: block;
	width: 100%;
	text-align: left;
	border: 0;
	margin: 0;
	padding: 12px 10px;
	border-radius: 6px;
	background: transparent;
	color: #eee;
	cursor: pointer;
	font: inherit;
	-webkit-tap-highlight-color: transparent;
}

.spheresb-context-menu button:hover,
.spheresb-context-menu button:focus {
	background: rgba(255, 255, 255, 0.08);
	outline: none;
}

/* ——— Desktop / tablet landscape ——— */
@media (min-width: 768px) {
	.spheresb-view-toggle {
		top: calc(var(--spheresb-pad) + var(--spheresb-safe-top)) !important;
		bottom: auto !important;
	}

	.dynmap.spheresb-mode-globe .spheresb-info-panel {
		top: calc(56px + var(--spheresb-safe-top));
	}

	.dynmap.spheresb-mode-flat .coord-control {
		bottom: var(--spheresb-bottom-ui) !important;
	}
}

/* ——— Tablet ——— */
@media (min-width: 768px) and (max-width: 1024px) {
	.spheresb-town-search {
		width: min(360px, calc(100vw - 280px));
	}

	.spheresb-layer-panel {
		width: min(260px, 34vw);
		max-height: min(48vh, 340px);
	}

	.spheresb-info-panel {
		width: min(360px, calc(100vw - 280px));
	}
}

/* ——— Phone / compact ——— */
@media (max-width: 767px) {
	:root {
		--spheresb-pad: 10px;
		--spheresb-dock-h: 56px;
	}

	.spheresb-town-search {
		top: calc(var(--spheresb-pad) + var(--spheresb-safe-top));
		left: calc(var(--spheresb-pad) + var(--spheresb-safe-left));
		right: calc(var(--spheresb-pad) + var(--spheresb-safe-right));
		width: auto;
	}

	.spheresb-town-results {
		max-height: min(36vh, 240px);
	}

	/* Toggle at top — frees bottom for coords / map center */
	.spheresb-view-toggle {
		top: calc(var(--spheresb-pad) + var(--spheresb-safe-top));
		bottom: auto;
		left: 50%;
		transform: translateX(-50%);
		width: min(100%, calc(100vw - 24px - var(--spheresb-safe-left) - var(--spheresb-safe-right)));
	}

	/* Toggle below search on small screens */
	.dynmap.spheresb-mode-flat .spheresb-view-toggle,
	.dynmap.spheresb-mode-globe .spheresb-view-toggle {
		top: calc(54px + var(--spheresb-safe-top));
	}

	.spheresb-info-panel {
		top: auto;
		bottom: calc(var(--spheresb-dock-h) + var(--spheresb-safe-bottom));
		left: calc(var(--spheresb-pad) + var(--spheresb-safe-left));
		right: calc(var(--spheresb-pad) + var(--spheresb-safe-right));
		width: auto;
		max-height: min(34vh, 280px);
	}

	.spheresb-view-modes {
		width: 100%;
	}

	.spheresb-view-toggle button {
		flex: 1;
		padding: 11px 12px;
		min-height: 44px;
	}

	.spheresb-lock-btn {
		flex: 1.15;
		font-size: 12px;
	}

	.spheresb-layer-fab {
		display: inline-flex;
		bottom: var(--spheresb-bottom-ui);
	}

	.spheresb-layer-panel {
		top: auto;
		right: calc(var(--spheresb-pad) + var(--spheresb-safe-right));
		left: calc(var(--spheresb-pad) + var(--spheresb-safe-left));
		bottom: calc(var(--spheresb-bottom-ui) + 52px);
		width: auto;
		max-height: min(42vh, 320px);
		padding: 12px 14px 14px;
		border-radius: 14px 14px 10px 10px;
		transform: translateY(calc(100% + 24px));
		opacity: 0;
		pointer-events: none;
		transition: transform 0.28s ease, opacity 0.28s ease;
	}

	.spheresb-layer-panel.is-expanded {
		transform: translateY(0);
		opacity: 1;
		pointer-events: auto;
	}

	.spheresb-layer-close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	.spheresb-layer-item {
		padding: 11px 8px;
		min-height: 44px;
	}

	.dynmap.spheresb-mode-flat .coord-control {
		bottom: calc(var(--spheresb-bottom-ui) + 8px) !important;
		min-width: 108px;
		font-size: 11px !important;
		padding: 7px 10px !important;
	}

	.spheresb-load-tip {
		font-size: 12px;
	}
}

/* Short landscape phones */
@media (max-width: 767px) and (max-height: 480px) {
	:root {
		--spheresb-dock-h: 48px;
	}

	.dynmap.spheresb-mode-flat .spheresb-view-toggle,
	.dynmap.spheresb-mode-globe .spheresb-view-toggle {
		top: calc(50px + var(--spheresb-safe-top));
	}

	.spheresb-layer-panel {
		max-height: min(50vh, 220px);
	}

	.spheresb-info-panel {
		max-height: min(28vh, 180px);
	}
}

/* Touch: larger hit areas */
@media (pointer: coarse) {
	.spheresb-context-menu button {
		padding: 14px 12px;
	}

	.dynmap.spheresb-mode-flat .leaflet-control-zoom a {
		width: 44px !important;
		height: 44px !important;
		line-height: 42px !important;
	}
}
