/* PlayScrab TNG theme: modern with a subtle retro neon vibe */

:root {
	--bg: #0f1115;
	--bg-2: #141820;
	--bg-3: #1a1f2a;
	--text: #e5e7eb;
	--text-dim: #9ca3af;
	--heading: #d6b36a; /* warm brass for titles/menus */
	--accent: #2dd4bf; /* teal */
	--accent-2: #ec4899; /* magenta */
	--accent-3: #f59e0b; /* amber for highlights */
	--border: rgba(255, 255, 255, 0.08);
	--shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
	--radius: 12px;
	--transition: 180ms ease;
	--font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
	--font-mono: "JetBrains Mono", "Space Mono", "SFMono-Regular", Consolas, monospace;
	--surface-contrast: #ffffff;
	--btn-text: #0b0d12;
}

:root[data-theme="light"] {
	--bg: #f4f6fb;
	--bg-2: #ffffff;
	--bg-3: #eef2f8;
	--text: #18202b;
	--text-dim: #455365;
	--heading: #6a4d14;
	--accent: #0f766e;
	--accent-2: #be185d;
	--accent-3: #b45309;
	--border: rgba(24, 32, 43, 0.14);
	--shadow: 0 12px 30px rgba(24, 32, 43, 0.13);
	--surface-contrast: #f8fbff;
	--btn-text: #f8fbff;
}

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

html {
	background: var(--bg);
	color: var(--text);
}

body {
	margin: 0;
	min-height: 100vh;
	font-family: var(--font-body);
	background: radial-gradient(circle at 20% 20%, rgba(45, 212, 191, 0.06), transparent 35%),
		radial-gradient(circle at 80% 0%, rgba(236, 72, 153, 0.08), transparent 30%),
		var(--bg);
	color: var(--text);
	-webkit-font-smoothing: antialiased;
	padding: 16px;
}

body::after {
	/* light scanline texture for retro hint */
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(rgba(255, 255, 255, 0.02) 50%, transparent 50%);
	background-size: 100% 2px;
	mix-blend-mode: soft-light;
	opacity: 0.2;
}

a {
	color: var(--accent);
	text-decoration: none;
	transition: color var(--transition), text-shadow var(--transition);
}

a:hover {
	color: var(--accent-2);
	text-shadow: 0 0 8px rgba(236, 72, 153, 0.45);
}

h1,
h2,
h3,
h4 {
	font-family: var(--font-mono);
	letter-spacing: 0.02em;
	margin: 0 0 8px;
	color: var(--heading);
}

p {
	margin: 0 0 10px;
	color: var(--text-dim);
}

main,
.page {
	max-width: 1080px;
	margin: 0 auto;
}

/* Cards / panels */
.card {
	background: linear-gradient(145deg, var(--bg-2), var(--bg-3));
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
}

.section {
	margin-bottom: 16px;
}

/* Forms */
form {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
}

label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #f7f7fa;
	font-size: 14px;
}

input,
select,
textarea,
button {
	font: inherit;
	color: var(--text);
	background: var(--bg-3);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 8px 10px;
	transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2);
}

button,
input[type="submit"],
input[type="button"] {
	background: linear-gradient(135deg, var(--accent), var(--accent-2));
	color: var(--btn-text);
	font-weight: 600;
	cursor: pointer;
	border: none;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
	transform: translateY(-1px);
	box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

button:active,
input[type="submit"]:active,
input[type="button"]:active {
	transform: translateY(0);
}

/* Tables */
table {
	width: 100%;
	border-collapse: collapse;
	background: linear-gradient(145deg, var(--bg-2), var(--bg-3));
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	box-shadow: var(--shadow);
}

th,
td {
	padding: 10px 12px;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

th {
	color: var(--text);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.02em;
	background: rgba(255, 255, 255, 0.02);
}

tbody tr:hover {
	background: rgba(45, 212, 191, 0.06);
}

/* Badges / chips */
.badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 8px;
	border-radius: 999px;
	background: rgba(45, 212, 191, 0.12);
	color: var(--text);
	font-size: 12px;
	border: 1px solid rgba(45, 212, 191, 0.35);
}

.badge.alt {
	background: rgba(236, 72, 153, 0.12);
	border-color: rgba(236, 72, 153, 0.35);
}

.muted {
	color: var(--text-dim);
}

/* Alerts */
.alert {
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: rgba(236, 72, 153, 0.12);
	color: var(--text);
}

.alert.info {
	background: rgba(45, 212, 191, 0.12);
}

/* Utility layout */
.stack {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.row {
	display: flex;
	gap: 12px;
	align-items: center;
}

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

.pill {
	border-radius: 999px;
	padding-inline: 14px;
}

.ghost {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text);
}

.ghost:hover {
	border-color: var(--accent);
	color: var(--accent);
}

/* Game board (generic styling) */
.board {
	display: grid;
	gap: 2px;
	background: var(--bg-3);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 8px;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 12px 24px rgba(0, 0, 0, 0.35);
}

.board .cell {
	width: var(--cell, 36px);
	height: var(--cell, 36px);
	min-width: 32px;
	min-height: 32px;
	display: grid;
	place-items: center;
	color: var(--text);
	background: rgba(255, 255, 255, 0.02);
	border: 1px solid rgba(255, 255, 255, 0.04);
	font-family: var(--font-mono);
	touch-action: manipulation;
}

.tile {
	background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
	border: 1px solid rgba(255, 255, 255, 0.2);
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.15);
	color: #0b0d12;
	font-weight: 700;
	border-radius: 8px;
	padding: 6px 8px;
}

.tile.bonus-dw { box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.4), 0 8px 18px rgba(236, 72, 153, 0.25); }
.tile.bonus-tw { box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.45), 0 8px 18px rgba(245, 158, 11, 0.28); }
.tile.bonus-dl { box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.45), 0 8px 18px rgba(45, 212, 191, 0.25); }
.tile.bonus-tl { box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4), 0 8px 18px rgba(99, 102, 241, 0.25); }

/* Lists */
ul {
	padding-left: 18px;
	color: var(--text-dim);
}

/* Inputs alignment in tables */
table input,
table select {
	width: 100%;
}

/* Footer / small text */
small {
	color: var(--text-dim);
}

/* Responsive */
@media (max-width: 720px) {
	form {
		flex-direction: column;
		align-items: stretch;
	}

	table {
		font-size: 14px;
	}
}
/* Header and nav */
.site-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 0 18px;
	gap: 12px;
	position: relative;
}

.header-controls {
	display: inline-flex;
	align-items: center;
	gap: 10px;
}

.site-header > a {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	color: var(--heading);
}

.site-header h1 {
	margin: 0;
	font-size: 22px;
	line-height: 1.2;
	color: var(--heading);
	position: relative;
	top: 1px; /* nudge to align with logo */
}

.logo {
	width: 48px;
	height: 48px;
	background-image: url("/static/images/s-crab-p.png");
	background-size: contain;
	background-repeat: no-repeat;
	background-position: center;
	border-radius: 12px;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.user-menu button {
	background: var(--bg-3);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 10px;
	padding: 8px 12px;
}

.user-menu {
	position: relative;
}

.user-menu ul {
	position: absolute;
	right: 0;
	top: calc(100% + 6px);
	background: var(--bg-2);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 10px;
	list-style: none;
	margin: 0;
	padding: 6px 0;
	min-width: 180px;
	box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
	display: none;
	z-index: 20;
}

.user-menu ul a {
	color: var(--text);
	display: block;
	padding: 8px 12px;
}

.menu-link {
	display: block;
	padding: 8px 12px;
}

.fixed {
	font-weight: 700
}

.placed {
	font-weight: 700;
	color: #1a1
}

.game {
	display: flex;
	gap: 22px;
	align-items: flex-start;
}

.game-board-panel,
.game-side-panel {
	background: linear-gradient(145deg, var(--bg-2), var(--bg-3));
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 14px;
}

.game-side-panel {
	min-width: 280px;
}

.game-toolbar {
	margin-top: 12px;
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.push-right {
	margin-left: auto;
}

.btn-link {
	display: inline-block;
	padding: 6px 10px;
	border: 1px solid var(--border);
	border-radius: 8px;
	text-decoration: none;
	color: var(--text);
	background: var(--bg-3);
}

.preview-box {
	margin-left: 8px;
	color: #06a;
}

.preview-box.error {
	color: #b00;
}

.game-meta-row,
.score-row {
	margin-top: 8px;
	font: 14px/1.4 system-ui, sans-serif;
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.game-meta-row {
	margin-bottom: 6px;
}

.seats-label {
	margin-left: 12px;
}

.rack {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 10px;
	border: 1px dashed var(--border);
	border-radius: 10px;
	min-height: 60px;
}

.rack .tile {
	min-width: 40px;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.tile.selected {
	outline: 2px solid var(--accent-3);
	outline-offset: 2px;
}

.game-status {
	margin-top: 10px;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text-dim);
	background: rgba(45, 212, 191, 0.08);
}

.game-status.error {
	color: #b00;
	background: rgba(236, 72, 153, 0.12);
}

.input-compact {
	width: 80px;
}

.input-wide {
	width: 160px;
}

.section-heading {
	margin-top: 16px;
}

.lobby-table {
	max-width: 960px;
}

.modal-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	z-index: 1000;
	align-items: center;
	justify-content: center;
}

.modal-card {
	background: var(--surface-contrast);
	padding: 20px;
	border-radius: 8px;
	max-width: 400px;
	width: 90%;
	max-height: 80vh;
	overflow-y: auto;
	color: var(--text);
}

.modal-title {
	margin-top: 0;
}

.modal-input-wrap {
	margin-bottom: 15px;
}

.modal-input {
	width: 100%;
}

.modal-result {
	margin-bottom: 15px;
	min-height: 60px;
	padding: 10px;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--bg-3);
}

.modal-actions {
	text-align: right;
}

/* A11y utilities */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
	position: static;
	width: auto;
	height: auto;
	margin: 0;
	overflow: visible;
	clip: auto;
	white-space: normal
}

:focus {
	outline: 2px solid #2a7;
	outline-offset: 2px
}

/* Footer */
footer {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: linear-gradient(145deg, var(--bg-3), var(--bg-2));
	border-top: 1px solid var(--border);
	padding: 8px 16px;
	font-size: 12px;
	text-align: center;
	color: var(--text-dim);
	box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
	z-index: 100;
}

footer a {
	color: var(--accent);
	text-decoration: none;
}

footer a:hover {
	color: var(--accent-2);
}

/* Ensure content doesn't get hidden behind footer */
main {
	padding-bottom: 60px;
}

/* Responsive adjustments */
@media (max-width: 900px) {
	.game {
		gap: 16px;
		padding: 12px
	}

	.cell {
		font-size: 13px
	}
}

@media (max-width: 700px) {
	.game {
		flex-direction: column;
		align-items: stretch
	}

	.game-side-panel,
	.game-board-panel {
		width: 100%;
	}

	.game-toolbar {
		position: sticky;
		bottom: 6px;
		background: var(--bg-2);
		padding: 8px;
		border: 1px solid var(--border);
		border-radius: 10px;
	}

	.board {
		--cell: clamp(18px, calc((100vw - 40px)/var(--n)), 36px)
	}

	.cell .start {
		font-size: 10px
	}

	.cell .bonus {
		font-size: 9px
	}
}

@media (max-width: 420px) {
	.board {
		--cell: clamp(16px, calc((100vw - 32px)/var(--n)), 32px)
	}

	.game {
		gap: 12px;
		padding: 10px
	}

	.rack .tile {
		min-width: 34px;
		min-height: 38px;
	}
}
