:root {
  color-scheme: dark;
  --page: #121116;
  --panel: #1a1921;
  --lift: #23222d;
  --edge: #2d2b3a;
  --text: #f7f5f0;
  --muted: #b0acb9;
  --accent: #f5b841;
  --mint: #63e6be;
  --radius: 16px;
  font: 16px/1.6 "DM Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
a { color: inherit; text-decoration: none; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
p, ul, ol, h1, h2, h3, h4, dl, dd { margin: 0; }

.frame {
  width: min(1240px, calc(100% - 64px));
  margin-inline: auto;
}
.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: fixed; z-index: 20; top: 10px; left: 10px;
  background: #2b2313; color: var(--accent); padding: 8px 12px; border-radius: 8px;
}

/* Header */
.top {
  min-height: 74px;
  background: #141319;
  border-bottom: 1px solid var(--edge);
}
.header-row {
  min-height: 74px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 11px;
  font-weight: 850; font-size: 1.12rem; letter-spacing: .01em; flex-shrink: 0;
}
.brand small {
  display: block; color: var(--accent);
  font: 700 .65rem/1.3 ui-monospace, monospace; letter-spacing: .14em;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: #231e15; border: 1px solid #59441e; color: var(--accent);
  font: 900 1.05rem/1 ui-monospace, monospace;
}
.header-row nav {
  display: flex; align-items: center; gap: 22px;
  font-size: .94rem; font-weight: 700; color: var(--muted);
}
.header-row nav a { padding-block: 10px; white-space: nowrap; }
.header-row nav a[aria-current], .header-row nav a:hover { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.progress-pill, .language-switch {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 6px 12px;
  border: 1px solid var(--edge); border-radius: 999px;
  background: var(--panel); color: var(--muted); font-size: .86rem; font-weight: 700;
  white-space: nowrap;
}
.progress-pill b { color: var(--accent); }
.progress-pill:hover, .language-switch:hover { border-color: var(--accent); color: var(--text); }

/* Hero */
.hero {
  margin-block: 24px 34px;
  padding: clamp(24px, 4vw, 48px);
  border-radius: 20px;
  border: 1px solid var(--edge);
  background: radial-gradient(circle at 85% 20%, rgba(245, 184, 65, 0.14), transparent 55%),
              radial-gradient(circle at 15% 80%, rgba(99, 230, 190, 0.08), transparent 50%),
              linear-gradient(135deg, #1b1924 0%, #14131a 100%);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font: 750 .78rem/1.4 ui-monospace, monospace; letter-spacing: .16em;
  color: var(--accent); text-transform: uppercase;
}
.eyebrow span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
h1 {
  font-size: clamp(2rem, 4.6vw, 3.6rem);
  letter-spacing: -.04em; line-height: 1.1; font-weight: 900;
  margin: .22em 0 .32em;
}
h1 em { font-style: normal; color: var(--accent); }
.hero-desc { max-width: 64ch; color: #d5d1df; font-size: 1.03rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

.primary, .secondary {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  border-radius: 10px; padding: 10px 18px; min-height: 44px;
  font-size: .94rem; font-weight: 750; border: 1px solid transparent;
}
.primary { background: var(--accent); color: #161209; }
.primary:hover { background: #ffc85c; }
.secondary { background: var(--lift); color: var(--text); border-color: #3a374b; }
.secondary:hover { border-color: var(--accent); }

/* Lobby continue & catalog */
.lobby-continue {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-bottom: 22px; padding: 14px 18px;
  border-radius: 14px; border: 1px solid #4d3e1e; background: #1e1a13;
}
.lobby-continue-heading { font-size: .8rem; font-weight: 750; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }

.catalog { margin-bottom: 44px; scroll-margin-top: 16px; }
.catalog-heading, .section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.catalog-heading h2, .section-head h2 { font-size: clamp(1.45rem, 2.8vw, 2.1rem); letter-spacing: -.03em; }
.catalog-heading p, .section-head p { color: var(--muted); margin-top: 4px; font-size: .94rem; }

.search {
  display: flex; align-items: center; gap: 8px;
  width: min(300px, 100%); padding: 4px 12px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
}
.search > span { color: var(--accent); font-size: 1.05rem; }
.search input {
  border: 0; background: none; color: var(--text); min-height: 36px; width: 100%; outline: none;
}
.search:focus-within { border-color: var(--accent); }

.catalog-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--edge);
}
.filters, .catalog-controls { display: flex; flex-wrap: wrap; gap: 7px; }
.filters button, .text-button {
  min-height: 38px; padding: 6px 12px; border-radius: 9px;
  border: 1px solid var(--edge); background: var(--panel);
  color: var(--muted); font-size: .88rem; font-weight: 700; white-space: nowrap;
}
.filters button:hover, .text-button:hover { border-color: #5a5572; color: var(--text); }
.filters [aria-pressed="true"], .text-button[aria-pressed="true"] {
  background: #2b2314; border-color: var(--accent); color: var(--accent);
}

.catalog-index {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
}
.catalog-game {
  min-width: 0; border: 1px solid var(--edge); border-radius: var(--radius);
  background: linear-gradient(160deg, color-mix(in srgb, var(--tone) 55%, #1a1921), #16151c 80%);
  overflow: hidden; transition: transform .16s ease, border-color .16s ease;
}
.catalog-game:hover { transform: translateY(-2px); border-color: var(--accent); }
.catalog-game > a { display: flex; flex-direction: column; height: 100%; }
.catalog-preview {
  position: relative; display: block; aspect-ratio: 5 / 3;
  background: #121116; border-bottom: 1px solid var(--edge); overflow: hidden;
}
.catalog-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.diy-badge {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(18, 17, 22, 0.88); border: 1px solid var(--accent);
  color: var(--accent); font: 750 .72rem/1.3 ui-monospace, monospace;
}
.catalog-card-body {
  display: flex; flex-direction: column; gap: 5px; padding: 13px 15px 15px; flex: 1;
}
.catalog-card-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: .76rem; font-weight: 750; color: var(--accent);
}
.catalog-card-meta span:last-child { color: var(--muted); }
.catalog-card-title {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  font-size: 1.12rem; font-weight: 850;
}
.catalog-card-caption { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.catalog-game small { margin-top: auto; padding-top: 6px; color: var(--mint); font-size: .78rem; font-weight: 700; }

.no-results {
  padding: 36px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--edge); border-radius: 12px;
}

/* Overview, tables & FAQ */
.arcade-overview {
  margin-block: 42px; display: grid; gap: 32px;
  padding-top: 28px; border-top: 1px solid var(--edge);
}
.overview-intro p { max-width: 72ch; color: #d5d1df; margin-top: 10px; }
.overview-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.overview-links a, .editorial-body p a, .guide-cross-link a {
  color: var(--accent); text-decoration: underline; text-underline-offset: .2em;
}
.overview-table-wrap { overflow-x: auto; border: 1px solid var(--edge); border-radius: 12px; background: var(--panel); }
.overview-table { width: 100%; border-collapse: collapse; font-size: .92rem; text-align: left; }
.overview-table caption { padding: 12px 16px; text-align: left; font-weight: 800; color: var(--accent); border-bottom: 1px solid var(--edge); }
.overview-table th, .overview-table td { padding: 11px 14px; border-bottom: 1px solid var(--edge); }
.overview-table tr:last-child th, .overview-table tr:last-child td { border-bottom: 0; }
.overview-table a { color: var(--mint); font-weight: 700; }

.faq-list { display: grid; gap: 14px; margin-top: 14px; }
.faq-list > div {
  padding: 15px 18px; border-radius: 12px; background: var(--panel); border: 1px solid var(--edge);
}
.faq-list dt { font-weight: 800; color: var(--text); }
.faq-list dd { margin-top: 6px; color: var(--muted); max-width: 72ch; }
.faq-list dd a { color: var(--accent); text-decoration: underline; }

/* Library & Editorial */
.editorial { max-width: 960px; padding-block: clamp(28px, 5vw, 56px); }
.editorial-head { padding-bottom: 22px; border-bottom: 1px solid var(--edge); }
.editorial-head > p:last-child { color: var(--muted); font-size: 1.04rem; max-width: 68ch; }
.editorial-meta { margin-top: 14px; font-size: .88rem; color: var(--muted); }
.editorial-body section { padding: 24px 0; border-bottom: 1px solid var(--edge); scroll-margin-top: 16px; }
.editorial-body h2 { font-size: clamp(1.25rem, 2.5vw, 1.65rem); }
.editorial-body p { max-width: 72ch; margin-top: 10px; line-height: 1.75; color: #dcd8e5; }
.guide-index, .guide-level-links { display: flex; flex-wrap: wrap; gap: 8px 14px; list-style: none; padding: 0; margin-top: 14px; }
.guide-index a, .guide-level-links a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 4px 12px;
  border: 1px solid var(--edge); border-radius: 8px; background: var(--panel); color: var(--mint); font-weight: 700;
}
.guide-index a:hover, .guide-level-links a:hover { border-color: var(--accent); }

.site-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 14px;
}
.site-facts > div { padding: 12px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--edge); }
.site-facts dt { font-size: .8rem; color: var(--accent); font-weight: 750; }
.site-facts dd { margin-top: 4px; color: var(--text); font-weight: 600; }

.reference-group { margin-bottom: 28px; scroll-margin-top: 16px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.group-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--tone); color: var(--accent); font-weight: 900;
}
.group-head h3 { font-size: 1.32rem; flex: 1; }
.group-links { display: flex; gap: 14px; font-size: .9rem; font-weight: 700; color: var(--mint); }
.reference-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.reference-list article { padding: 15px 17px; border-radius: 12px; background: var(--panel); border: 1px solid var(--edge); }
.reference-list article header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.reference-list article header a { color: var(--accent); font-size: .88rem; font-weight: 700; }
.reference-list p { color: var(--muted); font-size: .94rem; }
.reference-list .feedback { color: #e2dfeb; margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--accent); }

/* Progress page */
.player-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-block: 20px;
}
.stat-box { padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--edge); }
.stat-box small { color: var(--muted); font-size: .82rem; display: block; }
.stat-box strong { font-size: 1.45rem; color: var(--accent); }
.daily-list { list-style: none; padding: 0; display: grid; gap: 10px; margin-top: 12px; }
.daily-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-radius: 10px; background: var(--panel); border: 1px solid var(--edge);
}
.daily-list li.daily-done { border-color: var(--mint); }
.daily-list a { color: var(--text); font-weight: 750; }
.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.progress-card { padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--edge); }
.progress-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.level-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.level-dots a {
  display: grid; place-items: center; min-height: 34px; border-radius: 6px;
  background: var(--lift); color: var(--muted); font-size: .84rem; font-weight: 700;
}
.level-dots a.done { background: #193e33; color: var(--mint); border: 1px solid var(--mint); }
.backup-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 14px; }
.file-label {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--edge); border-radius: 10px; background: var(--lift); cursor: pointer; font-weight: 700;
}
.file-label input { display: none; }

/* Consent & Footer */
.consent-notice {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px;
  margin-block: 24px; padding: 14px 18px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--edge);
}
.consent-notice p { font-size: .92rem; color: var(--muted); margin-top: 4px; }
.consent-notice a { color: var(--accent); text-decoration: underline; margin-left: 8px; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.consent-actions button {
  min-height: 42px; padding: 6px 14px; border-radius: 8px;
  border: 1px solid #4d4862; background: var(--lift); color: var(--text); font-weight: 700;
}
.consent-actions button:hover { border-color: var(--accent); }

.footer {
  background: #141319; border-top: 1px solid var(--edge);
  padding: 26px 0; color: var(--muted); margin-top: 40px;
}
.footer > .frame { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px 24px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer nav a, .footer summary { display: inline-flex; align-items: center; min-height: 40px; font-size: .92rem; }
.footer nav a:hover, .footer summary:hover { color: var(--accent); text-decoration: underline; }
.consent-settings summary { cursor: pointer; }
.consent-settings p { margin-block: 6px 8px; font-size: .9rem; }

@media (max-width: 1120px) {
  .catalog-index { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .catalog-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .frame { width: min(1240px, calc(100% - 24px)); }
  .header-row { flex-wrap: wrap; padding-block: 10px; gap: 8px 12px; }
  .header-row nav { order: 3; width: 100%; justify-content: space-around; border-top: 1px solid var(--edge); padding-top: 6px; gap: 8px; }
  .header-row nav a { padding-block: 6px; font-size: .88rem; }
  .reference-list { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .catalog-index { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
