/* ===== PuzzleBox — zero-dependency static site styles ===== */

:root {
  --bg: #0b1020;
  --bg-soft: #10182c;
  --panel: #141d33;
  --panel-2: #1a2540;
  --line: #2a3757;
  --text: #e8edf8;
  --muted: #9aa9c6;
  --cyan: #4de2ff;
  --gold: #ffcf5a;
  --purple: #a78bfa;
  --green: #37d9a0;
  --red: #fb7185;
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(77, 226, 255, 0.10), transparent 60%),
    radial-gradient(900px 560px at 92% 8%, rgba(167, 139, 250, 0.10), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap {
  width: min(1080px, calc(100% - 40px));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--gold);
  color: #10131f;
  font-weight: 700;
  border-radius: 8px;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 16, 32, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 68px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  font-size: 1.15rem;
}
.brand__name small {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.site-nav {
  display: flex;
  gap: 18px;
  margin-left: auto;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}
.site-nav a:hover { color: var(--cyan); text-decoration: none; }
.header-badge {
  margin: 0;
  padding: 5px 11px;
  border: 1px solid rgba(55, 217, 160, 0.4);
  border-radius: 999px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.header-badge span { font-size: 0.6rem; vertical-align: 1px; }

/* ===== Hero ===== */
.hero {
  padding: 76px 0 54px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}
.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.hero h1 span {
  display: block;
  background: linear-gradient(100deg, var(--cyan), var(--purple) 55%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 0.62em;
  letter-spacing: 0.08em;
}
.lede {
  max-width: 760px;
  margin: 0 auto 30px;
  color: #c7d2e8;
  font-size: clamp(1rem, 2vw, 1.12rem);
}
.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 720px;
  margin: 0 auto 30px;
}
.fact {
  padding: 16px 8px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: 12px;
}
.fact strong {
  display: block;
  font-size: 1.7rem;
  color: var(--gold);
  line-height: 1.2;
}
.fact span { font-size: 0.8rem; color: var(--muted); }

.cta-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; border-color: var(--cyan); }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: linear-gradient(100deg, var(--cyan), #38bdf8);
  border-color: transparent;
  color: #071320;
}
.btn--ghost { background: transparent; }
.btn--small { padding: 7px 13px; font-size: 0.86rem; }

/* ===== Sections ===== */
.section { padding: 56px 0; border-bottom: 1px solid var(--line); }
.section-head { max-width: 760px; margin-bottom: 28px; }
.section-index {
  margin: 0 0 6px;
  color: var(--purple);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.section-head h2 {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  line-height: 1.25;
}
.section-desc { margin: 0; color: var(--muted); }

/* ===== Game shell ===== */
.game-shell {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.game-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  scrollbar-width: thin;
}
.game-tab {
  flex: 1 0 auto;
  min-width: 96px;
  padding: 14px 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.game-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.game-tab.is-active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  background: rgba(77, 226, 255, 0.07);
}
.game-panel { padding: 26px; }
.game-panel[hidden] { display: none; }
.game-meta h3 { margin: 0 0 6px; font-size: 1.35rem; }
.game-meta p { margin: 0 0 18px; color: var(--muted); font-size: 0.95rem; }
.game-stats {
  display: flex;
  gap: 26px;
  margin: 0 0 18px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.game-stats div { display: flex; align-items: baseline; gap: 8px; }
.game-stats dt { color: var(--muted); font-size: 0.8rem; }
.game-stats dd { margin: 0; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.game-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.key-hint { color: var(--muted); font-size: 0.8rem; }
.game-status {
  min-height: 1.7em;
  margin: 14px 0 0;
  padding: 9px 13px;
  border-left: 3px solid var(--cyan);
  background: rgba(77, 226, 255, 0.07);
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
}

/* ===== Shared board ===== */
.board {
  display: grid;
  gap: 6px;
  width: min(100%, 420px);
  padding: 10px;
  background: #0c1425;
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: manipulation;
}
.board--2048 { grid-template-columns: repeat(4, 1fr); }
.board--mines { grid-template-columns: repeat(8, 1fr); max-width: 460px; }
.board--sudoku { grid-template-columns: repeat(4, 1fr); max-width: 360px; }
.board--memory { grid-template-columns: repeat(4, 1fr); max-width: 460px; }
.board--slide { grid-template-columns: repeat(3, 1fr); max-width: 360px; }

.cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.cell:hover:not(:disabled) { border-color: var(--cyan); }
.cell:disabled { cursor: default; }

/* 2048 */
.cell--2048 { background: #17213a; font-size: 1.15rem; }
.cell--2048[data-v="2"] { background: #1d3a52; color: #bfeaff; }
.cell--2048[data-v="4"] { background: #1c4a5c; color: #c9f6ff; }
.cell--2048[data-v="8"] { background: #1d5f6b; color: #e2ffff; }
.cell--2048[data-v="16"] { background: #2a6a63; color: #eafff6; }
.cell--2048[data-v="32"] { background: #397a5b; color: #f0fff4; }
.cell--2048[data-v="64"] { background: #5a8242; color: #f7ffe8; }
.cell--2048[data-v="128"] { background: #8a7b32; color: #fffbe0; font-size: 0.95rem; }
.cell--2048[data-v="256"] { background: #9c6a32; color: #fff4e0; font-size: 0.95rem; }
.cell--2048[data-v="512"] { background: #a8513f; color: #fff0e8; font-size: 0.95rem; }
.cell--2048[data-v="1024"] { background: #b13d5c; color: #fff0f4; font-size: 0.82rem; }
.cell--2048[data-v="2048"] { background: linear-gradient(135deg, #d97706, var(--gold)); color: #231600; font-size: 0.82rem; }

/* Minesweeper */
.cell--mines { font-size: 0.92rem; padding: 0; }
.cell--mines.is-hidden { background: linear-gradient(160deg, #243356, #1a2642); }
.cell--mines.is-open { background: #0e182c; cursor: default; }
.cell--mines.is-flagged { color: var(--gold); background: #3a2f18; }
.cell--mines.is-mine { background: #5c2434; color: #ffd7de; }
.cell--mines[data-n="1"] { color: #7dd3fc; }
.cell--mines[data-n="2"] { color: #86efac; }
.cell--mines[data-n="3"] { color: #fca5a5; }
.cell--mines[data-n="4"] { color: #c4b5fd; }
.cell--mines[data-n="5"] { color: #fcd34d; }
.cell--mines[data-n="6"] { color: #67e8f9; }
.cell--mines[data-n="7"] { color: #f9a8d4; }
.cell--mines[data-n="8"] { color: #e2e8f0; }

/* Sudoku */
.cell--sudoku {
  padding: 0;
  font-size: 1.2rem;
  border-radius: 4px;
}
.cell--sudoku.is-given { background: #1a2642; color: var(--cyan); cursor: default; }
.cell--sudoku.is-input { background: #101a2e; }
.cell--sudoku.is-error { background: #5c2434; color: #ffd7de; }
.cell--sudoku.br-right { border-right: 2px solid var(--cyan); }
.cell--sudoku.bb-bottom { border-bottom: 2px solid var(--cyan); }

/* Memory */
.cell--memory { font-size: 1.4rem; background: linear-gradient(160deg, #243356, #1a2642); }
.cell--memory.is-up { background: #142b3d; border-color: var(--cyan); cursor: default; }
.cell--memory.is-matched { background: #173b32; border-color: var(--green); cursor: default; opacity: 0.85; }

/* Slide */
.cell--slide { font-size: 1.25rem; background: linear-gradient(160deg, #243356, #1a2642); }
.cell--slide.is-empty { background: #0a1120; border-style: dashed; cursor: default; }
.cell--slide.is-done { border-color: var(--green); }

/* Reaction */
.reaction-pad { display: grid; place-items: center; min-height: 220px; }
.reaction-btn {
  width: min(100%, 320px);
  aspect-ratio: 2.6 / 1;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, #243356, #1a2642);
  color: var(--text);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
.reaction-btn:hover { border-color: var(--cyan); }
.reaction-btn.is-wait { background: #5c2434; border-color: var(--red); }
.reaction-btn.is-go { background: linear-gradient(135deg, #1a8a5a, var(--green)); border-color: var(--green); color: #04231a; }
.reaction-btn.is-done { background: #243356; }

/* ===== Domain cards ===== */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.domain-card {
  padding: 20px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: 12px;
}
.domain-card h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--cyan); }
.domain-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* ===== Catalog ===== */
.catalog-groups { display: grid; gap: 10px; }
.catalog-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.catalog-group summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  list-style-position: inside;
}
.catalog-group summary::-webkit-details-marker { display: none; }
.catalog-group summary::before {
  content: "+";
  display: inline-block;
  width: 1.4em;
  color: var(--cyan);
  font-weight: 900;
}
.catalog-group[open] summary::before { content: "−"; }
.catalog-group summary span { color: var(--muted); font-weight: 500; font-size: 0.85rem; margin-left: 8px; }
.catalog-list {
  columns: 3;
  column-gap: 22px;
  margin: 0;
  padding: 6px 18px 18px 38px;
  list-style: disc;
  color: var(--muted);
  font-size: 0.88rem;
}
.catalog-list li { break-inside: avoid; padding: 1px 0; }

/* ===== FAQ & sources ===== */
.faq-list { display: grid; gap: 10px; }
.faq-list details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 18px;
}
.faq-list summary {
  padding: 14px 0;
  cursor: pointer;
  font-weight: 700;
}
.faq-list p { margin: 0 0 16px; color: var(--muted); }
.source-list { padding-left: 20px; color: var(--muted); }
.source-list li { margin-bottom: 10px; }
.source-list strong { color: var(--text); }

/* ===== Footer ===== */
.site-footer {
  padding: 30px 0 46px;
  color: var(--muted);
  font-size: 0.88rem;
}
.footer-inner p { margin: 4px 0; }

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; padding-block: 10px; }
  .site-nav { order: 3; width: 100%; margin-left: 0; gap: 14px; }
  .header-badge { margin-left: auto; }
  .hero { padding: 54px 0 40px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 42px 0; }
  .game-panel { padding: 18px 14px; }
  .catalog-list { columns: 2; }
}

@media (max-width: 520px) {
  .header-badge { display: none; }
  .game-stats { gap: 16px; }
  .board { gap: 4px; padding: 7px; }
  .cell--2048 { font-size: 0.92rem; }
  .cell--mines { font-size: 0.78rem; }
  .catalog-list { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
