body { background: black; margin: 0; padding: 34px 8px 8px; font-family: sans-serif; }
#topbar { position: absolute; top: 8px; right: 12px; font: 13px/18px sans-serif; color: #444; }
#topbar a { color: #666; text-decoration: none; }
#topbar a:hover { color: #aaa; text-decoration: underline; }
#loading, #more { color: #666; text-align: center; font-size: 15px; }
/* at most 5 Brians across; fewer as the window narrows, but never fewer than 2 (phones) */
#grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill,
    minmax(max(calc((100% - 4 * 8px) / 5), min(240px, calc((100% - 8px) / 2))), 1fr));
}
#grid img { width: 100%; aspect-ratio: 475 / 562; object-fit: contain; display: block; cursor: zoom-in;
            /* a "LOADING..." Brian (one small image, cached once) until this Brian arrives; color hides the
               caption the browser would otherwise draw as alt text while loading */
            background: #111 url(/loading.jpg) center / cover no-repeat; color: transparent; }
#grid img.loaded { background: #111; }  /* odd-shaped memes: no placeholder peeking out around them */
/* tap a Brian to see it big; tap again (or Esc) to go back to scrolling */
#big { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.92); display: flex; flex-direction: column;
       align-items: center; justify-content: center; gap: 10px; cursor: zoom-out; }
#big[hidden] { display: none; }
#big img { max-width: 96vw; max-height: calc(92vh - 50px); object-fit: contain; }
#bigbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(300px, 90vw); cursor: default; }
#bigbar button { font-size: 15px; padding: 8px 4px; cursor: pointer; }
#bigmsg { color: white; font-size: 14px; margin: 0; min-height: 1.2em; cursor: default; }
/* the congratulations at the very bottom, once every Brian has been shown */
#end { text-align: center; color: white; padding: 30px 0 40px; }
#end[hidden] { display: none; }
#end img { width: 100%; max-width: 420px; display: block; margin: 0 auto 14px; }
#end p { font-size: 18px; margin: 0 0 14px; }
#again { font-size: 15px; padding: 6px 16px; cursor: pointer; }
/* dark buttons, same as the main page */
button { background: #222; color: #ddd; border: 1px solid #444; border-radius: 6px; font-family: inherit; cursor: pointer; }
button:hover { background: #2e2e2e; color: #fff; border-color: #555; }
button:active { background: #3a3a3a; }
button:disabled { color: #777; cursor: default; }
/* search box + "Unintelligible only" switch above the grid */
#search { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; align-items: center;
          max-width: 640px; margin: 4px auto 6px; }
#q { flex: 1 1 260px; min-width: 0; color-scheme: dark; background: #161616; color: #eee; border: 1px solid #444;
     border-radius: 6px; padding: 8px 10px; font: 16px sans-serif; }  /* 16px: phones don't zoom in on it */
#q:focus { outline: none; border-color: #777; }
#q:disabled { opacity: 0.45; }
#unintlabel { color: #bbb; font-size: 14px; display: flex; align-items: center; gap: 6px; cursor: pointer;
              white-space: nowrap; user-select: none; }
#unint { accent-color: #777; width: 17px; height: 17px; margin: 0; cursor: pointer; }
#count { color: #777; text-align: center; font-size: 13px; margin: 0 0 8px; min-height: 1em; }

/* "Buy this Brian" under the big Brian (only for people with a gambling save), in the Brian's tier colour */
#buy { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: default; }
#buy[hidden] { display: none; }
#buy small { color: #888; font: 12px sans-serif; }
#buybtn { font-size: 15px; padding: 8px 14px; cursor: pointer; }
#buybtn.uncommon { border-color: #2fbf5a; color: #2fbf5a; } #buybtn.rare { border-color: #4a90ff; color: #4a90ff; }
#buybtn.legendary { border-color: #ffc21a; color: #ffc21a; }
#buybtn:disabled { opacity: 0.6; cursor: default; }
#big.buying img { max-height: calc(92vh - 120px); }
