:root {
	--primary: #3B82F6;
	--primary-hover: #2563EB;
	--success: #10B981;
	--success-hover: #059669;
	--danger: #EF4444;
	--danger-hover: #DC2626;

	--background: #121212;
	--surface: #1E1E1E;
	--surface-alt: #2D2D2D;

	--text-main: #F3F4F6;
	--text-muted: #9CA3AF;
	--border: #404040;

	--header-border: var(--primary);
	--radius: 8px;

	--action-btn-border: #6B7280;
}

body.light-mode {
	--primary: #2563EB;
	--primary-hover: #1D4ED8;
	--success: #10B981;
	--success-hover: #059669;
	--danger: #EF4444;
	--danger-hover: #DC2626;

	--background: #E2E8F0;
	--surface: #FFFFFF;
	--surface-alt: #F1F5F9;

	--text-main: #0F172A;
	--text-muted: #64748B;
	--border: #CBD5E1;

	--header-border: var(--primary);

	--action-btn-border: #9CA3AF;
}

* {
	box-sizing: border-box;
}

button,
input {
	touch-action: manipulation;
}

body {
	font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	background-color: var(--background);
	color: var(--text-main);
	margin: 0;
	padding: 20px;
	line-height: 1.5;
	transition: background-color 0.3s ease, color 0.3s ease;
	padding-top: 40px;
}

#themeToggle {
	position: absolute;
	top: 15px;
	right: 15px;
	z-index: 1000;
	background: transparent;
	border: none;
	font-size: 26px;
	cursor: pointer;
	color: var(--text-main);
	padding: 5px;
	transition: transform 0.2s;
}

#themeToggle:hover {
	transform: scale(1.15);
	background: transparent;
}

.drag-handle {
	cursor: grab;
	margin-right: 10px;
	font-size: 20px;
	color: var(--text-muted);
	user-select: none;
}

.drag-handle:active {
	cursor: grabbing;
}

.cat-item.dragging {
	opacity: 0.4;
}

.app-container {
	max-width: 1000px;
	margin: 30px auto 0;
	background: var(--surface);
	padding: 30px;
	border-radius: var(--radius);
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
	position: relative;
	transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.hidden {
	display: none !important;
}

.text-danger {
	color: var(--danger) !important;
}

.header-logo-container {
	text-align: center;
	margin-top: 0;
	padding-bottom: 15px;
	margin-bottom: 20px;
	border-bottom: 2px solid var(--border);
}

.game-logo {
	max-width: 100%;
	height: auto;
	max-height: 250px;
	display: inline-block;
}

h2,
h3 {
	color: var(--text-main);
}

p {
	margin: 10px 0;
}

button {
	background-color: var(--primary);
	color: white;
	border: none;
	border-radius: 4px;
	padding: 10px 16px;
	font-size: 14px;
	cursor: pointer;
	transition: background-color 0.2s, transform 0.1s, border-color 0.2s;
	font-family: inherit;
	font-weight: 500;
}

button:hover {
	background-color: var(--primary-hover);
}

button:active {
	transform: scale(0.98);
}

button:disabled {
	background-color: var(--border);
	color: var(--text-muted);
	cursor: not-allowed;
	transform: none;
	border-color: transparent;
}

button.action-btn {
	background-color: transparent;
	margin-left: 10px;
	font-size: 13px;
	padding: 8px 14px;
	color: var(--text-main);
	border: 1px solid var(--action-btn-border);
	font-weight: 600;
}

button.action-btn:hover {
	background-color: var(--surface-alt);
	border-color: var(--text-main);
}

button.btn-red {
	background-color: var(--danger);
	color: white;
	border: none;
}

button.btn-red:hover {
	background-color: var(--danger-hover);
	border: none;
}

button.btn-success {
	background-color: var(--success);
	font-size: 16px;
	padding: 12px 20px;
	width: 100%;
	margin-top: 10px;
}

button.btn-success:hover {
	background-color: var(--success-hover);
}

button.btn-secondary {
	background-color: var(--surface-alt);
	color: var(--text-main);
	border: 1px solid var(--border);
}

button.btn-secondary:hover {
	background-color: var(--border);
}

/* Flex Controls (für mobile Darstellung nebeneinander/untereinander) */
.flex-controls {
	margin-top: 20px;
	display: flex;
	gap: 15px;
	flex-wrap: wrap;
	justify-content: center;
}

.flex-controls button {
	flex: 1;
	min-width: 200px;
	margin: 0 !important;
}

input[type="text"],
input[type="number"] {
	width: 100%;
	padding: 10px;
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: 16px;
	font-family: inherit;
	background-color: var(--background);
	color: var(--text-main);
	transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Eigene animierte Checkboxen */
input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	background-color: var(--background);
	margin: 0 6px 0 0;
	font: inherit;
	color: currentColor;
	width: 1.25em;
	height: 1.25em;
	border: 2px solid var(--border);
	border-radius: 4px;
	display: inline-grid;
	place-content: center;
	cursor: pointer;
	transition: background-color 0.3s ease, border-color 0.3s ease;
	vertical-align: middle;
	transform: translateY(-2px);
}

input[type="checkbox"]::before {
	content: "";
	width: 0.7em;
	height: 0.7em;
	transform: scale(0);
	transition: transform 0.3s ease-in-out;
	background-color: white;
	clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:checked {
	background-color: var(--primary);
	border-color: var(--primary);
}

input[type="checkbox"]:checked::before {
	transform: scale(1);
}

input[type="checkbox"]:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Category Editor & Animationen */
@keyframes slideInFade {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.cat-item {
	display: flex;
	align-items: center;
	margin-bottom: 10px;
	transition: opacity 0.2s ease;
	background-color: transparent;
	gap: 8px;
	background: var(--surface-alt);
	padding: 6px 8px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	animation: slideInFade 0.15s ease-out forwards;
}

.cat-item input {
	flex: 1;
	padding: 6px;
}

.btn-cat-move {
	background: transparent;
	color: var(--text-main);
	border: none;
	padding: 0 4px;
	font-size: 16px;
}

.btn-cat-move:hover {
	background: var(--border);
}

.btn-cat-move:disabled {
	color: var(--border);
	cursor: default;
	background: transparent !important;
}

.btn-cat-remove {
	background: transparent;
	color: var(--danger);
	border: none;
	padding: 0 4px;
	font-size: 18px;
}

.btn-cat-remove:hover {
	background: transparent;
	color: var(--danger-hover);
	transform: scale(1.1);
}

.btn-cat-remove:disabled {
	background: transparent !important;
	color: var(--border);
	cursor: default;
	transform: none;
}

/* Category Pills (Guest View) */
.cat-pill-container {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
	margin-bottom: 25px;
}

.cat-pill {
	background: var(--surface);
	border: 1px solid var(--border);
	padding: 6px 14px;
	border-radius: 20px;
	font-weight: 500;
}

.input-group {
	margin-bottom: 20px;
}

#categoryInputs {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 15px;
	margin-bottom: 20px;
}

.host-only {
	border: 1px solid var(--border);
	padding: 20px;
	border-radius: var(--radius);
	margin-bottom: 20px;
	background-color: var(--surface);
}

#lobbyHeader {
	margin-bottom: 30px;
	padding-bottom: 25px;
	border-bottom: 3px solid var(--header-border);
}

.info-box {
	background-color: var(--surface-alt);
	padding: 15px;
	margin-bottom: 15px;
	border-left: 4px solid var(--primary);
	border-radius: 0 var(--radius) var(--radius) 0;
}

.note-text {
	font-size: 13px;
	color: var(--text-muted);
}

ul {
	padding-left: 20px;
	margin-top: 5px;
}

li {
	margin-bottom: 8px;
}

.disconnected-list {
	color: var(--text-muted);
	font-style: italic;
	list-style-type: circle;
}

.offline-player {
	color: var(--text-muted);
	font-style: italic;
}

.point-display {
	display: block;
	margin-top: 5px;
	font-weight: 600;
	color: var(--primary);
	font-style: normal;
}

.point-display.host-view {
	border-bottom: 1px dashed var(--primary);
	cursor: pointer;
}

.point-display.super-voted {
	color: #FCD34D !important;
}

.point-input {
	margin-top: 5px;
	width: 60px !important;
	text-align: center;
}

.vote-btn {
	background: var(--surface-alt);
	border: 1px solid var(--border);
	color: var(--text-main);
	cursor: pointer;
	border-radius: 20px;
	padding: 5px 12px;
	font-size: 13px;
	margin-top: 8px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	transition: all 0.2s ease;
	font-weight: 600;
}

.vote-btn:hover:not([disabled]),
.vote-btn.voted {
	background-color: #B91C1C;
	border-color: #B91C1C;
	color: #FFFFFF;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.vote-btn.host-voted {
	border: 2px solid #FCD34D;
}

.vote-btn.voted.host-voted {
	background-color: #B91C1C;
	border-color: #FCD34D;
}

.v-count {
	font-weight: bold;
}

#rollingLetterDisplay {
	font-size: 80px;
	font-weight: 800;
	margin: 30px 0;
	color: var(--primary);
	text-align: center;
}

#timerDisplay {
	text-align: center;
	color: var(--text-main);
	font-size: 24px;
	margin-bottom: 20px;
}

/* Podium */
.podium-list {
	list-style-type: none;
	padding: 0;
	text-align: center;
}

.podium-list li {
	margin-bottom: 10px;
	padding: 15px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: var(--surface-alt);
}

.podium-list li:nth-child(1) {
	background: #FEF08A;
	font-weight: bold;
	font-size: 24px;
	border-color: #FDE047;
	color: #1F2937;
}

.podium-list li:nth-child(2) {
	background: #E2E8F0;
	font-weight: bold;
	font-size: 20px;
	color: #1F2937;
}

.podium-list li:nth-child(3) {
	background: #FFEDD5;
	font-weight: bold;
	font-size: 18px;
	border-color: #FDBA74;
	color: #1F2937;
}

/* Modals & Overlays */
#connectionOverlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	background: #F59E0B;
	color: #fff;
	text-align: center;
	padding: 10px;
	font-weight: bold;
	z-index: 10000;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#customAlertBox,
#customConfirmBox {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.7);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	backdrop-filter: blur(3px);
}

.modal-content {
	background: var(--surface);
	padding: 25px;
	border-radius: var(--radius);
	text-align: center;
	max-width: 400px;
	width: 90%;
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
	border: 1px solid var(--border);
}

.modal-content p {
	margin-top: 0;
	white-space: pre-wrap;
	font-size: 16px;
	margin-bottom: 20px;
}

.modal-content button {
	margin: 0 5px;
}

@media (max-width: 600px) {
	body {
		padding: 10px;
	}

	.app-container {
		padding: 15px;
		margin-top: 40px;
	}

	#themeToggle {
		top: 5px;
		right: 5px;
	}

	#rollingLetterDisplay {
		font-size: 60px;
	}

	.action-btn {
		margin-left: 0;
		display: inline-block;
	}
}

#playerList,
#disconnectedPlayerList {
	list-style-type: none;
	padding: 0;
	margin: 0;
}

.player-list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background-color: var(--surface-alt);
	padding: 10px 15px;
	margin-bottom: 10px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	flex-wrap: wrap;
	gap: 10px;
}

.player-actions {
	display: flex;
	gap: 10px;
}

.player-actions button {
	margin: 0;
}

.site-footer {
	text-align: center;
	margin-top: 30px;
	padding-bottom: 10px;
	color: var(--text-muted);
	font-size: 0.85em;
	opacity: 0.7;
}

.cat-item.dragging {
	position: fixed;
	z-index: 1000;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
	pointer-events: none;
	margin: 0;
	opacity: 1;
}

.cat-item-placeholder {
	border: 2px dashed var(--primary, #007bff);
	border-radius: 4px;
	background: transparent;
	margin-bottom: 10px;
	box-sizing: border-box;
}

.drag-handle {
	cursor: grab;
	touch-action: none;
}

.drag-handle:active {
	cursor: grabbing;
}

label {
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.points-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	column-gap: clamp(20px, 8%, 150px);
	row-gap: 15px;
	margin-bottom: 20px;
	margin-top: 10px;
	max-width: 900px;
}

.point-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
}

@media (max-width: 650px) {
	.points-grid {
		grid-template-columns: 1fr;
		column-gap: 0;
	}
}

/* --- Scoreboard Tabelle Modern --- */
.table-responsive {
	overflow-x: auto;
	width: 100%;
	margin-top: 15px;
	margin-bottom: 25px;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 12px;
}

.scoreboard-table {
	width: max-content;
	min-width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	background-color: var(--surface);
}

.table-responsive::-webkit-scrollbar {
	height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
	background: transparent;
	margin: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
	background: var(--text-muted);
}

.scoreboard-table th,
.scoreboard-table td {
	border-bottom: 1px solid var(--border);
	border-right: 1px solid var(--border);
	padding: 12px 20px;
	text-align: center;
	vertical-align: middle;
	white-space: nowrap;
	transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.scoreboard-table thead tr:first-child th {
	border-top: 1px solid var(--border);
}

.scoreboard-table th:first-child,
.scoreboard-table td:first-child {
	border-left: 1px solid var(--border);
}

.scoreboard-table thead tr:first-child th:first-child {
	border-top-left-radius: 8px;
}

.scoreboard-table thead tr:first-child th:last-child {
	border-top-right-radius: 8px;
}

.scoreboard-table tbody tr:last-child td:first-child {
	border-bottom-left-radius: 8px;
}

.scoreboard-table tbody tr:last-child td:last-child {
	border-bottom-right-radius: 8px;
}

.scoreboard-table thead tr:first-child th:first-child::before {
	content: "";
	position: absolute;
	top: -1px;
	left: -1px;
	width: 12px;
	height: 12px;
	border-top-left-radius: 8px;
	box-shadow: -6px -6px 0 6px var(--surface);
	pointer-events: none;
	z-index: 10;
}

.scoreboard-table tbody tr:last-child td:first-child::after {
	content: "";
	position: absolute;
	bottom: -1px;
	left: -1px;
	width: 12px;
	height: 12px;
	border-bottom-left-radius: 8px;
	box-shadow: -6px 6px 0 6px var(--surface);
	pointer-events: none;
	z-index: 10;
}

.scoreboard-table thead th {
	background-color: var(--surface-alt);
	font-weight: 600;
	color: var(--text-main);
	position: relative;
}

.round-letter {
	font-size: 0.85em;
	font-weight: normal;
	opacity: 0.8;
}

.col-player {
	position: sticky;
	left: 0;
	z-index: 2;
	background-color: var(--surface);
	text-align: left;
	box-shadow: 3px 0 6px -3px rgba(0, 0, 0, 0.2);
	padding-left: 10px;
}

.scoreboard-table thead th.col-player {
	position: sticky;
	left: 0;
	z-index: 3;
	background-color: var(--surface-alt);
}

.col-total {
	background-color: var(--surface-alt);
}

.col-round {
	min-width: 50px;
	position: relative;
}

.scoreboard-table tbody td:hover {
	background-color: rgba(255, 255, 255, 0.08);
}

body.light-mode .scoreboard-table tbody td:hover {
	background-color: rgba(0, 0, 0, 0.08);
}

.scoreboard-table tbody td.col-player:hover {
	background-color: var(--surface-alt);
}

.latest-round-col {
	background-color: rgba(16, 185, 129, 0.15) !important;
	color: var(--success) !important;
	font-weight: bold;
}

.latest-round-cell {
	color: var(--success);
	font-weight: bold;
	background-color: rgba(16, 185, 129, 0.05);
}

.text-muted {
	color: var(--text-muted);
	opacity: 0.6;
}

@media (max-width: 600px) {

	.scoreboard-table th,
	.scoreboard-table td {
		padding: 10px 8px;
		font-size: 14px;
	}

	.col-round {
		min-width: 45px;
	}

	.col-player {
		padding-left: 14px;
	}

	.round-letter {
		font-size: 0.75em;
	}
}

.scroll-buttons {
	position: fixed;
	bottom: 20px;
	right: 20px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	z-index: 9999;
}

.scroll-buttons button {
	width: 45px;
	height: 45px;
	border-radius: 50%;
	background-color: var(--primary);
	color: #ffffff;
	border: none;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s, visibility 0.3s, transform 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.2em;
}

@media (hover: hover) {
	.scroll-buttons button:hover {
		background-color: var(--primary-hover);
		transform: scale(1.1);
	}
}

.scroll-buttons button.visible {
	opacity: 1;
	visibility: visible;
}

.best-of-round {
	color: #ffca28 !important;
	font-weight: bold;
}

.round-star {
	position: absolute;
	left: calc(50% + 15px);
	top: 50%;
	transform: translateY(-50%);
	font-size: 0.85em;
	color: #ffca28;
	pointer-events: none;
}

.scoreboard-table.evaluation-table th.col-player,
.scoreboard-table.evaluation-table td.col-player {
	text-align: center;
	padding-left: 15px;
	padding-right: 15px;
	vertical-align: middle;
}

@media (max-width: 600px) {

	.scoreboard-table.evaluation-table th.col-player,
	.scoreboard-table.evaluation-table td.col-player {
		padding-left: 8px;
		padding-right: 8px;
	}
}

.cell-highlight {
	background-color: rgba(59, 130, 246, 0.15);
	box-shadow: inset 0 0 0 2px var(--primary);
}

body.light-mode .cell-highlight {
	background-color: rgba(37, 99, 235, 0.1);
}

.scoreboard-table tbody td.cell-highlight:hover {
	background-color: rgba(59, 130, 246, 0.25);
}

body.light-mode .scoreboard-table tbody td.cell-highlight:hover {
	background-color: rgba(37, 99, 235, 0.2);
}

.scoreboard-table tbody tr {
	transition: background-color 0.2s ease;
}

#lobbyPlayersSection {
	max-height: 2000px;
	opacity: 1;
	overflow: hidden;
	transition: max-height 0.3s ease, opacity 0.3s ease;
}

#lobbyPlayersSection.collapsed {
	max-height: 0;
	opacity: 0;
	pointer-events: none;
}

.scoreboard-table.evaluation-table td {
	height: 1px;
	white-space: normal;
}

.eval-answer {
	flex-grow: 1;
	margin-bottom: 10px;
	word-break: break-word;
}

.eval-cell-wrapper {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.eval-controls {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
}