/* Comparison / reference ledger — white paper, near-black rules, ruby accent, teal secondary. */
:root {
  --ink: #161616;
  --rule: #161616;
  --rule-soft: #d8d8d8;
  --paper: #ffffff;
  --paper-soft: #f4f4f4;
  --ruby: #9b1b30;
  --ruby-dark: #7a1426;
  --ruby-tint: #fbf1f3;
  --teal: #146a66;
  --teal-tint: #e6f2f1;
  --muted: #5a5a5a;
  --measure: 1160px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font: 16px/1.65 system-ui, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  letter-spacing: 0;
}

[hidden] { display: none !important; }

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

a { color: var(--ruby); }
a:hover { color: var(--ruby-dark); }

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

svg {
  width: 1em;
  height: 1em;
  stroke: currentColor;
  fill: none;
  flex: none;
  vertical-align: -0.15em;
}

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 20px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Masthead — compact horizontal strip */
.masthead { border-bottom: 2px solid var(--rule); }

.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  min-height: 56px;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 8px 20px;
}

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

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

.brand-logo img { display: block; width: auto; height: 26px; }

.brand-name { font-size: 1.15rem; }

.site-nav { margin-left: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
.site-nav a {
  display: block;
  padding: 6px 10px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ruby); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--ruby); font-weight: 600; }

.menu-toggle { display: none; }

/* Page head */
.page-head { padding: 28px 0 18px; border-bottom: 1px solid var(--rule); }
.page-head h1 { margin: 0 0 6px; font-size: 1.75rem; line-height: 1.25; }
.page-lede { margin: 0; max-width: 72ch; color: var(--muted); }

.entry-links {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}
.entry-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--ruby);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* Sections */
.section { padding: 24px 0 8px; }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin: 0 0 10px;
}
.section-head h2 { margin: 0; font-size: 1.25rem; line-height: 1.3; }
.section-count { font-size: 0.9rem; font-weight: 400; color: var(--teal); }
.section-note { font-size: 0.9rem; color: var(--muted); }
.section-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.92rem;
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
.section-more:hover { color: var(--ruby); }
.section-group { scroll-margin-top: 12px; }

/* Comparison table */
.compare {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border-top: 2px solid var(--rule);
}
.compare th,
.compare td {
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule-soft);
  overflow-wrap: anywhere;
}
.compare thead th {
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 2px solid var(--rule);
}
.compare tbody th { font-weight: 600; }
.compare .record { scroll-margin-top: 12px; }
.compare .record:target { background: var(--ruby-tint); }
.compare .record:target td:first-child,
.compare .record:target th:first-child { box-shadow: inset 3px 0 0 var(--ruby); }
.compare th:first-child,
.compare td:first-child { padding-left: 0; }
.compare th:last-child,
.compare td:last-child { padding-right: 0; }

.w-game { width: 26%; }
.w-class { width: 15%; }
.w-action { width: 16%; }
.w-key { width: 20%; }
.w-count { width: 10%; }
.compare-3 .w-game { width: 30%; }

.game-ident { display: flex; align-items: flex-start; gap: 10px; }
.game-cover {
  flex: none;
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 3px;
}
.game-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.game-name { font-weight: 600; }
.game-en { font-size: 0.85rem; color: var(--muted); }

.cat-link {
  font-weight: 600;
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
.cat-link:hover { color: var(--ruby); }

.tag-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag-list li {
  padding: 1px 6px;
  font-size: 0.78rem;
  color: var(--teal);
  background: var(--teal-tint);
  border-radius: 3px;
}

.inline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.inline-list a { color: var(--ink); }
.inline-list a:hover { color: var(--ruby); }

.col-intro p { margin: 0; }

.dl-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-weight: 600;
  color: #fff;
  background: var(--ruby);
  border-radius: 4px;
  text-decoration: none;
}
.dl-link:hover { color: #fff; background: var(--ruby-dark); }
.no-action { color: var(--muted); }
.row-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--teal);
}
.col-action .row-link { display: flex; }
.row-link:hover { color: var(--ruby); }

/* Unframed toolbar (JS enhancement) */
.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 18px;
  margin: 0;
  padding: 16px 0 14px;
}
.tool { display: flex; flex-direction: column; gap: 4px; }
.tool-label { font-size: 0.85rem; font-weight: 600; }
.tool-search { flex: 1 1 260px; }
.tool-filter { flex: 0 1 220px; }
.tools input,
.tools select {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 4px;
}
.input-icon,
.select-wrap { position: relative; display: block; }
.input-icon svg,
.select-wrap svg {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.input-icon svg { left: 10px; }
.input-icon input { padding-left: 32px; }
.select-wrap svg { right: 10px; }
.select-wrap select { padding-right: 32px; appearance: none; }
.tool-status {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  padding-bottom: 7px;
  font-size: 0.95rem;
}
.tool-status strong { color: var(--ruby); }
.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}
.reset-btn:hover { color: var(--ruby); border-color: var(--ruby); }

.empty-note { margin: 0; padding: 20px 0; color: var(--muted); border-bottom: 1px solid var(--rule-soft); }

/* Supporting document — two-column heading/body rows */
.doc { border-top: 2px solid var(--rule); }
.doc-row {
  display: grid;
  grid-template-columns: minmax(150px, 24%) 1fr;
  gap: 8px 28px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.doc-key h2,
.doc-key h3 { margin: 0; font-size: 1.05rem; line-height: 1.4; }
.doc-key h3 { font-size: 0.95rem; color: var(--teal); }
.doc-val { min-width: 0; overflow-wrap: anywhere; }
.doc-val > :first-child { margin-top: 0; }
.doc-val > :last-child { margin-bottom: 0; }
.doc-val p { margin: 0 0 12px; }
.doc-val ul,
.doc-val ol { margin: 0 0 12px; padding-left: 1.5em; }
.doc-val li { margin: 0 0 4px; }
.doc code {
  padding: 1px 5px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 0.92em;
  background: var(--paper-soft);
  border-radius: 3px;
}

/* Footer */
.footer { margin-top: 32px; padding: 20px 0 28px; font-size: 0.9rem; color: var(--muted); border-top: 2px solid var(--rule); }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer-id { margin: 0; }
.footer-id strong { color: var(--ink); }
.footer-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.footer a { color: var(--ink); }
.footer a:hover { color: var(--ruby); }

/* Mobile: table records become label/value blocks */
@media (max-width: 767px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 6px 10px;
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: 4px;
    cursor: pointer;
  }
  .site-nav { width: 100%; margin-left: 0; }
  .js .site-nav { display: none; }
  .js .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; padding-top: 4px; border-top: 1px solid var(--rule-soft); }
  .site-nav a { padding: 10px 4px; border-bottom: 1px solid var(--rule-soft); }
  .site-nav a[aria-current="page"] { color: var(--ruby); border-bottom-color: var(--rule-soft); }

  .page-head { padding-top: 20px; }
  .page-head h1 { font-size: 1.5rem; }

  .compare,
  .compare tbody,
  .compare tr,
  .compare th,
  .compare td { display: block; }
  .compare colgroup { display: none; }
  .compare thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .compare .record { padding: 6px 0; border-bottom: 2px solid var(--rule); }
  .compare .record td,
  .compare .record th {
    display: grid;
    grid-template-columns: 5em 1fr;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--rule-soft);
  }
  .compare .record > :last-child { border-bottom: 0; }
  .compare .record td::before,
  .compare .record th::before {
    content: attr(data-label);
    padding-top: 1px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
  }
  .compare .record:target td:first-child,
  .compare .record:target th:first-child { box-shadow: none; }
  .compare .record:target { box-shadow: inset 3px 0 0 var(--ruby); padding-left: 8px; }
  .tool-status { margin-left: 0; padding-bottom: 0; }
  .doc-row { grid-template-columns: 1fr; gap: 6px; }
}

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

/* Download verification sheet — one ledger record lifted off the page */
.gate {
  width: min(560px, calc(100% - 32px));
  max-width: 560px;
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 16px 36px rgba(22, 22, 22, 0.2);
}
.gate:not([open]) { display: none; }
.gate::backdrop { background: rgba(22, 22, 22, 0.58); }
.gate[open] { animation: gate-enter 140ms ease-out; }

@keyframes gate-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.gate-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 2px solid var(--rule);
}
.gate-kicker { margin: 0 0 1px; font-size: 0.78rem; font-weight: 600; color: var(--teal); }
.gate-head h2 { margin: 0; font-size: 1.1rem; line-height: 1.3; }
.gate-close {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}
.gate-close:hover { color: var(--ruby); border-color: var(--ruby); }

.gate-record { margin: 0; padding: 0 18px; }
.gate-record-row {
  display: grid;
  grid-template-columns: 4.5em 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.gate-record dt { padding-top: 1px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.gate-record dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.gate-record [data-gate-name] { font-weight: 600; }
.gate-id { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 0.92em; }

.gate-status { display: flex; align-items: baseline; gap: 8px; }
.gate-status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--rule-soft);
  border-radius: 2px;
  transform: translateY(-1px);
}
.gate-status.is-loading::before { background: var(--muted); }
.gate-status.is-ready::before { background: var(--teal); }
.gate-status.is-ready { color: var(--teal); }
.gate-status.is-complete::before { background: var(--ruby); }
.gate-status.is-complete { color: var(--ruby); }
.gate-status.is-error::before { background: var(--ruby-dark); }
.gate-status.is-error { color: var(--ruby-dark); }

.gate-frame { padding: 14px 18px 0; }
.gate-frame-host {
  display: block;
  overflow: hidden;
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.gate-frame iframe {
  display: block;
  width: 100%;
  height: 232px;
  max-height: 56vh;
  border: 0;
  background: var(--paper);
}
.gate[data-gate-state="ready"] .gate-frame-host { border-color: var(--teal); }
.gate[data-gate-state="error"] .gate-frame-host { border-color: var(--ruby-dark); }
.gate-note { margin: 0; padding: 12px 18px 16px; font-size: 0.85rem; color: var(--muted); }

@media (max-width: 767px) {
  .gate {
    width: calc(100% - 20px);
    max-height: calc(100vh - 24px);
  }
  .gate-head { padding: 11px 14px; }
  .gate-record { padding: 0 14px; }
  .gate-record-row { grid-template-columns: 4em 1fr; gap: 8px; }
  .gate-frame { padding: 12px 14px 0; }
  .gate-frame iframe { height: 260px; max-height: 50vh; }
  .gate-note { padding: 10px 14px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .gate[open] { animation: none; }
}
