:root {
	--bg: #0a0f14;
	--bg-darker: #141c24;
	--bg-card: rgba(10, 15, 20, 0.92);
	--bg-input: rgba(20, 28, 36, 0.85);
	--text: #d4d4d4;
	--muted: #6b7280;
	--team-color-1: #88c0d0;
	--team-color-2: #81a1c1;
	--glow-color-1: rgba(136, 192, 208, 0.35);
	--glow-color-2: rgba(129, 161, 193, 0.2);
	--accent-soft: rgba(136, 192, 208, 0.45);
	--surface-1: rgba(10, 15, 20, 0.92);
	--surface-2: rgba(20, 28, 36, 0.84);
	--surface-3: rgba(20, 28, 36, 0.64);
	--border: rgba(255, 255, 255, 0.07);
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	font-family: "Poppins", system-ui, sans-serif;
	background: linear-gradient(180deg, var(--bg), var(--bg-darker));
	color: var(--text);
	min-height: 100vh;
	line-height: 1.5;
	overflow: hidden;
}

#particles-js {
	position: absolute;
	inset: 0;
	z-index: 2;
	background: radial-gradient(circle at top, var(--glow-color-1), var(--bg-darker));
	pointer-events: none;
}

.particles-canvas {
	display: block;
	width: 100%;
	height: 100%;
	opacity: 1;
}

.app-shell {
	position: relative;
	z-index: 1;
	height: 100%;
	display: flex;
	flex-direction: column;
	padding: 0.8rem 1rem;
	gap: 0.8rem;
}

.chrome {
	display: grid;
	gap: 0.7rem;
}

.tabs-row {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	background: var(--surface-3);
	border-radius: 1.1rem;
	padding: 0.4rem 0.55rem;
	border: 1px solid var(--border);
}

.tabs {
	display: flex;
	gap: 0.35rem;
	flex: 1;
	overflow-x: auto;
}

.tab {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.42rem 0.85rem;
	border-radius: 1rem;
	background: var(--surface-3);
	border: 1px solid var(--border);
	color: var(--text);
	font-size: 0.75rem;
	cursor: pointer;
	white-space: nowrap;
}

.tab.active {
	background: var(--surface-1);
	border-color: var(--accent-soft);
}

.tab-close {
	background: transparent;
	border: none;
	color: var(--muted);
	cursor: pointer;
	font-size: 0.8rem;
}

.tab-add {
	width: 34px;
	height: 34px;
	border-radius: 0.8rem;
	border: 1px solid var(--border);
	background: var(--surface-3);
	color: var(--text);
	cursor: pointer;
}

.shortcut-counter {
	font-size: 0.7rem;
	color: var(--muted);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.2rem 0.6rem;
	background: var(--bg-input);
}

.toolbar {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 0.8rem;
	border-radius: 1.2rem;
	padding: 0.7rem 0.8rem;
	background: var(--surface-2);
	border: 1px solid var(--border);
}

.toolbar-nav,
.toolbar-actions {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.nav-btn,
.toolbar-btn {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 1px solid var(--border);
	background: var(--surface-3);
	color: var(--text);
	cursor: pointer;
}

.toolbar-btn-logo {
	width: 16px;
	height: 16px;
	display: block;
	margin: 0 auto;
}

#aiBtn {
	width: 36px;
	height: 36px;
	border-radius: 10px;
}

#aiBtn .toolbar-btn-logo {
	width: 18px;
	height: 18px;
}

.address-bar {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	background: var(--bg-input);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.35rem 0.65rem;
}

.address-bar input {
	flex: 1;
	background: transparent;
	border: none;
	color: var(--text);
	font-size: 0.9rem;
	outline: none;
	font-family: inherit;
}

.address-bar button,
.home-search button {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(135deg, var(--team-color-1), var(--team-color-2));
	color: #111827;
	cursor: pointer;
}

.browser-shell {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0;
	flex: 1 1 auto;
	min-height: 0;
}

.browser-main {
	display: flex;
	flex-direction: column;
	min-height: 100%;
}

.browser-stage {
	position: relative;
	border-radius: 1.2rem;
	background: var(--surface-3);
	flex: 1;
	overflow: hidden;
	border: 1px solid var(--border);
}

#browserFrame {
	width: 100%;
	height: 100%;
	border: none;
	background: transparent;
	display: block;
}

.loading-banner {
	position: absolute;
	top: 0.75rem;
	left: 50%;
	transform: translateX(-50%);
	padding: 0.3rem 0.7rem;
	border-radius: 999px;
	font-size: 0.75rem;
	color: #e5e7eb;
	background: var(--surface-1);
	border: 1px solid var(--border);
	display: none;
	z-index: 9;
}

.loading-banner.show {
	display: inline-flex;
}

.browser-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(circle at top, rgba(10, 15, 20, 0.78), rgba(20, 28, 36, 0.82));
	z-index: 6;
}

.internal-page {
	position: absolute;
	inset: 0;
	display: none;
	z-index: 7;
	background: radial-gradient(circle at top, rgba(10, 15, 20, 0.84), rgba(20, 28, 36, 0.9));
	padding: 1rem;
	overflow-y: auto;
}

#aiPage {
	overflow: hidden;
}

.internal-page.active {
	display: block;
}

.settings-page-shell {
	max-width: 760px;
	margin: 0 auto;
	border: 1px solid var(--border);
	border-radius: 1rem;
	background: var(--bg-card);
}

.settings-page-header {
	padding: 0.9rem 1rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-page-header h2 {
	font-size: 1rem;
	font-weight: 600;
}

.settings-page-body {
	padding: 0.2rem 0;
}

.home-shell {
	display: grid;
	gap: 0.7rem;
	text-align: center;
	width: min(860px, 92%);
}

.home-logo {
	font-size: clamp(2.2rem, 5vw, 3.5rem);
	font-weight: 700;
	color: #e8e8e8;
	text-shadow: 0 0 18px var(--glow-color-1);
}

.home-tagline {
	font-size: 0.9rem;
	color: var(--muted);
}

.home-search {
	display: grid;
	grid-template-columns: auto 1fr auto;
	gap: 0.5rem;
	align-items: center;
	padding: 0.45rem 0.7rem;
	border-radius: 999px;
	background: var(--bg-input);
	border: 1px solid var(--border);
}

.home-search-icon {
	color: var(--muted);
}

.home-search input {
	background: transparent;
	border: none;
	color: var(--text);
	font-size: 0.9rem;
	outline: none;
	font-family: inherit;
}

.home-tiles {
	display: flex;
	justify-content: center;
}

.home-credits {
	position: fixed;
	left: 1.2rem;
	bottom: 1rem;
	margin-top: 0;
	z-index: 7;
}

.home-credits a {
	font-size: 0.78rem;
	color: var(--team-color-1);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.home-tile {
	min-width: 180px;
	padding: 0.65rem 0.7rem;
	border-radius: 0.9rem;
	border: 1px solid var(--border);
	background: var(--bg-card);
	color: var(--text);
	display: grid;
	gap: 0.35rem;
	justify-items: center;
	cursor: pointer;
}

.tile-icon {
	width: 34px;
	height: 34px;
	border-radius: 0.75rem;
	background: var(--surface-3);
	display: flex;
	align-items: center;
	justify-content: center;
}

.tile-label {
	font-size: 0.75rem;
}

.popup-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s;
	padding: 1rem;
}

.popup-overlay.open {
	opacity: 1;
	pointer-events: all;
}

.modal-content {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: 0.9rem;
	width: min(92vw, 380px);
	max-height: 88vh;
	display: flex;
	flex-direction: column;
}

.settings-content {
	width: min(92vw, 460px);
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.7rem 1rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header-right {
	display: flex;
	gap: 0.4rem;
}

.modal-label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
}

.close-btn,
.clear-btn {
	border-radius: 0.7rem;
	border: 1px solid var(--border);
	background: var(--surface-3);
	color: var(--text);
	padding: 0.2rem 0.55rem;
	cursor: pointer;
}

.modal-body {
	overflow-y: auto;
	padding: 0.4rem 0;
}

.history-item {
	padding: 0.55rem 0.75rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.04);
	font-size: 0.74rem;
	word-break: break-all;
}

.settings-section {
	padding: 0.8rem 1rem;
	display: grid;
	gap: 0.55rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.settings-label {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
}

.settings-select {
	width: 100%;
	padding: 0.6rem 0.75rem;
	border-radius: 0.75rem;
	border: 1px solid var(--border);
	background: var(--bg-input);
	color: #fff;
	font-family: inherit;
}

.settings-input {
	width: 100%;
	padding: 0.6rem 0.75rem;
	border-radius: 0.75rem;
	border: 1px solid var(--border);
	background: var(--bg-input);
	color: #fff;
	font-family: inherit;
}

.settings-row {
	display: flex;
	gap: 0.6rem;
}

.open-mode-row .open-mode-btn {
	flex: 1 1 220px;
}

.open-mode-btn.active {
	border-color: var(--accent-soft);
	box-shadow: 0 0 0 1px var(--accent-soft) inset;
	background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
}

.settings-color {
	flex: 1;
	height: 36px;
	border-radius: 0.6rem;
	border: 1px solid var(--border);
	background: transparent;
}

.settings-btn {
	padding: 0.55rem 0.8rem;
	border-radius: 0.7rem;
	border: 1px solid var(--border);
	background: var(--surface-3);
	color: var(--text);
	cursor: pointer;
	white-space: nowrap;
}

.settings-hint {
	font-size: 0.72rem;
	color: var(--muted);
}

.panic-box {
	display: grid;
	gap: 0.45rem;
}

.panic-title {
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--text);
}

.panic-key-pill {
	font-size: 1.2rem;
	font-weight: 700;
	background: rgba(255, 255, 255, 0.12);
	padding: 0.25rem 0.8rem;
	border-radius: 0.5rem;
	min-width: 2.4rem;
	text-align: center;
}

.credits-page-shell {
	max-width: 760px;
	margin: 0 auto;
	border: 1px solid var(--border);
	border-radius: 1rem;
	background: var(--bg-card);
}

.games-page-shell {
	max-width: none;
	width: 100%;
	margin: 0;
	border: 1px solid var(--border);
	border-radius: 1rem;
	background: var(--bg-card);
}

.games-toolbar {
	padding: 0 1rem 0.4rem;
}

.games-search {
	width: 100%;
	font-family: "Poppins", system-ui, sans-serif;
}

.ai-page-shell {
	max-width: none;
	width: 100%;
	margin: 0;
	border: 1px solid var(--border);
	border-radius: 1rem;
	background: var(--bg-card);
	height: 100%;
	display: flex;
	flex-direction: column;
}

.ai-body {
	padding: 0.2rem 0;
	flex: 1;
	min-height: 0;
}

.ai-chat {
	padding: 1.15rem;
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
	height: 100%;
}

.ai-chat button,
.ai-chat input,
.ai-chat select {
	font-family: "Poppins", sans-serif;
	font-weight: 400;
	font-style: normal;
}

.ai-speed-row {
	display: grid;
	grid-template-columns: auto 220px;
	align-items: center;
	gap: 0.6rem;
}

.ai-speed-select {
	padding: 0.5rem 0.65rem;
}

.ai-result {
	flex: 1;
	padding: 1rem 1.05rem;
	border: 1px solid var(--border);
	border-radius: 0.95rem;
	background: var(--surface-2);
	font-size: 0.86rem;
	white-space: pre-wrap;
	word-break: break-word;
	min-height: 420px;
	overflow-y: auto;
}

.ai-text-block {
	white-space: normal;
}

.ai-response-prefix {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin-bottom: 0.45rem;
}

.ai-response-prefix-logo {
	width: 14px;
	height: 14px;
	display: block;
}

.ai-response-prefix-text {
	font-size: 0.82rem;
	color: var(--muted);
}

.ai-response-body {
	display: block;
}

.ai-thread {
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
}

.ai-msg {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.ai-msg-prefix {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
}

.ai-user-prefix-icon {
	font-size: 0.92rem;
	color: var(--muted);
}

.ai-msg-content {
	display: block;
	white-space: pre-wrap;
	word-break: break-word;
}

.ai-code-block {
	margin-top: 0.6rem;
	border: 1px solid var(--border);
	border-radius: 0.65rem;
	background: var(--surface-1);
	overflow: hidden;
}

.ai-code-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.45rem 0.55rem;
	border-bottom: 1px solid var(--border);
	background: var(--surface-2);
}

.ai-code-lang {
	font-size: 0.7rem;
	color: var(--muted);
	text-transform: lowercase;
	letter-spacing: 0.03em;
}

.ai-code-actions {
	display: flex;
	gap: 0.4rem;
}

.ai-code-btn {
	padding: 0.22rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 0.42rem;
	background: var(--surface-3);
	color: var(--text);
	font-size: 0.7rem;
	font-family: "Poppins", sans-serif;
	font-weight: 400;
	cursor: pointer;
}

.ai-code-btn:hover {
	filter: brightness(1.08);
}

.ai-code-block pre {
	margin: 0;
	padding: 0.7rem 0.75rem;
	overflow: auto;
	font-size: 0.74rem;
	line-height: 1.35;
}

.ai-code-block code {
	font-family: Consolas, "Courier New", monospace;
}

.ai-prompt-wrap {
	display: flex;
	gap: 0.55rem;
	margin-top: auto;
	padding-top: 0.2rem;
	position: sticky;
	bottom: 0;
	background: linear-gradient(180deg, transparent, var(--bg-card) 18%);
	padding-bottom: 0.2rem;
}

.ai-prompt {
	flex: 1;
	min-height: 46px;
	padding: 0.75rem 0.9rem;
}

.games-grid {
	padding: 1rem;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 0.75rem;
}

.game-card {
	display: grid;
	grid-template-rows: 130px auto;
	border: 1px solid var(--border);
	border-radius: 0.8rem;
	background: var(--surface-2);
	overflow: hidden;
	text-align: left;
	color: var(--text);
	font-family: "Poppins", system-ui, sans-serif;
	font-weight: 400;
	cursor: pointer;
}

.game-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	background: var(--surface-3);
}

.game-body {
	padding: 0.6rem 0.65rem 0.7rem;
	display: grid;
	gap: 0.28rem;
}

.game-title {
	font-size: 0.82rem;
	font-weight: 600;
}

.game-desc {
	font-size: 0.72rem;
	color: var(--muted);
}

.credits-link {
	color: var(--team-color-1);
	text-decoration: underline;
	text-underline-offset: 2px;
}

@media (max-width: 760px) {
	.toolbar {
		grid-template-columns: 1fr;
	}

	.toolbar-nav,
	.toolbar-actions {
		justify-content: center;
	}
}
