/* Palette follows the forum style (hue 266). */
:root {
	--bg: hsl(266, 14%, 8%);
	--panel: hsl(266, 13%, 12%);
	--raised: hsl(266, 12%, 16%);
	--raised-2: hsl(266, 12%, 20%);
	--line: rgba(255, 255, 255, 0.08);
	--line-strong: rgba(255, 255, 255, 0.16);
	--text: hsl(266, 20%, 93%);
	--muted: hsl(266, 9%, 62%);
	--accent: hsl(266, 52%, 68%);
	--accent-strong: hsl(266, 40%, 56%);
	--t: #f0b35a;
	--ct: #6cb6ff;
	--ok: #58d39b;
	--warn: #f0b35a;
	--bad: #f2716e;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
	height: 100%;
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; }

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

button { font: inherit; color: inherit; }

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.t { color: var(--t); }
.ct { color: var(--ct); }

/* Radar mark: rings with a rotating sweep ------------------------------------ */

.landing-mark,
.overlay-mark {
	position: relative;
	width: 72px;
	height: 72px;
	margin: 0 auto 18px;
	border-radius: 50%;
	border: 1px solid var(--line-strong);
	background:
		radial-gradient(circle, var(--accent) 0 3px, transparent 4px),
		radial-gradient(circle, transparent 0 17px, var(--line-strong) 17px 18px, transparent 18px),
		radial-gradient(circle, hsla(266, 52%, 68%, 0.12), transparent 70%);
	overflow: hidden;
}

.landing-mark span,
.overlay-mark span {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: conic-gradient(from 0deg, hsla(266, 52%, 68%, 0.55), transparent 28%);
	animation: sweep 2.6s linear infinite;
}

.overlay-mark { width: 56px; height: 56px; margin-bottom: 14px; }

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

/* Landing ------------------------------------------------------------------- */

.landing {
	min-height: 100%;
	display: grid;
	place-items: center;
	padding: 16px;
	background:
		radial-gradient(60% 50% at 50% 0%, hsla(266, 52%, 55%, 0.20), transparent 70%),
		var(--bg);
}

.landing-card {
	width: min(380px, 100%);
	padding: 32px 26px 26px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
	text-align: center;
}

.landing-card h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.01em; }
.landing-card p { margin: 0 0 20px; color: var(--muted); }

.landing-card input {
	width: 100%;
	padding: 14px 12px;
	background: var(--bg);
	border: 1px solid var(--line-strong);
	border-radius: 10px;
	color: var(--text);
	font: 700 22px/1 var(--mono);
	letter-spacing: 0.24em;
	text-align: center;
	text-transform: uppercase;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.landing-card input::placeholder { color: hsl(266, 8%, 38%); }

.landing-card input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px hsla(266, 52%, 68%, 0.22);
}

.landing-card .landing-error { min-height: 20px; margin: 8px 0; color: var(--bad); }

.landing-card button {
	width: 100%;
	padding: 13px;
	background: linear-gradient(180deg, var(--accent), var(--accent-strong));
	border: 0;
	border-radius: 10px;
	color: #15101f;
	font-weight: 700;
	cursor: pointer;
	transition: filter 0.15s, transform 0.05s;
}
.landing-card button:hover { filter: brightness(1.08); }
.landing-card button:active { transform: translateY(1px); }

/* Top bar ------------------------------------------------------------------- */

.app {
	height: 100%;
	display: flex;
	flex-direction: column;
}

.bar {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 12px;
	min-height: 56px;
	padding: 8px 14px;
	padding-top: max(8px, env(safe-area-inset-top));
	background: var(--panel);
	border-bottom: 1px solid var(--line);
}

.bar-left, .bar-right {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
.bar-right { justify-content: flex-end; }

.brand {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--text);
	font-size: 15px;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
}
.brand b { color: var(--accent); font-weight: 700; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); }

.pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 10px 3px 8px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.05);
	font-size: 12px;
	font-weight: 600;
	color: var(--muted);
	white-space: nowrap;
}
.pill::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
}
.pill[data-state="live"] { color: var(--ok); background: rgba(88, 211, 155, 0.10); }
.pill[data-state="live"]::before { animation: pulse 1.8s ease-out infinite; }
.pill[data-state="offline"], .pill[data-state="connecting"] { color: var(--warn); background: rgba(240, 179, 90, 0.10); }
.pill[data-state="ended"] { color: var(--bad); background: rgba(242, 113, 110, 0.10); }

@keyframes pulse {
	0% { box-shadow: 0 0 0 0 rgba(88, 211, 155, 0.6); }
	100% { box-shadow: 0 0 0 7px rgba(88, 211, 155, 0); }
}

.scoreboard {
	display: flex;
	align-items: center;
	gap: 10px;
	font-variant-numeric: tabular-nums;
}
.score-team {
	padding: 2px 7px;
	border-radius: 5px;
	background: rgba(255, 255, 255, 0.06);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.06em;
}
.score-num { min-width: 22px; font-size: 24px; line-height: 1; text-align: center; }
.score-sep { display: grid; justify-items: center; line-height: 1; }
.score-sep i { color: var(--muted); font-style: normal; font-size: 18px; font-weight: 700; }
.score-sep small { margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; }

.viewers {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}
.viewers svg { width: 16px; height: 16px; }

.room-chip, .bar-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 32px;
	padding: 0 11px;
	background: var(--raised);
	border: 1px solid var(--line);
	border-radius: 8px;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.room-chip:hover, .bar-btn:hover { background: var(--raised-2); border-color: var(--line-strong); }

.room-chip { font: 600 13px var(--mono); letter-spacing: 0.08em; }
.room-chip svg { width: 15px; height: 15px; color: var(--accent); }
.room-chip.is-copied { border-color: var(--ok); color: var(--ok); }
.room-chip.is-copied svg { color: var(--ok); }

.bar-btn[aria-pressed="false"] { color: var(--muted); background: transparent; }
.bar-btn[aria-pressed="true"] { border-color: hsla(266, 52%, 68%, 0.45); }

/* Stage ---------------------------------------------------------------------- */

.stage {
	flex: 1;
	min-height: 0;
	display: flex;
}

.canvas-wrap {
	position: relative;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	touch-action: none;
	cursor: grab;
	background:
		radial-gradient(55% 55% at 50% 50%, hsla(266, 40%, 40%, 0.16), transparent 75%),
		repeating-linear-gradient(0deg, transparent 0 47px, rgba(255, 255, 255, 0.022) 47px 48px),
		repeating-linear-gradient(90deg, transparent 0 47px, rgba(255, 255, 255, 0.022) 47px 48px),
		var(--bg);
}
.canvas-wrap.is-dragging { cursor: grabbing; }

canvas { display: block; width: 100%; height: 100%; }

.map-tag {
	position: absolute;
	left: 14px;
	bottom: 14px;
	padding: 4px 10px;
	background: rgba(20, 16, 28, 0.7);
	border: 1px solid var(--line);
	border-radius: 7px;
	color: var(--muted);
	font: 600 11px var(--mono);
	letter-spacing: 0.06em;
	text-transform: uppercase;
	pointer-events: none;
	backdrop-filter: blur(6px);
}

.focus-chip {
	position: absolute;
	top: 14px;
	left: 14px;
	display: flex;
	align-items: center;
	gap: 7px;
	height: 32px;
	padding: 0 8px 0 12px;
	background: hsla(266, 30%, 18%, 0.9);
	border: 1px solid hsla(266, 52%, 68%, 0.6);
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
	max-width: calc(100% - 28px);
	backdrop-filter: blur(6px);
}
.focus-chip:hover { background: hsla(266, 30%, 24%, 0.95); }
.focus-label { color: var(--muted); font-size: 12px; }
.focus-chip b { overflow: hidden; text-overflow: ellipsis; }
.focus-x {
	display: grid;
	place-items: center;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	color: var(--text);
	line-height: 1;
}

.bomb-banner {
	position: absolute;
	top: 14px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 7px 14px 7px 11px;
	background: rgba(48, 16, 20, 0.85);
	border: 1px solid rgba(242, 113, 110, 0.6);
	border-radius: 999px;
	box-shadow: 0 6px 24px rgba(242, 113, 110, 0.2);
	color: #ffdcdb;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	pointer-events: none;
	backdrop-filter: blur(6px);
}
.bomb-banner img { height: 16px; }
.bomb-banner[data-state="defused"] {
	background: rgba(14, 30, 50, 0.85);
	border-color: rgba(108, 182, 255, 0.6);
	box-shadow: none;
	color: #d6eaff;
}

.overlay {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 16px;
	background: hsla(266, 14%, 8%, 0.78);
	backdrop-filter: blur(3px);
}

.overlay-card { max-width: 340px; text-align: center; }
.overlay-card h2 { margin: 0 0 6px; font-size: 19px; }
.overlay-card p { margin: 0 0 14px; color: var(--muted); }
.overlay-link {
	display: inline-block;
	padding: 8px 14px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	color: var(--text);
	text-decoration: none;
}
.overlay-link:hover { border-color: var(--accent); color: var(--accent); }

/* Roster --------------------------------------------------------------------- */

.roster {
	width: 290px;
	padding: 12px;
	background: var(--panel);
	border-left: 1px solid var(--line);
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.team {
	--team: var(--ct);
	background: var(--raised);
	border: 1px solid var(--line);
	border-radius: 12px;
	overflow: hidden;
}
.team-t { --team: var(--t); }

.team h3 {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin: 0;
	padding: 9px 12px;
	border-bottom: 1px solid var(--line);
	background: linear-gradient(90deg, color-mix(in srgb, var(--team) 16%, transparent), transparent 80%);
	color: var(--team);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}
.team h3 b { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0; white-space: nowrap; }
.team-short { display: none; }

.team ul { margin: 0; padding: 0; list-style: none; }

.team li {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 4px 10px;
	padding: 8px 12px 9px 14px;
	border-bottom: 1px solid var(--line);
}
.team li:last-child { border-bottom: 0; }

.team li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 8px;
	bottom: 8px;
	width: 3px;
	border-radius: 0 3px 3px 0;
	background: var(--team);
}

.team li.is-dead { opacity: 0.38; }
.team li.is-dead::before { background: var(--muted); }
.team li.is-local { background: rgba(255, 255, 255, 0.035); }
.team li[data-id] { cursor: pointer; transition: background 0.12s; }
.team li[data-id]:hover { background: rgba(255, 255, 255, 0.06); }
.team li.is-focused { background: hsla(266, 52%, 68%, 0.16); box-shadow: inset 0 0 0 1px hsla(266, 52%, 68%, 0.5); }
.team li[data-id]:focus-visible { outline-offset: -2px; }

.r-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.r-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.r-badge {
	flex: none;
	padding: 1px 5px;
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.08);
	color: var(--muted);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}
.r-badge.is-host { background: hsla(266, 52%, 68%, 0.18); color: var(--accent); }
.r-badge.is-kit { background: rgba(108, 182, 255, 0.16); color: var(--ct); }
.r-c4 { flex: none; height: 13px; filter: drop-shadow(0 0 4px rgba(242, 113, 110, 0.9)); }

.r-hp { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.is-dead .r-hp { font-weight: 500; font-size: 12px; }

.r-weapon {
	display: flex;
	align-items: center;
	gap: 7px;
	min-width: 0;
	height: 18px;
	color: var(--muted);
	font-size: 12px;
}
.r-weapon img { flex: none; height: 16px; max-width: 62px; object-fit: contain; object-position: left; opacity: 0.9; }
.r-weapon span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.03em; font-size: 11px; }

.r-bar {
	grid-column: 2;
	width: 64px;
	height: 5px;
	background: rgba(255, 255, 255, 0.08);
	border-radius: 3px;
	overflow: hidden;
}
.r-bar span {
	display: block;
	height: 100%;
	border-radius: 3px;
	background: var(--ok);
	transition: width 0.25s ease-out;
}
.r-bar span[data-level="mid"] { background: var(--warn); }
.r-bar span[data-level="low"] { background: var(--bad); }

.team-empty { padding: 12px; color: var(--muted); font-size: 12px; }

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

@media (max-width: 900px) {
	.bar { grid-template-columns: auto 1fr; row-gap: 6px; }
	.bar-right { grid-column: 1 / -1; justify-content: space-between; }
	.scoreboard { justify-self: end; }
	.score-num { font-size: 20px; }
}

@media (max-width: 760px) {
	.stage { flex-direction: column; }
	.roster {
		width: auto;
		max-height: 38%;
		border-left: 0;
		border-top: 1px solid var(--line);
		padding: 10px;
		padding-bottom: max(10px, env(safe-area-inset-bottom));
		flex-direction: row;
		align-items: flex-start;
		gap: 10px;
	}
	.team { flex: 1; min-width: 0; }
	.bomb-banner { top: 54px; }
	.team-long { display: none; }
	.team-short { display: inline; }
	.team li { padding: 6px 8px 7px 11px; gap: 3px 6px; }
	.r-bar { width: 40px; }
	.r-weapon span { display: none; }
	.brand span { display: none; }
	.bar-btn#resetBtn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.landing-mark span, .overlay-mark span, .pill::before { animation: none; }
	.r-bar span { transition: none; }
}
