:root {
	--bg: #000000;
	--grid-border: #5f5f5f;
	--text: #f2f2f2;
	--hover: rgba(255, 255, 255, 0.16);
	--selected: #f2f2f2;
	--solved-fill: rgba(56, 201, 74, 0.22);
	--solved-border: #38c94a;
	--cell-size: min(3.45vw, 31px);
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	min-height: 100%;
	background: var(--bg);
}

body {
	color: var(--text);
	font-family: 'Space Mono', monospace;
}

.page {
	min-height: 100vh;
	display: grid;
	place-content: center;
	padding: 12px 16px;
	background: var(--bg);
	gap: 14px;
}

.page-title {
	margin: 0;
	color: var(--text);
	letter-spacing: 0.12em;
    font-weight: 100;
}

.puzzle-layout {
	display: grid;
	grid-template-columns: minmax(132px, 170px) auto minmax(150px, 200px);
	align-items: center;
	gap: 18px;
	width: 100%;
	max-width: 1180px;
}

.panel {
	display: flex;
	align-items: center;
	justify-content: center;
}

.panel-codes {
	justify-content: flex-end;
}

.panel-hint {
	justify-content: flex-start;
}

.hint-panel-content {
	display: grid;
	gap: 10px;
	justify-items: start;
}

.code-list {
	width: 100%;
	display: grid;
	gap: 7px;
}

.code-line {
	color: var(--text);
	font-size: clamp(0.72rem, 0.92vw, 0.92rem);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	white-space: nowrap;
}

.code-line.is-solved {
	color: #8cff9d;
}

.hint-frame {
	width: min(18vw, 190px);
	aspect-ratio: 1;
	border: 1px solid var(--grid-border);
	background: #000000;
	position: relative;
	overflow: hidden;
	display: grid;
	place-items: center;
}

.hint-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	background: #000000;
}

.hint-text {
	min-height: 2.6em;
	max-width: min(18vw, 190px);
	color: var(--text);
	font-size: clamp(0.68rem, 0.9vw, 0.9rem);
	line-height: 1.4;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-align: left;
}

.crossword {
	display: grid;
	grid-template-columns: repeat(var(--cols), var(--cell-size));
	grid-template-rows: repeat(var(--rows), var(--cell-size));
	gap: 0;
	outline: none;
	user-select: none;
	align-items: center;
	justify-items: center;
}

.cell {
	width: var(--cell-size);
	height: var(--cell-size);
	padding: 0;
	border: 1px solid var(--grid-border);
	background: transparent;
	color: var(--text);
	appearance: none;
	font: inherit;
	display: grid;
	place-items: center;
	font-size: clamp(0.78rem, 1.18vw, 1.12rem);
	text-transform: uppercase;
	transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, color 120ms ease;
}

.cell:focus {
	outline: none;
}

.cell.word-hover {
	background: var(--hover);
}

.cell.word-selected {
	border-color: var(--selected);
	box-shadow: inset 0 0 0 1px var(--selected);
}

.cell.word-start {
	cursor: pointer;
}

.cell.word-start:hover {
	border-color: #9b9b9b;
}

.clue-cell {
	width: var(--cell-size);
	height: var(--cell-size);
	padding: 0;
	border: 1px solid #f2f2f2;
	background: #ffffff;
	color: #000000;
	appearance: none;
	font: inherit;
	display: grid;
	place-items: center;
	font-size: clamp(0.66rem, 0.95vw, 0.9rem);
	cursor: pointer;
	transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.clue-cell:hover,
.clue-cell.clue-hover {
	transform: translateY(-1px);
	box-shadow: 0 0 0 1px #ffffff;
}

.clue-cell.clue-selected {
	box-shadow: 0 0 0 2px #ffffff;
}

.clue-cell:focus {
	outline: none;
}

.cell.word-solved {
	color: #a3ff8c;
	border-color: var(--solved-border);
	background: var(--solved-fill);
	box-shadow: inset 0 0 0 1px var(--solved-border);
}

@media (max-width: 720px) {
	:root {
		--cell-size: min(5.2vw, 28px);
	}

	.page {
		padding: 12px;
		overflow-x: auto;
		place-content: start center;
	}

	.puzzle-layout {
		grid-template-columns: 1fr;
		gap: 18px;
		justify-items: center;
	}

	.panel-codes,
	.panel-hint {
		justify-content: center;
	}

	.code-list {
		justify-items: center;
	}

	.hint-frame {
		width: min(58vw, 180px);
	}

	.hint-text {
		max-width: min(58vw, 180px);
	}
}
