/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:hover { background: var(--surface-hover); border-color: color-mix(in srgb, var(--text) 22%, transparent); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn svg { width: 16px; height: 16px; }
.btn:focus-visible, a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: transparent; }

.btn-sm { padding: 7px 13px; font-size: 0.84rem; }
.btn-lg { padding: 13px 24px; font-size: 1rem; border-radius: var(--radius-md); }

kbd, .kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- Form controls ---------- */
select, .text-input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.86rem;
  transition: border-color 0.2s ease;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
select option { background: var(--elevated); color: var(--text); }
select:hover, .text-input:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); }
select:disabled { opacity: 0.55; cursor: not-allowed; }

.field-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: none; }
.field-label { font-weight: 600; font-size: 0.93rem; }
.field-desc { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch-track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong);
  transition: background-color 0.2s ease;
}
.switch-track::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text); transition: transform 0.25s var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(18px); background: var(--accent-contrast); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.segmented button {
  position: relative;
  padding: 6px 11px;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-faint);
  transition: color 0.2s ease, background-color 0.2s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--elevated); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: 0.86rem; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s ease, transform 0.25s var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- Section headings ---------- */
.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.section-heading { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.15; margin-bottom: 10px; }
.section-sub { color: var(--text-muted); font-size: 1rem; max-width: 620px; margin-bottom: 28px; }

/* ---------- Tiles (category and game cards) ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }

.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition: transform 0.35s var(--ease-out), border-color 0.25s ease, box-shadow 0.35s var(--ease-out);
}
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), var(--accent-soft), transparent 45%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.tile:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.tile:hover::before { opacity: 1; }
.tile > * { position: relative; }
.tile-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: 4px;
  transition: transform 0.35s var(--ease-out);
}
.tile-icon svg { width: 22px; height: 22px; }
.tile:hover .tile-icon { transform: scale(1.06) rotate(-4deg); }
.tile h3 { font-size: 1.08rem; font-weight: 650; letter-spacing: -0.02em; }
.tile p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; }
.tile-link {
  margin-top: auto;
  padding-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent);
}
.tile-link svg { width: 15px; height: 15px; transition: transform 0.3s var(--ease-out); }
.tile:hover .tile-link svg { transform: translateX(4px); }
.tile-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; background: var(--surface-hover); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Utility ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.text-muted { color: var(--text-muted); }

/* Scroll reveal: content is visible by default and only animates once JS
   has marked the document, so nothing stays hidden if scripts fail. */
.js-reveal .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out); transition-delay: var(--d, 0s); }
.js-reveal .reveal.is-in { opacity: 1; transform: none; }

/* ---------- Theme picker grid (settings page) ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.theme-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface); font-size: 0.88rem; font-weight: 600; color: var(--text-muted);
  transition: border-color 0.2s ease, transform 0.2s var(--ease-out);
}
.theme-card:hover { transform: translateY(-2px); border-color: var(--border-strong); color: var(--text); }
.theme-card.is-active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-card-swatch { width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 0 0 1px var(--border-strong); flex-shrink: 0; }

/* ---------- Settings panel groups ---------- */
.settings-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 24px;
  margin-bottom: 20px;
}
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-note { margin-top: 10px; font-size: 0.82rem; color: var(--text-faint); }
.settings-note a { color: var(--accent); }
.settings-group h2 { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); padding: 18px 0 6px; }
.range-input { width: 160px; accent-color: var(--accent); }

@media (max-width: 480px) {
  .settings-group { padding: 6px 16px; }
  .card-grid { grid-template-columns: 1fr; }
}
