html,
body,
h1,
h2,
h3,
form,
p,
input,
output,
div,
section {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font: 1em sans-serif;
	line-height: 1.2;
	background: #f8f8fc;
	padding: 0 1rem;
}

header {
	text-align: center;
	margin: 0.5rem 0 1rem;
}

h1 {
	font: lighter 1.6rem sans-serif;
	color: #666688;
}

.note {
	display: inline-block;
	position: relative;
	text-align: center;
	width: 1rem;
	height: 1rem;
	border-radius: 100%;
	background: #666666;
	color: white;
	font-size: 0.8rem;
	line-height: 1rem;
	vertical-align: middle;
	cursor: help;
}

.note:hover::after {
	content: attr(title);
	position: absolute;
	top: 0.8rem;
	left: 0.8rem;
	background: rgba(0, 0, 0, 0.8);
	width: 10rem;
	text-align: left;
	padding: 0.3rem 0.5rem;
	border-radius: 4px;
	line-height: 1.2;
}

main {
	max-width: 1000px;
	margin: 0 auto;
}

.input-grid {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.5rem 1rem;
	align-items: center;
}

input[type='text'],
output {
	padding: 0.5rem 0.8rem;
	font: 1.5rem monospace;
	line-height: 1.8rem;
	letter-spacing: 0.2rem;
	border: 1px solid #ccccdd;
	border-radius: 2px;
	background: white;
	white-space: pre;
}

output {
	overflow-x: auto;
}

.fail output {
	background: #ff8080;
}

#form-rect {
	padding: 1rem 13rem;
}

.grid {
	display: block;
	margin: 12rem auto;
	position: relative;
}

.grid.rect {
	--w: 3rem;
	--h: 3rem;
}

.grid button {
	position: absolute;
	width: 1.5rem;
	height: 1.5rem;
	user-select: none;
}

.grid.rect button[name='add-row'] {
	bottom: -2rem;
	left: -4rem;
}
.grid.rect button[name='remove-row'] {
	top: -2rem;
	left: -4rem;
}
.grid.rect button[name='add-col'] {
	right: -2rem;
	top: -4rem;
}
.grid.rect button[name='remove-col'] {
	left: -2rem;
	top: -4rem;
}

.grid.rect .double {
	display: block;
	position: absolute;
	top: -1.5rem;
	right: -12rem;
	width: 11.5rem;
	font-size: 0.8rem;
}

.grid .pattern,
.grid .cell {
	position: absolute;
	border: 1px solid #bbbbcc;
	border-radius: 0;
}

.grid .pattern {
	font-size: 0.9rem;
	width: 12rem;
	background: #fcfcfe;
	height: var(--h);
}

.grid .pattern:focus {
	background: white;
}

.grid .pattern.row,
.grid .pattern.col {
	text-align: right;
	border-top-left-radius: 5px;
	border-bottom-left-radius: 5px;
}

.grid .pattern.altrow,
.grid .pattern.altcol {
	text-align: left;
	border-top-right-radius: 5px;
	border-bottom-right-radius: 5px;
}

.grid .pattern.row {
	left: -12rem;
}
.grid .pattern.altrow {
	right: -12rem;
}

.grid .pattern.col,
.grid .pattern.altcol {
	height: var(--w);
	transform: rotate(90deg);
	transform-origin: calc(var(--w) / 2) calc(var(--w) / 2);
	cursor: vertical-text;
}
.grid .pattern.col {
	top: -12rem;
}
.grid .pattern.altcol {
	bottom: calc(var(--w) * -1);
}

.grid .cell {
	padding: 0.2rem;
	width: var(--w);
	height: var(--h);
	font-size: 0.5rem;
	text-align: center;
	line-height: calc(var(--h) - 0.4rem - 2px);
}

.grid .cell.solved {
	background: #ddffcc;
	font-size: 1.5rem;
}

.grid.hex {
	--h: 3rem;
	--d: 3.8rem;
	--sx: var(--d);
	--sy: calc(var(--d) * 0.866025403784439); /* sqrt(3)/2 */
	margin: 13rem auto;
	min-width: 1px;
	min-height: 1px;
}

.grid.hex button {
	width: 2rem;
	height: 2rem;
	margin: -1rem;
}

.grid.hex button[name='add-d1'],
.grid.hex button[name='remove-d1'] {
	transform: rotate(120deg);
}
.grid.hex button[name='add-d3'],
.grid.hex button[name='remove-d3'] {
	transform: rotate(-120deg);
}

.grid.hex .pattern,
.grid.hex .cell {
	margin: calc(var(--h) * -0.5);
}
.grid .pattern.d1,
.grid .pattern.d2,
.grid .pattern.d3 {
	margin-left: calc(-12rem - var(--h) * -0.5);
	width: 12rem;
	height: var(--h);
	text-align: right;
	border-top-left-radius: 5px;
	border-bottom-left-radius: 5px;
	border-top-right-radius: 100px;
	border-bottom-right-radius: 100px;
	transform-origin: calc(12rem - var(--h) / 2) calc(var(--h) / 2);
}
.grid .pattern.d1 {
	transform: rotate(120deg);
}
.grid .pattern.d3 {
	transform: rotate(-120deg);
}

.grid.hex .cell {
	border-radius: 100%;
	width: var(--h);
}

.error {
	grid-column: 1 / 3;
	font-size: 0.9rem;
	line-height: 1rem;
	font-style: italic;
	color: #800000;
	min-height: 2rem;
}

footer {
	margin: 20px 0;
	text-align: center;
	font-size: 0.9rem;
	color: #666666;
}

footer a:link,
footer a:visited {
	text-decoration: underline;
	color: #445599;
}

footer a:active,
footer a:hover {
	text-decoration: none;
	color: #5566bb;
}

/* tab control */

.tabbox {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
}

.tabbox > input {
	position: absolute;
	top: -100px;
}

.tabbox > label:first-of-type {
	margin-left: 0.5rem;
}

.tabbox > label {
	position: relative;
	padding: 0.6rem 1rem 0.5rem;
	cursor: pointer;
	border: 2px solid transparent;
	border-bottom: none;
	border-top-left-radius: 3px;
	border-top-right-radius: 3px;
	z-index: 1;
}

.tabbox > input:checked + label {
	background: white;
	border-color: #ccccdd;
	padding: 0.5rem 1rem 0.6rem;
}

.tabbox > input:focus + label::after {
	content: '';
	position: absolute;
	top: 0.3rem;
	left: 0.3rem;
	right: 0.3rem;
	bottom: 0.4rem;
	border: 2px solid #0080ff;
	border-radius: 5px;
}

.tabbox > .tabcontent {
	display: none;
	flex: 100%;
	margin-top: -2px;
	border: 2px solid #ccccdd;
	background: white;
	padding: 1.5rem;
	border-radius: 3px;
}

#t1:checked ~ .tabcontent[data-for='t1'],
#t2:checked ~ .tabcontent[data-for='t2'],
#t3:checked ~ .tabcontent[data-for='t3'] {
	display: block;
}

/* loading info */

#noscript-overlay {
	position: fixed;
	display: flex;
	background: rgba(240, 240, 240, 0.8);
	backdrop-filter: blur(2px);
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 1rem;
	align-items: center;
	justify-content: center;
	z-index: 10;
}

#loading {
	position: fixed;
	top: 0;
	left: 0;
	display: inline-block;
	background: white;
	padding: 0.5rem 1.5rem 0.5rem 1rem;
}
