/* Shared shell. Each theme sets the --ui-* tokens on :root[data-theme="<id>"]
   so the two buttons match it; everything else a theme draws lives in #scene. */
:root {
  --ui-bg: #f3f4f7;
  --ui-fg: #000000;
  --ui-border: transparent;
  --ui-radius: 9999px;
  --ui-font: system-ui, sans-serif;
  --ui-transform: none;
  --pad: max(10px, env(safe-area-inset-top));
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #000;
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

#scene { position: fixed; inset: 0; overflow: hidden; }

.ui-button {
  position: fixed; z-index: 50;
  font: 600 14px/1 var(--ui-font);
  text-transform: var(--ui-transform);
  letter-spacing: .04em;
  color: var(--ui-fg); background: var(--ui-bg);
  border: 2px solid var(--ui-border); border-radius: var(--ui-radius);
  min-height: 44px; padding: 0 18px;
  cursor: pointer;
  transition: filter 150ms ease-out, transform 150ms ease-out;
}
.ui-button:hover { filter: brightness(1.12); }
.ui-button:active { transform: scale(.97); filter: brightness(.9); }
.ui-button:focus-visible { outline: 3px solid var(--ui-fg); outline-offset: 3px; }
.ui-button[hidden] { display: none; }

#theme-button { top: calc(var(--pad) + 4px); right: calc(var(--pad) + 4px); }
#again-button {
  left: 50%; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 28px);
  transform: translateX(-50%); min-width: 180px; min-height: 52px; font-size: 16px;
}
#again-button:active { transform: translateX(-50%) scale(.97); }

/* ── Theme picker ── */
#picker {
  margin: auto; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 48px);
  border: 0; border-radius: 18px; padding: 0;
  background: #15161a; color: #f3f4f7;
  font-family: system-ui, sans-serif;
  overflow: auto;
}
#picker::backdrop { background: rgb(0 0 0 / .55); }
#picker[open] { animation: picker-in 180ms ease-out; }
@keyframes picker-in { from { opacity: 0; transform: translateY(12px); } }

.picker-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px 20px; background: #15161a;
}
.picker-head h2 { font-size: 20px; font-weight: 650; }
.picker-close {
  font: 600 15px/1 system-ui, sans-serif; color: #15161a; background: #f3f4f7;
  border: 0; border-radius: 9999px; min-height: 40px; padding: 0 18px; cursor: pointer;
}
.picker-close:focus-visible { outline: 3px solid #f3f4f7; outline-offset: 3px; }

.picker-grid {
  list-style: none; padding: 4px 16px 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.picker-card {
  width: 100%; display: flex; flex-direction: column; gap: 8px;
  padding: 8px; border-radius: 14px; border: 2px solid transparent;
  background: #202228; color: inherit; cursor: pointer; text-align: left;
  font: 600 14px/1.2 system-ui, sans-serif;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.picker-card:hover { background: #2a2c33; }
.picker-card:focus-visible { outline: 3px solid #f3f4f7; outline-offset: 2px; }
.picker-card[aria-pressed="true"] { border-color: #f3f4f7; }
.picker-swatch { aspect-ratio: 4 / 3; border-radius: 9px; background-size: cover; background-position: center; overflow: hidden; }
.picker-swatch img { display: block; width: 100%; height: 100%; object-fit: cover; }
.picker-name { padding: 0 4px 2px; }

@media (prefers-reduced-motion: reduce) {
  #picker[open] { animation: none; }
  .ui-button { transition: none; }
}
