/* Modern styles for the question game */
:root {
	--bg-1: #0f1724;
	/* deep navy */
	--bg-2: #0b1220;
	/* darker */
	--card: rgba(255, 255, 255, 0.06);
	--glass: rgba(255, 255, 255, 0.06);
	--accent: #3333b2;
	/* violet */
	--accent-2: #72b04e;
	/* teal */
	--muted: #9aa4b2;
	--success: #16a34a;
	--danger: #ef4444;
	--glass-border: rgba(255, 255, 255, 0.08);
	--radius: 14px;
}

/* Light theme variables override */
body.theme-light {
	--bg-1: #f7fafc;
	--bg-2: #eef2f7;
	--card: rgba(4,6,10,0.04);
	--glass: rgba(0,0,0,0.04);
	--accent: #2563eb; /* blue */
	--accent-2: #06b6d4; /* teal */
	--muted: #475569;
	--success: #0f766e;
	--danger: #b91c1c;
	--glass-border: rgba(0,0,0,0.06);
	color: #0b1220;
}

/* explicit topbar foreground to ensure icon contrast in each theme */
:root{ --topbar-foreground: #e6eef6 }
body.theme-light{ --topbar-foreground: #0b1220 }
.topbar{ color: var(--topbar-foreground); }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap');

* {
	box-sizing: border-box;
}

html {
	min-height: 100%;
}

/* Use flex-start by default so pages can scroll naturally. Pages that need vertical centering (the quiz) will set body.align-center */
body {
	margin: 0;
	font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
	background: radial-gradient(1200px 600px at 10% 10%, rgba(124, 58, 237, 0.14), transparent),
		radial-gradient(900px 450px at 85% 85%, rgba(6, 182, 212, 0.08), transparent),
		linear-gradient(180deg, var(--bg-1), var(--bg-2));
	color: #e6eef6;
	-webkit-font-smoothing: antialiased;
	display: flex;
	align-items: flex-start;
	/* allow scrolling and top-aligned content */
	justify-content: center;
	padding: 48px 20px;
}

/* helper class for pages that should be vertically centered (e.g. index.html) */
body.align-center {
	align-items: center
}

.container {
	width: 100%;
	max-width: 920px;
}

.app-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	margin-bottom: 20px;
}

h1 {
	margin: 0;
	font-size: clamp(20px, 3vw, 28px);
	font-weight: 700;
	letter-spacing: -0.5px;
}

.brand-sub {
	color: var(--muted);
	font-weight: 500;
	font-size: 12px;
}

.card {
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02));
	border-radius: var(--radius);
	padding: 28px;
	box-shadow: 0 8px 30px rgba(2, 6, 23, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.02);
	border: 1px solid var(--glass-border);
}

#gameArea.card {
	display: block;
}

.center {
	display: flex;
	align-items: center;
	justify-content: center;
}

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

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

.start-form input[type="text"] {
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.06);
	background: rgba(255, 255, 255, 0.02);
	color: inherit;
	min-width: 180px;
	box-shadow: 0 8px 30px rgba(2, 6, 23, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.02);
	font-size: 1.2rem;
}

.button {
	-webkit-appearance: none;
	appearance: none;
	border: 0;
	padding: 10px 16px;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	border-radius: 10px;
	cursor: pointer;
	font-weight: 600;
	transition: all .18s ease;
	box-shadow: 0 6px 18px rgba(10, 20, 40, 0.32);
}

.button:active {
	transform: translateY(1px) scale(.995)
}

.button--primary {
	background: linear-gradient(90deg, var(--accent), var(--accent-2));
	color: white;
}

.button--ghost {
	background: transparent;
	color: var(--accent);
	border: 1px solid rgba(124, 58, 237, 0.18);
	box-shadow: none;
}

#startButton {
	padding: 10px 18px;
	border-radius: 12px
}

.game-card {
	margin-top: 12px;
	display: flex;
	gap: 18px;
	flex-direction: column;
}

#question {
	font-size: clamp(18px, 3.2vw, 22px);
	font-weight: 700;
	margin: 0 0 6px 0;
}

.input-row {
	display: flex;
	gap: 12px;
	align-items: center;
	margin-top: 6px;
}

#answerInput {
	flex: 1;
	padding: 12px 14px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.06);
	background: rgba(255, 255, 255, 0.02);
	color: inherit;
	outline: none;
	transition: box-shadow .14s ease, border-color .12s ease;
	box-shadow: 0 6px 12px rgba(2, 6, 23, 0.35);
}

#answerInput:focus {
	border-color: rgba(124, 58, 237, 0.7);
	box-shadow: 0 8px 26px rgba(124, 58, 237, 0.14);
}

#submitAnswer {
	padding: 10px 14px;
	border-radius: 10px;
	min-width: 120px
}

/* Multiple choice option buttons */
.options {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 6px
}

.option-btn {
	-webkit-appearance: none;
	appearance: none;
	border: 1px solid rgba(255, 255, 255, 0.06);
	background: rgba(255, 255, 255, 0.02);
	padding: 12px 14px;
	border-radius: 10px;
	color: inherit;
	cursor: pointer;
	text-align: left;
	transition: transform .12s ease, box-shadow .12s ease, background .12s linear;
}

.option-btn:hover {
	transform: translateY(-3px);
	box-shadow: 0 10px 26px rgba(2, 6, 23, 0.42)
}

.option-btn:active {
	transform: translateY(0)
}

.option-btn.correct {
	background: linear-gradient(90deg, rgba(22, 163, 74, 0.15), rgba(22, 163, 74, 0.06));
	border-color: rgba(22, 163, 74, 0.45);
}

.option-btn.wrong {
	background: linear-gradient(90deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.02));
	border-color: rgba(239, 68, 68, 0.35);
	opacity: 0.95
}

/* small touch target on mobile */
@media (max-width:520px) {
	.option-btn {
		padding: 14px 16px;
		font-size: 15px
	}
}

#feedback {
	margin-top: 8px;
	font-size: 14px;
	color: var(--muted);
	min-height: 20px;
	transition: color .12s ease, transform .12s ease;
}

.feedback--right {
	color: var(--success);
	transform: translateY(-2px)
}

.feedback--wrong {
	color: var(--danger);
	transform: translateY(-2px)
}

#score {
	margin: 0;
	color: var(--muted);
	font-weight: 600;
	font-size: 13px;
}

/* progress bar */
.meta-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	margin-top: 8px;
}

/* timer */
.timer {
	font-weight: 700;
	color: var(--muted);
	background: rgba(255, 255, 255, 0.02);
	padding: 6px 10px;
	border-radius: 99px;
	border: 1px solid rgba(255, 255, 255, 0.03);
	font-size: 13px
}

.timer-bar {
	width: 110px;
	height: 8px;
	border-radius: 99px;
	background: rgba(255, 255, 255, 0.02);
	border: 1px solid rgba(255, 255, 255, 0.03);
	overflow: hidden
}

.timer-bar>span {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, #f97316, #fb7185);
	width: 100%;
	transition: width 1s linear
}

.progress {
	height: 8px;
	border-radius: 99px;
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02));
	border: 1px solid rgba(255, 255, 255, 0.03);
	flex: 1;
	overflow: hidden;
}

.progress>span {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, rgba(124, 58, 237, 0.95), rgba(6, 182, 212, 0.9));
	width: 0%;
	transition: width .45s cubic-bezier(.2, .9, .2, 1);
}

/* small screens */
@media (max-width:520px) {
	body {
		padding: 28px 14px
	}

	.card {
		padding: 18px
	}

	#answerInput {
		padding: 10px
	}

	.controls {
		flex-direction: column;
		align-items: stretch
	}

	#submitAnswer {
		min-width: unset;
		width: 100%
	}
}

/* tiny decorative footer */
.footer-note {
	font-size: 12px;
	color: var(--muted);
	margin-top: 8px
}

/* Leaderboard details view */
#detailsArea {
	margin-top: 12px
}

.details-card {
	padding: 12px;
	border-radius: 8px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
	border: 1px solid var(--glass-border)
}

.details-btn {
	padding: 6px 10px;
	border-radius: 6px;
	border: 1px solid rgba(255, 255, 255, 0.06);
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: all .12s ease
}

.details-btn:hover {
	transform: translateY(-2px);
	background: rgba(255, 255, 255, 0.02)
}

.details-list {
	padding-left: 18px;
	margin: 0;
	margin-top: 8px;
	/* no max-height - show all answers */
}

.details-list {
	list-style: decimal outside;
	padding-left: 56px;
	list-style-position: outside
}

.category-heading {
	margin: 14px 0 6px 0;
	font-size: 14px;
	color: var(--muted);
	font-weight: 700
}

.category-block {
	margin-bottom: 10px
}

.detail-item {
	margin-bottom: 8px;
	padding: 8px;
	border-radius: 6px
}

.detail-right {
	background: linear-gradient(90deg, rgba(22, 163, 74, 0.06), rgba(22, 163, 74, 0.02));
	border: 1px solid rgba(22, 163, 74, 0.12)
}

.detail-wrong {
	background: linear-gradient(90deg, rgba(239, 68, 68, 0.03), rgba(239, 68, 68, 0.01));
	border: 1px solid rgba(239, 68, 68, 0.06)
}

.detail-item .question {
	font-weight: 600
}

.detail-item .meta {
	font-size: 0.9rem;
	margin-top: 4px;
	color: var(--muted)
}

/* small icon next to question text */
.detail-icon {
	display: inline-block;
	vertical-align: middle;
	margin-right: 8px
}

/* per-row details table row */
.details-row td.details-col {
	padding: 10px 12px;
	background: transparent;
	border-top: 0
}

/* helper for screen-reader-only text */
.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
}

.details-btn:focus {
	outline: 2px solid rgba(124, 58, 237, 0.28);
	outline-offset: 2px
}

/* Improve scroll visibility */
.details-list::-webkit-scrollbar {
	height: 6px;
	width: 8px
}

.details-list::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.06);
	border-radius: 6px
}

.details-list::-webkit-scrollbar-track {
	background: transparent
}

/* Score table layout */
.scores-table {
	width: 100%;
	border-collapse: collapse
}

.scores-table th,
.scores-table td {
	padding: 8px 12px;
	text-align: left
}

.scores-head {
	color: var(--muted)
}

.scores-body {
	background: transparent
}

.scores-td {
	padding: 8px 12px
}

.details-title {
	margin: 0 0 8px 0
}

/* smooth theme transitions */
html, body, .card, .topbar, .details-card, .scores-table { transition: background-color .22s ease, color .22s ease, border-color .18s ease, box-shadow .18s ease; }

/* grade column styling */
.grade-cell {
	padding: 8px 12px;
	font-weight: 700;
	text-align: center;
	width: 80px
}

.grade-pos {
	color: var(--success);
	background: linear-gradient(90deg, rgba(22, 163, 74, 0.05), rgba(22, 163, 74, 0.02));
	border-radius: 6px
}

.grade-neg {
	color: var(--danger);
	background: linear-gradient(90deg, rgba(239, 68, 68, 0.03), rgba(239, 68, 68, 0.01));
	border-radius: 6px
}

.grade-neutral {
	color: var(--muted);
	background: transparent;
	border-radius: 6px
}

/* sorting header */
.scores-head th.sortable {
	cursor: pointer;
	position: relative;
	padding-right: 18px;
	user-select: none
}

.scores-head th.sortable .sort-indicator {
	display: inline-block;
	width: 10px;
	height: 10px;
	margin-left: 8px;
	transform-origin: center;
	opacity: 0.6
}

.scores-head th.sortable[aria-sort="ascending"] .sort-indicator {
	transform: rotate(180deg);
	opacity: 1
}

.scores-head th.sortable[aria-sort="descending"] .sort-indicator {
	transform: rotate(0deg);
	opacity: 1
}

.scores-head th.sortable .sort-indicator::before {
	content: '▴';
	display: block;
	text-align: center
}

/* Custom select (consistent across browsers) */
.custom-select {
	position: relative;
	display: inline-block;
	min-width: 120px
}

.custom-select__button {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 12px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.06);
	background: rgba(255, 255, 255, 0.02);
	color: inherit;
	cursor: pointer;
	font-weight: 600
}

.custom-select__button:focus {
	outline: 2px solid rgba(124, 58, 237, 0.22);
	outline-offset: 2px
}

.custom-select__value {
	display: inline-block
}

.custom-select__arrow {
	font-size: 12px;
	color: var(--muted)
}

.custom-select__list {
	position: absolute;
	left: 0;
	right: 0;
	margin-top: 8px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
	border-radius: 10px;
	border: 1px solid var(--glass-border);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
	padding: 8px;
	z-index: 60;
	list-style: none
}

.custom-select__list[hidden] {
	display: none
}

.custom-select__list li {
	padding: 8px 10px;
	border-radius: 8px;
	cursor: pointer
}

.custom-select__list li[aria-selected="true"] {
	background: linear-gradient(90deg, rgba(124, 58, 237, 0.08), rgba(6, 182, 212, 0.03));
	font-weight: 700
}

.custom-select__list li:hover {
	background: rgba(255, 255, 255, 0.03)
}

/* Site navigation (header) */
.site-nav {
	display: flex;
	gap: 8px;
	align-items: center
}

.nav-link {
	display: inline-flex;
	padding: 8px 12px;
	border-radius: 8px;
	border: 1px solid transparent;
	color: inherit;
	text-decoration: none;
	font-weight: 700
}

.nav-link:hover {
	background: rgba(255, 255, 255, 0.02);
	border-color: rgba(255, 255, 255, 0.04)
}

.nav-link.active {
	background: linear-gradient(0deg, var(--accent), var(--accent-2));
	color: white;
	border-color: transparent;
	box-shadow: 0 10px 30px rgba(0,0,0,0.25), inset 0 -3px 0 rgba(255,255,255,0.04);
	transform: translateY(-1px);
	transition: transform .12s ease, box-shadow .12s ease;
}
.nav-link.active:focus{outline:3px solid rgba(124,58,237,0.14); outline-offset:2px}

@media (max-width:520px) {
	.custom-select {
		min-width: 140px
	}

	.site-nav {
		gap: 6px
	}

	.nav-link {
		padding: 8px 10px
	}
}

/* Topbar / fixed header */
.topbar {
	position: fixed;
	left: 0;
	right: 0;
	top: 0;
	height: 64px;
	background: linear-gradient(180deg, rgba(6, 6, 12, 0.6), rgba(6, 6, 12, 0.4));
	backdrop-filter: blur(6px);
	z-index: 120;
	border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.topbar-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 10px
}

.topbar .topbar-brand {
	font-weight: 700;
	font-size: 2rem;
}

.topbar .topbar-brand a{
	color: lawngreen;
	text-decoration: none;
}

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

.topbar-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 10px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.06);
	background: rgba(255, 255, 255, 0.02);
	cursor: pointer;
	color: inherit;
}

.topbar-toggle:focus {
	outline: 2px solid rgba(124, 58, 237, 0.24);
	outline-offset: 2px
}

/* Hamburger -> X morph */
.topbar-toggle .hamburger{display:block}
.topbar-toggle .bar{transition:transform .28s cubic-bezier(.2,.9,.2,1), opacity .18s ease; transform-box: fill-box; transform-origin: center center}
.topbar-toggle.open .bar.top{transform-origin:center;transform:translateY(5px) rotate(45deg); }
.topbar-toggle.open .bar.mid{opacity:0;transform:scaleX(.8)}
.topbar-toggle.open .bar.bot{transform-origin:center;transform:translateY(-5px) rotate(-45deg)}

/* ensure icons follow theme color. The theme-icon path already has fill="currentColor" */
.topbar-toggle .bar { fill: currentColor; }

/* Light topbar adjustments */
body.theme-light .topbar{
	background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.9));
	border-bottom-color: rgba(0,0,0,0.06);
}
body.theme-light .topbar-toggle, body.theme-light .theme-toggle{background:rgba(2,6,10,0.02);border-color:rgba(0,0,0,0.06);}

.theme-toggle{display:inline-flex;align-items:center;justify-content:center;padding:8px;border-radius:10px;border:1px solid rgba(255,255,255,0.06);background:rgba(255,255,255,0.02);cursor:pointer;color:var(--topbar-foreground);}
.theme-toggle:focus{outline:2px solid rgba(124,58,237,0.22);outline-offset:2px}
.theme-toggle .theme-icon{display:inline-block;color:inherit}

.topbar-nav {
	display: flex;
	gap: 8px;
	align-items: center
}

.topbar-nav a {
	padding: 8px 10px;
	border-radius: 8px;
	text-decoration: none
}

.topbar-nav.open {
	animation: navIn .22s ease both
}

@keyframes navIn {
	from {
		opacity: 0;
		transform: translateY(-6px)
	}

	to {
		opacity: 1;
		transform: translateY(0)
	}
}

/* mobile: show nav as an overlay panel */
@media (max-width:720px) {
	.topbar-nav {
		position: fixed;
		left: 12px;
		right: 12px;
		top: 72px;
		background: linear-gradient(180deg, rgba(10, 12, 20, 0.96), rgba(6, 6, 12, 0.96));
		border-radius: 12px;
		padding: 10px;
		flex-direction: column;
		z-index: 130;
		box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
		border: 1px solid rgba(255, 255, 255, 0.03)
	}

	.topbar-nav[hidden] {
		display: none
	}
}

/* space for fixed header */
.with-topbar {
	padding-top: 84px
}