/* "wired" theme for EmyGames, after Serial Experiments Lain: black CRT screen with scan lines and static,
 * pale cold-grey monospace text in lower case, thin 1px lines, red accent, chromatic glitch on titles.
 * serve.py injects this file into every page (it is served from /_theme/theme.css).
 * Other looks are kept next to it: theme.modern.css, theme.retro-blue.css, theme.retro-red.css
 * (copy one over this file to switch). */

html,
html[data-theme],
html[data-mode],
html[data-mode][data-theme] {
  --color-bg: #050607 !important;
  --color-surface: #0a0d0f !important;
  --color-surface-2: #11161a !important;
  --color-surface-3: #1b2328 !important;
  --color-border: #232c31 !important;
  --color-border-2: #3a464c !important;
  --color-border-subtle: #2d373c !important;
  --color-accent: #e0323c !important;
  --color-accent-soft: #e0323c24 !important;
  --color-accent-glow: #e0323c59 !important;
  --color-ring: #e0323c !important;
  --color-text-1: #d6dfe2 !important;
  --color-text-2: #a3b0b5 !important;
  --color-text-3: #6b7a80 !important;
  --color-green: #7fe0b0 !important;
  --color-red: #ff5964 !important;
  --color-amber: #d9b25a !important;
  --glass-bg: #050607e6 !important;
  --font-body: Consolas, "Lucida Console", "MS Gothic", "Courier New", monospace !important;
  --font-sans: Consolas, "Lucida Console", "MS Gothic", "Courier New", monospace !important;
  --font-display: Consolas, "Lucida Console", "MS Gothic", "Courier New", monospace !important;
  --font-mono: Consolas, "Lucida Console", "MS Gothic", "Courier New", monospace !important;
  --line: #232c31;
  --line-2: #3a464c;
  --red: #e0323c;
  --cyan: #7fd6e0;
  color-scheme: dark;
}

/* the screen: black with a very faint wire grid */
html { background-color: #050607 !important; }
html body { background-color: transparent !important; }
/* The grid and the red glow are drawn once on a fixed layer behind the page. They used to be the body's background with
 * "background-attachment: fixed", which makes the browser paint the whole background again on every scroll step: on a PC
 * without a good graphics card that was about 40% of the cost of each frame at 1920x1080 (measured). Same look. */
html::before {
  content: "";
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(900px 500px at 78% -10%, rgba(224, 50, 60, 0.07), transparent 60%),
    linear-gradient(rgba(140, 180, 190, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 180, 190, 0.05) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
}
body {
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0.01em;
}
::selection { background: #e0323c; color: #000; }

/* everything is square and flat */
*, *::before, *::after { border-radius: 0 !important; }

/* No blur behind overlays (search box, menus, bars). A backdrop blur has to be calculated again on every frame while
 * anything under it moves, and here the scan lines / static / glitch keep moving: that made the search box and its
 * results slow to hover. The overlays keep their dark tint, only the blur is gone. */
*, *::before, *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }

/* ----- CRT: scan lines + vignette, static, a slow rolling band ------------------------------------ */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: 9998;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 0, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.6) 100%);
}
body::after {
  content: "";
  position: fixed; inset: -10%;   /* a bit larger than the screen so the shake never shows an edge (kept small: it is a full-screen layer) */
  z-index: 9997;
  pointer-events: none;
  will-change: transform;
  contain: strict;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.2 -0.1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: lain-static 0.8s steps(1) infinite;
}
html::after {
  content: "";
  position: fixed; left: 0; right: 0; top: 0;
  height: 18vh;
  z-index: 9996;
  pointer-events: none;
  will-change: transform;
  background: linear-gradient(to bottom, transparent, rgba(190, 230, 240, 0.035), transparent);
  transform: translateY(-20vh);
  animation: lain-roll 9s linear infinite;
}
@keyframes lain-static {   /* moves are small (the layer is only 10% bigger than the screen on each side) */
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 3%); }
  40%  { transform: translate(4%, -5%); }
  60%  { transform: translate(-3%, 6%); }
  80%  { transform: translate(6%, 2%); }
}
/* transform only (runs on the GPU compositor, no layout): the band crosses the screen from above to below */
@keyframes lain-roll { from { transform: translateY(-20vh); } to { transform: translateY(110vh); } }
@keyframes lain-blink { 50% { opacity: 0; } }
@keyframes lain-glitch {
  0%, 91%, 100% { transform: none; text-shadow: 1.5px 0 rgba(255, 40, 70, 0.55), -1.5px 0 rgba(0, 220, 255, 0.45); }
  92% { transform: translate(-3px, 0) skewX(10deg); text-shadow: 4px 0 rgba(255, 40, 70, 0.9), -4px 0 rgba(0, 220, 255, 0.8); }
  94% { transform: translate(3px, 1px) skewX(-6deg); text-shadow: -3px 0 rgba(255, 40, 70, 0.9), 3px 0 rgba(0, 220, 255, 0.8); }
  96% { transform: translate(-1px, -1px); text-shadow: 2px 0 rgba(255, 40, 70, 0.8), -2px 0 rgba(0, 220, 255, 0.7); }
}
@media (prefers-reduced-motion: reduce) {
  body::after, html::after, h1.font-display, header.site-header a.font-display { animation: none !important; }
}

/* ----- type: monospace, lower case titles, chromatic aberration ---------------------------------- */
.font-display { font-stretch: normal; font-variation-settings: normal; font-weight: 400; }
h1.font-display,
h2.font-display,
a.font-display.uppercase {
  text-transform: lowercase !important;
  letter-spacing: 0.06em;
  font-weight: 400;
}
h1.font-display {
  color: #e6eef0;
  text-shadow: 1.5px 0 rgba(255, 40, 70, 0.55), -1.5px 0 rgba(0, 220, 255, 0.45);
  animation: lain-glitch 7s steps(1, end) infinite;
}
h1.font-display .text-accent { color: #e0323c; }
h2.font-display { color: #e6eef0; }
/* small display texts (game titles, labels) keep their own case */
p.font-display, h3.font-display, h4.font-display, span.font-display, div.font-display {
  font-weight: 400 !important;
  letter-spacing: 0.02em;
}

:focus-visible { outline: 1px solid #e0323c !important; outline-offset: 2px; }

/* links inside text */
main p a, main li a, main td a { color: #7fd6e0; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
main p a:hover, main li a:hover, main td a:hover { color: #e0323c; }

/* ----- buttons: thin outline, red on hover -------------------------------------------------------- */
button:not([role="switch"]):not([class*="bg-accent"]),
a[class*="rounded"][class*="border"]:not([class*="bg-accent"]) {
  background: transparent !important;
  color: var(--color-text-2) !important;
  border: 1px solid var(--line-2) !important;
  box-shadow: none !important;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  transition: border-color 0.12s, color 0.12s, background-color 0.12s;
}
button:not([role="switch"]):not([class*="bg-accent"]):hover,
a[class*="rounded"][class*="border"]:not([class*="bg-accent"]):hover {
  border-color: #e0323c !important;
  color: #fff !important;
  background: rgba(224, 50, 60, 0.1) !important;
}
button:not([role="switch"]):not([class*="bg-accent"]):active,
a[class*="rounded"][class*="border"]:not([class*="bg-accent"]):active { background: rgba(224, 50, 60, 0.28) !important; }
button:disabled { opacity: 0.4; }

/* the tabs of the requests board (abiertas / en curso / en espera / agregado / rechazadas): the one that is chosen stays
 * boxed in red (the rule above makes every button look the same, so the chosen one would not show) */
button[class*="text-accent"][class*="bg-surface"][class*="shadow-sm"]:not([role="switch"]):not([class*="bg-accent"]),
button[class*="text-accent"][class*="bg-surface"][class*="shadow-sm"]:not([role="switch"]):not([class*="bg-accent"]):hover,
button[class*="text-accent"][class*="bg-surface"][class*="shadow-sm"]:not([role="switch"]):not([class*="bg-accent"]):active {
  border-color: #e0323c !important;
  background: rgba(224, 50, 60, 0.2) !important;
  color: #fff !important;
  box-shadow: 0 0 12px -3px rgba(224, 50, 60, 0.65), inset 0 0 0 1px rgba(224, 50, 60, 0.35) !important;
}

/* primary buttons: solid dark red, red edge */
.bg-accent { background-image: none !important; background-color: #9e1b25 !important; }
a.bg-accent,
button.bg-accent {
  color: #fff !important;
  border: 1px solid #e0323c !important;
  box-shadow: 0 0 14px -2px rgba(224, 50, 60, 0.45) !important;
  text-transform: lowercase;
  letter-spacing: 0.08em;
  text-shadow: 1px 0 rgba(255, 40, 70, 0.6), -1px 0 rgba(0, 220, 255, 0.4);
}
a.bg-accent:hover,
button.bg-accent:hover { background-color: #c2202d !important; box-shadow: 0 0 22px -2px rgba(224, 50, 60, 0.7) !important; }

/* on/off switch */
button[role="switch"] > span:first-child { background: #000 !important; border: 1px solid var(--line-2); }
button[role="switch"] > span:first-child > span { background: #6b7a80 !important; }
button[role="switch"][aria-checked="true"] > span:first-child > span { background: #e0323c !important; }

/* fields */
input,
textarea,
select {
  caret-color: #e0323c;
  background: #000 !important;
  color: var(--color-text-1) !important;
  border: 1px solid var(--line-2) !important;
  box-shadow: none !important;
}
input::placeholder, textarea::placeholder { color: #566368 !important; }
input:focus, textarea:focus, select:focus { border-color: #e0323c !important; outline: none; }
kbd { background: transparent !important; border: 1px solid var(--line-2) !important; color: var(--color-text-3) !important; }

/* floating menus and dialogs */
[class*="absolute"][class*="bg-surface"][class*="border"],
[role="menu"], [role="listbox"], [role="dialog"] {
  background: #07090a !important;
  border: 1px solid var(--line-2) !important;
  box-shadow: 0 0 0 1px #000, 0 12px 34px rgba(0, 0, 0, 0.85) !important;
  backdrop-filter: none !important;
}

/* dialog buttons: a label that needs two lines breaks in the middle ("mantener la / sesión iniciada"), not with a
 * lonely word on the second line, and the main button ("cerrar sesión") keeps its label on one line */
[role="dialog"][aria-modal="true"] button { text-wrap: balance; line-height: 1.25; }
[role="dialog"][aria-modal="true"] button.bg-accent { flex-shrink: 0; }

/* thin dark scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #050607; border-left: 1px solid var(--line); }
::-webkit-scrollbar-thumb { background: #1b2328; border: 1px solid var(--line-2); }
::-webkit-scrollbar-thumb:hover { background: #3a1216; border-color: #e0323c; }
::-webkit-scrollbar-corner { background: #050607; }

/* ====================================================================================================
 * THE PAGE IS ONE TERMINAL WINDOW (all sizes): title strip "wired // emygames" and a thin frame
 * ================================================================================================== */
main#main-content {
  background: rgba(5, 6, 7, 0.86) !important;
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px #000, 0 0 40px -10px rgba(224, 50, 60, 0.18);
  width: calc(100% - 16px);
  margin: 8px auto 14px;
  padding: 0;
}
main#main-content::before {
  content: "conectado a la wired de emygames_";
  display: block;
  margin: 0;
  padding: 7px 12px 7px 30px;
  background:
    linear-gradient(#e0323c, #e0323c) no-repeat 13px center / 6px 6px,
    #080b0d;
  border-bottom: 1px solid var(--line);
  color: #8a9da5;
  font: 400 11px/16px var(--font-body);
  letter-spacing: 0.16em;
  text-transform: lowercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* the same line in the other languages */
html:lang(en) main#main-content::before { content: "connected to the wired of emygames_"; }
html:lang(de) main#main-content::before { content: "verbunden mit der wired von emygames_"; }
html:lang(pt) main#main-content::before { content: "conectado à wired de emygames_"; }
html:lang(ru) main#main-content::before { content: "подключено к wired emygames_"; }
html:lang(zh) main#main-content::before { content: "已连接到 emygames_ 的 wired"; }
/* the page content inside the window (home: <main>, other pages: <div>) */
#main-content > main.container-page { padding: 18px 12px 22px !important; max-width: none; }
#main-content > div.container-page { padding-top: 18px; }
#main-content > div.min-h-screen { background: transparent !important; }

/* game banner: picture in a thin frame, light shading only so the logo stays readable */
#main-content section.relative.w-full.overflow-hidden { border-bottom: 1px solid var(--line); }
#main-content section.relative.w-full.overflow-hidden img:first-of-type { opacity: 1 !important; }
img[src*="library_hero"] { filter: grayscale(0.35) contrast(1.1) brightness(0.85); }
#main-content div.container-page.-mt-8 > nav,
#main-content div.container-page.-mt-8 > nav * { color: #cfd9dc !important; text-shadow: 0 1px 2px #000; }
.hero-scrim { background: linear-gradient(to top, rgba(5, 6, 7, 0.95) 0%, rgba(5, 6, 7, 0.25) 55%, rgba(5, 6, 7, 0) 100%) !important; }
.hero-scrim-side { background: linear-gradient(to right, rgba(5, 6, 7, 0.7) 0%, rgba(5, 6, 7, 0) 55%) !important; }

body footer.w-full {
  background: rgba(5, 6, 7, 0.86) !important;
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px #000;
  width: calc(100% - 16px);
  margin: 0 auto 14px !important;
  color: var(--color-text-3);
}

/* footer: only Biblioteca / Géneros / Ayuda stay, centered, with the credit line centered under them.
 * Gone: the "Comunidad" and "Incluido en" columns (the 4th and 5th, whatever the language) and the big
 * "EMYGAMES" logo with its tagline. */
footer.w-full > .container-page > div:first-child > nav:nth-child(n+4) { display: none !important; }
footer.w-full > .container-page > div:last-child > div.min-w-0 { display: none !important; }
footer.w-full > .container-page > div:first-child {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  gap: 32px 72px !important;
  text-align: center;
}
footer.w-full > .container-page > div:first-child > nav { min-width: 120px; }
footer.w-full > .container-page > div:last-child {
  justify-content: center !important;
  align-items: center !important;
  text-align: center;
  padding-top: 24px !important;
  padding-bottom: 28px !important;
}

/* sticky filter bar: its backdrop is a black strip as wide as the window */
.full-bleed-bar:before {
  left: -12px !important; right: -12px !important; width: auto !important;
  background: rgba(5, 6, 7, 0.96) !important;
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* game tiles: thin frame, posters slightly washed like a bad signal, caption strip with a red edge */
section.game-grid > a > div:first-child {
  border: 1px solid var(--line) !important;
  background: #000 !important;
  box-shadow: none !important;
}
/* hover is instant (no filter / glow transitions: those repaint the tile on every frame of the animation) */
section.game-grid img { filter: grayscale(0.4) contrast(1.08) brightness(0.9); transition: none !important; }
section.game-grid > a > div:first-child { transition: none !important; }
section.game-grid > a:hover img { filter: none; }
section.game-grid > a:hover > div:first-child { border-color: #e0323c !important; box-shadow: 0 0 10px -3px rgba(224, 50, 60, 0.6) !important; }
section.game-grid > a > div:first-child > div.absolute {
  background: rgba(5, 6, 7, 0.93) !important;
  border-top: 1px solid #e0323c;
  backdrop-filter: none !important;
}

/* ====================================================================================================
 * LAYOUT (desktop, >= 1024px): navigation terminal on the left, hero as a "welcome" panel,
 * game tiles with the title always on the poster. Below 1024px the site keeps its own mobile layout.
 * ================================================================================================== */
@media (min-width: 1024px) {
  :root { --sb: 244px; }

  /* --- the top header becomes a black column on the left; the logo is its title strip ----------- */
  header.site-header {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: var(--sb);
    height: 100vh;
    display: flex !important;
    flex-direction: column;
    overflow: visible;
    padding: 0 0 72px;
    border: 0 !important;
    border-right: 1px solid var(--line) !important;
    background: linear-gradient(180deg, #080b0d 0%, #050607 100%) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    z-index: 60;
  }
  header.site-header > .container-page {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 14px !important;
    height: auto !important;
    min-height: calc(100vh - 72px);  /* so "idioma" / "iniciar sesión" can sit at the bottom */
    max-width: none;
    padding: 0 12px !important;
    grid-template-columns: none !important;
  }
  /* logo */
  header.site-header > .container-page > div:nth-child(1) {
    order: 0;
    margin: 0 -12px;
    padding: 12px 16px 11px;
    border-bottom: 1px solid var(--line);
    background: #080b0d;
  }
  header.site-header a.font-display {
    font-size: 17px !important;
    line-height: 22px;
    letter-spacing: 0.28em;
    color: #e6eef0 !important;
    text-shadow: 1.5px 0 rgba(255, 40, 70, 0.55), -1.5px 0 rgba(0, 220, 255, 0.45);
    animation: lain-glitch 6s steps(1, end) infinite;
    display: inline-block;
  }
  header.site-header a.font-display span { color: #e0323c !important; }
  header.site-header a.font-display::after { content: "_"; color: #e0323c; animation: lain-blink 1s steps(1) infinite; }
  /* search + language + account: the group dissolves so each piece can be placed on its own:
   * search under the logo, main links next, language and account at the bottom of the column */
  header.site-header > .container-page > div:nth-child(3) { display: contents; }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(1) { order: 1; margin: 0 !important; display: block; }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(2) { order: 3; margin-top: auto !important; }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(3) { order: 4; margin-top: -6px !important; }
  header.site-header > .container-page > div:nth-child(3) > span:first-child > button {
    width: 100%; height: 36px;
    background: #000 !important; color: var(--color-text-3) !important;
    border: 1px solid var(--line-2) !important;
  }
  /* the search button: icon, "buscar juegos..." and "ctrl k" always on ONE line */
  header.site-header > .container-page > div:nth-child(3) > span:first-child > button {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding: 0 8px !important;
    white-space: nowrap !important;
    letter-spacing: 0 !important;
    font-size: 12px !important;
    text-align: left;
  }
  header.site-header > .container-page > div:nth-child(3) > span:first-child > button > svg { flex: 0 0 auto; }
  header.site-header > .container-page > div:nth-child(3) > span:first-child > button > span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap !important;
    line-height: 1.2;
  }
  header.site-header > .container-page > div:nth-child(3) > span:first-child > button > kbd {
    flex: 0 0 auto;
    margin-left: auto !important;
    white-space: nowrap !important;
    font-size: 10px !important;
    line-height: 1;
    letter-spacing: 0 !important;
    padding: 3px 5px !important;
  }
  /* language and account: full-width rows with a label next to the icon */
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) { display: block !important; }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) > div.relative { width: 100%; }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) button,
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) > a {
    width: 100% !important;
    height: 34px !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 0 12px;
  }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) > a {
    border: 1px solid var(--line-2);
    color: var(--color-text-2) !important;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    transition: border-color 0.12s, color 0.12s, background-color 0.12s;
  }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) > a:hover {
    border-color: #e0323c;
    color: #fff !important;
    background: rgba(224, 50, 60, 0.1);
  }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) button[aria-label]::after,
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(n+2) > a[aria-label]::after {
    content: attr(aria-label);
    font-size: 12px;
    letter-spacing: 0.06em;
  }
  /* signed in: the original drops the language button's content and adds the notifications bell (a div, 3rd) before
   * the account (a 4th span). Order at the bottom of the column: language, bell, account, as rows like the others. */
  header.site-header > .container-page > div:nth-child(3) > div.relative { order: 4; margin-top: -6px !important; width: 100%; }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(4) { order: 5; margin-top: -6px !important; }
  header.site-header > .container-page > div:nth-child(3) > div.relative > button {
    width: 100% !important;
    height: 34px !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 0 12px;
  }
  /* just the word, the unread count stays in the red box (the aria-label says "N notificaciones sin leer") */
  header.site-header > .container-page > div:nth-child(3) > div.relative > button[aria-label]::after {
    content: "notificaciones";
    font-size: 12px;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }
  html:lang(en) header.site-header > .container-page > div:nth-child(3) > div.relative > button[aria-label]::after { content: "notifications"; }
  html:lang(de) header.site-header > .container-page > div:nth-child(3) > div.relative > button[aria-label]::after { content: "benachrichtigungen"; }
  html:lang(pt) header.site-header > .container-page > div:nth-child(3) > div.relative > button[aria-label]::after { content: "notificações"; }
  html:lang(ru) header.site-header > .container-page > div:nth-child(3) > div.relative > button[aria-label]::after { content: "уведомления"; }
  html:lang(zh) header.site-header > .container-page > div:nth-child(3) > div.relative > button[aria-label]::after { content: "通知"; }
  /* the account button: a bordered row, "t  username" (the initial in red), like the sign-in link was */
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(4) button {
    background: transparent !important;
    border: 1px solid var(--line-2);
    border-radius: 0 !important;
    font-weight: 400;
    color: #e0323c !important;
    transition: border-color 0.12s, color 0.12s, background-color 0.12s;
  }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(4) button::after {
    color: var(--color-text-2);
    text-transform: lowercase;
  }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(4) button:hover,
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(4) button[aria-expanded="true"] {
    border-color: #e0323c;
    background: rgba(224, 50, 60, 0.1) !important;
    box-shadow: none !important;
  }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(4) button:hover::after,
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(4) button[aria-expanded="true"]::after { color: #fff; }
  /* the language panel opens upwards from the bottom of the column (it floats over the links) */
  header.site-header div[class*="top-full"][class*="right-0"] {
    left: 0;
    right: auto;
    top: auto;
    bottom: calc(100% + 8px);
    margin-top: 0 !important;
    width: 290px !important;  /* a bit wider than the column */
    transform-origin: bottom left;
  }
  /* main links, stacked: "> link" with a blinking cursor on the current page */
  header.site-header > .container-page > div:nth-child(2) { order: 2; margin: 4px 0 0 !important; display: block; }
  header.site-header nav ul { flex-direction: column; align-items: stretch !important; gap: 3px !important; }
  header.site-header nav ul a {
    display: block;
    padding: 9px 12px !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: var(--color-text-2) !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    transition: color 0.12s, border-color 0.12s, background-color 0.12s;
  }
  header.site-header nav ul a::before { content: "> "; color: #e0323c; opacity: 0; }
  header.site-header nav ul a:hover {
    color: #fff !important;
    border-color: #e0323c !important;
    background: rgba(224, 50, 60, 0.09) !important;
  }
  header.site-header nav ul a:hover::before { opacity: 1; }
  header.site-header nav ul a[aria-current] { color: #e0323c !important; border-color: var(--line-2) !important; }
  header.site-header nav ul a[aria-current]::before { opacity: 1; }
  header.site-header nav ul a[aria-current]::after { content: "_"; margin-left: 2px; animation: lain-blink 1s steps(1) infinite; }

  /* the little "ayuda / lista negra" bar sits at the bottom of the column */
  div.hidden.lg\:block.border-b {
    position: fixed;
    left: 0; bottom: 0;
    width: var(--sb);
    z-index: 61;
    border: 0 !important;
    border-top: 1px solid var(--line) !important;
    border-right: 1px solid var(--line) !important;
    background: #050607 !important;
    padding: 14px 16px 16px;
  }
  div.hidden.lg\:block.border-b > nav {
    height: auto !important;
    padding: 0 !important;
    max-width: none;
    justify-content: flex-start !important;
    flex-wrap: wrap;
    gap: 8px 18px !important;
  }
  div.hidden.lg\:block.border-b a { color: var(--color-text-3) !important; text-transform: lowercase; letter-spacing: 0.05em; }
  div.hidden.lg\:block.border-b a:hover { color: #e0323c !important; }

  /* --- content sits to the right of the column ------------------------------------------------- */
  main#main-content {
    max-width: 96rem;
    width: calc(100% - var(--sb) - 28px);
    margin: 14px auto 20px calc(var(--sb) + 14px);
  }
  #main-content > main.container-page { padding: 26px 30px 30px !important; }
  #main-content > div.container-page { padding-top: 26px; }
  body footer.w-full { width: calc(100% - var(--sb) - 28px) !important; margin: 0 14px 14px calc(var(--sb) + 14px) !important; }
  aside.fixed { left: calc(var(--sb) + 14px) !important; right: auto !important; width: 340px; }

  /* sticky filter bar: no top header any more */
  .full-bleed-bar { top: 0 !important; }
  .full-bleed-bar:before { left: -30px !important; right: -30px !important; width: auto !important; }

  /* --- home: the intro becomes a "welcome" panel over the wire grid ------------------------------ */
  #main-content > main > header.fade-up {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title steps" "text steps" "links links";
    column-gap: 48px;
    align-items: center;
    margin: 0 0 28px;
    padding: 34px 36px 28px !important;
    border: 1px solid var(--line-2);
    background:
      radial-gradient(520px 220px at 100% 0%, rgba(224, 50, 60, 0.16), transparent 62%),
      linear-gradient(rgba(140, 180, 190, 0.06) 1px, transparent 1px),
      linear-gradient(90deg, rgba(140, 180, 190, 0.06) 1px, transparent 1px),
      #07090b;
    background-size: auto, 24px 24px, 24px 24px, auto;
    overflow: hidden;
    position: relative;
  }
  /* corner brackets */
  #main-content > main > header.fade-up::before,
  #main-content > main > header.fade-up::after {
    content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  }
  #main-content > main > header.fade-up::before { top: 6px; left: 6px; border-top: 1px solid #e0323c; border-left: 1px solid #e0323c; }
  #main-content > main > header.fade-up::after { bottom: 6px; right: 6px; border-bottom: 1px solid #e0323c; border-right: 1px solid #e0323c; }
  #main-content > main > header.fade-up > h1 { grid-area: title; font-size: clamp(22px, 2.5vw, 34px) !important; max-width: none; line-height: 1.2; }
  #main-content > main > header.fade-up > p { grid-area: text; margin-top: 14px !important; max-width: 40rem; color: var(--color-text-2) !important; }
  #main-content > main > header.fade-up > div {
    grid-area: steps;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px !important;
    min-width: 210px;
  }
  #main-content > main > header.fade-up > div > span.h-3\.5 { display: none; }
  #main-content > main > header.fade-up > div > span.flex {
    padding: 9px 14px;
    border: 1px solid var(--line-2);
    background: rgba(255, 255, 255, 0.02);
    align-items: center;
    gap: 14px !important;
  }
  #main-content > main > header.fade-up > div > span.flex > span:first-child { font-size: 12px; color: #e0323c; }
  #main-content > main > header.fade-up > div > span.flex > span:last-child { font-size: 13px; color: var(--color-text-1); text-transform: lowercase; letter-spacing: 0.06em; }
  #main-content > main > header.fade-up > nav { grid-area: links; margin-top: 24px !important; }
  #main-content > main > header.fade-up > nav a { height: 32px; padding-inline: 16px; }

  /* --- game tiles: bigger posters, title and details always on the poster ------------------------ */
  /* Every listing page holds 48 games, so the number of columns must divide 48 (3, 4, 6, 8, 12), otherwise the
   * last row is left half empty. The count changes with the width of the window, never to anything else. */
  section.game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 22px 18px !important;
  }
  /* title, genres and size slide up over the poster only while the mouse is on it (or the tile has keyboard focus) */
  section.game-grid > a > div:first-child > div.absolute { padding-top: 12px !important; }
  /* touch screens have no hover: keep the caption visible there */
  @media (hover: none) {
    section.game-grid > a > div:first-child > div.absolute { translate: none !important; transform: none !important; }
  }
  section.game-grid > a > div:first-child > div.absolute p:first-child { font-size: 12.5px; }
  section.game-grid > a > div:nth-child(2) { display: none !important; }

  /* --- game page: shorter banner, and the download panel moves to the LEFT of the description ----- */
  #main-content section.relative.w-full.overflow-hidden { height: 46vh !important; min-height: 340px; }
  #main-content div.grid.lg\:grid-cols-12 {
    grid-template-columns: 340px minmax(0, 1fr) !important;
    gap: 40px !important;
  }
  #main-content div.grid.lg\:grid-cols-12 > aside { order: -1; grid-column: auto !important; }
  #main-content div.grid.lg\:grid-cols-12 > div { grid-column: auto !important; }
}

/* listing grid: 3 columns up to 1149px, then 4, then 6 (the window stops growing at 96rem, so 6 is the most) */
@media (min-width: 1150px) {
  section.game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}
@media (min-width: 1480px) {
  section.game-grid { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
}

/* phones: the sort / filter bar has to fit between the window borders */
@media (max-width: 639px) {
  .full-bleed-bar > div { gap: 4px !important; flex-wrap: wrap !important; }
  .full-bleed-bar button:not([role="switch"]) { padding-inline: 7px !important; letter-spacing: 0 !important; font-size: 12px !important; gap: 6px !important; }
  .full-bleed-bar button[role="switch"] { font-size: 12px !important; letter-spacing: 0 !important; }
  .full-bleed-bar button[role="switch"] { padding-inline: 2px !important; gap: 4px !important; }
  main#main-content::before { letter-spacing: 0.08em; }
}

/* very short windows: tighter menu column so nothing overlaps */
@media (min-width: 1024px) and (max-height: 500px) {
  header.site-header > .container-page { gap: 6px !important; min-height: calc(100vh - 72px); }
  header.site-header > .container-page > div:nth-child(1) { padding: 8px 16px 7px; }
  header.site-header > .container-page > div:nth-child(2) { margin-top: 0 !important; }
  header.site-header nav ul { gap: 2px !important; }
  header.site-header nav ul a { padding: 5px 12px !important; }
  header.site-header > .container-page > div:nth-child(3) > span:nth-child(3) { margin-top: -2px !important; }
}

/* ====================================================================================================
 * RANDOM GAME PICKER ("wired"): one poster tuned like a TV channel, red/cyan ghosting, terminal log,
 * signal lock and a typed title. The markup comes from tools/random_game.js (silent, no sound files).
 * ================================================================================================== */
.wired-roll { font-family: var(--font-body); color: var(--color-text-1); }
.wired-roll__bg {
  background:
    linear-gradient(rgba(140, 180, 190, 0.05) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(140, 180, 190, 0.05) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(ellipse at center, rgba(10, 14, 16, 0.96) 0%, rgba(0, 0, 0, 0.99) 100%);
}
.wired-roll::after {  /* its own scan lines (the page overlay sits below this window) */
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.65) 100%);
}
.wired-roll__x { color: var(--color-text-2) !important; }
.wired-roll__box { display: flex; flex-direction: column; align-items: center; width: min(380px, 100%); }
.wired-roll__status {
  margin: 0;
  font-size: 12px; letter-spacing: 0.24em; text-transform: lowercase;
  color: #cfd9dc;
  text-shadow: 1px 0 rgba(255, 40, 70, 0.55), -1px 0 rgba(0, 220, 255, 0.4);
}
.wired-roll__mark { display: inline-block; width: 6px; height: 6px; margin-right: 10px; background: #e0323c; vertical-align: 1px; }
.wired-roll__cur { display: inline-block; width: 0.55em; height: 1em; margin-left: 4px; background: #e0323c; vertical-align: -2px; animation: lain-blink 1s steps(1) infinite; }
.wired-roll__sub { margin: 4px 0 16px; font-size: 11px; letter-spacing: 0.2em; text-transform: lowercase; color: #6b7a80; }
.wired-roll__load { display: flex; align-items: center; justify-content: center; height: 120px; color: #e0323c; }
.wired-roll__err { margin: 24px 0; font-size: 13px; color: #ff5964; text-align: center; }

.wired-roll__frame {
  position: relative;
  width: min(260px, 62vw);
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #000;
  border: 1px solid #3a464c;
  box-shadow: 0 0 0 1px #000, 0 0 44px -10px rgba(224, 50, 60, 0.4);
}
.wired-roll__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: grayscale(0.55) contrast(1.18) brightness(0.9);
  animation: wired-flick 0.18s steps(2) both;
}
.wired-roll__img--r { mix-blend-mode: screen; opacity: 0.55; translate: -5px 0; filter: grayscale(1) sepia(1) hue-rotate(-40deg) saturate(8) brightness(0.85); }
.wired-roll__img--c { mix-blend-mode: screen; opacity: 0.5; translate: 5px 0; filter: grayscale(1) sepia(1) hue-rotate(150deg) saturate(8) brightness(0.85); }
@keyframes wired-flick {
  0%   { transform: translate(-7px, 0) skewX(7deg); clip-path: inset(8% 0 58% 0); }
  50%  { transform: translate(6px, 0); clip-path: inset(48% 0 12% 0); }
  100% { transform: none; clip-path: inset(0 0 0 0); }
}
.wired-roll__noise {
  position: absolute; inset: -20%;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -0.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: lain-static 0.35s steps(1) infinite;
}
.wired-roll__sweep {
  position: absolute; left: 0; right: 0; top: -15%; height: 14%;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(190, 230, 240, 0.28), transparent);
  animation: wired-sweep 0.8s linear infinite;
}
@keyframes wired-sweep { from { top: -15%; } to { top: 105%; } }
.wired-roll__corner { position: absolute; width: 14px; height: 14px; pointer-events: none; border: 0 solid #e0323c; }
.wired-roll__corner--tl { top: 7px; left: 7px; border-top-width: 1px; border-left-width: 1px; }
.wired-roll__corner--tr { top: 7px; right: 7px; border-top-width: 1px; border-right-width: 1px; }
.wired-roll__corner--bl { bottom: 7px; left: 7px; border-bottom-width: 1px; border-left-width: 1px; }
.wired-roll__corner--br { bottom: 7px; right: 7px; border-bottom-width: 1px; border-right-width: 1px; }
.wired-roll__tag {
  position: absolute; left: 10px; bottom: 10px;
  padding: 2px 6px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: lowercase;
  color: #cfd9dc;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid #232c31;
}
.wired-roll__log {
  width: 100%; height: 9em; margin: 14px 0 0; padding: 0;
  list-style: none;
  font-size: 11px; line-height: 1.5; letter-spacing: 0.04em;
  color: #8a9da5;
  display: flex; flex-direction: column; justify-content: flex-end;
  overflow: hidden;
}
.wired-roll__log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* signal locked: red frame, flash, the picture settles */
.wired-roll[data-phase="landed"] .wired-roll__frame { border-color: #e0323c; box-shadow: 0 0 0 1px #000, 0 0 60px -6px rgba(224, 50, 60, 0.65); animation: wired-lock 0.5s steps(1); }
.wired-roll[data-phase="landed"] .wired-roll__img { animation: none; filter: contrast(1.06); }
.wired-roll[data-phase="landed"] .wired-roll__noise { opacity: 0.05; animation: none; }
.wired-roll[data-phase="landed"] .wired-roll__sweep { display: none; }
.wired-roll[data-phase="landed"] .wired-roll__tag { color: #e0323c; border-color: #e0323c; }
@keyframes wired-lock {
  0%   { filter: brightness(3) contrast(1.6); transform: translate(-4px, 0); }
  20%  { filter: none; transform: translate(3px, 1px); }
  40%  { filter: brightness(2) hue-rotate(20deg); transform: translate(-2px, 0); }
  60%  { filter: none; transform: none; }
  100% { filter: none; transform: none; }
}
.wired-roll__result { width: 100%; margin-top: 18px; text-align: center; }
.wired-roll__title {
  margin: 0; min-height: 2.5em;
  font-family: var(--font-body);
  font-size: clamp(16px, 4.6vw, 21px); font-weight: 400; line-height: 1.25; letter-spacing: 0.05em;
  color: #e6eef0;
  text-shadow: 1.5px 0 rgba(255, 40, 70, 0.55), -1.5px 0 rgba(0, 220, 255, 0.45);
  overflow-wrap: anywhere;
}
.wired-roll__meta { margin: 6px 0 0; font-size: 12px; letter-spacing: 0.08em; color: #6b7a80; }
.wired-roll__actions { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) {
  .wired-roll *, .wired-roll *::before { animation: none !important; }
}
@media (max-height: 700px) {
  .wired-roll__log { height: 4.5em; }
  .wired-roll__frame { width: min(190px, 52vw); }
}

/* The two choices of the review form (tools/reviews_panel.js): the one picked lights up, "Lo recomiendo" in green and
 * "No lo recomiendo" in red. */
/* (the extra attribute tests only raise the specificity above the theme's generic button hover rule, which is red) */
button[data-rec="yes"][aria-pressed="true"][type="button"][class],
button[data-rec="yes"][aria-pressed="true"][type="button"][class]:hover {
  background: #7fe0b0 !important;
  border-color: #7fe0b0 !important;
  color: #04110b !important;
}
button[data-rec="no"][aria-pressed="true"][type="button"][class],
button[data-rec="no"][aria-pressed="true"][type="button"][class]:hover {
  background: #ff5964 !important;
  border-color: #ff5964 !important;
  color: #1a0406 !important;
}
button[data-rec="yes"][aria-pressed="false"][type="button"][class]:hover { background: rgba(127, 224, 176, 0.12) !important; border-color: #7fe0b0 !important; color: #7fe0b0 !important; }
button[data-rec="no"][aria-pressed="false"][type="button"][class]:hover { background: rgba(255, 89, 100, 0.12) !important; border-color: #ff5964 !important; color: #ff5964 !important; }

/* ====================================================================================================
 * COMMENTS: every registered account comments (the team's show as "emygames_"). The comments of the live site's
 * ordinary users are not shown (serve.py, team_comments), so the sorting, the vote buttons and the total count, which
 * would be about those, are hidden; "reply" and the "more actions" menu (copy link, edit and delete your own, the
 * team's "Eliminar") stay.
 * ================================================================================================== */
section#comments > div:first-child > div.ml-auto { display: none !important; }            /* new / best / old */
section#comments > div:first-child h2 > span { display: none !important; }                 /* total comment count */
section#comments [id^="comment-"] > div[class*="-ml-1.5"] > div.flex.items-center.text-3 { display: none !important; }  /* votes */
/* mobile tab bar: the count of the "comments" tab (the last one) is the live site's total, not ours */
div.sticky.top-0.z-30 > button:last-child > span { display: none !important; }

/* ====================================================================================================
 * No Blog and no Discord entries in the navigation: menu column, mobile menu, footer and the blog notice.
 * (Links written inside the page content itself, e.g. in the FAQ, are left alone.)
 * ================================================================================================== */
/* the Blog link carries the language prefix in the other languages: /blog, /en/blog, /de/blog, /pt/blog, /ru/blog, /zh/blog */
body > *:not(#main-content) a:is([href="/blog"], [href$="/blog"], [href="/blog/"], [href$="/blog/"]),
body > *:not(#main-content) a[href^="https://discord.gg/"],
footer li:has(> a[href^="https://discord.gg/"]),
footer li:has(> a:is([href="/blog"], [href$="/blog"], [href="/blog/"], [href$="/blog/"])),
aside:has(a:is([href^="/blog"], [href^="/en/blog"], [href^="/de/blog"], [href^="/pt/blog"], [href^="/ru/blog"], [href^="/zh/blog"])) {
  display: none !important;
}

/* The "Still stuck?" box at the end of the help pages keeps only "Request a fix": its Discord button (the purple one)
 * goes, and serve.py rewrites its sentence so it does not mention Discord either. */
#main-content a[href^="https://discord.gg/"][class*="5865F2"] { display: none !important; }

/* ====================================================================================================
 * No donations for now: the "Donaciones" entry of the menu (desktop and mobile) and the "Donar" link of the
 * footer go; the /support page itself redirects to the home page (serve.py).
 * ================================================================================================== */
body > *:not(#main-content) a:is([href="/support"], [href$="/support"], [href="/support/"], [href$="/support/"]),
body > *:not(#main-content) li:has(> a:is([href="/support"], [href$="/support"], [href="/support/"], [href$="/support/"])) {
  display: none !important;
}

/* ====================================================================================================
 * The account pages of the original ("Cuenta" / "Ajustes" in the account menu: /<user>/settings) are not part of this
 * copy and would be a 404, so the links to them are not shown. Sign out stays.
 * ================================================================================================== */
body > *:not(#main-content) a[href*="/settings"] {
  display: none !important;
}

/* ==================================================================================================
 * Who uploaded a game is not shown on the game pages: the "Uploaded by <name>" card of the side column (the only
 * section.isolate of the page) and the "Uploaded by" / "Updated by" row of the version table (serve.py's small script
 * marks it with data-emy-hide, whatever the language).
 * ================================================================================================== */
[data-emy-hide],
aside section.isolate.overflow-hidden[aria-label] {
  display: none !important;
}

/* ==================================================================================================
 * Light mode for a slow PC (?lite=1 on any page, ?lite=0 to undo; serve.py sets html[data-lite]): no scan lines, static,
 * rolling band or wire grid, no picture filters, no glitch shadows. The colours and the layout stay the same.
 * ================================================================================================== */
html[data-lite]::before,
html[data-lite]::after,
html[data-lite] body::before,
html[data-lite] body::after {
  display: none !important;
}
html[data-lite] img { filter: none !important; }
html[data-lite] *, html[data-lite] *::before, html[data-lite] *::after { text-shadow: none !important; }
