/* Screen: Pub-Karte, warmes Layout */
:root {
	--bg-top: #2d4a3e;
	--bg-bottom: #1a2e26;
	--paper: #fffef8;
	--paper-edge: #e8e4d8;
	--ink: #1a1a1a;
	--accent: #b8860b;
	--accent-dark: #8a6410;
	--shuffle-bg: rgba(45, 74, 62, 0.08);
	--focus: #2d6a4f;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	padding: 1rem 0.75rem 2rem;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	background: linear-gradient(165deg, var(--bg-top) 0%, var(--bg-bottom) 55%, #0f1a15 100%);
	background-attachment: fixed;
	color: var(--ink);
	min-height: 100vh;
}

.app {
	max-width: 42rem;
	margin: 0 auto;
}

/* Papier-Karte mit Schatten */
.card-shell {
	background: var(--paper);
	border: 1px solid var(--paper-edge);
	border-radius: 12px;
	padding: 1.25rem 1rem 1.35rem;
	box-shadow:
		0 4px 6px rgba(0, 0, 0, 0.12),
		0 12px 28px rgba(0, 0, 0, 0.22),
		inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.card-header {
	text-align: center;
	margin-bottom: 1.15rem;
	padding-bottom: 0.85rem;
	border-bottom: 2px solid var(--accent);
}

.card-id {
	font-family: "Courier New", Courier, monospace;
	font-size: 0.7rem;
	letter-spacing: 0.02em;
	color: #444;
	margin: 0 0 0.55rem;
	text-align: left;
}

.card-title {
	font-family: Georgia, "Times New Roman", serif;
	font-size: clamp(1.35rem, 5vw, 1.9rem);
	font-weight: 600;
	margin: 0;
	line-height: 1.15;
	color: #142018;
}

.shuffle-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	margin-bottom: 1.1rem;
	padding: 0.65rem 0.85rem;
	background: var(--shuffle-bg);
	border-radius: 10px;
	border: 1px solid rgba(45, 74, 62, 0.15);
}

.shuffle-bar__label {
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--accent-dark);
}

.card-nr-form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	flex: 1 1 12rem;
	min-width: 0;
	margin: 0;
}

.shuffle-bar__input {
	width: 8.5rem;
	max-width: 100%;
	padding: 0.45rem 0.6rem;
	border: 1px solid #b8b4a8;
	border-radius: 8px;
	font: inherit;
	font-size: 0.9rem;
	background: #fff;
}

.shuffle-bar__input--grow {
	flex: 1 1 7rem;
	width: auto;
	min-width: 6rem;
	max-width: 100%;
}

.shuffle-bar__input:focus {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

.shuffle-bar__btn {
	padding: 0.5rem 1rem;
	border: none;
	border-radius: 8px;
	background: linear-gradient(180deg, #3d6b55 0%, #2d4a3e 100%);
	color: #fff;
	font: inherit;
	font-size: 0.85rem;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.shuffle-bar__btn:hover {
	filter: brightness(1.06);
}

.shuffle-bar__btn--secondary {
	background: linear-gradient(180deg, #5a6b62 0%, #3d4a44 100%);
}

.shuffle-bar__btn:focus {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

.grid {
	display: grid;
	grid-template-rows: repeat(4, 1fr);
	gap: 0;
	width: 100%;
	border: 1px solid #000;
	border-radius: 4px;
	overflow: hidden;
	background: #fff;
}

.grid-row {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	min-height: 0;
}

.grid-cell {
	border: 1px solid #000;
	margin: -1px 0 0 -1px;
	min-height: 4.5rem;
	display: flex;
	align-items: stretch;
	justify-content: stretch;
}

.cell-btn {
	width: 100%;
	min-height: 4.5rem;
	margin: 0;
	padding: 0.35rem;
	border: none;
	background: #fff;
	font: inherit;
	font-size: clamp(0.65rem, 2.8vw, 0.95rem);
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	position: relative;
	color: var(--ink);
	-webkit-tap-highlight-color: transparent;
}

.cell-btn:focus {
	outline: 2px solid var(--focus);
	outline-offset: -2px;
	z-index: 1;
}

.cell-btn--emphasis {
	font-size: clamp(1rem, 4.5vw, 1.35rem);
	font-weight: 700;
}

.cell-btn:hover {
	background: #faf9f4;
}

.cell-btn.marked::after {
	content: "";
	position: absolute;
	inset: 8%;
	border: none;
	background: linear-gradient(
		to top right,
		transparent calc(50% - 2px),
		#c00 calc(50% - 2px),
		#c00 calc(50% + 2px),
		transparent calc(50% + 2px)
	),
	linear-gradient(
		to top left,
		transparent calc(50% - 2px),
		#c00 calc(50% - 2px),
		#c00 calc(50% + 2px),
		transparent calc(50% + 2px)
	);
	pointer-events: none;
	opacity: 0.85;
}

.error {
	max-width: 36rem;
	margin: 2rem auto;
	padding: 1rem 1.25rem;
	background: #fee;
	border: 1px solid #c00;
	border-radius: 8px;
	color: #600;
	text-align: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.print-batch-ctrl {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.6rem;
	width: 100%;
	justify-content: flex-start;
	margin-top: 0.25rem;
}

.shuffle-bar__input--count {
	width: 3.75rem;
	min-width: 3rem;
	flex: 0 0 auto;
}

/* Wort-Editor */
.word-editor {
	margin-bottom: 1.1rem;
	border: 1px solid rgba(45, 74, 62, 0.15);
	border-radius: 10px;
	background: var(--shuffle-bg);
	overflow: hidden;
}

.word-editor__toggle {
	display: block;
	padding: 0.6rem 0.9rem;
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--accent-dark);
	cursor: pointer;
	user-select: none;
	list-style: none;
}

.word-editor__toggle::-webkit-details-marker {
	display: none;
}

.word-editor__toggle::before {
	content: "▶ ";
	font-size: 0.65em;
}

.word-editor[open] .word-editor__toggle::before {
	content: "▼ ";
}

.word-editor__body {
	padding: 0 0.9rem 0.9rem;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.word-editor__textarea {
	width: 100%;
	padding: 0.55rem 0.65rem;
	border: 1px solid #b8b4a8;
	border-radius: 8px;
	font: inherit;
	font-size: 0.85rem;
	line-height: 1.5;
	resize: vertical;
	background: #fff;
}

.word-editor__textarea:focus {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

.word-editor__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.65rem;
}

.word-editor__hint {
	font-size: 0.78rem;
	color: #3d6b55;
}

.word-editor__hint--error {
	color: #c00;
}

@media print {
	.word-editor { display: none !important; }
}

/* Mehrere Karten: Screen ausblenden, nur Stapel (bis print) */
.print-stack {
	display: none;
}

body.print-batch-mode .app {
	display: none !important;
}

body.print-batch-mode .print-stack {
	display: block;
}

body.print-batch-mode {
	background: #fff;
	padding: 0;
}

/* Druck: A4 Hochformat, klare Linien, keine Schatten */
@media print {
	@page {
		size: A4 portrait;
		margin: 16mm 18mm 20mm;
	}

	body {
		background: #fff !important;
		padding: 0;
	}

	/* Keine Screen-Dekoration im Druck */
	body,
	.app,
	.card-shell,
	.grid,
	.grid-cell,
	.cell-btn,
	.card-header {
		box-shadow: none !important;
		text-shadow: none !important;
		filter: none !important;
	}

	.card-shell {
		border: none;
		border-radius: 0;
		padding: 0;
		background: #fff !important;
		max-width: 170mm;
		margin: 0 auto;
	}

	.shuffle-bar {
		display: none !important;
	}

	.print-stack__page {
		page-break-after: always;
		page-break-inside: avoid;
	}

	.print-stack__page:last-child {
		page-break-after: auto;
	}

	.app {
		max-width: none;
		margin: 0;
		min-height: 0;
		padding-top: 0;
	}

	.card-header {
		margin: 0 0 10mm;
		padding: 0 0 4mm;
		border-bottom: 0.6pt solid #000;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.card-id {
		font-size: 8.5pt;
		text-align: left;
		color: #000 !important;
		margin: 0 0 2mm;
	}

	.card-title {
		font-size: 20pt;
		text-align: center;
		color: #000 !important;
		margin: 0;
		font-weight: 700;
	}

	/*
	 * Tabelle + border-collapse: durchgehende schwarze Gitterlinien
	 * (1px-Grid mit negativem Margin wirkt in der Druckvorschau oft zu dünn.)
	 */
	.grid {
		display: table;
		width: 100%;
		max-width: 155mm;
		margin: 0 auto;
		table-layout: fixed;
		border-collapse: collapse;
		border: 1.25pt solid #000;
		border-radius: 0;
		overflow: visible;
		background: #fff !important;
		page-break-inside: avoid;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.grid-row {
		display: table-row;
	}

	.grid-cell {
		display: table-cell;
		margin: 0;
		vertical-align: middle;
		width: 25%;
		min-height: 0;
		height: 30mm;
		padding: 0;
		border: 0.75pt solid #000;
		background: #fff !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.cell-btn {
		display: block;
		width: 100%;
		min-height: 30mm;
		height: 30mm;
		margin: 0;
		padding: 1.5mm 1mm;
		font-size: 7.5pt;
		line-height: 1.15;
		cursor: default;
		color: #000 !important;
		background: #fff !important;
		border: none !important;
		outline: none !important;
		box-shadow: none !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.cell-btn--emphasis {
		font-size: 11pt;
		font-weight: 700;
	}

	.cell-btn.marked::after {
		display: none !important;
	}
}
