/* =========================================================================
   Page-specific layouts: home hero, categories, library toolbar,
   game page, settings, about.
   ========================================================================= */

/* ---------- Home: featured hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: var(--sp-6); align-items: center;
  padding: var(--sp-6); margin-bottom: var(--sp-7);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.hero-media { border-radius: var(--r-md); overflow: hidden; display: block; }
.hero-media .thumb { border-radius: var(--r-md); }
.hero-copy { display: grid; gap: var(--sp-4); min-width: 0; }
.hero-copy h2 { font-size: var(--fs-2xl); }
.hero-copy p { color: var(--muted); max-width: 46ch; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding: var(--sp-4); gap: var(--sp-4); } }
@media (max-width: 520px) { .hero-copy h2 { font-size: 1.9rem; } }

/* ---------- Home: category tiles ---------- */
.cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
@media (max-width: 720px) { .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cat {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-4); min-height: var(--tap);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--text); text-decoration: none; font-weight: 600;
}
.cat::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--cat, var(--cat-other)); flex: none; }
.cat:hover { border-color: var(--cat, var(--muted)); }
.cat-name { flex: 1; min-width: 0; }
.cat-count { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- Library toolbar ---------- */
.toolbar {
  display: grid; gap: var(--sp-3); padding: var(--sp-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.toolbar-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }
.toolbar .search { flex: 1 1 260px; }

/* ---------- Game page ---------- */
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 500; text-decoration: none; margin-bottom: var(--sp-4); }
.game-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.game-title { display: grid; gap: var(--sp-2); min-width: 0; }
.game-title h1 { overflow-wrap: anywhere; }
.game-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
@media (max-width: 720px) {
  .game-head { flex-direction: column; align-items: stretch; }
  .game-actions { flex-wrap: nowrap; }
  .game-actions .btn { flex: 1 1 0; padding: 10px 6px; min-width: 0; }
  .game-actions .btn span { overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 400px) { .game-actions .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-5); align-items: start; }
@media (max-width: 980px) { .game-layout { grid-template-columns: 1fr; } }

.stage {
  position: relative; width: 100%; max-width: 100%;
  aspect-ratio: 16 / 10; max-height: calc(100vh - 140px);
  background: var(--stage-bg); color: var(--stage-text);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.stage iframe { width: 100%; height: 100%; border: 0; background: var(--stage-bg); }
.stage:fullscreen { max-height: none; border-radius: 0; border: 0; aspect-ratio: auto; }
.stage-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-content: center; justify-items: center; gap: var(--sp-3);
  padding: var(--sp-5); text-align: center;
  background: var(--stage-bg); color: var(--stage-text);
}
.stage-overlay p { color: var(--stage-muted); font-size: var(--fs-sm); max-width: 42ch; }
.stage-overlay strong { font-family: var(--font-display); font-size: 1.3rem; }
.stage-overlay .error-title { color: #ff8a7a; }
.stage-overlay .btn-secondary { background: #1d2d28; color: var(--stage-text); border-color: #2a3d36; }
.stage-overlay .spinner { border-color: #2a3d36; border-top-color: var(--accent); }

.game-side { display: grid; gap: var(--sp-4); align-content: start; min-width: 0; }
.best { font-family: var(--font-display); font-weight: 800; font-size: 2.2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.best-flash { color: var(--ok); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: var(--fs-sm); align-items: center; margin: 0; }
.keys dt { display: flex; gap: 4px; flex-wrap: wrap; }
.keys dd { margin: 0; }
.game-notice { margin-top: var(--sp-3); }

/* ---------- Settings ---------- */
.settings { display: grid; gap: var(--sp-4); max-width: 760px; }
.option-group { border: 0; padding: 0; margin: 0; display: grid; gap: var(--sp-3); min-width: 0; }
.option-group legend { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; padding: 0; margin-bottom: var(--sp-1); }
.segmented { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.segmented label, .swatch-option {
  position: relative; display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-sm); font-weight: 500;
}
.segmented input, .swatch-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked), .swatch-option:has(input:checked) { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.segmented label:has(input:focus-visible), .swatch-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2); }
.swatch-option { border-radius: var(--r-md); padding: 8px 12px; }
.swatch-dot { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 2px solid var(--line); background: var(--sw-bg); box-shadow: inset -9px 0 0 var(--sw-surface); }
.check { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.data-summary { margin: 0; padding-left: 1.2em; font-size: var(--fs-sm); color: var(--muted); }

/* ---------- About / prose ---------- */
.prose { display: grid; gap: var(--sp-4); max-width: 68ch; }
.prose h2 { font-size: var(--fs-lg); margin-top: var(--sp-3); }
.prose p, .prose li { color: var(--muted); }
.prose ul { margin: 0; padding-left: 1.2em; display: grid; gap: var(--sp-2); }
.prose strong { color: var(--text); }
