:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --text: #1c1a22;
  --muted: #6a6574;
  --border: #e3dfd8;
  --accent: #ff4f6d;
  --accent-ink: #fff;
  --chip: #ebe7e0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #14121c;
    --surface: #1e1b28;
    --text: #f1eef7;
    --muted: #a39db3;
    --border: #2e2a3b;
    --chip: #2a2637;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme='dark'] {
  --bg: #14121c;
  --surface: #1e1b28;
  --text: #f1eef7;
  --muted: #a39db3;
  --border: #2e2a3b;
  --chip: #2a2637;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top,
.filters,
main,
.foot {
  max-width: 1280px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 20px;
  padding-bottom: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.tag {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.logo {
  width: 44px;
  height: 44px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex: none;
}
.logo span {
  border-radius: 6px;
}
.logo span:nth-child(1) { background: #39ff6a; }
.logo span:nth-child(2) { background: #ff4f6d; }
.logo span:nth-child(3) { background: #ffd23f; }
.logo span:nth-child(4) { background: #5c94fc; }

.actions {
  display: flex;
  gap: 8px;
}
.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  min-height: 40px;
}
.pill.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.pill.ag-mute {
  width: 40px;
  padding: 0;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 8px;
  padding-bottom: 12px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: none;
  border: 0;
  background: var(--chip);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  min-height: 36px;
}
.chip[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 16px;
  padding-bottom: 24px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 16px 32px rgba(0, 0, 0, 0.14);
}
.card:active {
  transform: translateY(0) scale(0.99);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
}
.thumb .glyph {
  font-size: clamp(40px, 9vw, 56px);
  line-height: 1;
  text-shadow: 0 0 12px currentColor;
}
.thumb .sub {
  font-size: 11px;
  letter-spacing: 0.18em;
  opacity: 0.85;
}
.thumb.cavern::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.thumb.cavern .glyph {
  animation: blink 1.1s steps(2) infinite;
}
.thumb.hopper .glyph {
  text-shadow: 3px 3px 0 #000;
}
.thumb.hopper .sub {
  text-shadow: none;
  font-size: 9px;
}
.thumb.tapblitz .glyph {
  font-size: 64px;
  animation: pulse 1.2s ease-in-out infinite;
  text-shadow: none;
}
.thumb.idleidle .glyph {
  text-shadow: none;
  font-weight: 200;
}
.thumb.hoard .glyph,
.thumb.manor .glyph,
.thumb.lexicon .glyph {
  text-shadow: none;
}
.thumb.gemjam .glyph {
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 0 16px rgba(255, 255, 255, 0.7);
}
.thumb.gemjam::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 50%;
  background: linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.05));
}
.thumb.serpent .glyph {
  text-shadow: 0 0 8px #00f0ff, 0 0 20px #ff2e97;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
@keyframes pulse {
  50% {
    transform: scale(1.18);
  }
}

.body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.badge {
  background: var(--chip);
  border-radius: 6px;
  padding: 2px 7px;
}
.card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}
.blurb {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  flex: 1;
}
.stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.stats strong {
  color: var(--text);
}
.new {
  color: var(--accent);
  font-weight: 800;
}

.foot {
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 32px;
  text-align: center;
}
.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  padding: 4px;
}

/* Phones: compact horizontal cards so more games fit on screen. */
@media (max-width: 560px) {
  .grid {
    gap: 12px;
  }
  .card {
    flex-direction: row;
  }
  .thumb {
    flex: 0 0 34%;
    aspect-ratio: auto;
    min-height: 120px;
  }
  .thumb .glyph {
    font-size: 34px;
  }
  .thumb.tapblitz .glyph {
    font-size: 42px;
  }
  .thumb .sub {
    font-size: 8.5px;
    letter-spacing: 0.1em;
    text-align: center;
    padding: 0 4px;
  }
  .body {
    padding: 10px 12px 10px;
    gap: 4px;
    min-width: 0;
  }
  .card h2 {
    font-size: 16.5px;
  }
  .blurb {
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .stats {
    padding-top: 6px;
  }
}

/* Glimmer (from Out of Context) after it escapes */
.glimmer-banner {
  max-width: 1280px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(109, 74, 255, 0.12), rgba(255, 79, 163, 0.12));
  border: 1px dashed #b39cff;
  font-size: 14px;
}
.glimmer-sprite {
  position: fixed;
  z-index: 50;
  font-size: 26px;
  pointer-events: none;
  transition: left 3.8s ease-in-out, top 3.8s ease-in-out;
  filter: drop-shadow(0 0 8px #ff4fa3) drop-shadow(0 0 14px #6d4aff);
  animation: glimmer-twinkle 1.2s ease-in-out infinite;
}
@keyframes glimmer-twinkle {
  50% { transform: scale(1.3) rotate(20deg); opacity: 0.7; }
}
