* {
	box-sizing: border-box;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	margin: 0;
	padding: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	/* Prevent text size adjustments on orientation change */
	-webkit-text-size-adjust: 100%;
	-moz-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

/* Skip link for accessibility */
.skip-link {
	position: absolute;
	top: -40px;
	left: 0;
	background: #000;
	color: white;
	padding: 8px;
	text-decoration: none;
	z-index: 1000;
}

.skip-link:focus {
	top: 0;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Header */
header {
	background: rgba(255, 255, 255, 0.98);
	backdrop-filter: blur(10px);
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
	padding: 1.5rem 0;
	width: 100%;
}

.header-content {
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 1rem;
	gap: 1rem;
}

.header-content img {
	width: 60px;
	height: 60px;
	object-fit: contain;
}

.header-text {
	text-align: center;
}

.header-text h1 {
	margin: 0;
	font-size: 2rem;
	font-weight: 700;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.header-text .subtitle {
	margin: 0.5rem 0 0 0;
	font-size: 0.95rem;
	color: #555;
	font-weight: 500;
}

.header-text .date-heading {
	margin: 0.25rem 0 0 0;
	font-size: 0.9rem;
	color: #666;
	font-weight: 400;
}

/* Main content */
.game-container {
	max-width: 900px;
	margin: 2rem auto;
	padding: 0 1rem;
	flex: 1;
}

/* Results table card */
.table-card {
	background: white;
	border-radius: 16px;
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
	padding: 1.5rem;
	margin-bottom: 2rem;
	overflow-x: auto;
	animation: slideIn 0.4s ease-out;
	/* Smooth scrolling on mobile */
	-webkit-overflow-scrolling: touch;
	/* Scroll snap for better table navigation on mobile */
	scroll-snap-type: x proximity;
}

@keyframes slideIn {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

table {
	width: 100%;
	border-collapse: collapse;
	min-width: 600px;
}

thead {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
}

th {
	padding: 1rem 0.75rem;
	text-align: center;
	font-weight: 600;
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border: none;
}

td {
	padding: 1rem 0.75rem;
	text-align: center;
	background-color: #f8f9fa;
	border: 1px solid #e9ecef;
	font-size: 0.9rem;
	transition: background-color 0.2s ease;
}

tbody tr {
	animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

tbody tr:hover td {
	background-color: #e9ecef;
}

/* Input section */
.input-card {
	background: white;
	border-radius: 16px;
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
	padding: 2rem;
	text-align: center;
}

/* Previous guesses */
.previous-guesses {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	margin-bottom: 1.5rem;
	min-height: 50px;
}

.previous-guesses input {
	padding: 0.875rem 1.25rem;
	border-radius: 12px;
	border: 2px solid transparent;
	font-size: 1rem;
	font-weight: 500;
	text-align: center;
	animation: popIn 0.3s ease-out;
}

@keyframes popIn {
	0% {
		opacity: 0;
		transform: scale(0.8);
	}
	50% {
		transform: scale(1.05);
	}
	100% {
		opacity: 1;
		transform: scale(1);
	}
}

.incorrect {
	background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
	color: white;
}

.correct {
	background: linear-gradient(135deg, #51cf66 0%, #37b24d 100%);
	color: white;
}

/* Guess form */
#guesses {
	margin-bottom: 1.5rem;
}

.input-group {
	display: flex;
	gap: 0.75rem;
	justify-content: center;
	align-items: flex-start;
	flex-wrap: wrap;
}

.input-wrapper {
	position: relative;
	flex: 1;
	min-width: 250px;
	max-width: 400px;
}

#nameInput {
	width: 100%;
	padding: 1rem 1.25rem;
	font-size: 1rem;
	border: 2px solid #dee2e6;
	border-radius: 12px;
	transition: all 0.2s ease;
	background: white;
}

#nameInput:focus {
	outline: none;
	border-color: #667eea;
	box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#nameInput.correct {
	border-color: #51cf66;
	background: linear-gradient(135deg, #51cf66 0%, #37b24d 100%);
	color: white;
	font-weight: 600;
}

#nameInput.correct::placeholder {
	color: rgba(255, 255, 255, 0.7);
}

/* Autocomplete */
#listDiv {
	position: absolute;
	width: 100%;
	top: 100%;
	left: 0;
	margin-top: 0.5rem;
	z-index: 10;
}

ul {
	list-style-type: none;
	padding: 0;
	margin: 0;
	background: white;
	border-radius: 12px;
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
	overflow: hidden;
	max-height: 300px;
	overflow-y: auto;
}

li {
	padding: 0.875rem 1.25rem;
	cursor: pointer;
	transition: background-color 0.15s ease;
	border-bottom: 1px solid #f1f3f5;
	font-size: 0.95rem;
}

li:last-child {
	border-bottom: none;
}

li:hover,
li:focus {
	background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
	outline: none;
}

/* Submit button */
#submitButton {
	padding: 1rem 2rem;
	font-size: 1rem;
	font-weight: 600;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border: none;
	border-radius: 12px;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

#submitButton:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

#submitButton:active {
	transform: translateY(0);
}

#submitButton:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

/* Message */
#message {
	margin-top: 1.5rem;
	font-size: 1.125rem;
	font-weight: 600;
	color: #495057;
	min-height: 2rem;
	animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Footer */
footer {
	background: rgba(255, 255, 255, 0.95);
	padding: 1.5rem 0;
	margin-top: 3rem;
	text-align: center;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
	width: 100%;
}

footer p {
	margin: 0;
	padding: 0 1rem;
	color: #495057;
	font-size: 0.9rem;
}

footer a {
	color: #667eea;
	text-decoration: none;
	font-weight: 500;
	transition: color 0.2s ease;
}

footer a:hover,
footer a:focus {
	color: #764ba2;
	text-decoration: underline;
}

/* Scrollbar styling */
ul::-webkit-scrollbar {
	width: 8px;
}

ul::-webkit-scrollbar-track {
	background: #f1f3f5;
}

ul::-webkit-scrollbar-thumb {
	background: #adb5bd;
	border-radius: 4px;
}

ul::-webkit-scrollbar-thumb:hover {
	background: #868e96;
}

/* Mobile-specific improvements */
@media (hover: none) and (pointer: coarse) {
	/* Touch device optimizations */
	#nameInput,
	#submitButton,
	li {
		-webkit-tap-highlight-color: rgba(102, 126, 234, 0.1);
	}

	/* Disable hover effects on touch devices */
	tbody tr:hover td {
		background-color: #f8f9fa;
	}

	#submitButton:hover {
		transform: none;
		box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
	}

	/* Better touch feedback */
	#submitButton:active {
		transform: scale(0.98);
	}

	li:active {
		background: linear-gradient(90deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
	}
}

/* Tablet breakpoint */
@media (min-width: 481px) and (max-width: 768px) {
	.table-card {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	table {
		min-width: 600px;
	}
}

/* Responsive design */
@media (max-width: 768px) {
	/* Header adjustments */
	header {
		padding: 1rem 0;
	}

	.header-content {
		padding: 0 0.75rem;
		gap: 0.75rem;
	}

	.header-content img {
		width: 45px;
		height: 45px;
	}

	.header-text h1 {
		font-size: 1.5rem;
		line-height: 1.2;
	}

	.header-text .subtitle {
		font-size: 0.8rem;
		margin-top: 0.25rem;
	}

	.header-text .date-heading {
		font-size: 0.75rem;
		margin-top: 0.25rem;
	}

	/* Main content spacing */
	.game-container {
		margin: 1rem auto;
		padding: 0 0.75rem;
	}

	/* Cards */
	.table-card,
	.input-card {
		padding: 1rem;
		border-radius: 12px;
		margin-bottom: 1.5rem;
	}

	/* Table improvements */
	.table-card {
		padding: 0.75rem;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	table {
		min-width: 550px;
	}

	th {
		padding: 0.75rem 0.4rem;
		font-size: 0.7rem;
		letter-spacing: 0.3px;
	}

	td {
		padding: 0.75rem 0.4rem;
		font-size: 0.75rem;
		line-height: 1.3;
	}

	/* Input section */
	.input-card {
		padding: 1.25rem;
	}

	.previous-guesses {
		margin-bottom: 1rem;
		gap: 0.5rem;
	}

	.previous-guesses input {
		padding: 0.75rem 1rem;
		font-size: 0.9rem;
	}

	.input-wrapper {
		min-width: 100%;
	}

	#nameInput {
		padding: 0.875rem 1rem;
		font-size: 1rem;
		border-radius: 10px;
	}

	/* Autocomplete */
	ul {
		max-height: 200px;
	}

	li {
		padding: 0.75rem 1rem;
		font-size: 0.9rem;
	}

	/* Button */
	#submitButton {
		padding: 0.875rem 1.5rem;
		font-size: 0.95rem;
		width: 100%;
		margin-top: 0.5rem;
	}

	/* Message */
	#message {
		font-size: 0.95rem;
		margin-top: 1rem;
	}

	/* Footer */
	footer {
		padding: 1.25rem 0;
		margin-top: 2rem;
	}

	footer p {
		padding: 0 0.75rem;
		font-size: 0.85rem;
	}
}

@media (max-width: 480px) {
	/* Header - extra compact */
	header {
		padding: 0.75rem 0;
	}

	.header-content {
		padding: 0 0.5rem;
		gap: 0.5rem;
	}

	.header-content img {
		width: 40px;
		height: 40px;
	}

	.header-content img:last-child {
		display: none;
	}

	.header-text h1 {
		font-size: 1.25rem;
	}

	.header-text .subtitle {
		font-size: 0.7rem;
		display: none; /* Hide subtitle on very small screens */
	}

	.header-text .date-heading {
		font-size: 0.7rem;
	}

	/* Main content */
	.game-container {
		margin: 0.75rem auto;
		padding: 0 0.5rem;
	}

	/* Cards */
	.table-card {
		padding: 0.5rem;
		border-radius: 10px;
		margin-bottom: 1rem;
	}

	.input-card {
		padding: 1rem;
		border-radius: 10px;
	}

	/* Table - more compact */
	table {
		min-width: 480px;
		font-size: 0.7rem;
	}

	th {
		padding: 0.6rem 0.3rem;
		font-size: 0.65rem;
	}

	td {
		padding: 0.6rem 0.3rem;
		font-size: 0.7rem;
		word-break: break-word;
	}

	/* Input improvements for touch */
	.input-group {
		flex-direction: column;
		gap: 0.5rem;
	}

	.input-wrapper {
		max-width: 100%;
		width: 100%;
	}

	#nameInput {
		font-size: 16px; /* Prevents iOS zoom on focus */
		padding: 1rem;
		border-radius: 10px;
	}

	/* Autocomplete - better touch targets */
	ul {
		max-height: 180px;
	}

	li {
		padding: 1rem;
		font-size: 0.95rem;
		min-height: 48px; /* Touch-friendly size */
	}

	/* Button - full width and touch-friendly */
	#submitButton {
		width: 100%;
		padding: 1rem 1.5rem;
		font-size: 1rem;
		margin-top: 0.5rem;
		min-height: 48px; /* Touch-friendly size */
	}

	/* Previous guesses */
	.previous-guesses input {
		padding: 0.75rem;
		font-size: 0.85rem;
	}

	/* Message */
	#message {
		font-size: 0.9rem;
		margin-top: 0.75rem;
	}

	/* Footer */
	footer {
		padding: 1rem 0;
		margin-top: 1.5rem;
	}

	footer p {
		padding: 0 0.5rem;
		font-size: 0.8rem;
		line-height: 1.5;
	}
}
