:root {
  color-scheme: light;
  --ink: #28180e;
  --paper: #fff1c9;
  --paper-soft: #fff8df;
  --paper-deep: #e9c979;
  --green: #2e765f;
  --orange: #d78a32;
  --blue: #345e7f;
  --red: #a83f35;
  --muted: #6d4727;
  --shadow: 7px 7px 0 var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", "PingFang SC", "Microsoft YaHei", monospace;
  background: #17100a;
  color: var(--ink);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: #17100a;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: #17100a;
}

button,
input,
a { font: inherit; }

a { color: inherit; }

svg {
  width: 1.05em;
  height: 1.05em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-shell {
  position: relative;
  min-height: 100svh;
  isolation: isolate;
}

.catalog-loader {
  display: grid;
  place-items: center;
  width: min(920px, calc(100% - 32px));
  min-height: clamp(210px, 32svh, 340px);
  margin: 22px auto;
  padding: 22px;
  opacity: 1;
}

.catalog-loader.is-hidden {
  display: none;
}

.catalog-loader__content {
  display: grid;
  justify-items: center;
  gap: clamp(18px, 2.4vw, 26px);
  width: min(100%, 680px);
  padding: clamp(34px, 5vw, 58px) clamp(22px, 5vw, 56px);
  border: 4px solid var(--ink);
  background: rgb(255 248 223 / 0.97);
  box-shadow: 7px 7px 0 var(--ink), inset 0 0 0 3px rgb(255 255 255 / 0.3);
  color: var(--ink);
  text-align: center;
}

.catalog-loader__content p {
  margin: 0;
  font-size: clamp(0.98rem, 2vw, 1.28rem);
  font-weight: 900;
  line-height: 1.45;
}

.catalog-loader__strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 12px);
  width: min(100%, 310px);
}

.catalog-loader__strip span {
  height: clamp(11px, 1.5vw, 15px);
  border: 3px solid var(--ink);
  background: var(--green);
  box-shadow: 4px 4px 0 var(--ink);
  animation: loading-pulse 900ms steps(2, end) infinite;
}

.catalog-loader__strip span:nth-child(2) {
  background: var(--orange);
  animation-delay: 140ms;
}

.catalog-loader__strip span:nth-child(3) {
  background: var(--paper-deep);
  animation-delay: 280ms;
}

.site-shell::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(135deg, transparent 0 72%, rgb(255 203 104 / 0.08) 72% 75%, transparent 75%) 0 0 / 72px 72px,
    linear-gradient(90deg, rgb(23 14 9 / 0.5), rgb(23 14 9 / 0.12) 52%, rgb(23 14 9 / 0.44)),
    linear-gradient(180deg, rgb(59 38 22 / 0.22), rgb(23 16 10 / 0.48)),
    image-set(
      url("/assets/webrpg-background-mobile.webp") type("image/webp"),
      url("/assets/webrpg-background-mobile.jpg") type("image/jpeg")
    ) center top / cover no-repeat;
  background-color: #17100a;
}

.site-scrim {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  padding: clamp(12px, 2vw, 28px);
  background: linear-gradient(90deg, rgb(18 12 8 / 0.3), transparent 35%, rgb(18 12 8 / 0.24));
}

.hero-band,
.command-band,
.ad-slot,
.catalog-status,
.catalog-grid,
.site-footer {
  width: min(1360px, calc(100% - 16px));
  margin-inline: auto;
}

.hero-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(12px, 1.6vw, 18px) clamp(14px, 2vw, 22px);
  border: 4px solid var(--ink);
  background: rgb(255 241 201 / 0.96);
  box-shadow: var(--shadow), inset 0 0 0 4px rgb(255 255 255 / 0.25);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: clamp(12px, 2vw, 20px);
}

.brand-mark {
  display: block;
  width: clamp(36px, 4vw, 46px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 3px solid var(--ink);
  background: var(--paper-deep);
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-2deg);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.brand-text {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(1.55rem, 4.5vw, 3.4rem);
  line-height: 1;
  text-wrap: balance;
  text-shadow: 2px 2px 0 rgb(215 138 50 / 0.45);
}

.brand-text p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.7rem, 1vw, 0.88rem);
  line-height: 1.55;
}

.hero-actions,
.language-switch,
.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.game-actions.two-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.hero-actions {
  align-items: center;
  justify-content: flex-end;
}

.language-switch { flex-wrap: nowrap; }

.pixel-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid var(--ink);
  border-radius: 0;
  padding: 9px 13px;
  background: var(--orange);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  transition: transform 80ms linear, box-shadow 80ms linear, filter 80ms linear;
}

.pixel-button:hover,
.pixel-button:focus-visible {
  filter: brightness(1.07);
  outline: 3px solid var(--paper-soft);
  outline-offset: 2px;
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}

.pixel-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.language-button {
  min-width: 43px;
  padding-inline: 10px;
  background: var(--paper-deep);
}

.language-button.is-active {
  background: var(--green);
  color: var(--paper-soft);
}

.publish-button { min-width: 138px; }

.reload-button {
  width: 46px;
  padding-inline: 10px;
  background: var(--blue);
  color: var(--paper-soft);
}

.reload-button.is-loading svg { animation: spin 700ms steps(8, end) infinite; }

.ads-toggle {
  width: 46px;
  padding-inline: 10px;
  background: var(--red);
  color: var(--paper-soft);
}

.ads-toggle.is-active { background: var(--green); }

.ad-slot { margin-bottom: 18px; }

.ad-slot a {
  display: block;
  padding: 13px 18px;
  border: 4px solid var(--ink);
  background: linear-gradient(90deg, var(--red), #d2603e 62%, var(--orange));
  color: #fff8df;
  box-shadow: 6px 6px 0 var(--ink);
  font-size: clamp(0.78rem, 1.4vw, 1rem);
  font-weight: 900;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
}

.ad-slot a::before { content: "✦ "; }
.ad-slot a::after { content: " ↗"; }
.ad-slot a:hover,
.ad-slot a:focus-visible { filter: brightness(1.12); outline: 3px solid var(--paper-soft); }
.ad-slot[hidden] { display: none; }

.command-band {
  margin-top: 18px;
  padding: 12px;
  border: 4px solid var(--paper);
  background: rgb(40 24 14 / 0.93);
  box-shadow: 6px 6px 0 var(--ink);
}

.search-row { position: relative; min-width: 0; }

.search-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  z-index: 1;
  width: 19px;
  height: 19px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

#search {
  width: 100%;
  min-height: 49px;
  border: 0;
  border-radius: 0;
  padding: 12px 16px 12px 48px;
  background: var(--paper-soft);
  color: var(--ink);
  outline: none;
  font-size: 0.96rem;
}

#search:focus { box-shadow: inset 0 0 0 4px var(--orange); }

.ad-slot--search { margin-top: 18px; margin-bottom: 0; }
.ad-slot--search a { background: linear-gradient(90deg, var(--blue), var(--green)); }

.catalog-status {
  min-height: 1.4rem;
  margin-top: 22px;
  margin-bottom: 14px;
  padding-inline: 4px;
  color: var(--paper);
  font-size: 0.78rem;
  line-height: 1.5;
}

.catalog-status.is-error { color: #ffb4a9; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr));
  gap: clamp(18px, 2vw, 28px);
  align-items: start;
  padding: 2px clamp(2px, 1vw, 10px) 44px;
}

.catalog-more {
  display: flex;
  width: min(1360px, calc(100% - 16px));
  justify-content: center;
  margin: 0 auto 44px;
}

.catalog-more .pixel-button {
  min-width: min(100%, 260px);
  background: var(--paper-deep);
}

.has-auto-load .catalog-more {
  min-height: 2px;
  margin-bottom: 2px;
}

.has-auto-load .catalog-more .pixel-button { display: none; }

.game-card {
  min-width: 0;
  overflow: hidden;
  border: 4px solid var(--ink);
  background: linear-gradient(180deg, rgb(255 248 223 / 0.99), rgb(239 205 139 / 0.99));
  box-shadow: var(--shadow), inset 0 0 0 3px rgb(255 255 255 / 0.25);
  content-visibility: auto;
  contain-intrinsic-size: 430px;
}

.cover-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 4px solid var(--ink);
  background: var(--paper-deep);
}

.cover-base,
.cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-base { image-rendering: pixelated; }
.cover-image { z-index: 1; opacity: 0; transition: opacity 120ms linear; }
.cover-image.is-loaded { opacity: 1; }

.game-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.game-heading { display: grid; min-width: 0; gap: 8px; }

.game-title {
  display: -webkit-box;
  min-height: 3.05em;
  margin: 0;
  overflow: hidden;
  font-size: clamp(0.92rem, 1.18vw, 1.04rem);
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.game-repo {
  min-height: 2.7em;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.45;
}

.game-meta {
  display: flex;
  min-height: 27px;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border: 2px solid var(--ink);
  padding: 4px 7px;
  background: var(--paper-soft);
  font-size: 0.67rem;
  line-height: 1.3;
}

.game-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  gap: 10px;
}

.game-actions .pixel-button {
  width: 100%;
  min-width: 0;
  padding-inline: 8px;
}

.game-actions .play { background: var(--green); color: var(--paper-soft); }
.game-actions .source { background: var(--paper-deep); }
.game-actions .acquire { background: var(--blue); color: var(--paper-soft); }

.card-ad {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 78px;
  border: 4px solid var(--paper);
  padding: 14px 20px;
  background: rgb(47 123 99 / 0.97);
  color: var(--paper-soft);
  box-shadow: 7px 7px 0 var(--ink);
  line-height: 1.6;
  text-decoration: none;
}

.card-ad:hover,
.card-ad:focus-visible { outline: 4px solid var(--orange); outline-offset: 3px; }
.card-ad-label { border: 2px solid currentColor; padding: 3px 6px; font-size: 0.65rem; }
.card-ad strong { overflow-wrap: anywhere; }

.state-card {
  grid-column: 1 / -1;
  width: min(560px, calc(100% - 16px));
  margin: 40px auto;
  border: 4px solid var(--ink);
  padding: 22px;
  background: var(--paper-soft);
  box-shadow: var(--shadow);
  text-align: center;
}

.site-footer {
  padding: 14px 18px;
  border: 4px solid var(--ink);
  background: rgb(255 241 201 / 0.94);
  box-shadow: 6px 6px 0 var(--ink);
}

.site-footer p { margin: 0; font-size: 0.72rem; line-height: 1.8; }
.site-footer a { color: var(--blue); text-underline-offset: 3px; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loading-pulse { 50% { filter: brightness(1.3); transform: translateY(-3px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (max-width: 920px) {
  .hero-band { align-items: flex-start; }
  .hero-actions { flex-direction: column; align-items: flex-end; }
}

@media (max-width: 640px) {
  .catalog-loader {
    width: min(100%, calc(100% - 8px));
    min-height: 180px;
    margin-block: 14px;
    padding: 10px 4px;
  }
  .catalog-loader__content { gap: 16px; padding: 30px 18px; }
  .catalog-loader__content p { font-size: 0.92rem; }
  .site-scrim { padding: 12px 8px; }
  .hero-band,
  .command-band,
  .ad-slot,
  .catalog-status,
  .catalog-grid,
  .site-footer { width: min(100%, calc(100% - 8px)); }
  .hero-band { gap: 10px; padding: 10px 12px; flex-direction: column; box-shadow: 5px 5px 0 var(--ink); }
  .brand-lockup { gap: 9px; }
  .brand-text { gap: 4px; }
  .brand-text h1 { font-size: clamp(1.35rem, 9vw, 2rem); }
  .brand-text p { font-size: 0.66rem; line-height: 1.35; }
  .hero-actions { width: 100%; flex-direction: row; flex-wrap: nowrap; gap: 5px; align-items: center; }
  .language-switch { width: auto; flex: 0 0 auto; flex-wrap: nowrap; gap: 4px; }
  .language-button { min-width: 34px; min-height: 36px; padding: 6px; }
  .publish-button { min-width: 0; min-height: 36px; padding: 6px 8px; flex: 1 1 auto; }
  .publish-button svg:last-child { display: none; }
  .reload-button { width: 38px; min-height: 36px; padding: 6px; }
  .command-band { margin-top: 12px; padding: 8px; }
  #search { min-height: 42px; padding-block: 9px; }
  .game-card { contain-intrinsic-size: 350px; }
  .cover-frame { aspect-ratio: 16 / 7; }
  .game-body { gap: 8px; padding: 10px; }
  .game-heading { gap: 5px; }
  .game-title { min-height: 2.8em; font-size: 0.9rem; line-height: 1.4; }
  .game-repo { min-height: 1.4em; font-size: 0.68rem; -webkit-line-clamp: 1; display: -webkit-box; -webkit-box-orient: vertical; }
  .game-meta { min-height: 24px; gap: 5px; }
  .badge { padding: 3px 6px; }
  .game-actions { gap: 7px; }
  .game-actions .pixel-button { min-height: 38px; padding-block: 7px; }
  .catalog-grid { grid-template-columns: 1fr; }
  .card-ad { grid-template-columns: auto minmax(0, 1fr); }
  .card-ad > :last-child { display: none; }
}
