/* Cover gallery template — white / black / emerald with a coral accent */

:root {
  --white: #ffffff;
  --ink: #111111;
  --ink-2: #3f3f3f;
  --ink-3: #6a6a6a;
  --line: #e3e5e2;
  --surface: #f3f4f2;
  --emerald: #0f7b52;
  --emerald-deep: #0a5a3c;
  --coral: #ff5a3c;
  --wrap: 1280px;
  --gutter: clamp(20px, 5vw, 72px);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--white);
  overflow-wrap: break-word;
}

[hidden] { display: none !important; }

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a { color: var(--emerald); }

button { font-family: inherit; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

h1, h2, h3 {
  line-height: 1.25;
  font-weight: 700;
  margin: 0;
}

h1 { font-size: 34px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Skip link ---------- */

.skip {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 20;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--white);
  border-radius: 4px;
  text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Header ---------- */

.site-head {
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 28px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-logo {
  display: block;
  padding: 6px 10px;
  background: var(--ink);
  border-radius: 4px;
}

.brand-logo img {
  width: auto;
  height: 28px;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
}

.site-nav { margin-left: auto; }

.site-nav ul {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: block;
  padding: 20px 12px 18px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: border-color .15s, color .15s;
}

.site-nav a:hover { border-bottom-color: var(--coral); }

.site-nav a[aria-current="page"] {
  color: var(--emerald);
  border-bottom-color: var(--emerald);
}

.menu-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}

.menu-toggle .ico-x { display: none; }
.menu-toggle[aria-expanded="true"] .ico-x { display: block; }
.menu-toggle[aria-expanded="true"] .ico-menu { display: none; }

@media (max-width: 899px) {
  .js .menu-toggle { display: inline-flex; }

  .site-nav {
    flex-basis: 100%;
    margin-left: 0;
  }

  .js .site-nav:not(.is-open) { display: none; }

  .site-nav ul {
    flex-direction: column;
    gap: 0;
    padding: 4px 0 12px;
  }

  .site-nav a {
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
  }

  .site-nav a:hover { border-bottom-color: var(--coral); }

  .site-nav a[aria-current="page"] {
    padding-left: 10px;
    border-bottom-color: var(--line);
    box-shadow: inset 3px 0 0 var(--emerald);
  }
}

/* Vertical typographic accent, desktop only */

.side-label { display: none; }

@media (min-width: 1200px) {
  .side-label {
    display: block;
    position: fixed;
    top: 50%;
    left: 16px;
    z-index: 5;
    margin: 0;
    padding-left: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--emerald);
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: translateY(-50%) rotate(180deg);
    border-left: 2px solid var(--coral);
    pointer-events: none;
    user-select: none;
  }
}

/* ---------- Shared page pieces ---------- */

.page-head {
  max-width: 900px;
  padding: 40px 0 24px;
}

.page-desc,
.intro-desc {
  margin: 12px 0 0;
  font-size: 17px;
  color: var(--ink-2);
}

.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin: 0 0 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.sec-count {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--emerald);
}

.sec-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--emerald);
}

.sec-link:hover { border-bottom-color: var(--coral); }
.sec-link .ico { width: 16px; height: 16px; }

/* ---------- Index ---------- */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: end;
  gap: 16px 40px;
  padding: 44px 0 36px;
}

.intro h1 { grid-column: 1 / -1; }

.intro-stats {
  display: flex;
  gap: 20px;
  justify-self: end;
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.intro-stats span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: var(--emerald);
}

.intro-stats span:last-child::before { background: var(--coral); }

.wall-sec { margin-bottom: 72px; }

.wall {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 44px 24px;
  align-items: start;
}

.wall-item {
  grid-column: span 12;
  min-width: 0;
}

.wall-cover {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

.wall-cover img,
.tile-cover img,
.cat-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wall-cap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 14px;
  padding-top: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.wall-name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.wall-name a {
  color: var(--ink);
  text-decoration: none;
}

.wall-name a:hover { color: var(--emerald); }

.wall-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 0;
  color: var(--ink-3);
}

.wall-cat,
.tile-cat {
  color: var(--emerald);
}

.wall-cat::before,
.tile-cat::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 2px 0;
  border-radius: 50%;
  background: var(--coral);
}

.wall-dl {
  grid-column: 2;
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: start;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--emerald);
}

.wall-dl:hover { border-bottom-color: var(--coral); }
.wall-dl .ico { width: 14px; height: 14px; }

@media (min-width: 640px) {
  .wall-item:nth-child(2n + 1) { grid-column: span 7; }
  .wall-item:nth-child(2n) { grid-column: span 5; }
}

@media (min-width: 1024px) {
  .wall-item:nth-child(6n + 1) { grid-column: span 5; }
  .wall-item:nth-child(6n + 2) { grid-column: span 4; }
  .wall-item:nth-child(6n + 3) { grid-column: span 3; }
  .wall-item:nth-child(6n + 4) { grid-column: span 3; }
  .wall-item:nth-child(6n + 5) { grid-column: span 5; }
  .wall-item:nth-child(6n) { grid-column: span 4; }

  .wall-item:nth-child(6n + 1) .wall-cover,
  .wall-item:nth-child(6n + 5) .wall-cover { aspect-ratio: 16 / 10; }

  .wall-item:nth-child(6n + 3) .wall-cover,
  .wall-item:nth-child(6n + 4) .wall-cover { aspect-ratio: 1 / 1; }
}

.cats-sec { margin-bottom: 56px; }

.cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cat-list a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  color: var(--ink);
  font-size: 15px;
  text-decoration: none;
  border-bottom: 2px solid var(--line);
}

.cat-list a:hover { border-bottom-color: var(--coral); }

.cat-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--emerald);
}

.go-sec {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.go-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--white);
  font-weight: 600;
  text-decoration: none;
  background: var(--ink);
  border-radius: 4px;
  transition: background-color .15s;
}

.go-link:hover { background: var(--emerald); }
.go-link:last-child { background: var(--emerald); }
.go-link:last-child:hover { background: var(--emerald-deep); }

/* ---------- Games ---------- */

.tools {
  display: grid;
  gap: 16px;
  margin-bottom: 40px;
  padding: 20px 0 24px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
}

.tools-search { margin: 0; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
}

.search-box:focus-within {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  padding: 11px 0;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.search-box input:focus { outline: none; }

.tools-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tools-filter button {
  padding: 6px 14px;
  font-size: 14px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.tools-filter button:hover { border-color: var(--ink); }

.tools-filter button[aria-pressed="true"] {
  color: var(--white);
  background: var(--emerald);
  border-color: var(--emerald);
}

.tools-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}

.tools-status b { color: var(--coral); }

.tools-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}

.tools-reset:hover { background: var(--surface); }
.tools-reset .ico { width: 14px; height: 14px; }

.empty {
  margin: 0 0 40px;
  padding: 36px 0;
  font-size: 16px;
  border-bottom: 1px solid var(--line);
}

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

@media (min-width: 768px) {
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  scroll-margin-top: 24px;
}

.tile:target .tile-cover { outline: 3px solid var(--coral); }

.tile-cover {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

.tile-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
}

.tile-cat {
  margin: 0;
  font-size: 12px;
}

.tile-cat a {
  color: inherit;
  text-decoration: none;
}

.tile-cat a:hover { text-decoration: underline; }

.tile-name {
  font-size: 20px;
  font-weight: 700;
}

.tile-en {
  margin: -4px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.tile-desc {
  margin: 0;
  font-size: 15px;
  color: var(--ink-2);
}

.tile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile-tags li {
  padding: 2px 8px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface);
  border-radius: 4px;
}

.tile-dl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin-top: auto;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  text-decoration: none;
  background: var(--ink);
  border-radius: 4px;
  transition: background-color .15s;
}

.tile-dl:hover { background: var(--emerald); }

/* ---------- Category ---------- */

.toc {
  margin: 0 0 40px;
  padding: 14px 0;
  font-size: 14px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
}

.toc ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: inline-block;
  padding: 2px 0;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.toc a:hover { border-bottom-color: var(--coral); }

.toc-count {
  margin-left: 4px;
  font-size: 12px;
  color: var(--emerald);
}

.cat-group {
  margin-bottom: 60px;
  scroll-margin-top: 24px;
}

.cat-covers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .cat-covers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .cat-covers { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.cat-covers a {
  display: block;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}

.cat-cover {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  margin-bottom: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

.cat-name {
  display: block;
  font-weight: 600;
}

.cat-covers a:hover .cat-name { color: var(--emerald); }

.cat-en {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------- Supporting pages ---------- */

.prose {
  max-width: 900px;
  font-size: 17px;
  line-height: 1.8;
}

.prose-index {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.prose h2 {
  margin: 44px 0 14px;
  padding-left: 14px;
  font-size: 24px;
  border-left: 3px solid var(--emerald);
  scroll-margin-top: 24px;
}

.prose h2:first-child { margin-top: 0; }

.prose h3 {
  margin: 28px 0 8px;
  font-size: 19px;
  scroll-margin-top: 24px;
}

.prose p { margin: 0 0 16px; }

.prose a {
  color: var(--emerald);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.prose a:hover { color: var(--coral); }

.prose code {
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface);
  border-radius: 4px;
}

.prose ol,
.prose ul {
  margin: 0 0 18px;
  padding-left: 1.5em;
}

.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--emerald); font-weight: 600; }

.contact-link { margin-top: 28px; }

/* ---------- Download verification dialog ---------- */

.gate {
  width: min(560px, calc(100vw - 28px));
  max-width: none;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.gate:not([open]) { display: none; }

.gate::backdrop { background: rgba(17, 17, 17, .64); }

.gate-panel {
  position: relative;
  padding: 22px 22px 24px 58px;
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  border-radius: 4px;
  animation: gate-rise .18s ease-out;
}

@keyframes gate-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Vertical accent, echoing the masthead label */
.gate-rail {
  position: absolute;
  top: 22px;
  left: 24px;
  margin: 0;
  padding-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--emerald);
  white-space: nowrap;
  writing-mode: vertical-rl;
  border-left: 2px solid var(--coral);
  user-select: none;
}

.gate-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 16px;
}

.gate-title { font-size: 20px; }

.gate-game {
  grid-column: 1;
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.gate-game::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 2px 0;
  border-radius: 50%;
  background: var(--coral);
}

.gate-close {
  grid-column: 2;
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color .15s;
}

.gate-close:hover { background: var(--surface); }

.gate-note {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}

.gate-stage {
  position: relative;
  margin-top: 14px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

/* The frame keeps a fixed default until it reports its own content height;
   the viewport cap below always wins, so the panel stays on screen. */
.gate-frame {
  display: block;
  width: 100%;
  height: var(--gate-frame-height, 300px);
  max-height: 56vh;
  max-height: min(72vh, calc(100vh - 200px));
  max-height: min(72dvh, calc(100dvh - 200px));
  border: 0;
  background: transparent;
  transition: height .18s ease-out;
}

.gate[data-gate-state="loading"] .gate-frame,
.gate[data-gate-state="error"] .gate-frame { visibility: hidden; }

.gate-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 16px;
  font-size: 14px;
  text-align: center;
  color: var(--ink-2);
  background: var(--surface);
}

.gate-state p { margin: 0; }

.gate-dot {
  width: 8px;
  height: 8px;
  background: var(--coral);
  animation: gate-pulse 1s ease-in-out infinite;
}

@keyframes gate-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

.gate-done {
  color: var(--emerald);
  font-weight: 600;
}

.gate-fail-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
}

.gate-retry {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}

.gate-retry:hover { background: var(--white); border-color: var(--coral); }

.gate-direct {
  color: var(--emerald);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.gate-direct:hover { color: var(--coral); }

@media (max-width: 599px) {
  .gate { width: calc(100vw - 20px); }
  .gate-panel { padding: 18px 16px 20px; }
  .gate-rail { display: none; }
  .gate-title { font-size: 18px; }
  .gate-frame {
    height: var(--gate-frame-height, 280px);
    max-height: min(68vh, calc(100vh - 170px));
    max-height: min(68dvh, calc(100dvh - 170px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-panel,
  .gate-dot { animation: none; }
  .gate-frame { transition: none; }
}

/* ---------- Footer ---------- */

.site-foot {
  margin-top: 88px;
  padding: 28px 0 44px;
  font-size: 13px;
  color: var(--ink-2);
  border-top: 2px solid var(--ink);
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 32px;
}

.foot-brand {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.foot-meta { margin: 0; }

.foot-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}

.foot-nav a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.foot-nav a:hover { border-bottom-color: var(--coral); }

/* ---------- Responsive text ---------- */

@media (max-width: 767px) {
  h1 { font-size: 26px; }
  h2 { font-size: 20px; }

  .page-head { padding: 28px 0 16px; }

  .intro {
    grid-template-columns: minmax(0, 1fr);
    padding: 28px 0 28px;
  }

  .intro-stats { justify-self: start; }

  .page-desc,
  .intro-desc,
  .prose { font-size: 16px; }

  .prose h2 { font-size: 21px; }
  .prose h3 { font-size: 18px; }

  .wall { gap: 32px 20px; }
  .wall-sec { margin-bottom: 52px; }
  .site-foot { margin-top: 56px; }
  .foot-nav { margin-left: 0; }
}

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