/* PuzzleSteps - single stylesheet, mobile first. No frameworks. */
:root {
  --bg: #fbfaf8; --fg: #222; --muted: #666; --card: #fff; --line: #e4e0da;
  --accent: #1f6feb; --accent-fg: #fff; --chip: #f0ece6;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16161a; --fg: #e8e6e3; --muted: #a09c96; --card: #202027; --line: #34343c;
          --accent: #6ea8ff; --accent-fg: #0b0b0f; --chip: #2a2a33; }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC",
        "Microsoft JhengHei", sans-serif;
  overflow-wrap: anywhere;
}
img, iframe { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.5rem; line-height: 1.3; margin: 1rem 0; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .25rem; }
.small { font-size: .9rem; color: var(--muted); }
.lead { font-size: 1.1rem; }

.site-header { border-bottom: 1px solid var(--line); background: var(--card); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); min-height: 44px; display: flex; align-items: center; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.nav a, .lang-switch { min-height: 44px; display: inline-flex; align-items: center; }
.site-footer { margin-top: 2rem; padding: 1rem 0 2rem; border-top: 1px solid var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 1rem 0; }
figure { margin: 0 0 1rem; }
figure img { border-radius: 8px; margin: 0 auto; }
.info { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 .5rem; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 22px;
        background: var(--chip); text-decoration: none; font-size: .95rem; }
.stars { color: #e0a100; letter-spacing: 2px; }

.btn, .jump button, details.reveal > summary {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg);
  font: inherit; text-decoration: none; cursor: pointer;
}
.jump { margin: 1rem 0; }
.jump label { display: block; margin-bottom: 4px; }
.jump-row { display: flex; gap: 8px; }
.jump input { flex: 1; min-width: 0; min-height: 44px; font-size: 16px; padding: 0 12px;
              border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--fg); }
.jump button { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.prevnext { display: flex; justify-content: space-between; gap: 8px; margin: 1rem 0; }

details.reveal { margin: 1rem 0; }
details.reveal > summary { width: 100%; list-style: none; font-weight: 600; background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal[open] > summary { margin-bottom: .75rem; }
details.reveal img { border-radius: 8px; margin: 0 auto; }
.answer { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.steps { padding-left: 1.4rem; }
.steps li { margin: .35rem 0; }
.keystep { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.keystep figcaption { margin-bottom: .5rem; }

.level-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.level-grid a { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 8px;
                background: var(--card); border: 1px solid var(--line); text-decoration: none; }
.tech-list { padding-left: 1.2rem; }
.tech-list li { margin: .5rem 0; }
.tech-list a { display: inline-block; min-height: 44px; line-height: 44px; }

/* Ad placeholders: empty until an ad network is approved. */
/* ad slots: fixed minimum height so loading ads never shifts the page (CLS) */
.ad-slot { margin: 1.5rem 0; min-height: 280px; text-align: center; }
.ad-label { display: block; font-size: .75rem; color: var(--muted); letter-spacing: .05em; margin-bottom: 4px; }
.ad-box { min-height: 250px; display: flex; align-items: center; justify-content: center;
          border: 2px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: .9rem; }
body { padding-bottom: env(safe-area-inset-bottom); }

.video { position: relative; aspect-ratio: 16 / 9; width: 100%; margin: 0 auto; }  /* 16:9 compilations */
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 12px; }

@media (min-width: 640px) {
  h1 { font-size: 1.9rem; }
  .card { padding: 16px; }
}

/* language menu (no JS: <details>) */
.lang-menu { position: relative; }
.lang-menu summary { cursor: pointer; list-style: none; padding: 0 4px; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu ul { position: absolute; right: 0; top: 100%; z-index: 10; margin: 0; padding: 4px 0; list-style: none;
                background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-width: 9rem;
                box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.lang-menu li a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; text-decoration: none; }
.lang-menu li a[aria-current] { font-weight: 700; }

/* most-viewed ranking */
.ranking { list-style: none; padding: 0; margin: 0 0 1rem; }
.ranking li a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 10px;
                border-bottom: 1px solid var(--line); text-decoration: none; }
.ranking .rank { min-width: 2.2em; font-weight: 700; color: var(--muted); text-align: right; }
.ranking li:nth-child(-n+3) .rank { color: #e0a100; }
.ranking .rk-name { flex: 1; }
.ranking .rk-views { color: var(--muted); font-size: .9rem; white-space: nowrap; }

/* update log */
.latest-update{background:var(--chip);border:1px solid var(--line);border-radius:10px;padding:.6em .9em;font-size:.95em}
.updates{list-style:none;padding:0}
.updates li{padding:.55em 0;border-bottom:1px solid var(--line)}
.updates time{display:inline-block;min-width:6.5em;color:var(--muted);font-variant-numeric:tabular-nums}
