:root {
	--felt: #0c6b3a;
	--felt-deep: #084828;
	--card-w: 92px;
	--card-h: 128px;
	--radius: 10px;
	--overlap-down: 22px;
	--overlap-up: 34px;
	--ink: #172033;
	--red: #c0392b;
	--gold: #f0c14a;
	--shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
	color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	min-height: 100%;
}

body {
	font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
	color: #f4f7f2;
	background:
		radial-gradient(1200px 500px at 50% -10%, rgba(255, 255, 255, 0.08), transparent 60%),
		linear-gradient(180deg, var(--felt) 0%, var(--felt-deep) 100%);
	min-height: 100vh;
}

button, .card, .slot { touch-action: manipulation; }

#app {
	max-width: 1100px;
	margin: 0 auto;
	padding: 16px 16px 28px;
}

header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 8px;
}

h1 {
	font-size: 2rem;
	line-height: 1;
	margin: 0;
	letter-spacing: 0.02em;
}

.title p {
	margin: 4px 0 0;
	opacity: 0.8;
	font-size: 0.95rem;
}

.scorebox {
	background: rgba(0, 0, 0, 0.22);
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 12px;
	padding: 8px 14px 10px;
	min-width: 96px;
	text-align: right;
}

.scorebox span {
	display: block;
	font-size: 0.75rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.75;
}

.scorebox strong {
	font-size: 1.8rem;
	line-height: 1;
}

.mode-indicator {
	display: block;
	margin-top: 4px;
	font-size: 0.75rem;
	letter-spacing: 0.04em;
	opacity: 0.8;
}

.mode-label {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.95rem;
}

.mode-label select {
	font: inherit;
	color: #102017;
	background: #f4f1e4;
	border: 0;
	border-radius: 999px;
	padding: 10px 14px;
	box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.message {
	min-height: 1.4em;
	margin: 0 0 12px;
	font-size: 1.05rem;
}

.board { display: flex; flex-direction: column; gap: 18px; }

.top {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	align-items: flex-start;
}

.stock-waste, .foundations {
	display: flex;
	gap: 10px;
}

.tableau {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 8px;
	align-items: start;
}

.slot, .pile {
	width: var(--card-w);
	min-height: var(--card-h);
	position: relative;
}

.pile { width: 100%; display: flex; flex-direction: column; align-items: center; }

.empty, .card {
	width: var(--card-w);
	height: var(--card-h);
	border-radius: var(--radius);
}

.empty.red { color: rgba(255, 180, 170, 0.7); }

.empty {
	border: 2px dashed rgba(255, 255, 255, 0.28);
	background: rgba(0, 0, 0, 0.12);
	color: rgba(255, 255, 255, 0.45);
	display: grid;
	place-items: center;
	font-size: 1.6rem;
}

.card {
	position: relative;
	background: #fffef8;
	color: var(--ink);
	box-shadow: var(--shadow);
	border: 0;
	padding: 6px 8px;
	text-align: left;
	cursor: pointer;
	font: inherit;
	line-height: 1;
}

.card .rank { font-size: 1.25rem; font-weight: 700; }
.card .pip {
	position: absolute;
	left: 0;
	right: 0;
	top: 42%;
	text-align: center;
	font-size: 1.8rem;
}
.card.red { color: var(--red); }
.card.back {
	background:
		repeating-linear-gradient(135deg, #1d4e89 0 8px, #163e70 8px 16px);
	color: transparent;
	box-shadow: var(--shadow), inset 0 0 0 3px rgba(255, 255, 255, 0.35);
	cursor: default;
}
.card.small-peek { margin-top: calc(var(--overlap-down) - var(--card-h)); }
.card.big-peek { margin-top: calc(var(--overlap-up) - var(--card-h)); }
.pile .card:first-child, .slot .card { margin-top: 0; }

.card.selected {
	outline: 3px solid var(--gold);
	transform: translateY(-8px);
	z-index: 2;
}
.card.hinted, .empty.hinted, .slot.hinted .empty, .slot.hinted {
	outline: 3px solid #8fd0ff;
	border-radius: var(--radius);
}
.empty.legal, .card.legal {
	outline: 3px solid rgba(240, 193, 74, 0.9);
}
.slot.legal .empty { outline: 3px solid rgba(240, 193, 74, 0.9); }

button {
	font: inherit;
	font-size: 1rem;
	color: #102017;
	background: #f4f1e4;
	border: 0;
	border-radius: 999px;
	padding: 10px 16px;
	cursor: pointer;
	box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--gold); }
button.stop { background: #f0b4a0; }

.controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 18px;
}

.help {
	max-width: 70ch;
	opacity: 0.85;
	font-size: 0.95rem;
	line-height: 1.4;
}

.overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	display: grid;
	place-items: center;
	padding: 20px;
	z-index: 5;
}
.overlay.hidden { display: none; }
.dialog {
	background: #f7f4ea;
	color: #1b241c;
	border-radius: 18px;
	padding: 24px 22px;
	width: min(420px, 100%);
	box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 8px; font-size: 2rem; }
.dialog ol { padding-left: 1.2rem; }
.dialog li { margin: 2px 0; }

@media (max-width: 800px) {
	:root {
		--card-w: 46px;
		--card-h: 66px;
		--overlap-down: 12px;
		--overlap-up: 20px;
		--radius: 7px;
	}
	h1 { font-size: 1.5rem; }
	.card { padding: 3px 4px; }
	.card .rank { font-size: 0.85rem; }
	.card .pip { font-size: 1rem; top: 46%; }
	.scorebox strong { font-size: 1.4rem; }
	.top { gap: 6px; }
	.stock-waste, .foundations { gap: 4px; }
	.tableau { gap: 3px; }
	.controls button { flex: 1 1 calc(33% - 8px); padding: 12px 8px; }
}

@media (prefers-reduced-motion: reduce) {
	.card.selected { transform: none; }
}
