:root {
	--bg: #0e1014;
	--fg: #f2f3f5;
	--muted: #9aa1ad;
	--accent: #f5b82e;
	--pill: rgba(255, 255, 255, .08);
	--pill-border: rgba(255, 255, 255, .18);
}
* { box-sizing: border-box; }
html, body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--fg);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
}
/* #app is the scroll container (it is also the fullscreen element): carousel on top, list below */
#app {
	position: fixed;
	inset: 0;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-snap-type: y proximity;
	background: var(--bg);
}
#hero {
	position: relative;
	height: 100%;
	display: flex;
	flex-direction: column;
	background: radial-gradient(ellipse at 50% 45%, #232733 0%, var(--bg) 70%);
	scroll-snap-align: start;
}

/* ---------- header ---------- */
.top {
	flex: none;
	display: flex;
	align-items: center;
	gap: 8px;
	height: calc(52px + env(safe-area-inset-top));
	padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
#logo { flex: none; display: flex; align-items: center; border-radius: 6px; }
#logo img { display: block; height: 26px; width: auto; }
#logo .mini { display: none; }
#logo:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
/* the logo already says the site name: on the consoles view the h1 stays for screen readers only */
#back[hidden] + #title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#title {
	flex: 1;
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: .02em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.actions { display: flex; gap: 8px; flex: none; margin-left: auto; }
.pill {
	font: 600 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--fg);
	background: var(--pill);
	border: 1px solid var(--pill-border);
	border-radius: 18px;
	padding: 9px 14px;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
}
.pill:hover, .pill:focus-visible { background: var(--accent); border-color: var(--accent); color: #111; outline: none; }
.pill.primary { background: var(--accent); border-color: var(--accent); color: #111; }
/* header button picked with the arrows / d-pad (js/app.js topMode), Search above the cards (list mode) */
#list-search.kb,
.top .pill.kb { background: var(--accent); border-color: var(--accent); color: #111; outline: none; box-shadow: 0 0 0 3px rgba(245, 184, 46, .35); }
.pill { display: inline-flex; align-items: center; gap: 6px; }
.pill .ico { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#back span[aria-hidden] { font-size: 18px; line-height: 13px; }
[hidden] { display: none !important; }

/* ---------- settings ---------- */
.settings-wrap { position: relative; }
#settings-panel {
	position: fixed;
	right: max(12px, env(safe-area-inset-right));
	top: 56px;
	z-index: 40;
	width: min(260px, calc(100vw - 24px));
	background: #1b1e25;
	border: 1px solid rgba(255, 255, 255, .15);
	border-radius: 12px;
	padding: 12px 14px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
	display: flex;
	flex-direction: column;
	gap: 6px;
}
#settings-panel .opt { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
#settings-panel input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; cursor: pointer; }
#settings-panel small { font-size: 12px; color: var(--muted); line-height: 1.4; }
#settings-panel .opt-group { display: flex; flex-direction: column; gap: 6px; }
#settings-panel .kb { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
#settings-panel .panel-link {
	display: flex; align-items: center; gap: 10px;
	padding: 9px 10px; margin: 2px -4px 0;
	border-radius: 10px; border: 1px solid var(--pill-border);
	color: var(--fg); text-decoration: none; font-size: 14px; font-weight: 600;
}
#settings-panel .panel-link:hover, #settings-panel .panel-link:focus-visible { border-color: var(--accent); background: rgba(245, 184, 46, .12); outline: none; }
#settings-panel .panel-link .ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
#settings-panel .panel-link small { display: block; font-weight: 400; }

/* ---------- carousel ---------- */
#stage {
	position: relative;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	container-type: size;
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
	--s: min(calc(100cqh - 166px), 78cqh, 72cqw, 780px);   /* centre item (room left only for name + info line) */
	--side: calc(var(--s) * .3);     /* items next to it */
	--gap: max(10px, calc(var(--s) * .06));
	--cy: calc(50cqh - 66px);        /* circle + caption block centred */
}
/* short screens (landscape phone): name and info are one line each, so the circle can grow */
@media (max-height: 440px) { #stage { --s: min(calc(100cqh - 134px), 72cqw); --cy: calc(50cqh - 54px); } }
/* guide lifted above "All games" (narrow screens): leave it a row under the caption */
body.guide-up #stage { --s: min(calc(100cqh - 202px), 78cqh, 72cqw, 780px); --cy: calc(50cqh - 84px); }
@media (max-height: 440px) { body.guide-up #stage { --s: min(calc(100cqh - 166px), 72cqw); --cy: calc(50cqh - 70px); } }
#carousel { position: absolute; inset: 0; }
.slide {
	position: absolute;
	left: 50%;
	top: var(--cy);
	width: var(--size, var(--side));
	height: var(--size, var(--side));
	transform: translate(calc(-50% + var(--x, 0px)), -50%);
	border-radius: 50%;
	background: #2b2f3a center / cover no-repeat;
	border: 2px solid rgba(255, 255, 255, .7);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: #fff;
	font-weight: 700;
	font-size: calc(var(--size, var(--side)) * .1);
	padding: calc(var(--size, var(--side)) * .12);
	overflow: hidden;
}
#carousel.ready .slide { transition: transform .45s ease, width .45s ease, height .45s ease, opacity .45s ease, border-width .45s ease; }
.slide.has-img { color: transparent; }
.slide.p0 {
	--size: var(--s);
	z-index: 3;
	border: max(4px, calc(var(--s) * .03)) solid #fff;
	box-shadow: 0 0 0 2px rgba(245, 184, 46, .0), 0 18px 60px rgba(0, 0, 0, .55);
}
#carousel.focus .slide.p0 { box-shadow: 0 0 0 4px var(--accent), 0 18px 60px rgba(0, 0, 0, .55); }
.slide.pm1 { --x: calc(-1 * (var(--s) / 2 + var(--side) / 2 + var(--gap))); z-index: 2; }
.slide.pp1 { --x: calc(var(--s) / 2 + var(--side) / 2 + var(--gap)); z-index: 2; }
.slide.pm2, .slide.pp2 { --size: calc(var(--side) * .6); opacity: .55; z-index: 1; }
.slide.pm2 { --x: calc(-1 * (var(--s) / 2 + var(--side) + var(--side) * .3 + var(--gap) * 2)); }
.slide.pp2 { --x: calc(var(--s) / 2 + var(--side) + var(--side) * .3 + var(--gap) * 2); }
.slide.far { --size: 0px; opacity: 0; pointer-events: none; border-width: 0; }
.slide:not(.p0):hover { border-color: var(--accent); }

/* ---------- caption ---------- */
#caption {
	position: absolute;
	left: 50%;
	top: calc(var(--cy) + var(--s) / 2 + 10px);
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 10px;
	width: min(94cqw, 640px);
	justify-content: center;
}
#name { min-width: 0; text-align: center; display: flex; flex-direction: column; gap: 3px; }
#name-text {
	font-size: clamp(15px, 2.6cqh, 22px);
	line-height: 1.25;
	overflow: hidden;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}
#name-sub {
	font-size: 12px;
	line-height: 1.4;
	color: var(--muted);
	display: flex;
	flex-direction: column;
	min-width: 0;
}
#name-sub .sl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#name-sub.warn, #name-sub .warn { color: var(--accent); }

/* screenshot slideshow inside the centre circle */
.slide .shot {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: #000 center / cover no-repeat;
	opacity: 0;
	transition: opacity .7s ease;
	pointer-events: none;
}
.slide .shot.on { opacity: 1; }
.nav {
	flex: none;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 1px solid var(--pill-border);
	background: var(--pill);
	color: var(--fg);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 0 3px;
}
.nav:hover, .nav:focus-visible { background: var(--accent); color: #111; outline: none; }
.nav:disabled { visibility: hidden; }

/* ---------- status (loading / error / empty) ---------- */
#status {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	color: var(--muted);
	font-size: 15px;
	text-align: center;
	padding: 16px;
	background: var(--bg);
}
#status .spinner {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 4px solid rgba(255, 255, 255, .15);
	border-top-color: var(--accent);
	animation: spin .9s linear infinite;
}
#status.soft { background: transparent; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- footer hint ---------- */

#settings-panel .credit { border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 8px; margin-top: 4px; }
#settings-panel .credit a { color: var(--accent); }

/* ---------- game frame ---------- */
#player {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #000;
	z-index: 50;
}
#app.playing { overflow: hidden; }
#app.playing #hero, #app.playing #list { visibility: hidden; }

/* ---------- "All games ↓" ---------- */
#more {
	position: absolute;
	left: 50%;
	bottom: calc(16px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	z-index: 4;
	font: 600 12px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--muted);
	background: rgba(255, 255, 255, .06);
	border: 1px solid var(--pill-border);
	border-radius: 16px;
	padding: 7px 14px;
	cursor: pointer;
}
#more:hover, #more:focus-visible { color: #111; background: var(--accent); border-color: var(--accent); outline: none; }
@media (hover: none) { #more { bottom: calc(10px + env(safe-area-inset-bottom)); } }
/* short (landscape phone) screens: still centred, a little lower */
@media (max-height: 430px) { #more { bottom: calc(8px + env(safe-area-inset-bottom)); padding: 6px 12px; } }

/* ---------- list under the carousel ---------- */
#list {
	scroll-snap-align: start;
	min-height: 100%;
	padding: 28px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
	max-width: 1280px;
	margin: 0 auto;
}
.list-head { margin-bottom: 18px; }
#list-title { margin: 0 0 6px; font-size: 22px; }
#list-intro { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 760px; }
.cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
	gap: 16px;
}
.card {
	display: flex;
	flex-direction: column;
	background: #171a21;
	border: 1px solid rgba(255, 255, 255, .08);
	border-radius: 14px;
	overflow: hidden;
	color: var(--fg);
	text-decoration: none;
	transition: transform .15s, border-color .15s, box-shadow .15s;
}
.card:hover { border-color: rgba(245, 184, 46, .6); }
.card:focus-visible, .card.kb {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent);
	transform: translateY(-2px);
}
.card .cover { display: block; aspect-ratio: 1; background: #2b2f3a; }
.card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .noimg { display: flex; height: 100%; align-items: center; justify-content: center; text-align: center; padding: 12px; font-weight: 700; }
.card-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; }
.card-title { margin: 0; font-size: 15px; line-height: 1.3; }
.card-line { font-size: 12px; color: var(--muted); }
.card-desc {
	font-size: 12px;
	line-height: 1.45;
	color: #b7bcc6;
	overflow: hidden;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}
.list-foot { margin: 28px 0 0; font-size: 12px; color: var(--muted); opacity: .7; }
/* home page: most played games + link to /games */
#home-games { margin-top: 44px; }
.list-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.list-head h2 { margin: 0 0 6px; font-size: 22px; }
.list-intro { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 760px; }
.see-all { flex: none; }
.see-all span { font-size: 17px; line-height: 12px; }
.cards.games { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
.card .cover { position: relative; }
.rank {
	position: absolute;
	left: 8px;
	top: 8px;
	min-width: 28px;
	height: 28px;
	padding: 0 8px;
	border-radius: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	font: 800 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: #111;
	background: var(--accent);
	box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.all-games {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-top: 18px;
	padding: 16px 20px;
	border-radius: 14px;
	border: 1px solid rgba(245, 184, 46, .35);
	background: linear-gradient(90deg, rgba(245, 184, 46, .14), rgba(245, 184, 46, .04));
	color: var(--fg);
	text-decoration: none;
	transition: border-color .15s, background .15s;
}
.all-games b { display: block; font-size: 17px; }
.all-games small { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }
.all-games .arrow { flex: none; width: 40px; height: 40px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 26px; line-height: 1; color: #111; background: var(--accent); }
.all-games:hover, .all-games:focus-visible { border-color: var(--accent); background: linear-gradient(90deg, rgba(245, 184, 46, .24), rgba(245, 184, 46, .08)); outline: none; }
@media (max-width: 420px) {
	.list-head.row .see-all { display: none; } /* the big link below the cards is enough */
	.cards.games { grid-template-columns: repeat(2, 1fr); }
	.cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
	.card-desc { display: none; }
	.card-title { font-size: 14px; }
}

/* ---------- modal ---------- */
#modal {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, .6);
	padding: 16px;
}
.dialog {
	background: #1b1e25;
	border: 1px solid rgba(255, 255, 255, .15);
	border-radius: 14px;
	padding: 20px 22px;
	max-width: 380px;
	width: 100%;
	text-align: center;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 16px; font-size: 14px; color: #c8ccd4; line-height: 1.45; }
.dialog .row { display: flex; gap: 10px; justify-content: center; }
.dialog .pill { padding: 10px 20px; font-size: 14px; }

/* phones: icon-only header buttons */
@media (max-width: 700px) {
	.top { gap: 6px; }
	#title { font-size: 16px; }
	#logo img { height: 22px; }
	/* inside a console the name needs the room: logo shrinks to the pad icon */
	.top:has(#back:not([hidden])) #logo .full { display: none; }
	.top:has(#back:not([hidden])) #logo .mini { display: block; }
	.top .pill .lbl { display: none; }
	.top .pill { padding: 0; width: 36px; height: 36px; justify-content: center; }
	.top .pill .ico { width: 17px; height: 17px; }
}
/* narrow phones: the full logo and four header buttons do not fit in one row, so only the pad icon */
@media (max-width: 400px) {
	#logo .full { display: none; }
	#logo .mini { display: block; }
}

/* ---------- controller connected / disconnected notice ---------- */
#pad-toast {
	position: fixed;
	left: 50%;
	top: calc(max(0px, env(safe-area-inset-top)) + 60px); /* below the header */
	transform: translate(-50%, -20px);
	z-index: 70;
	width: max-content;
	max-width: calc(100vw - 32px);
	padding: 10px 16px;
	border-radius: 12px;
	background: rgba(27, 30, 37, .95);
	border: 1px solid rgba(255, 255, 255, .15);
	border-left: 4px solid #7ee2a8;
	color: var(--fg);
	font-size: 14px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
	opacity: 0;
	pointer-events: none;
	transition: opacity .25s, transform .25s;
}
#pad-toast.off { border-left-color: #ff8a65; }
#pad-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* "All games" highlighted after one Down press (Down again / Enter / A goes to the list) */
#more.armed {
	color: #111;
	background: var(--accent);
	border-color: var(--accent);
	box-shadow: 0 0 0 4px rgba(245, 184, 46, .35), 0 6px 24px rgba(0, 0, 0, .5);
	animation: more-pulse 1.4s ease-in-out infinite;
	outline: none;
}
#more.armed::after { content: " \00b7  press again"; font-weight: 400; opacity: .8; }
@keyframes more-pulse {
	50% { box-shadow: 0 0 0 8px rgba(245, 184, 46, .15), 0 6px 24px rgba(0, 0, 0, .5); }
}
@media (prefers-reduced-motion: reduce) { #more.armed { animation: none; } }

/* ---------- scrollbar: thin, dark, matches the page ---------- */
#app {
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
#app:hover { scrollbar-color: rgba(255, 255, 255, .32) transparent; }
#app::-webkit-scrollbar { width: 6px; }
#app::-webkit-scrollbar-track { background: transparent; }
#app::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 6px; }
#app::-webkit-scrollbar-thumb:hover { background: var(--accent); }
/* fullscreen: no visible scrollbar at all (wheel, keys, gamepad and touch still scroll) */
#app:fullscreen { scrollbar-width: none; }
#app:fullscreen::-webkit-scrollbar { display: none; width: 0; }
#app:-webkit-full-screen::-webkit-scrollbar { display: none; width: 0; }

/* ---------- key / button guide (keyboard or gamepad in use) ---------- */
#guide {
	position: fixed;
	right: max(12px, env(safe-area-inset-right));
	bottom: calc(12px + env(safe-area-inset-bottom));
	z-index: 30;
	display: none;
	flex-direction: row;
	flex-wrap: nowrap;
	align-items: center;
	gap: 14px;
	width: max-content;
	max-width: calc(100vw - 24px);
	padding: 6px 12px;
	border-radius: 12px;
	background: rgba(14, 16, 20, .82);
	border: 1px solid rgba(255, 255, 255, .1);
	box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
	backdrop-filter: blur(6px);
	font-size: 12px;
	color: var(--muted);
	pointer-events: none;
}
body.show-guide #guide { display: flex; }
/* narrow (portrait phone) screens: one row does not fit, so it may wrap */
@media (max-width: 560px) { body #guide { flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; } }
/* short (landscape phone) screens: tighter row, still in the corner */
@media (max-height: 480px) {
	body #guide { gap: 10px; padding: 4px 9px; font-size: 11px; bottom: calc(8px + env(safe-area-inset-bottom)); }
	body #guide .k { min-width: 16px; height: 16px; }
}
#app.playing ~ #guide, #app.playing #guide { display: none; }
#guide .g { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
#guide .gl { margin-left: 3px; color: var(--fg); }
#guide .or { margin: 0 2px; opacity: .7; }
#guide .k {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 20px; height: 20px; padding: 0 5px;
	border-radius: 5px; border: 1px solid rgba(255, 255, 255, .3);
	background: rgba(255, 255, 255, .08);
	color: var(--fg); font: 600 11px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset;
}
#guide .kp { border-radius: 4px; font-size: 9px; min-width: 18px; height: 18px; background: #2b2f3a; }
#guide .pb {
	display: inline-flex; align-items: center; justify-content: center;
	width: 20px; height: 20px; border-radius: 50%;
	font: 700 11px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #fff;
}
#guide .pb-xbox-ok { background: #2e9d4f; }
#guide .pb-xbox-back { background: #c8402f; }
#guide .pb-ps-ok, #guide .pb-ps-back { background: #1d2230; border: 1px solid rgba(255, 255, 255, .25); font-size: 12px; }
#guide .pb-ps-ok { color: #7da2ff; }
#guide .pb-ps-back { color: #ff6b7a; }
#guide .pb-nin-ok, #guide .pb-nin-back { background: #3a3f4b; border: 1px solid rgba(255, 255, 255, .3); }
/* the guide sits on the button's row; when they would touch (narrow screens) it moves up a row */
body.guide-up #guide { bottom: calc(52px + env(safe-area-inset-bottom)); }
@media (max-height: 430px) { body.guide-up #guide { bottom: calc(42px + env(safe-area-inset-bottom)); } }
#guide .g.hl {
	color: #111;
	background: var(--accent);
	border-radius: 10px;
	padding: 2px 8px 2px 4px;
	margin: -2px 0;
	animation: more-pulse 1.4s ease-in-out infinite;
}
#guide .g.hl .gl { color: #111; font-weight: 600; }
#guide .g.hl .k { color: #111; background: rgba(0, 0, 0, .12); border-color: rgba(0, 0, 0, .45); box-shadow: none; }
#guide .g.hl .or { color: #111; }
@media (prefers-reduced-motion: reduce) { #guide .g.hl { animation: none; } }

/* ---------- search with an on-screen keyboard (js/app.js) ---------- */
#search-layer {
	position: fixed;
	inset: 0;
	z-index: 45;
	display: flex;
	justify-content: center;
	padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	background: rgba(10, 11, 15, .94);
	backdrop-filter: blur(8px);
}
/* the key guide stays on top, the results keep a row free for it */
body.search-on #guide { z-index: 46; }
body.search-on.show-guide #search-layer { padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
.search-wrap { width: min(1180px, 100%); height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.search-left { flex: none; width: min(100%, 560px); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.search-right { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.search-row { display: flex; align-items: center; gap: 8px; }
.search-row > .ico { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
#search-q {
	flex: 1;
	min-width: 0;
	height: 44px;
	padding: 0 14px;
	border-radius: 12px;
	border: 1px solid var(--pill-border);
	background: #171a21;
	color: var(--fg);
	font: 600 17px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	outline: none;
}
#search-q:focus { border-color: var(--accent); }
#search-q::placeholder { color: var(--muted); font-weight: 400; }
#search-close { flex: none; width: 44px; height: 44px; padding: 0; justify-content: center; font-size: 24px; font-weight: 400; }
#search-close.kb { background: var(--accent); border-color: var(--accent); color: #111; box-shadow: 0 0 0 3px rgba(245, 184, 46, .35); }
#osk { display: flex; flex-direction: column; gap: 5px; user-select: none; -webkit-user-select: none; }
.osk-row { display: flex; gap: 5px; justify-content: center; }
.key {
	flex: 0 0 calc((100% - 45px) / 10);
	min-width: 0;
	height: clamp(32px, 7.5vh, 50px);
	padding: 0;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, .14);
	background: #1f232c;
	color: var(--fg);
	font: 600 clamp(13px, 2.4vh, 17px)/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	cursor: pointer;
	box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
	touch-action: manipulation;
}
.key.w3 { flex-basis: calc((100% - 45px) / 10 * 3 + 10px); }
.key.w7 { flex-basis: calc((100% - 45px) / 10 * 7 + 30px); }
.key.wide { font-size: clamp(12px, 2vh, 15px); color: #c8ccd4; background: #272b35; }
.key:hover { border-color: rgba(245, 184, 46, .7); }
.key:active { transform: translateY(1px); box-shadow: none; }
.key:focus { outline: none; }
.key:focus-visible, .key.kb { background: var(--accent); border-color: var(--accent); color: #111; box-shadow: 0 0 0 3px rgba(245, 184, 46, .35); }
#search-count { flex: none; font-size: 13px; color: var(--muted); padding: 0 2px; }
#search-count.none { color: var(--accent); }
#search-results {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
	align-content: start;
	gap: 8px;
	padding: 4px;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
.sr {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	padding: 6px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, .08);
	background: #171a21;
	color: var(--fg);
	text-decoration: none;
}
.sr:hover { border-color: rgba(245, 184, 46, .6); }
.sr:focus { outline: none; }
.sr:focus-visible, .sr.kb { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }
.sr-img { flex: none; width: 56px; height: 56px; border-radius: 7px; overflow: hidden; background: #2b2f3a; }
.sr-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sr-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sr-text b { font-size: 14px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.sr-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* wide screens (desktop, landscape phone): keyboard on the left, results on the right */
@media (min-aspect-ratio: 6/5) {
	.search-wrap { flex-direction: row; gap: 18px; }
	.search-left { width: min(46%, 540px); margin: 0; }
	#search-count { line-height: 44px; } /* results start level with the field */
}
@media (max-height: 480px) {
	#search-layer { padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
	body.search-on.show-guide #search-layer { padding-bottom: calc(36px + env(safe-area-inset-bottom)); }
	.search-left { gap: 6px; }
	#search-q, #search-close { height: 36px; }
	#search-close { width: 36px; }
	#osk, .osk-row { gap: 4px; }
	.key { flex-basis: calc((100% - 36px) / 10); }
	.key.w3 { flex-basis: calc((100% - 36px) / 10 * 3 + 8px); }
	.key.w7 { flex-basis: calc((100% - 36px) / 10 * 7 + 24px); }
	.sr-img { width: 44px; height: 44px; }
}
/* the X / Y (square / triangle) buttons in the guide */
#guide .pb-xbox-2 { background: #2f6fd6; }
#guide .pb-xbox-3 { background: #d9a21b; color: #111; }
#guide .pb-ps-2, #guide .pb-ps-3 { background: #1d2230; border: 1px solid rgba(255, 255, 255, .25); font-size: 12px; }
#guide .pb-ps-2 { color: #ff8fd0; }
#guide .pb-ps-3 { color: #5fd6a4; }
#guide .pb-nin-2, #guide .pb-nin-3 { background: #3a3f4b; border: 1px solid rgba(255, 255, 255, .3); }

/* Search above the cards (list mode) */
#list-search { flex: none; padding: 10px 16px; font-size: 14px; }
#list-search .ico { width: 16px; height: 16px; }

/* search: nothing on this console (or anywhere): a notice instead of the plain count */
#search-count.none { line-height: 1.4; padding: 7px 11px; border-radius: 10px; border: 1px solid rgba(245, 184, 46, .45); background: rgba(245, 184, 46, .1); }

/* search: "Search in" Nintendo NES / All games (inside a console only) */
#search-scope { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#search-scope .scope-lbl { font-size: 12px; color: var(--muted); margin-right: 2px; }
#search-scope .chip {
	font: 600 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	padding: 8px 13px;
	border-radius: 16px;
	border: 1px solid var(--pill-border);
	background: var(--pill);
	color: var(--fg);
	cursor: pointer;
	white-space: nowrap;
}
#search-scope .chip.on { background: rgba(245, 184, 46, .18); border-color: var(--accent); color: var(--accent); }
#search-scope .chip:hover { border-color: rgba(245, 184, 46, .7); }
#search-scope .chip:focus { outline: none; }
#search-scope .chip:focus-visible, #search-scope .chip.kb { background: var(--accent); border-color: var(--accent); color: #111; box-shadow: 0 0 0 3px rgba(245, 184, 46, .35); }
@media (max-height: 480px) { #search-scope .chip { padding: 6px 11px; font-size: 12px; } }
/* links to About / Help / Contact / legal pages under the list (index.php) */
.site-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 40px 0 0; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 14px; }
.site-links a { color: #d6d9df; font-weight: 600; text-decoration: none; }
.site-links a:hover { color: #f5b82e; }
.site-links + .list-foot { margin-top: 12px; }
