/* Křížovka Respekt — vzhled tištěné strany: papír, černá linka, patkové písmo, červený akcent. */

:root {
	--paper: #f6f3ec;
	--paper-2: #ece7dc;
	--ink: #111;
	--ink-soft: #4a4844;
	--rule: #111;
	--block: #111;
	--red: #ce0b24;
	--red-soft: #f6d7d6;
	--active: #fbe7a6;
	--cursor: #f4c430;
	--secret: #e7e1d3;
	--wrong: #a3001a;
	--revealed: #1d4f8c;
	--white: #fffdf8;
	--serif: adelle, "Bitter", Georgia, serif;
	--sans: adelle-sans, "Source Sans 3", Arial, sans-serif;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--paper: #17171a;
		--paper-2: #222227;
		--ink: #efece4;
		--ink-soft: #a9a59c;
		--rule: #8d897f;
		--block: #050505;
		--red: #ff4d5e;
		--red-soft: #4a1d22;
		--active: #4a4122;
		--cursor: #5a490a;
		--secret: #4a4330;
		--wrong: #ff8a95;
		--revealed: #9cc3ff;
		--white: #34343a;
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--paper: #17171a;
	--paper-2: #222227;
	--ink: #efece4;
	--ink-soft: #a9a59c;
	--rule: #8d897f;
	--block: #050505;
	--red: #ff4d5e;
	--red-soft: #4a1d22;
	--active: #4a4122;
	--cursor: #5a490a;
	--secret: #4a4330;
	--wrong: #ff8a95;
	--revealed: #9cc3ff;
	--white: #34343a;
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--serif);
	font-size: 17px;
	line-height: 1.5;
}

a {
	color: inherit;
}

/* ---------- hlavička jako záhlaví stránky časopisu ---------- */

.masthead {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	max-width: 1180px;
	margin: 0 auto;
	padding: 14px 16px 10px;
	border-bottom: 3px solid var(--rule);
}

.masthead__brand {
	display: flex;
	align-items: baseline;
	gap: 12px;
	text-decoration: none;
}

.wordmark {
	color: var(--red);
	font-family: var(--sans);
	font-weight: 900;
	font-size: 28px;
	letter-spacing: -0.02em;
	line-height: 1;
}

.masthead__section,
.kicker {
	font-family: var(--sans);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.masthead__nav {
	display: flex;
	gap: 18px;
	font-family: var(--sans);
	font-weight: 600;
	font-size: 15px;
}

.masthead__nav a {
	text-decoration: none;
}

.masthead__nav a:hover {
	color: var(--red);
}

.page {
	max-width: 1180px;
	margin: 0 auto;
	padding: 24px 16px 64px;
}

.kicker {
	color: var(--red);
}

.title {
	margin: 4px 0 4px;
	font-family: var(--serif);
	font-weight: 800;
	font-size: clamp(28px, 5vw, 44px);
	line-height: 1.1;
	letter-spacing: -0.01em;
}

.meta {
	margin: 0 0 20px;
	color: var(--ink-soft);
	font-family: var(--sans);
	font-size: 15px;
}

/* ---------- hra ---------- */

.player {
	display: grid;
	gap: 24px 40px;
	padding-top: 16px;
	border-top: 1px solid var(--rule);
}

@media (min-width: 900px) {
	.player {
		grid-template-columns: auto minmax(280px, 1fr);
		align-items: start;
	}
	.player__board {
		position: sticky;
		top: 12px;
	}
	.player .board {
		--cell: min(
			44px,
			calc(
				(min(100vw, 1180px) - 32px - 400px - 6px - var(--labels, 0px) - (var(--cols, 13) - 1) * 1px) /
				var(--cols, 13)
			),
			calc((100vh - 220px - var(--labels, 0px) - (var(--rows, 13) - 1) * 1px) / var(--rows, 13))
		);
	}
	.player__board {
		max-height: calc(100vh - 24px);
		overflow: auto;
	}
}

.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
	font-family: var(--sans);
}

.toolbar__timer {
	margin-right: auto;
	min-width: 3.5em;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	font-size: 18px;
}

.toolbar__menu {
	position: relative;
}

.toolbar__menu summary {
	list-style: none;
}

.toolbar__menu summary::-webkit-details-marker {
	display: none;
}

.toolbar__menu-list {
	position: absolute;
	z-index: 10;
	top: calc(100% + 4px);
	right: 0;
	display: grid;
	min-width: 210px;
	padding: 6px;
	background: var(--white);
	border: 1px solid var(--rule);
	box-shadow: 4px 4px 0 var(--rule);
}

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 6px 14px;
	border: 1.5px solid var(--rule);
	border-radius: 0;
	background: transparent;
	color: var(--ink);
	font-family: var(--sans);
	font-weight: 700;
	font-size: 15px;
	text-decoration: none;
	cursor: pointer;
}

.button:hover {
	background: var(--paper-2);
}

.button--primary {
	background: var(--ink);
	color: var(--paper);
}

.button--primary:hover {
	background: var(--red);
	border-color: var(--red);
}

.button--plain {
	justify-content: flex-start;
	border-color: transparent;
	font-weight: 600;
}

.button--danger {
	color: var(--red);
	border-color: var(--red);
}

.button:disabled {
	opacity: 0.4;
	cursor: default;
}

.cluebar {
	display: flex;
	align-items: baseline;
	gap: 8px;
	min-height: 52px;
	margin-bottom: 10px;
	padding: 8px 12px;
	background: var(--ink);
	color: var(--paper);
	font-family: var(--serif);
	line-height: 1.3;
}

.cluebar__label {
	flex: none;
	color: var(--cursor);
	font-family: var(--sans);
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.cluebar__len {
	flex: none;
	margin-left: auto;
	opacity: 0.7;
	font-family: var(--sans);
	font-size: 14px;
}

.board {
	/* šířka stránky minus okraje, rámeček (2×3px), mezery mezi políčky (1px) a popisky řádků */
	--cell: min(48px, calc((100vw - 32px - 6px - var(--labels, 0px) - (var(--cols, 13) - 1) * 1px) / var(--cols, 13)));
	display: inline-block;
}

.board--rowcol {
	--labels: 26px;
	display: inline-grid;
	grid-template-columns: 22px auto;
	grid-template-rows: 22px auto;
}

.board__cols,
.board__rows {
	display: grid;
	font-family: var(--sans);
	font-weight: 700;
	font-size: 12px;
	color: var(--ink-soft);
	text-align: center;
}

.board__cols {
	grid-template-columns: repeat(var(--cols), var(--cell));
	align-items: end;
	padding-left: 3px;
}

.board__rows {
	grid-template-rows: repeat(var(--rows), var(--cell));
	align-items: center;
	padding-top: 3px;
}

.grid {
	position: relative;
	display: grid;
	width: fit-content;
	grid-template-columns: repeat(var(--cols), var(--cell));
	grid-template-rows: repeat(var(--rows), var(--cell));
	border: 3px solid var(--rule);
	background: var(--rule);
	gap: 1px;
	user-select: none;
	touch-action: manipulation;
}

.cell {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--white);
	cursor: pointer;
}

.cell--block {
	background: var(--block);
	cursor: default;
}

.cell--secret {
	background: var(--secret);
}

.cell--secret::after {
	content: "";
	position: absolute;
	inset: 3px;
	border: 1px solid var(--ink-soft);
	border-radius: 50%;
	pointer-events: none;
	opacity: 0.55;
}

.cell.is-active {
	background: var(--active);
}

.cell.is-cursor {
	background: var(--cursor);
}

.cell__num {
	position: absolute;
	top: 1px;
	left: 2px;
	font-family: var(--sans);
	font-weight: 600;
	font-size: calc(var(--cell) * 0.26);
	line-height: 1;
}

.cell__letter {
	font-family: var(--sans);
	font-weight: 700;
	font-size: calc(var(--cell) * 0.56);
	line-height: 1;
	text-transform: uppercase;
}

.cell.is-multi .cell__letter {
	font-size: calc(var(--cell) * 0.4);
	letter-spacing: -0.04em;
}

.cell.is-wrong .cell__letter {
	color: var(--wrong);
	text-decoration: line-through;
	text-decoration-thickness: 2px;
}

.cell.is-revealed .cell__letter {
	color: var(--revealed);
}

.grid__input {
	position: absolute;
	z-index: -1;
	width: var(--cell);
	height: var(--cell);
	padding: 0;
	border: 0;
	opacity: 0;
	font-size: 16px;
	caret-color: transparent;
	pointer-events: none;
}

.player.is-done .cell {
	cursor: default;
}

.secret {
	margin-top: 16px;
}

.secret__label {
	margin-bottom: 6px;
	font-family: var(--sans);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.secret__cells {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
}

.secret__cell {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 32px;
	border-bottom: 2px solid var(--rule);
	font-family: var(--sans);
	font-weight: 700;
	font-size: 18px;
}

.secret__cell.is-cursor {
	background: var(--cursor);
}

.hints {
	margin: 14px 0 0;
	font-family: var(--sans);
	font-size: 15px;
	color: var(--ink-soft);
}

/* legenda: souvislý odstavec jako v tisku */
.legend + .legend {
	margin-top: 20px;
}

.legend__title {
	margin: 0 0 6px;
	padding-bottom: 4px;
	border-bottom: 1px solid var(--rule);
	font-family: var(--sans);
	font-weight: 900;
	font-size: 14px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.legend__text {
	margin: 0;
	text-align: justify;
	hyphens: auto;
	line-height: 1.55;
}

.legend__clue {
	cursor: pointer;
	border-radius: 2px;
	box-decoration-break: clone;
	-webkit-box-decoration-break: clone;
}

.legend__clue:hover {
	background: var(--paper-2);
}

.legend__clue.is-filled {
	color: var(--ink-soft);
}

.legend__clue.is-active {
	background: var(--active);
	color: var(--ink);
}

.legend__label {
	font-family: var(--sans);
	font-weight: 900;
}

.stats {
	margin-top: 24px;
	color: var(--ink-soft);
	font-family: var(--sans);
	font-size: 14px;
}

.done {
	max-width: min(440px, calc(100vw - 32px));
	padding: 24px;
	border: 3px solid var(--rule);
	background: var(--paper);
	color: var(--ink);
	box-shadow: 8px 8px 0 var(--rule);
}

.done::backdrop {
	background: rgb(0 0 0 / 0.35);
}

.done__title {
	margin: 4px 0 8px;
	font-weight: 800;
	font-size: 30px;
	line-height: 1.1;
}

.done__secret {
	font-weight: 600;
}

.done__meta {
	color: var(--ink-soft);
	font-family: var(--sans);
}

.done__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 16px;
}

.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 50;
	padding: 10px 16px;
	background: var(--ink);
	color: var(--paper);
	font-family: var(--sans);
	font-weight: 600;
	transform: translate(-50%, 20px);
	opacity: 0;
	transition:
		opacity 0.2s,
		transform 0.2s;
	pointer-events: none;
}

.toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ---------- archiv ---------- */

.archive__year h2 {
	margin: 28px 0 6px;
	padding-bottom: 4px;
	border-bottom: 3px solid var(--rule);
	font-family: var(--sans);
	font-weight: 900;
	font-size: 22px;
}

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

.archive__list a {
	display: grid;
	grid-template-columns: 4.5em 1fr auto 1.5em;
	gap: 12px;
	align-items: baseline;
	padding: 10px 0;
	border-bottom: 1px solid var(--paper-2);
	text-decoration: none;
}

.archive__list a:hover .archive__title {
	color: var(--red);
}

.archive__issue,
.archive__date {
	font-family: var(--sans);
	color: var(--ink-soft);
	font-size: 15px;
}

.archive__title {
	font-weight: 600;
}

.is-done .archive__state::after {
	content: "✓";
	color: var(--red);
	font-weight: 900;
}

.is-started .archive__state::after {
	content: "…";
	color: var(--ink-soft);
}

@media (max-width: 560px) {
	.archive__list a {
		grid-template-columns: 3.5em 1fr 1.2em;
	}
	.archive__date {
		display: none;
	}
}

/* ---------- správa ---------- */

.admin-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	margin: 12px 0 16px;
}

.admin-bar select,
.admin-bar input,
.field input,
.field select,
.field textarea {
	min-height: 40px;
	padding: 6px 10px;
	border: 1.5px solid var(--rule);
	border-radius: 0;
	background: var(--white);
	color: var(--ink);
	font-family: var(--sans);
	font-size: 15px;
}

.field {
	display: grid;
	gap: 4px;
	margin-bottom: 12px;
	font-family: var(--sans);
	font-weight: 600;
	font-size: 14px;
}

.field textarea {
	width: 100%;
	min-height: 420px;
	font-family: ui-monospace, "SF Mono", Menlo, monospace;
	font-size: 13px;
	line-height: 1.45;
	tab-size: 2;
}

.table {
	width: 100%;
	border-collapse: collapse;
	font-family: var(--sans);
	font-size: 15px;
}

.table th,
.table td {
	padding: 8px 6px;
	border-bottom: 1px solid var(--paper-2);
	text-align: left;
	vertical-align: baseline;
}

.table th {
	border-bottom: 2px solid var(--rule);
	font-size: 12px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.table tr[data-id] {
	cursor: pointer;
}

.table tr[data-id]:hover td {
	background: var(--paper-2);
}

.badge {
	display: inline-block;
	padding: 1px 8px;
	border: 1px solid currentColor;
	font-family: var(--sans);
	font-weight: 700;
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}

.badge--published {
	color: var(--red);
}

.badge--review {
	background: var(--active);
	color: var(--ink);
}

.badge--archived {
	color: var(--ink-soft);
}

.admin-detail {
	display: grid;
	gap: 24px;
}

@media (min-width: 1000px) {
	.admin-detail {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	}
}

.messages {
	margin: 0 0 12px;
	padding: 0;
	list-style: none;
	font-family: var(--sans);
	font-size: 14px;
}

.messages li {
	padding: 6px 10px;
	border-left: 3px solid var(--red);
	background: var(--red-soft);
	margin-bottom: 4px;
}

.messages--warn li {
	border-left-color: var(--cursor);
	background: var(--active);
}

.messages--ok li {
	border-left-color: var(--ink);
	background: var(--paper-2);
}

.preview .grid {
	--cell: min(32px, calc((100vw - 32px) / var(--cols, 13)));
	margin-bottom: 16px;
}

.preview .cell {
	cursor: default;
}

.revisions {
	font-family: var(--sans);
	font-size: 14px;
}

.revisions li {
	display: flex;
	gap: 8px;
	align-items: baseline;
	padding: 4px 0;
	border-bottom: 1px solid var(--paper-2);
}

.revisions button {
	margin-left: auto;
}

.token-box {
	padding: 12px;
	border: 2px dashed var(--red);
	font-family: ui-monospace, Menlo, monospace;
	word-break: break-all;
}

/* ---------- tisk: vypadá jako strana z časopisu ---------- */

@media print {
	/* Stejná specificita jako tmavý režim, aby se vždy tiskla světlá strana. */
	:root,
	:root:not([data-theme="light"]),
	:root[data-theme="dark"] {
		--paper: #fff;
		--paper-2: #eee;
		--white: #fff;
		--ink: #000;
		--ink-soft: #333;
		--rule: #000;
		--block: #000;
		--active: #fff;
		--cursor: #fff;
		--secret: #fff;
		--red: #ce0b24;
		color-scheme: light;
	}
	* {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}
	.board,
	.player .board {
		--cell: min(9mm, calc(180mm / var(--cols, 13)));
	}
	.masthead__nav,
	.toolbar,
	.cluebar,
	.stats,
	.toast,
	.done {
		display: none;
	}
	/* Mřížka nahoře, legenda pod ní ve dvou sloupcích jako v časopise. */
	.player {
		display: block;
		border-top: 0;
	}
	.player__board {
		position: static;
		max-height: none;
		overflow: visible;
		margin-bottom: 6mm;
		break-inside: avoid;
	}
	.player__legend {
		columns: 2;
		column-gap: 8mm;
	}
	.legend {
		break-inside: avoid-column;
	}
	.cell__letter {
		visibility: hidden;
	}
	.legend__text {
		font-size: 10pt;
	}
	.legend__clue.is-active,
	.legend__clue.is-filled {
		background: none;
		color: #000;
	}
	.secret__cell {
		color: transparent;
	}
}
