:root {
	--bg: #0f172a;
	--panel: #111827;
	--text: #e5e7eb;
	--muted: #94a3b8;
	--accent: #22c55e;
	--danger: #ef4444;
	--grid-gap: 5px;
	--side: 6;
	--cell: 64px;
	/* cell x side x 1.3 */
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
	background: radial-gradient(1200px 600px at 10% -20%, #1f2937 0%, #0b1020 40%, #0b1020 100%);
	color: var(--text);
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1200px; }
body.admin-page .container { max-width: 1400px; }

.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.topbar h1 { font-size: 20px; font-weight: 700; margin: 0; }

.actions { display: flex; gap: 8px; }

.panel {
	background: rgba(17, 24, 39, 0.8);
	padding: 24px;
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	margin-top: 20px;
}

.form {
	display: flex;
	flex-direction: column;
	gap: 12px;
	max-width: 360px;
}

.form label { font-size: 14px; color: var(--muted); }

.form input {
	padding: 10px 14px;
	border-radius: 10px;
	border: 1px solid #334155;
	background: rgba(15, 23, 42, 0.6);
	color: var(--text);
}

.btn {
	background: #1f2937;
	color: var(--text);
	border: 1px solid #334155;
	padding: 10px 14px;
	border-radius: 10px;
	cursor: pointer;
	transition: transform .06s ease, background .2s ease, border-color .2s ease;
}

.btn.primary { background: linear-gradient(180deg, #16a34a, #15803d); border-color: #16a34a; }
.btn.secondary { background: linear-gradient(180deg, #a3a3a3, #808080); border-color: #a3a3a3; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0px) scale(0.99); }

.message { min-height: 24px; color: var(--muted); margin: 12px 0; text-align: center; }
.message.error { color: var(--danger); }
.message.success { color: var(--accent); }

.grid {
	display: grid;
	gap: var(--grid-gap);
	user-select: none;
	-webkit-user-select: none;
	margin-top: 8px;
	width: max-content;
    margin-inline: auto;
}

.cell {
  display: flex;
  justify-content: center;
  align-items: center;
  width: var(--cell);
  height: var(--cell);
  border: 1px solid #1e293b;
  border-radius: 12px;
  font-weight: 800;
  font-size: 22px;
  background: #0b1224;

  /* Needed because we position .segment absolutely */
  position: relative;

  transition: background .15s ease, border-color .15s ease;
}

.cell.occupied { border-color: #245b3a; }

.cell:hover { background: #0f1630; }

.segment {
	position: absolute;
	background: rgba(34, 197, 94, 0.12);
	border: 2px solid var(--accent);
	border-radius: 10px;
	box-shadow: 0 0 0 1px rgba(34,197,94,0.3) inset;
}

.segment.horizontal { height: 70%; width: calc(100% + var(--grid-gap)); top: 15%; left: calc(-1 * var(--grid-gap) / 2); }
.segment.vertical { width: 70%; height: calc(100% + var(--grid-gap)); left: 15%; top: calc(-1 * var(--grid-gap) / 2); }

.node {
	position: absolute; inset: 15% 15% 15% 15%;
	border-radius: 10px;
	background: rgba(34, 197, 94, 0.2);
	border: 2px solid var(--accent);
}

.center { display: grid; min-height: 100vh; place-items: center; text-align: center; }

.stats-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 16px;
	font-size: 14px;
	table-layout: auto;
}
.stats-table-wrapper {
	overflow-x: auto;
	width: 100%;
}

.stats-table th,
.stats-table td {
	border: 1px solid #1e293b;
	padding: 12px;
	text-align: left;
	vertical-align: top;
}

.stats-table th {
	background: rgba(30, 41, 59, 0.8);
	font-weight: 600;
}

.stats-table code {
	font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
	font-size: 12px;
	background: rgba(15, 23, 42, 0.6);
	padding: 4px 6px;
	border-radius: 6px;
	display: inline-block;
	max-width: 220px;
	overflow-wrap: break-word;
}
/* Колонка "Путь" (предпоследняя) */
.stats-table th:nth-last-child(2),
.stats-table td:nth-last-child(2) {
	min-width: 250px;
	width: 300px;
}
.stats-table td:nth-last-child(2) code {
	max-width: 280px;
	word-break: break-all;
}
/* Колонка "Дополнительно" (последняя) */
.stats-table th:last-child,
.stats-table td:last-child {
	min-width: 300px;
	width: 400px;
}
.stats-table td:last-child code {
	max-width: 380px;
	word-break: break-all;
}

.leaderboard-wrapper { margin-top: 12px; }
.leaderboard-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 12px;
	font-size: 14px;
}
.leaderboard-table th,
.leaderboard-table td {
	border: 1px solid #1e293b;
	padding: 8px;
	text-align: left;
}
.leaderboard-table th {
	background: rgba(30, 41, 59, 0.8);
	font-weight: 600;
}
.leaderboard-table td:first-child,
.leaderboard-table th:first-child { width: 40px; text-align: center; }


@media (max-width: 640px) {
	.cell { width: 48px; height: 48px; font-size: 18px; }
	.segment.horizontal { height: 70%; }
	.segment.vertical { width: 70%; }
}


