/* ────────────────────────────────────────────────────────────────
   Editorial Library Theme — cream page, dark hero band on top
   Direction: deep teal primary, warm coral secondary, refined ochre
   for shelf-mode. Cream paper bg, pure-white cards, generous airy.
   The hero band itself is dark (see .hero rules below) so the
   light-coloured logo can sit on it.
   ──────────────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:       #F6F2EA;   /* page — warm paper cream */
  --bg2:      #FFFFFF;   /* cards / panels */
  --bg3:      #FBF7EF;   /* subtle hover / tint */
  --bg-deep:  #EEE7D8;   /* slightly stronger tint */

  /* Lines */
  --line:     rgba(31,30,28,0.07);   /* hairline */
  --line2:    rgba(31,30,28,0.16);   /* visible border */
  --line3:    rgba(31,30,28,0.28);   /* strong border */

  /* Text — warm, near-black (page-level default) */
  --text:     #1A1410;
  --text2:    #524938;
  --text3:    #897E69;

  /* Primary accent — deep teal-green (table felt, refined) */
  --accent:        #1F4B4D;
  --accent-hover:  #143637;
  --accent-soft:   rgba(31,75,77,0.08);
  --accent-tint:   rgba(31,75,77,0.14);

  /* Secondary — warm coral, brings energy */
  --accent-2:        #D86F3A;
  --accent-2-hover:  #B8531F;
  --accent-2-soft:   rgba(216,111,58,0.10);

  /* Tertiary — refined ochre, used for shelf mode */
  --accent-3:        #C9923A;
  --accent-3-soft:   rgba(201,146,58,0.10);

  /* Cool support — sage for highlights */
  --sage:        #6B8E6A;
  --sage-soft:   rgba(107,142,106,0.10);

  /* Elevation — warm-tinted, never grey-on-grey */
  --shadow-sm:  0 1px 2px rgba(31,20,10,0.04);
  --shadow-md:  0 4px 12px rgba(31,20,10,0.06), 0 1px 3px rgba(31,20,10,0.04);
  --shadow-lg:  0 18px 40px rgba(31,20,10,0.10), 0 4px 10px rgba(31,20,10,0.06);
  --shadow-accent: 0 10px 24px rgba(31,75,77,0.18);

  --r:   10px;   /* baseline radius */
  --r-lg: 16px;  /* large radius (cards) */
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.hero {
  /* Plain chocolate brown — no patterns, no glows */
  background: #3D2716;
  padding: 1.8rem 2rem 2.4rem;
  text-align: center;
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
}
.hero::before {
  /* Glowing two-tone underline rule */
  content: '';
  position: absolute;
  bottom: 14px; left: 50%; transform: translateX(-50%);
  width: 90px; height: 2px;
  background: linear-gradient(90deg, transparent 0%, #FFB266 30%, #FF8A5C 70%, transparent 100%);
  border-radius: 2px;
  box-shadow: 0 0 18px rgba(255,140,90,0.55);
  z-index: 2;
}
.hero-logo {
  height: 38px;
  margin-bottom: 0.7rem;
  opacity: 1;
  filter: drop-shadow(0 2px 12px rgba(0,0,0,0.30));
}
.hero-eyebrow {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #F0C272;
  margin-bottom: 0.6rem;
  opacity: 0.92;
}
.hero-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  font-weight: 700;
  color: #FBF3DF;
  margin-bottom: 0.5rem;
  letter-spacing: -.02em;
  line-height: 1.05;
  text-shadow: 0 3px 14px rgba(0,0,0,0.30);
}
.hero-accent {
  color: #F18A55;
  font-style: italic;
  font-weight: 600;
}
/* Tagline / count beneath the title */
.hero-sub {
  display: inline-block !important;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(241,232,213,0.65);
  margin-top: 0.2rem;
  padding-bottom: 0.6rem;
}
.hero-sub {
  display: none;
}

/* Toolbar */
.toolbar {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0.5rem;
}
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  width: 100%;
}
.toolbar-controls {
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}
#game-search {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--line2);
  border-radius: var(--r);
  padding: 0.85rem 1.2rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.97rem;
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  box-shadow: var(--shadow-sm);
}
#game-search::placeholder { color: var(--text3); }
#game-search:hover { border-color: var(--line3); }
#game-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm);
}
.search-count {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  font-weight: 500;
}

/* ── Quick-pick pills (always-visible shortcuts under the search bar) ── */
.quick-picks {
  gap: 0.5rem 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.quick-picks-label {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text3); font-weight: 600; margin-right: 0.1rem;
}
.qp-pill {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.35em;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.86rem; font-weight: 600;
  padding: 0.42rem 0.9rem; border-radius: 999px;
  background: var(--bg2, #fff);
  border: 1.5px solid var(--line2);
  color: var(--text2);
  box-shadow: var(--shadow-sm);
  transition: all .15s; white-space: nowrap;
}
.qp-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.qp-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
@media (max-width: 600px) {
  .quick-picks { gap: 0.4rem; }
  .qp-pill { font-size: 0.8rem; padding: 0.38rem 0.75rem; }
  .quick-picks-label { width: 100%; margin-bottom: 0.1rem; }
}

/* ── Filters slide-in drawer ── */
.toolbar-top { margin-bottom: 0; }
.filter-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.82rem 1.1rem; border-radius: var(--r);
  background: var(--bg2); border: 1.5px solid var(--line2);
  color: var(--text); font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.92rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: border-color .2s, color .2s; box-shadow: var(--shadow-sm); flex-shrink: 0;
}
.filter-toggle:hover { border-color: var(--accent); color: var(--accent); }
.filter-toggle svg { stroke: currentColor; }

.filter-overlay {
  position: fixed; inset: 0; background: rgba(20,12,6,0.5);
  opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; z-index: 1200;
}
.filter-overlay.open { opacity: 1; visibility: visible; }

.filter-drawer {
  position: fixed; top: 0; left: 0; height: 100%; width: min(360px, 88vw);
  background: var(--bg); border-right: 1px solid var(--line2);
  box-shadow: 10px 0 45px rgba(20,12,6,0.32);
  transform: translateX(-100%); transition: transform .35s cubic-bezier(.4,0,.2,1);
  z-index: 1201; display: flex; flex-direction: column; overflow: hidden;
}
.filter-drawer.open { transform: translateX(0); }
.filter-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--line2); flex-shrink: 0;
}
.filter-drawer-title { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.filter-drawer-close {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--line2); color: var(--text);
  font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color .2s, color .2s;
}
.filter-drawer-close:hover { border-color: var(--accent); color: var(--accent); }
.filter-drawer-body { padding: 1.2rem 1.3rem 2rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1.4rem; }
/* Stack filter sections vertically inside the narrow drawer */
.filter-drawer .taxonomy-row { flex-direction: column; gap: 0.8rem; margin: 0; }
.filter-drawer .taxonomy-row .shelf-wrapper { width: 100%; }
.filter-drawer .toolbar-controls { flex-direction: column; align-items: stretch; gap: 1.3rem; }
.filter-drawer .filter-group { flex-direction: column; align-items: flex-start; width: 100%; gap: 0.55rem; }
.filter-drawer .shelf-panel { grid-template-columns: repeat(2, 1fr); }
.filter-drawer #sort-select { width: 100%; }
.drawer-home-link {
  display: inline-flex; align-items: center; gap: 0.5rem; align-self: flex-start;
  color: var(--text); text-decoration: none;
  font-family: 'Inter', system-ui, sans-serif; font-size: 0.9rem; font-weight: 600;
  padding: 0.6rem 0.9rem; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--line2);
  transition: border-color .2s, color .2s;
}
.drawer-home-link:hover { border-color: var(--accent); color: var(--accent); }
.drawer-home-link svg { stroke: currentColor; }

/* List/table view — game thumbnail */
.game-table .th-img { width: 56px; padding-left: 8px; padding-right: 4px; }
.game-table .td-img { width: 56px; padding: 6px 4px 6px 8px; }
.row-img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; display: block; box-shadow: var(--shadow-sm); }
.row-img-ph {
  width: 42px; height: 42px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center; background: var(--bg2);
  border: 1px solid var(--line2); font-size: 1.1rem;
}
/* Game name cell — name left, BGG + Guide pills pushed to the right */
.game-table .td-name { display: flex; align-items: center; gap: 0.4rem; }
.game-table .td-name-text { margin-right: auto; }
.game-table .game-row { cursor: default; }
a.td-name-text { color: inherit; text-decoration: none; }
a.td-name-text:hover { color: var(--accent); }
/* BGG link pill (list view) */
.row-bgg-btn {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  padding: 0.18rem 0.55rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; text-decoration: none;
  background: var(--text); color: var(--bg); transition: opacity .2s;
}
.row-bgg-btn:hover { opacity: 0.85; }
/* BGG link badge (grid card, on the image) */
.card-bgg {
  position: absolute; left: 8px; bottom: 8px; z-index: 2;
  background: rgba(20,12,6,0.74); color: #fff; text-decoration: none;
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.03em;
  padding: 0.25rem 0.5rem; border-radius: 7px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: background .2s;
}
.card-bgg:hover { background: var(--accent); }
a.card-name { color: inherit; text-decoration: none; }
a.card-name:hover { color: var(--accent); }
/* Guide pill next to the game name in list view */
.row-guide-btn {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 0.6rem; padding: 0.18rem 0.6rem; vertical-align: middle;
  border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-decoration: none;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: background .2s, color .2s; white-space: nowrap;
}
.row-guide-btn:hover { background: var(--accent); color: #fff; }
.row-guide-btn svg { stroke: currentColor; }

/* Collapsible side-panel handle — fixed tab on the left edge */
.filter-fab {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 1150;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 0.95rem 0.45rem 0.95rem 0.35rem;
  background: var(--accent); color: #fff; border: none;
  border-radius: 0 14px 14px 0;
  box-shadow: 4px 0 18px rgba(31,20,10,0.28);
  cursor: pointer;
  transition: padding-left .2s, box-shadow .2s, opacity .25s, visibility .25s;
}
.filter-fab:hover { padding-left: 0.7rem; box-shadow: 6px 0 24px rgba(31,20,10,0.34); }
.filter-fab svg { stroke: currentColor; width: 18px; height: 18px; }
.filter-fab-text {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: 'Inter', system-ui, sans-serif; font-weight: 700;
  font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
}
body.filters-open .filter-fab { opacity: 0; visibility: hidden; }

@media (max-width: 900px) {
  .toolbar-top { flex-direction: row !important; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
  .toolbar-top #game-search { flex: 1 1 150px; }
}

/* Filter groups */
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}
.filter-label {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  font-weight: 500;
}
.filter-chips {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
/* Browse mode toggle */
.browse-toggle-wrapper {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
}
.browse-toggle {
  display: inline-flex;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}
.browse-btn {
  padding: 0.55rem 1.3rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text3);
  background: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  letter-spacing: 0.02em;
}
.browse-btn:hover { color: var(--text2); }
.browse-btn.active {
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.browse-btn.active.mode-shelf { background: var(--accent-3); color: #fff; }
.browse-btn.active.mode-category { background: var(--accent); color: #fff; }

/* Category panel */
.category-wrapper {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
}
.category-toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  padding: 0.85rem 1.3rem;
  border-radius: var(--r);
  border: 1.5px solid var(--line2);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.category-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}
.category-active-cat {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--accent);
}
.category-toggle .shelf-arrow { color: var(--text3); }
.category-toggle.open .shelf-arrow { transform: rotate(180deg); }
.category-panel {
  display: none;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  padding-top: 0.6rem;
  width: 100%;
}
.category-panel.open { display: grid; }
.cat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.85rem 0.4rem;
  border-radius: 12px;
  border: 1.5px solid var(--line2);
  background: var(--bg2);
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.cat-item:hover {
  border-color: var(--cc-color);
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cc-color) 12%, transparent), var(--shadow-md);
}
.cat-item.active {
  border-color: var(--cc-color);
  background: color-mix(in srgb, var(--cc-color) 10%, var(--bg2));
  box-shadow: 0 0 0 2px var(--cc-color), var(--shadow-md);
}
.cat-item.active .ci-name { color: var(--text); }
.cat-item.active .ci-count { color: var(--cc-color); }
.ci-emoji { font-size: 1.3rem; line-height: 1; }
.ci-name {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text3);
  text-align: center;
  white-space: nowrap;
  transition: color .2s;
}
.ci-count {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10px;
  color: var(--text3);
  transition: color .2s;
}

/* Shelf collapsible panel */
.shelf-wrapper {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
}
.shelf-toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  padding: 0.85rem 1.3rem;
  border-radius: var(--r);
  border: 1.5px solid var(--line2);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.shelf-toggle:hover {
  border-color: var(--accent-3);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-3-soft), var(--shadow-sm);
}
.shelf-active-cat {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--accent-2);
}
.shelf-arrow {
  font-size: 10px;
  margin-left: auto;
  transition: transform .25s;
  color: var(--text3);
}
.shelf-toggle.open .shelf-arrow { transform: rotate(180deg); }
.shelf-panel {
  display: none;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  padding-top: 0.6rem;
  width: 100%;
}
.shelf-panel.open { display: grid; }
.shelf-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.85rem 0.4rem;
  border-radius: 12px;
  border: 1.5px solid var(--line2);
  background: var(--bg2);
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.shelf-item:hover {
  border-color: var(--sc-color);
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc-color) 12%, transparent), var(--shadow-md);
}
.shelf-item.active {
  border-color: var(--sc-color);
  background: color-mix(in srgb, var(--sc-color) 10%, var(--bg2));
  box-shadow: 0 0 0 2px var(--sc-color), var(--shadow-md);
}
.shelf-item.active .si-name { color: var(--text); }
.shelf-item.active .si-count { color: var(--sc-color); }
.si-emoji { font-size: 1.3rem; line-height: 1; }
.si-name {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text3);
  text-align: center;
  white-space: nowrap;
  transition: color .2s;
}
.si-shelf {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.9em;
  font-weight: 700;
  color: var(--accent-2, #D86F3A);
  text-transform: none;
  margin-left: 2px;
}
.si-count {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10px;
  color: var(--text3);
  transition: color .2s;
}

/* ── Player-mode cycle button — tap label to cycle Players / Rec / Best ── */
.filter-label-row {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 0.6rem; width: 100%; margin-bottom: 0.4rem;
}
.player-mode-cycle {
  /* Strip native button styling — iOS Safari / mobile Chrome force a
     white background otherwise and the light text becomes invisible. */
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  display: inline-flex; align-items: center; gap: 0.45em;
  background-color: rgba(193,154,62,0.10) !important;
  border: 1px solid rgba(193,154,62,0.35) !important;
  color: var(--accent-2) !important;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; padding: 0.4rem 0.85rem; border-radius: 999px;
  cursor: pointer; transition: all .15s; min-height: 32px;
  text-shadow: none;
}
.player-mode-cycle:hover {
  background-color: rgba(193,154,62,0.18) !important;
  border-color: rgba(193,154,62,0.55) !important;
}
.player-mode-cycle .cycle-arrow {
  font-size: 11px; opacity: 0.7; transition: opacity .15s;
}
.player-mode-cycle:hover .cycle-arrow { opacity: 1; }
/* Visual signal for the two BGG modes */
.player-mode-cycle.mode-recommended {
  color: #6ab07a !important;
  border-color: rgba(106,176,122,0.5) !important;
  background-color: rgba(106,176,122,0.14) !important;
}
.player-mode-cycle.mode-best {
  color: var(--accent-2) !important;
  border-color: rgba(193,154,62,0.6) !important;
  background-color: rgba(193,154,62,0.18) !important;
}
.player-mode-cycle.mode-exact {
  color: #6ea8d8 !important;
  border-color: rgba(110,168,216,0.55) !important;
  background-color: rgba(110,168,216,0.15) !important;
}

@media (max-width: 600px) {
  .filter-label-row { flex-wrap: wrap; gap: 0.4rem; }
  .player-mode-cycle { font-size: 11px; padding: 0.4rem 0.85rem; min-height: 34px; }
}

/* ── Taxonomy row — Category + Sub-category dropdowns side-by-side ── */
.taxonomy-row {
  display: flex; gap: 0.6rem;
  max-width: 1480px; margin: 0 auto; padding: 0 1.5rem;
  margin-bottom: 0.75rem;
  width: 100%; box-sizing: border-box;
}
/* Strip the wrapper's own max-width / padding / margin — they live on
   .taxonomy-row now so the two children share the same horizontal band. */
.taxonomy-row .shelf-wrapper {
  flex: 1 1 0; min-width: 0;
  max-width: none; margin: 0; padding: 0;
  position: relative;
}
.shelf-toggle-label {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text3, var(--text-muted));
  margin-right: 0.5em;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .taxonomy-row { flex-direction: column; gap: 0.5rem; }
}

/* ── Legacy sub-category chip strip (kept in case anyone still uses it) ── */
.subcat-wrapper {
  margin: 0.75rem 0 0.25rem;
  padding: 0.8rem 1rem;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 100%;
}
.subcat-label {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted, var(--text3));
  margin-bottom: 0.55rem;
}
.subcat-chips {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.subcat-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: var(--bg);
  border: 1.5px solid var(--line);
  color: var(--text2);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.subcat-chip:hover { border-color: var(--accent-2); color: var(--text); }
.subcat-chip.active {
  background: rgba(193,154,62,0.12);
  border-color: var(--accent-2);
  color: var(--accent-2);
}
.subcat-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.5em; padding: 0 0.4em;
  background: rgba(31,30,28,0.08);
  color: var(--text3);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10px; font-weight: 700;
  border-radius: 999px;
}
.subcat-chip.active .subcat-count {
  background: rgba(193,154,62,0.2);
  color: var(--accent-2);
}

@media (max-width: 600px) {
  .subcat-wrapper { padding: 0.65rem 0.85rem; }
  .subcat-chip {
    min-height: 36px; padding: 0.4rem 0.8rem;
    font-size: 12px;
  }
}

.chip {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 0.4rem 0.85rem;
  border-radius: 100px;
  border: 1px solid var(--line2);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  transition: all .18s;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-accent);
  font-weight: 600;
}

/* Sort select */
#sort-select {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .05em;
  padding: 0.55rem 0.85rem;
  border-radius: var(--r);
  border: 1.5px solid var(--line2);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
#sort-select:hover { border-color: var(--line3); }
#sort-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}
#sort-select option {
  background: var(--bg2);
  color: var(--text);
}

/* View toggle */
.view-toggle {
  display: flex;
  gap: 0.2rem;
  padding: 4px;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.view-btn {
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.view-btn:hover { color: var(--text); background: var(--bg2); }
.view-btn.active {
  background: var(--bg2);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Grid view */
.grid {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 1fr;  /* every row stretches to the same height — keeps the Guide button at a consistent bottom across the whole grid */
  gap: 1rem;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 0;
  text-decoration: none;
  color: inherit;
  transition: transform .3s cubic-bezier(.2,.7,.3,1), box-shadow .3s, border-color .2s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg3);
  overflow: hidden;
  display: block;
  text-decoration: none;
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s cubic-bezier(.2,.7,.3,1);
}
.card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text3);
}
.card-body {
  padding: 0.8rem 1rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-weight-badge,
.card-complexity-badge {
  position: absolute;
  top: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.22);
}
.card-weight-badge {
  right: 8px;
  font-size: 0.7rem;
}
.card-complexity-badge {
  left: 8px;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* Per-card "Guide" button — sits at the bottom of every card on the library
   grid. margin-top: auto + the flex:1 on .card-desc above guarantee the
   button bottom-aligns no matter how much content sits above it. */
.card-guide-btn {
  display: inline-flex;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: auto;
  padding: 0.6rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--r);
  background: var(--accent-soft);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.card-guide-btn::before {
  content: '📖';
  font-size: 0.9em;
  filter: saturate(0.85);
}
.card-guide-btn:hover,
.card-guide-btn:focus-visible {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #fff;
  outline: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
}
.card-guide-btn:active { transform: translateY(0); box-shadow: none; }
.card-category {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-color, var(--text3));
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}
.card-shelf-id {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  color: #FF6B35;
  background: rgba(255, 107, 53, 0.1);
  border: 1px solid rgba(255, 107, 53, 0.25);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.card-desc {
  font-size: 0.75rem;
  color: var(--text3);
  line-height: 1.45;
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Reserve two lines so empty/short descriptions hold the same vertical
     space as 2-line clamped ones. flex:1 lets the description block also
     absorb any remaining row-stretch slack, so the Guide button below
     pins to the very bottom of every card regardless of row height. */
  min-height: calc(0.75rem * 1.45 * 2);
  flex: 1 1 auto;
}
.card::before {
  display: none;
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}
.card:hover .card-img { transform: scale(1.04); }
.card-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  /* Reserve two lines so one-line and two-line game names produce the same
     vertical footprint. Combined with .card-desc's min-height, this keeps the
     Guide button at a consistent bottom position across every card. */
  min-height: calc(1.1rem * 1.25 * 2);
}
.card:hover .card-name { color: var(--accent); }
.card-meta {
  display: flex;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--text3);
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
  /* Reserve 2 lines so 1-line and 2-line meta have the same vertical footprint */
  min-height: calc(0.72rem * 1.5 * 2);
  align-content: flex-start;
}
.card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.rulebook-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(180,150,110,0.10);
  color: var(--text3);
  cursor: pointer;
  transition: all 0.2s;
}
.rulebook-icon:hover {
  background: var(--accent-light, rgba(193,127,62,0.15));
  color: var(--accent);
}
.rules-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  transition: color 0.2s;
}
.rules-link:hover {
  color: var(--accent);
}
.th-rules, .td-rules {
  text-align: center;
  width: 60px;
}
.weight-tag {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .05em;
}

/* List / Table view */
.list-view {
  display: block !important;
  grid-template-columns: none !important;
}
.game-table {
  width: 100%;
  border-collapse: collapse;
}
.game-table thead th {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line2);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.sortable {
  cursor: pointer;
  user-select: none;
  transition: color .2s;
}
.sortable:hover {
  color: var(--text2);
}
.game-table .th-players,
.game-table .th-time,
.game-table .th-weight,
.game-table .th-complexity,
.game-table .th-rank {
  text-align: center;
}
.game-row {
  cursor: pointer;
  transition: background .15s;
}
.game-row:hover {
  background: var(--bg3);
}
.game-row td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.td-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-color);
  display: inline-block;
}
.td-category {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
}
.td-players,
.td-time,
.td-rank,
.td-complexity {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  color: var(--text2);
  text-align: center;
}
.td-weight {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
  /* Make mobile text comfortably bigger — desktop unchanged */
  body { font-size: 18px; line-height: 1.65; }
  .browse-btn { font-size: 14px; }
  .chip { font-size: 13px; }
  .filter-label { font-size: 12px; }
  .search-count { font-size: 12px; }
  .shelf-toggle, .category-toggle { font-size: 14px; }
  .card-name { font-size: 1rem; }
  .si-count, .ci-count { font-size: 11px; }
  .game-table thead th { font-size: 11px; }
  .hero { padding: 1.5rem 1.5rem 1.2rem; }
  .hero-title { font-size: 1.8rem; }
  .toolbar { padding: 1rem 1rem 0.5rem; }
  .toolbar-row { flex-direction: column; gap: 0.5rem; }
  #game-search { width: 100%; }
  .toolbar-controls { flex-direction: column; align-items: center; gap: 0.75rem; }
  .filter-group { flex-wrap: wrap; justify-content: center; width: 100%; }
  .filter-label { width: 100%; text-align: center; }
  .filter-chips { flex-wrap: wrap; justify-content: center; }
  .shelf-panel { grid-template-columns: repeat(3, 1fr); }
  .category-panel { grid-template-columns: repeat(3, 1fr); }
  .shelf-toggle, .category-toggle { font-size: 12px; padding: 0.7rem 1.1rem; }
  .browse-toggle-wrapper { padding: 0 1rem; }
  .category-wrapper { padding: 0 1rem; }
  .view-toggle { margin-left: 0; }
  .browse-btn { padding: 0.65rem 1.2rem; }
  .chip { padding: 0.45rem 0.75rem; }
  .filter-chips { gap: 0.4rem; }
  .th-category, .td-category,
  .th-complexity, .td-complexity,
  .th-rank, .td-rank { display: none; }
  /* Table scroll wrapper for mobile */
  .game-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
/* Larger desktop cards; phones are handled by the 2-col media rule below */
.grid:not(.list-view) {
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 45%), 1fr));
}
/* Phones (incl. landscape & small foldables): always 2 cards per row */
@media (max-width: 600px) {
  .grid:not(.list-view) { grid-template-columns: repeat(2, 1fr) !important; }
}
/* Small tablets / phones with very wide viewport: 3 cards per row */
@media (min-width: 601px) and (max-width: 900px) {
  .grid:not(.list-view) { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 480px) {
  body { font-size: 17px; }   /* small phones — fractionally smaller so cards still fit */
  .hero { padding: 1.2rem 1rem 1rem; }
  .hero-title { font-size: 1.5rem; }
  .grid { padding: 0 0.75rem 3rem; gap: 0.75rem; }
  .grid:not(.list-view) {
    grid-template-columns: repeat(2, 1fr);
  }
  .th-category, .td-category,
  .th-complexity, .td-complexity,
  .th-rank, .td-rank,
  .th-time, .td-time { display: none; }
  .card-name { font-size: 0.85rem; }
  .card-body { padding: 0.5rem 0.6rem 0.7rem; }
  .card { border-radius: 10px; }
  .card-img-placeholder { font-size: 2.2rem; }
  .card-guide-btn { padding: 0.45rem 0.8rem; font-size: 0.75rem; margin-top: 0.55rem; }
  .shelf-panel, .category-panel { grid-template-columns: repeat(2, 1fr); }
  .shelf-item, .cat-item { padding: 0.7rem 0.4rem; }
  .browse-btn { padding: 0.6rem 1rem; font-size: 12px; }
  .chip { padding: 0.45rem 0.7rem; font-size: 11px; }
}

/* ════════════════════════════════════════════════════════════════════
   LIBRARY MOBILE REDESIGN v2 (June 2026)
   Goals: bigger touch targets, less clutter, search-first layout,
          easier shelf/category panel taps.
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Hero — compact title, less wasted top space */
  .hero { padding: 1rem 1rem 0.6rem !important; }
  .hero-title { font-size: clamp(1.4rem, 6.5vw, 1.85rem) !important; }
  .hero-logo { height: 28px !important; }

  /* Toolbar — clean vertical stack */
  .toolbar { padding: 0.75rem 0.9rem 0.4rem !important; gap: 0.6rem; }
  .toolbar-row { gap: 0.55rem !important; }

  /* Big search bar */
  #game-search {
    width: 100% !important; min-height: 48px;
    padding: 0.7rem 0.95rem !important;
    font-size: 16px !important;     /* avoids iOS auto-zoom on focus */
    border-radius: 10px;
  }
  .search-count { font-size: 13px !important; }

  /* Browse mode toggle (Shelf / Category) — bigger, easier */
  .browse-toggle-wrapper { padding: 0 0 !important; }
  .browse-toggle { gap: 4px; padding: 4px; border-radius: 10px; }
  .browse-btn {
    flex: 1; min-height: 42px; font-size: 13px !important;
    padding: 0.55rem 0.8rem !important; border-radius: 8px;
  }

  /* Shelf / Category toggle button — clear tap target */
  .shelf-toggle, .category-toggle {
    width: 100%; min-height: 48px;
    padding: 0.75rem 1rem !important; font-size: 14px !important;
    border-radius: 10px;
    justify-content: space-between !important;
  }
  .shelf-active-cat, .category-active-cat { font-size: 13px !important; }

  /* Panels — 2-col grid (was 3), bigger tap targets */
  .shelf-panel, .category-panel {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.4rem !important; padding: 0.6rem !important;
    max-height: 60vh !important; overflow-y: auto;
  }
  .shelf-item, .cat-item {
    padding: 0.85rem 0.6rem !important; min-height: 56px;
    border-radius: 10px; align-items: center;
  }
  .si-emoji, .ci-emoji { font-size: 1.2rem; }
  .si-name, .ci-name { font-size: 0.86rem; line-height: 1.25; }
  .si-count, .ci-count { font-size: 11px !important; padding: 1px 6px; }

  /* Complexity & Players filter chips — wrap nicely with breathing room */
  .filter-group { width: 100%; gap: 0.45rem; flex-wrap: wrap; }
  .filter-label {
    width: 100%; text-align: center; font-size: 0.75rem !important;
    color: var(--text-muted); margin-bottom: 0.2rem;
  }
  .filter-chips { gap: 0.4rem !important; justify-content: center; flex-wrap: wrap; }
  .chip {
    min-height: 36px; padding: 0.45rem 0.85rem !important;
    font-size: 12px !important; border-radius: 999px;
  }

  /* Sort + view toggle row */
  #sort-select { min-height: 42px; font-size: 14px; padding: 0.5rem 0.8rem; border-radius: 8px; }
  .view-btn { min-height: 42px; min-width: 42px; }

  /* Cards — comfortable text + tap area */
  .card { border-radius: 14px; }
  .card-img-wrap { border-radius: 14px 14px 0 0; }
  .card-body { padding: 0.65rem 0.75rem 0.85rem; }
  .card-category { font-size: 0.7rem; letter-spacing: 0.05em; }
  .card-name { font-size: 0.92rem !important; line-height: 1.25; margin: 0.2rem 0 0.35rem; }
  .card-meta { gap: 0.5rem; font-size: 0.78rem; flex-wrap: wrap; }
  .card-desc { display: none; }     /* hide on mobile — saves vertical space */
  .card-guide-btn {
    min-height: 36px; padding: 0.45rem 0.75rem !important;
    font-size: 0.78rem !important; margin-top: 0.5rem; font-weight: 600;
  }

  /* Event-view banner (when shared link is open) */
  .event-banner { padding: 0.85rem 1rem !important; gap: 0.6rem; flex-direction: column; align-items: stretch; }
  .event-banner-text { align-items: center; text-align: center; }
  .event-banner-title { font-size: 1.05rem; }
  .event-banner-actions { justify-content: center; }
  .event-banner-btn { min-height: 40px; padding: 0.5rem 0.95rem; }
}

/* Small phones */
@media (max-width: 480px) {
  .hero { padding: 0.9rem 0.9rem 0.5rem !important; }
  .hero-title { font-size: 1.5rem !important; }
  .toolbar { padding: 0.6rem 0.75rem 0.3rem !important; }
  .grid { padding: 0 0.6rem 3rem !important; gap: 0.6rem !important; }
  .grid:not(.list-view) { grid-template-columns: repeat(2, 1fr); }
  .card-name { font-size: 0.88rem !important; }
  .card-meta { font-size: 0.74rem; gap: 0.4rem; }
  .card-body { padding: 0.5rem 0.6rem 0.7rem; }
  .shelf-panel, .category-panel { grid-template-columns: 1fr !important; }
  .shelf-item, .cat-item { padding: 0.7rem 0.85rem !important; min-height: 52px; }
  .si-name, .ci-name { font-size: 0.92rem; }
}
