@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
	--font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
	--font-mono: "JetBrains Mono", monospace;
	--browser-bar-height: 52px;
	--games-header-height: 112px;

	/* Light theme */
	--bg-primary: #f8fafc;
	--bg-secondary: #f1f5f9;
	--bg-card: #ffffff;
	--text-primary: #0f172a;
	--text-secondary: #475569;
	--text-muted: #94a3b8;
	--accent: #6366f1;
	--accent-hover: #4f46e5;
	--border: #e2e8f0;
	--error: #dc2626;
}

[data-theme="dark"] {
	--bg-primary: #0f172a;
	--bg-secondary: #1e293b;
	--bg-card: #1e293b;
	--text-primary: #f8fafc;
	--text-secondary: #cbd5e1;
	--text-muted: #64748b;
	--accent: #818cf8;
	--accent-hover: #a5b4fc;
	--border: #334155;
	--error: #f87171;
}

* {
	box-sizing: border-box;
}

/* Ad placements */
.ad-vertical {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	width: 160px;
	min-height: 600px;
	z-index: 50;
}

.ad-vertical-left {
	left: 12px;
}

.ad-vertical-right {
	right: 12px;
}

.ad-horizontal {
	width: 100%;
	max-width: 728px;
	min-height: 90px;
	margin: 1.5rem auto 0;
	display: flex;
	justify-content: center;
	align-items: center;
}

/* Horizontal ad responsive - hide on very small screens if needed */
@media (max-width: 400px) {
	.ad-horizontal {
		min-height: 50px;
		margin: 1rem auto 0;
	}
}

/* Hide vertical ads on tablet and mobile */
@media (max-width: 1199px) {
	.ad-vertical {
		display: none;
	}
}

/* Add side margin to main content when vertical ads are visible */
@media (min-width: 1200px) {
	.main-content {
		margin-left: 184px;
		margin-right: 184px;
	}
}

/* Main content */


body {
	font-family: var(--font-sans);
	margin: 0;
	background: var(--bg-primary);
	color: var(--text-primary);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	transition: background-color 0.3s ease, color 0.3s ease;
}

/* Browser navigation bar */
.browser-bar {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	background: var(--bg-primary);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 101;
}

.browser-controls {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	flex-shrink: 0;
}

.browser-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid var(--border);
	background: var(--bg-card);
	color: var(--text-primary);
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.2s, border-color 0.2s;
}

.browser-btn:hover {
	background: var(--bg-secondary);
	border-color: var(--text-muted);
}

.browser-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.browser-btn svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

.browser-url-wrap {
	flex: 1;
	min-width: 0;
}

#browser-url {
	width: 100%;
	padding: 0.5rem 1rem;
	font-family: var(--font-mono);
	font-size: 0.875rem;
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text-primary);
	outline: none;
}

#browser-url:focus {
	border-color: var(--accent);
}

@media (max-width: 480px) {
	.browser-bar {
		padding: 0.5rem;
		gap: 0.25rem;
	}

	.browser-btn {
		width: 32px;
		height: 32px;
	}

	.browser-btn svg {
		width: 16px;
		height: 16px;
	}

	#browser-url {
		font-size: 0.75rem;
		padding: 0.4rem 0.75rem;
	}
}

/* Navbar */
.navbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem 2rem;
	background: var(--bg-secondary);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: var(--browser-bar-height, 52px);
	z-index: 100;
}

.logo {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--text-primary);
	text-decoration: none;
	letter-spacing: -0.02em;
}

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

.nav-links {
	display: flex;
	gap: 2rem;
	align-items: center;
}

.nav-link {
	color: var(--text-secondary);
	text-decoration: none;
	font-weight: 500;
	transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
	color: var(--accent);
}

.theme-toggle {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: 8px;
	width: 44px;
	height: 44px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.theme-icon {
	font-size: 1.25rem;
	position: absolute;
}

.theme-icon.moon { display: none; }
.theme-icon.sun { display: block; }

[data-theme="dark"] .theme-icon.moon { display: block; }
[data-theme="dark"] .theme-icon.sun { display: none; }

.nav-toggle {
	display: none;
	background: none;
	border: none;
	cursor: pointer;
	flex-direction: column;
	gap: 5px;
}

.nav-toggle span {
	width: 24px;
	height: 2px;
	background: var(--text-primary);
	border-radius: 2px;
}

/* Main content */
.main-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	padding: 3rem 1.5rem;
}

/* Hero */
.hero {
	text-align: center;
	max-width: 640px;
}

.hero-title {
	font-size: clamp(2.5rem, 6vw, 4rem);
	font-weight: 700;
	letter-spacing: -0.03em;
	margin: 0 0 0.5rem;
	background: linear-gradient(135deg, var(--accent), #a78bfa);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.hero-tagline {
	font-size: 1.25rem;
	color: var(--text-secondary);
	margin: 0 0 1rem;
	font-weight: 500;
}

.hero-desc {
	color: var(--text-muted);
	font-size: 1rem;
	line-height: 1.6;
	margin: 0 0 2rem;
}

/* Search form */
.search-form {
	display: flex;
	justify-content: center;
	margin-top: 1rem;
}

#uv-address {
	background: var(--bg-card);
	font-family: inherit;
	font-size: 1rem;
	padding: 1rem 1.5rem;
	height: 56px;
	border: 2px solid var(--border);
	color: var(--text-primary);
	border-radius: 12px;
	outline: none;
	width: 100%;
	max-width: 480px;
	transition: border-color 0.2s, box-shadow 0.2s;
}

#uv-address::placeholder {
	color: var(--text-muted);
}

#uv-address:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Quick Links */
.quick-links {
	width: 100%;
	max-width: 720px;
	margin-top: 2.5rem;
	padding: 0 1rem;
}

.quick-links-title {
	font-size: 1rem;
	font-weight: 600;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin: 0 0 1rem;
	text-align: center;
}

.quick-links-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 1rem;
	justify-items: center;
}

.quick-link-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	width: 100%;
	min-height: 100px;
	padding: 1.25rem 1rem;
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: 12px;
	text-decoration: none;
	color: var(--text-primary);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.quick-link-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	border-color: var(--accent);
}

[data-theme="dark"] .quick-link-card:hover {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.quick-link-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
}

.quick-link-icon svg {
	width: 36px;
	height: 36px;
	fill: currentColor;
}

.quick-link-name {
	font-size: 0.9rem;
	font-weight: 500;
	text-align: center;
	line-height: 1.2;
}

@media (max-width: 600px) {
	.quick-links-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 0.75rem;
	}

	.quick-link-card {
		min-height: 90px;
		padding: 1rem 0.75rem;
	}

	.quick-link-icon svg {
		width: 32px;
		height: 32px;
	}

	.quick-link-name {
		font-size: 0.85rem;
	}
}

/* Error area */
.error-area {
	margin-top: 1.5rem;
	text-align: center;
	max-width: 560px;
}

#uv-error {
	color: var(--error);
	white-space: pre-wrap;
	margin: 0;
}

#uv-error-code {
	font-size: 12px;
	font-family: var(--font-mono);
	color: var(--text-muted);
	margin: 0.5rem 0 0;
}

/* Frame (full-page viewer) - positioned below browser bar so nav stays visible */
#uv-frame {
	border: none;
	position: fixed;
	top: var(--browser-bar-height, 52px);
	left: 0;
	width: 100vw;
	height: calc(100vh - var(--browser-bar-height, 52px));
	background: var(--bg-primary);
	z-index: 1000;
}

/* Keep browser bar above frame when viewing proxied content */
body.frame-visible .browser-bar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1001;
}

/* Prevent body scroll when frame is active; frame has its own scroll */
body.frame-visible {
	overflow: hidden;
}

/* Hide navbar and main when frame is active */
body.frame-visible .navbar,
body.frame-visible .main-content,
body.frame-visible .footer {
	visibility: hidden;
	pointer-events: none;
}

#uv-register-sw {
	display: none;
	padding: 0.75rem 1.5rem;
	background: var(--accent);
	color: white;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-family: inherit;
	font-weight: 500;
}

#uv-register-sw.show {
	display: inline-block;
}

#uv-register-sw:hover {
	background: var(--accent-hover);
}

/* Footer */
.footer {
	padding: 1.5rem 2rem;
	background: var(--bg-secondary);
	border-top: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
}

.footer-links {
	display: flex;
	gap: 1.5rem;
}

.footer a {
	color: var(--text-secondary);
	text-decoration: none;
	font-size: 0.9rem;
}

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

.footer-copy {
	color: var(--text-muted);
	font-size: 0.85rem;
}

/* Page layout (for subpages) */
.page-header {
	text-align: center;
	padding: 2rem 1.5rem;
}

.page-title {
	font-size: 2rem;
	font-weight: 700;
	margin: 0 0 0.5rem;
}

.page-desc {
	color: var(--text-secondary);
	margin: 0;
}

/* Games grid */
.games-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1.5rem;
	padding: 2rem;
	max-width: 1200px;
	margin: 0 auto;
}

.game-card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: 12px;
	overflow: hidden;
	transition: transform 0.2s, box-shadow 0.2s;
}

.game-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .game-card:hover {
	box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.game-card iframe {
	width: 100%;
	height: 200px;
	border: none;
	display: block;
}

.game-card-content {
	padding: 1rem 1.25rem;
}

.game-card h3 {
	margin: 0 0 0.25rem;
	font-size: 1.1rem;
}

.game-card p {
	margin: 0;
	font-size: 0.9rem;
	color: var(--text-muted);
}

.game-card .category {
	display: inline-block;
	margin-top: 0.5rem;
	padding: 0.25rem 0.75rem;
	background: var(--bg-secondary);
	border-radius: 6px;
	font-size: 0.75rem;
	color: var(--text-secondary);
}

/* Game card as clickable link (no inline iframe) */
.game-card-link {
	display: block;
	text-decoration: none;
	color: inherit;
	cursor: pointer;
}

.game-card-link .game-card-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 140px;
	background: var(--bg-secondary);
}

.game-card-link .game-card-icon svg {
	width: 48px;
	height: 48px;
	fill: var(--text-muted);
}

/* Game view - dedicated fullscreen game page, below nav */
.game-view {
	position: fixed;
	top: var(--games-header-height, 112px);
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 99;
	background: var(--bg-primary);
	display: flex;
	flex-direction: column;
}

.game-view[hidden] {
	display: none;
}

.game-view-header {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1rem 1.5rem;
	background: var(--bg-secondary);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.game-back-btn {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text-primary);
	font-family: inherit;
	font-size: 0.9rem;
	cursor: pointer;
	transition: background 0.2s, border-color 0.2s;
}

.game-back-btn:hover {
	background: var(--bg-secondary);
	border-color: var(--accent);
}

.game-back-btn svg {
	width: 20px;
	height: 20px;
}

.game-view-title {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 600;
}

.game-iframe-wrap {
	flex: 1;
	min-height: 0;
	position: relative;
}

.game-iframe-wrap iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: none;
}

@media (max-width: 768px) {
	.game-view-header {
		padding: 0.75rem 1rem;
		flex-wrap: wrap;
	}

	.game-back-btn {
		font-size: 0.85rem;
		padding: 0.4rem 0.75rem;
	}

	.game-view-title {
		font-size: 1rem;
	}
}

/* Category filters */
.category-filters {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	padding: 1rem 2rem;
	max-width: 1200px;
	margin: 0 auto;
}

.filter-btn {
	padding: 0.5rem 1rem;
	border: 1px solid var(--border);
	background: var(--bg-card);
	color: var(--text-secondary);
	border-radius: 8px;
	cursor: pointer;
	font-family: inherit;
	font-size: 0.9rem;
	transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
	background: var(--accent);
	color: white;
	border-color: var(--accent);
}

/* Responsive */
@media (max-width: 768px) {
	.nav-links {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		background: var(--bg-secondary);
		flex-direction: column;
		padding: 1rem;
		border-bottom: 1px solid var(--border);
	}

	.nav-links.open {
		display: flex;
	}

	.nav-toggle {
		display: flex;
	}

	.navbar {
		padding: 1rem 1.25rem;
	}

	.hero-desc {
		font-size: 0.95rem;
	}

	.games-grid {
		grid-template-columns: 1fr;
		padding: 1rem;
	}

	.category-filters {
		padding: 1rem;
	}
}
