/* xfg0.com: Russian adult Flash games.
   The look is a Soviet pocket LCD game: a brushed-aluminium faceplate, numbers on an LCD
   with the unlit "8" segments showing through, and round red keys for voting and paging.
   Night mode swaps the grey-green LCD for an amber backlight. */

/* Self-hosted: PT Sans, PT Sans Narrow (SIL OFL 1.1, cyrillic + latin subsets),
   DSEG7 / DSEG14 Classic by keshikan (SIL OFL 1.1) for the LCD digits and the logo. */
@font-face {
  font-family: "PT Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/pt-sans-400-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "PT Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/pt-sans-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "PT Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/pt-sans-700-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "PT Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/pt-sans-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "PT Sans Narrow"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/pt-sans-narrow-700-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "PT Sans Narrow"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/pt-sans-narrow-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DSEG7"; font-style: normal; font-weight: 700; font-display: block;
  src: url("/static/fonts/dseg7-classic-bold.woff2") format("woff2");
}
@font-face {
  font-family: "DSEG14"; font-style: normal; font-weight: 700; font-display: block;
  src: url("/static/fonts/dseg14-classic-bold.woff2") format("woff2");
}

:root {
  --chassis: #b9bcb4;    /* page background: the device body */
  --face: #e6e7e1;       /* faceplate: surfaces that hold content */
  --face-2: #d6d8d0;     /* recessed areas on the faceplate */
  --ink: #1f221d;
  --muted: #565b51;
  --line: #9ea296;
  --bezel: #2a2c27;      /* dark frame around screens and the player */
  --lcd: #a9b48f;        /* LCD glass */
  --seg: #1f2a17;        /* a lit segment */
  --seg-off: rgba(31, 42, 23, 0.11);
  --key: #d23a1c;        /* the round red keys */
  --key-shade: #8f2410;
  --key-ink: #a52a12;    /* red as text on the faceplate (contrast) */
  --focus: #1f5fd1;
  --sans: "PT Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --narrow: "PT Sans Narrow", "PT Sans", system-ui, sans-serif;
  --digits: "DSEG7", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chassis: #191b18;
    --face: #242722;
    --face-2: #1e201c;
    --ink: #e7e8e1;
    --muted: #a0a598;
    --line: #3b3f37;
    --bezel: #0d0e0c;
    --lcd: #2a1d0b;
    --seg: #ffb23e;
    --seg-off: rgba(255, 178, 62, 0.1);
    --key: #e2482a;
    --key-shade: #8a2412;
    --key-ink: #ff8a6b;
    --focus: #7fb0ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--chassis);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--sans);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-underline-offset: 0.15em; }
a:hover { color: var(--key-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--narrow); font-weight: 700; line-height: 1.1; }
h1 { font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem); letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--face); padding: 8px 12px; }

/* ---------- LCD readouts (lcd.html) ---------- */
.lcd {
  display: inline-grid; vertical-align: middle;
  padding: 0.3em 0.45em 0.25em; border-radius: 3px;
  background: var(--lcd); color: var(--seg);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  font: 700 0.95rem/1 var(--digits); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.lcd > span { grid-area: 1 / 1; justify-self: end; }
.lcd .ghost { color: var(--seg-off); }
.lcd--s { font-size: 0.72rem; }
.lcd--l { font-size: 1.9rem; padding: 0.25em 0.35em; }
.lcd--inline { font-size: 0.85em; vertical-align: 0.05em; }

/* ---------- Keys ---------- */
.key {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0;
  background: radial-gradient(circle at 35% 30%, #f0705a, var(--key) 55%);
  color: #fff; font: 700 1.1rem/1 var(--sans); text-decoration: none; cursor: pointer;
  box-shadow: 0 3px 0 var(--key-shade), 0 4px 6px rgba(0, 0, 0, 0.3);
}
.key:hover { color: #fff; filter: brightness(1.08); }
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--key-shade), 0 2px 3px rgba(0, 0, 0, 0.3); }
span.key { opacity: 0.35; cursor: default; filter: grayscale(1); }

.btn, .search button {
  font: 700 1rem/1 var(--sans); border: 0; cursor: pointer;
}
.btn {
  display: inline-block; padding: 13px 22px; border-radius: 22px;
  background: var(--key); color: #fff; text-decoration: none;
  box-shadow: 0 3px 0 var(--key-shade);
}
.btn:hover { color: #fff; filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--key-shade); }
.btn--quiet { background: var(--face-2); color: var(--ink); box-shadow: 0 2px 0 var(--line); }
.btn--quiet:hover { color: var(--ink); }

input[type="text"], input[type="email"], input[type="search"], textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--face); border: 2px solid var(--line); border-radius: 6px;
  padding: 10px 12px;
}
input:focus, textarea:focus { border-color: var(--ink); outline: none; }
input:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }

/* ---------- Header: the faceplate ---------- */
.faceplate {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--face), var(--face-2));
  border-bottom: 3px solid var(--bezel);
}
.faceplate-inner {
  max-width: 1320px; margin: 0 auto; padding: 16px 24px 14px;
  display: grid; align-items: center; gap: 14px 28px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "logo search account" "logo modes modes";
}
.logo { grid-area: logo; display: grid; gap: 6px; text-decoration: none; justify-items: start; }
.logo:hover { color: inherit; }
.logo-lcd {
  display: inline-grid; padding: 10px 14px 8px; border-radius: 6px;
  background: var(--lcd); color: var(--seg);
  border: 6px solid var(--bezel);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  font: 700 2.4rem/1 "DSEG14", ui-monospace, monospace;
}
.logo-lcd > span { grid-area: 1 / 1; }
.logo-lcd .ghost { color: var(--seg-off); }
.logo-caption { font: 700 0.95rem/1 var(--narrow); color: var(--muted); padding-left: 2px; }

/* The home page opens with the LCD self-test: every segment lit, then the logo. */
@media (prefers-reduced-motion: no-preference) {
  .home .logo-lcd .ghost { animation: segment-test 1.1s steps(1, end) both; }
  .home .logo-lcd .lit { animation: segment-wait 1.1s steps(1, end) both; }
}
@keyframes segment-test { 0%, 70% { color: var(--seg); } 100% { color: var(--seg-off); } }
@keyframes segment-wait { 0%, 70% { opacity: 0; } 100% { opacity: 1; } }

.search { grid-area: search; display: flex; max-width: 520px; }
.search input { border-radius: 6px 0 0 6px; border-right: 0; }
.search button { padding: 0 18px; border-radius: 0 6px 6px 0; background: var(--bezel); color: #e7e8e1; }
.search button:hover { background: var(--key); }

.account { grid-area: account; display: flex; align-items: center; gap: 16px; }
.account a { text-decoration: none; }
.account a:hover { text-decoration: underline; }
.account .upload { font-weight: 700; color: var(--key-ink); }
#user_panel { display: inline-flex; gap: 14px; align-items: center; white-space: nowrap; }
.score, .author-score {
  font: 700 0.7rem/1 var(--digits); padding: 3px 5px; border-radius: 2px;
  background: var(--lcd); color: var(--seg);
}

/* Section switches: the small rectangular mode keys under the screen. */
.modes { grid-area: modes; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; }
.modes a {
  padding: 7px 14px; border-radius: 4px; white-space: nowrap; text-decoration: none;
  font: 700 1rem/1 var(--narrow); color: var(--ink);
  background: var(--face); box-shadow: 0 2px 0 var(--line), inset 0 0 0 1px var(--line);
}
.modes a:hover { color: var(--ink); background: var(--face-2); }
.modes a[aria-current] {
  background: var(--bezel); color: #f0f1ea;
  box-shadow: 0 0 0 var(--line); transform: translateY(2px);
}

/* ---------- Page frame ---------- */
.frame {
  width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 24px 56px;
  display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) 250px; align-items: start;
}
main { min-width: 0; }
.frame > main:only-child { grid-column: 1 / -1; }

.genres {
  background: var(--face); border-radius: 10px; padding: 18px 16px;
  box-shadow: 0 2px 0 var(--line);
  position: sticky; top: 16px;
}
.genres h2 { font-size: 1.2rem; margin-bottom: 10px; }
.genres ul { list-style: none; margin: 0; padding: 0; }
.genres a {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 6px 8px; margin: 0 -8px; border-radius: 4px; text-decoration: none;
}
.genres a:hover { background: var(--face-2); color: var(--ink); }
.genres a[aria-current] { background: var(--bezel); color: #f0f1ea; }

.page-head { margin: 0 0 18px; display: grid; gap: 6px; }
.page-head p { color: var(--muted); max-width: 62ch; }

.intro { margin-bottom: 32px; display: grid; gap: 10px; }
.intro h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.2rem); max-width: 18ch; }
.intro p { font-size: 1.2rem; max-width: 52ch; }

/* ---------- Game tiles ---------- */
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile {
  background: var(--face); border-radius: 10px; padding: 10px 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 2px 0 var(--line);
}
.screen {
  display: block; padding: 6px; border-radius: 6px; background: var(--bezel);
}
.screen img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; background: #000; }
.tile h3 { padding: 2px 4px 0; }
.tile h3 a { text-decoration: none; }
.tile h3 a:hover { text-decoration: underline; }
.tile p { padding: 0 4px; color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }
.tile .stats { margin-top: auto; padding: 4px 4px 0; }
.empty { grid-column: 1 / -1; padding: 24px; background: var(--face); border-radius: 10px; }

.stats { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.rating { display: inline-flex; align-items: center; gap: 8px; }
.plays { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }

/* Best rated: a strip of screens, first one larger. */
.best { margin-bottom: 36px; }
.best h2 { margin-bottom: 14px; }
.best ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.best li:first-child { grid-column: span 2; grid-row: span 2; }
.best a { display: grid; gap: 6px; text-decoration: none; }
.best .name { font-weight: 700; line-height: 1.25; }
.best li:first-child .name { font: 700 1.4rem/1.15 var(--narrow); }
.best a:hover .name { text-decoration: underline; }

/* ---------- Pager ---------- */
.pager {
  margin: 32px 0 0; padding: 14px 18px; border-radius: 10px;
  background: var(--face); box-shadow: 0 2px 0 var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px;
}
.pager-display { display: inline-flex; align-items: baseline; gap: 8px; }
.pager-display .of { color: var(--muted); }
.pages { list-style: none; margin: 0 0 0 auto; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.pages a, .pages span {
  display: inline-block; min-width: 36px; padding: 7px 8px; text-align: center; border-radius: 4px;
  text-decoration: none; font-weight: 700;
}
.pages a:hover { background: var(--face-2); }
.pages span { background: var(--bezel); color: #f0f1ea; }

/* ---------- Home: comments and the high-score table ---------- */
.lower { margin-top: 44px; display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
.lower h2 { margin-bottom: 12px; }
.players ol {
  list-style: none; margin: 0; padding: 10px 14px; border-radius: 10px;
  background: var(--face); box-shadow: 0 2px 0 var(--line); counter-reset: place;
}
.players li {
  display: flex; align-items: center; gap: 10px; padding: 7px 0;
  counter-increment: place;
}
.players li + li { border-top: 1px solid var(--face-2); }
.players li::before { content: counter(place); width: 1.4em; color: var(--muted); font-weight: 700; }
.players .name { flex: 1; overflow-wrap: anywhere; }

.comment { background: var(--face); border-radius: 10px; padding: 12px 16px; box-shadow: 0 2px 0 var(--line); }
.comment + .comment { margin-top: 10px; }
.comment header { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 6px; font-size: 0.92rem; }
.comment header img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.comment .author { font-weight: 700; }
.comment time { color: var(--muted); }
.comment .on-game { color: var(--key-ink); }
.comment p { overflow-wrap: anywhere; }
.comment .staff { font-size: 0.85rem; color: var(--muted); }

/* ---------- Random shelf ---------- */
.shelf { margin-top: 44px; }
.shelf h2 { margin-bottom: 12px; }
.shelf-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.shelf-row a { display: grid; gap: 6px; text-decoration: none; font-size: 0.95rem; line-height: 1.25; }
.shelf-row a:hover .name { text-decoration: underline; }

/* ---------- Game page: the console ---------- */
.frame--game { display: block; max-width: 1100px; }
.crumbs { display: flex; gap: 8px; margin-bottom: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.console {
  background: var(--bezel); border-radius: 14px; padding: 10px 14px 16px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.console-label {
  display: flex; align-items: center; gap: 8px; padding: 0 2px 8px;
  font: 700 0.95rem/1 var(--narrow); color: #a3a79b;
}
.led { width: 8px; height: 8px; border-radius: 50%; background: #ff4a2a; box-shadow: 0 0 8px #ff4a2a; }
.stage { background: #000; border-radius: 4px; overflow: hidden; }
.stage .game-player { color: #e7e8e1; }
.stage .player-fallback a { color: #ffb23e; }
.player-note { color: #a3a79b; }

.game-info {
  margin-top: 24px; display: grid; gap: 24px 40px;
  grid-template-columns: minmax(0, 1fr) auto; align-items: start;
}
.game-about { display: grid; gap: 12px; }
.description { max-width: 70ch; overflow-wrap: anywhere; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips a {
  display: inline-block; padding: 5px 12px; border-radius: 4px; text-decoration: none;
  font: 700 0.95rem/1.2 var(--narrow); background: var(--face); box-shadow: 0 2px 0 var(--line);
}
.game-side {
  background: var(--face); border-radius: 10px; padding: 16px; display: grid; gap: 10px;
  box-shadow: 0 2px 0 var(--line); min-width: 260px;
}
.game-side .stats { flex-direction: column; align-items: flex-start; }
.game-side .lcd:not(.lcd--s) { font-size: 1.5rem; }
.game-side .key { width: 38px; height: 38px; font-size: 1.3rem; }
.uploader { color: var(--muted); font-size: 0.95rem; }
.edit-link { color: var(--key-ink); }

.discussion { margin-top: 40px; max-width: 760px; }
.discussion h2 { margin-bottom: 12px; }
.comment-form { display: grid; gap: 10px; justify-items: start; margin-bottom: 18px; }
.comment-form textarea { min-height: 96px; resize: vertical; }
.more-comments { margin-top: 12px; }

/* ---------- Panels and forms ---------- */
.panel {
  background: var(--face); border-radius: 10px; padding: 24px; max-width: 720px;
  box-shadow: 0 2px 0 var(--line); display: grid; gap: 14px; justify-items: start;
}
.panel .page-head { margin: 0; }
.notice { padding: 12px 14px; border-radius: 6px; background: var(--face-2); border-left: 4px solid var(--key); }
.notice--ok { border-left-color: #4b8a2e; }
.form { display: grid; gap: 16px; width: 100%; justify-items: start; }
.field { display: grid; gap: 6px; width: 100%; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font-weight: 700; padding: 0; }
.checks { display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.form-error { color: var(--key-ink); font-weight: 700; }
.no-signal { justify-items: start; }

/* ---------- Footer ---------- */
.foot { margin-top: auto; background: var(--bezel); color: #c9ccc2; font-size: 0.95rem; }
.foot-inner { max-width: 1320px; margin: 0 auto; padding: 28px 24px 36px; display: grid; gap: 10px; }
.foot a { color: #f0f1ea; }
.foot a:hover { color: #ffb23e; }
.adults { display: flex; gap: 10px; align-items: center; }
.badge {
  flex: none; padding: 3px 7px; border-radius: 3px; background: var(--key); color: #fff;
  font: 700 0.9rem/1 var(--narrow);
}
.friends { display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1000px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .genres { position: static; }
  .genres ul { columns: 2; column-gap: 24px; }
  .genres li { break-inside: avoid; }
  .lower { grid-template-columns: minmax(0, 1fr); }
  .best ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .best li:first-child { grid-row: auto; }
}
@media (max-width: 760px) {
  .faceplate-inner {
    padding: 12px 16px; gap: 12px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "logo account" "search search" "modes modes";
  }
  .logo-lcd { font-size: 1.6rem; padding: 7px 10px 6px; border-width: 4px; }
  .logo-caption { display: none; }
  .account { justify-content: flex-end; flex-wrap: wrap; gap: 6px 14px; font-size: 0.95rem; }
  .search { max-width: none; }
  .frame { padding: 20px 16px 44px; gap: 28px; }
  .grid { gap: 14px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .tile p { display: none; }
  .tile .stats { flex-direction: column; align-items: flex-start; }
  .game-info { grid-template-columns: minmax(0, 1fr); }
  .game-side { min-width: 0; }
  .console { padding: 8px 8px 10px; border-radius: 10px; margin: 0 -8px; }
  .pages { margin-left: 0; width: 100%; }
  .panel { padding: 18px; }
  .foot-inner { padding: 24px 16px 32px; }
}
@media (max-width: 420px) {
  .genres ul { columns: 1; }
}
