* {
	box-sizing: border-box;
}

:root {
	--bg: #222222;
	--accent: #e67e22;
	--card-bg: #34495e;
	--card-back: #faf8f5;
}

body {
	background: var(--bg);
	color: #ffffff;
	font-family: Helvetica, Arial, sans-serif;
	margin: 0;
	padding: 0;
}

body::before {
	content: "";
	position: fixed;
	top: 0;
	bottom: 0;
	left: calc(50vw - 170px);
	width: 2px;
	height: 100%;
	background: var(--accent);
	z-index: 10;
	pointer-events: none;
	opacity: 0;
	animation: fadeIn 2.5s 2s forwards;
}

@keyframes fadeIn {
	0% { opacity: 0; }
	100% { opacity: 1; }
}

header {
	position: fixed;
	background: linear-gradient(to bottom, var(--bg) 80%, rgba(44, 62, 80, 0));
	top: 0;
	left: 0;
	width: 100%;
	z-index: 1000;
	padding-bottom: 20px;
}

footer {
	position: fixed;
	background: linear-gradient(to top, var(--bg) 80%, rgba(44, 62, 80, 0));
	bottom: 0;
	left: 0;
	width: 100%;
	z-index: 1000;
	text-align: center;
	font-size: 12px;
	padding-top: 20px;
}

h1 {
	margin: 0;
	font-size: 18px;
	padding: 5px;
}

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

/* Blog selector */
#blogSelector {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	margin-bottom: 2px;
}

#blogSelect {
	background: var(--card-bg);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	padding: 4px 8px;
	font-size: 13px;
	cursor: pointer;
	outline: none;
}

#blogSelect option {
	background: var(--card-bg);
	color: #fff;
}

#customFeedInput {
	display: flex;
	gap: 4px;
	align-items: center;
}

#feedUrlInput {
	background: var(--card-bg);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	padding: 4px 8px;
	font-size: 12px;
	width: 200px;
	outline: none;
}

#feedUrlInput::placeholder {
	color: rgba(255, 255, 255, 0.4);
}

#feedUrlGo {
	background: var(--accent);
	color: #fff;
	border: none;
	border-radius: 4px;
	padding: 4px 10px;
	font-size: 12px;
	cursor: pointer;
}

#dateDisplay {
	display: flex;
	color: #ffffff;
	justify-content: center;
	margin-top: -2px;
	text-transform: capitalize;
	letter-spacing: 1px;
	font-size: 18px;
	font-weight: bold;
}

#subtitle {
	display: flex;
	color: #ffffff;
	justify-content: center;
	letter-spacing: 1.4px;
	font-size: 10px;
	text-transform: uppercase;
}

#status {
	font-size: 13px;
	text-align: center;
	margin-top: 4px;
	margin-bottom: 4px;
	height: 40px;
	color: #bbb;
}

#status strong {
	color: #fff;
}

/* Loading state */
#loadingMessage {
	text-align: center;
	color: #bbb;
	font-size: 14px;
	margin-top: 40vh;
}

#loadingMessage .spinner {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 2px solid rgba(255, 255, 255, 0.2);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	margin-right: 8px;
	vertical-align: middle;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* ===== Card system — copied from WikiDates, colors swapped ===== */

#eventsContainer {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 100vh;
	align-items: center;
	padding: 50px 16px;
	gap: 0;
}

.card {
	position: fixed;
	top: 50vh;
	left: 50%;
	transform: translate(-50%, -50%) rotateY(0deg);
	z-index: 20;
	transition:
		transform 0.6s ease,
		width 0.6s ease,
		height 0.6s ease,
		box-shadow 0.6s ease,
		margin 0.6s ease,
		opacity 0.6s ease;
	opacity: 1;
	width: 280px;
	height: 150px;
	background-color: var(--card-bg);
	border: 2px solid rgba(255, 255, 255, 0.1);
	border-radius: 8px;
	box-shadow: 0 12px 16px rgba(0, 0, 0, 0.3);
	transform-style: preserve-3d;
	margin: 8px 0;
	cursor: pointer;
}

.card.visible {
	opacity: 1;
}

.card.lowering {
	margin-left: -78px;
	box-shadow: none;
	transform: translate(-50%, -50%) rotateY(180deg);
	height: 120px;
	width: 224px;
}

.card.placed {
	position: relative;
	transform: rotateY(180deg);
	z-index: 10;
	top: auto;
	left: -78px;
	transition: box-shadow 0.6s ease, transform 0.6s ease, width 0.6s ease, height 0.6s ease;
	box-shadow: none;
	height: 120px;
	width: 224px;
	cursor: pointer;
}

/* Front and Back — matches WikiDates exactly */
.card .front,
.card .back {
	position: absolute;
	width: 100%;
	height: 100%;
	backface-visibility: hidden;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 10px;
}

.card .back {
	transform: rotateY(180deg);
	background-color: var(--card-back);
	border-radius: 8px;
}

/* Year — matches WikiDates exactly */
.card .year {
	display: block;
	font-weight: bold;
	color: white;
	position: absolute;
	margin-left: -181px;
	transform: rotate(270deg) scale(0.8);
	background-color: var(--card-bg);
	padding: 8px 4px;
	text-align: center;
	border-radius: 8px 8px 0 0;
	font-size: 30px;
	width: 148px;
}

/* Description — matches WikiDates exactly */
.card .description {
	color: #ddd;
	line-height: 1.2;
	text-align: left;
	display: flex;
	align-items: center;
	width: 100%;
	height: 100%;
	padding: 0 10px;
	font-size: 15px;
	line-height: 1.3;
}

.card.placed .description,
.card.lowering .description {
	padding-left: 0;
	color: #333;
	font-size: 12px;
}

/* ===== Blogs On This Day additions: snippets and post links ===== */

/* Front card: column layout for title + snippet */
.card .front {
	flex-direction: column;
	justify-content: center;
	align-items: center;
}

.card .front .description {
	height: auto;
	font-weight: 600;
	font-size: 13px;
	margin-bottom: -4px;
}

.card .snippet {
	color: #ddd;
	text-align: left;
	width: 100%;
	padding: 0 10px;
	font-size: 13px;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Back content wrapper: column layout without affecting year position */
.card .back-content {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	padding-left: 35px;
	justify-content: center;
	overflow: hidden;
}

.card.placed .back,
.card.lowering .back {
	padding: 4px 10px;
}

.card.placed .back-content,
.card.lowering .back-content {
	justify-content: flex-start;
	padding-top: 0;
}

.card.placed .description,
.card.lowering .description {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	height: auto;
	font-weight: 600;
	margin-bottom: -2px;
}

.card.placed .snippet,
.card.lowering .snippet {
	padding: 0;
	-webkit-line-clamp: 2;
}

/* Post link on card back */
.card .post-link {
	position: absolute;
	bottom: 6px;
	right: 10px;
	font-size: 10px;
	color: var(--accent);
	text-decoration: none;
	opacity: 0.7;
}

.card .post-link:hover {
	opacity: 1;
}

/* ===== Blog-specific theming ===== */

.blog-styled .card .front {
	background-color: var(--blog-bg);
}

.blog-styled .card .front .description {
	color: var(--blog-title-color);
	font-family: var(--blog-font);
	font-size: var(--blog-font-size);
	text-transform: var(--blog-title-transform, none);
}

.blog-styled .card .front .snippet {
	color: var(--blog-color);
	font-family: var(--blog-font);
	font-size: var(--blog-font-size);
}

.blog-styled .card .back {
	background-color: var(--blog-bg);
}

.blog-styled .card.placed .description,
.blog-styled .card.lowering .description {
	color: var(--blog-title-color);
	font-family: var(--blog-font);
	font-size: var(--blog-font-size);
	text-transform: var(--blog-title-transform, none);
}

.blog-styled .card.placed .snippet,
.blog-styled .card.lowering .snippet {
	color: var(--blog-color);
	font-family: var(--blog-font);
	font-size: var(--blog-font-size);
}

.blog-styled .card .year {
	background-color: var(--blog-year-bg);
}

.blog-styled .card .post-link {
	color: var(--blog-color);
	opacity: 0.6;
}

/* ===== End Blogs On This Day additions ===== */

.card.incorrect {
	border: 3px solid #e74c3c;
}

.gap {
	margin: 0;
	height: 0;
	width: 224px;
	transition: height 0.5s ease;
	will-change: height;
}

.gap.highlight {
	position: relative;
	height: 120px;
	width: 224px;
	left: -78px;
	border: 2px dashed rgba(255, 255, 255, 0.4);
	border-radius: 12px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 8px 0;
	background: rgba(44, 62, 80, 0.8);
	z-index: 15;
}

.gap.highlight::after {
	content: attr(data-text);
	transform: rotate(-90deg);
	font-size: 14px;
	letter-spacing: 1px;
	white-space: nowrap;
	position: absolute;
	margin-left: -184px;
	opacity: 0;
	color: rgba(204, 204, 204, 0.9);
	animation: fadeIn 0.5s ease-in forwards;
}

#feedbackFooter {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px;
}

/* Feedback Squares */
#feedbackRow {
	display: flex;
	gap: 8px;
	margin: 0 auto;
}

.feedback-square {
	width: 20px;
	height: 20px;
	background-color: var(--bg);
	border-radius: 4px;
	border: 1px solid var(--card-bg);
}

.feedback-square.correct {
	background-color: #27ae60;
}

.feedback-square.incorrect {
	background-color: #e74c3c;
}

.hidden {
	display: none !important;
}

/* Share Link */
#shareLink {
	text-decoration: none;
	color: var(--accent);
	font-size: 14px;
}

/* Popup */
#popup {
	position: fixed;
	top: 50vh;
	left: 50%;
	transform: translate(-50%, -50%) rotateY(0deg);
	z-index: 20;
	transition:
		transform 0.6s ease,
		width 0.6s ease,
		box-shadow 0.6s ease,
		margin 0.6s ease,
		opacity 0.6s ease;
	opacity: 1;
	min-width: 280px;
	background-color: var(--card-back);
	border: 2px solid rgba(255, 255, 255, 0.1);
	border-radius: 8px;
	box-shadow: 0 12px 16px rgba(0, 0, 0, 0.3);
	transform-style: preserve-3d;
	padding: 20px;
}

#popup .popup-content {
	text-align: center;
}

#popup .popup-content p {
	color: #333;
	font-size: 15px;
}

#popup h2 {
	margin-top: 15px;
	color: var(--card-bg);
}

#popup-score-section {
	margin: 12px 0 20px 0;
}

#popup-score-label {
	color: #888;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 1.5px;
	margin-bottom: 6px;
}

#popup-score-value {
	color: var(--card-bg);
	font-size: 36px;
	font-weight: bold;
	margin: 3px 0;
}

#average-score-section {
	margin: 0 0 15px 0;
}

.average-score-text {
	color: #888;
	font-size: 13px;
	margin: 0;
}

.average-score-text strong {
	color: #555;
	font-size: 14px;
	font-weight: normal;
}

#popup .popup-actions {
	margin-top: 20px;
	display: flex;
	justify-content: center;
	gap: 10px;
}

#popup a {
	background-color: var(--accent);
	color: #fff;
	border: none;
	padding: 5px 10px;
	border-radius: 4px;
	text-decoration: none;
	cursor: pointer;
	font-size: 14px;
}

#popup a:hover {
	opacity: 0.9;
}

#popup #closePopup {
	position: absolute;
	top: 0px;
	right: 0px;
	background-color: transparent;
	color: var(--card-bg);
	border: none;
	font-size: 14px;
	font-weight: bold;
	cursor: pointer;
}

#shareIcon {
	background-color: var(--card-bg);
	padding: 4px;
	border-radius: 50%;
	text-align: center;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
	cursor: pointer;
	transition: opacity 0.3s ease-in-out, transform 0.2s ease-in-out;
	opacity: 0.8;
	text-decoration: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	position: absolute;
	margin-left: -30px;
	margin-top: -2px;
}

#shareIcon:hover {
	opacity: 1;
	transform: scale(1.1);
}

#shareIcon svg {
	width: 24px;
	height: 24px;
	fill: white;
}

/* Pop animation */
@keyframes pop {
	0% { transform: scale(1); }
	50% { transform: scale(1.2); }
	100% { transform: scale(1); }
}

@keyframes popCard {
	0% { transform: rotateY(180deg) scale(1); }
	50% { transform: rotateY(180deg) scale(1.1); }
	100% { transform: rotateY(180deg) scale(1); }
}

.card.pop {
	animation: popCard 0.8s ease both;
}

.feedback-square.pop {
	animation: pop 0.8s ease both;
}

/* Shake animation */
.card.cannot-place {
	animation: shake 0.5s ease both;
}

@keyframes shake {
	10%, 90% { transform: translate(-50%, -50%) rotateY(0deg) translateX(-1px); }
	20%, 80% { transform: translate(-50%, -50%) rotateY(0deg) translateX(2px); }
	30%, 50%, 70% { transform: translate(-50%, -50%) rotateY(0deg) translateX(-4px); }
	40%, 60% { transform: translate(-50%, -50%) rotateY(0deg) translateX(4px); }
}

/* Game Navigation Tabs */
.game-tabs {
	display: flex;
	justify-content: center;
	margin-top: 25px;
	padding-top: 20px;
	border-top: 1px solid #d8d8e8;
	gap: 0;
	background: transparent;
}

.game-tab {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 12px 8px;
	text-decoration: none;
	color: #6b6b88 !important;
	background: #fafafe !important;
	transition: all 0.2s ease;
	position: relative;
	border: 1px solid #d8d8e8;
	border-right: none;
}

.game-tab:first-child {
	border-top-left-radius: 8px;
	border-bottom-left-radius: 8px;
}

.game-tab:last-child {
	border-top-right-radius: 8px;
	border-bottom-right-radius: 8px;
	border-right: 1px solid #d8d8e8;
}

.game-tab-active {
	background: #e8e8f8 !important;
	color: #4a4a77 !important;
	font-weight: 600;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
	cursor: default;
}

.game-tab:not(.game-tab-active):hover {
	background: #f0f0fa;
	transform: translateY(-1px);
}

.tab-emoji {
	font-size: 20px;
	margin-bottom: 4px;
}

.tab-name {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}
