*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --box-w: 160px;
  --box-h: 180px;
  --shelf-plank: 22px;
  --shelf-height: calc(var(--box-h) + var(--shelf-plank));
  --shelf-bg: #4a5568;
  --shelf-edge: #2d3748;
  --bg: #0f1117;
  --text: #e8eaf0;
  --text-muted: #8090a8;
  --accent: #5b9bd5;
  --lb-bg: #13161e;
  --lb-panel: #1a1d28;
  --gap: 8px;
  --frame-w: 28px;
  --wood-light: #5a6880;
  --wood-mid: #4a5568;
  --wood-dark: #2d3748;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Special Gothic', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  width: 100%;
  padding: 10px 24px 0;
  border-bottom: 2px solid var(--shelf-edge);
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg);
  transition: box-shadow 0.25s, border-color 0.25s;
}

/* Row 1: title left + counter+button right */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
}

.site-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

header h1 {
  font-size: 3.8rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  font-family: 'Special Gothic Condensed One', sans-serif;
  line-height: 1;
}

.site-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: 'Special Gothic', sans-serif;
}

/* Right side: counter + Game Nights button side by side, vertically centred */
.header-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.game-nights-link {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 12px 20px;
  border: 1.5px solid rgba(91,155,213,0.45);
  border-radius: 10px;
  background: rgba(91,155,213,0.08);
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
  letter-spacing: 0.02em;
}
.game-nights-link:hover {
  background: rgba(91,155,213,0.18);
  border-color: var(--accent);
}

/* Row 2: search + filters on one line */
.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 0 8px;
  flex-wrap: wrap;
}
.header-controls .search-wrap {
  margin-top: 0;
  flex-shrink: 0;
  /* search-wrap is a column-flex that also contains #search-hint;
     suppress the hint so it doesn't add invisible height that
     breaks vertical alignment with the filter row */
  gap: 0;
}
.header-controls #search-hint {
  display: none;
}
/* Pin search to same visual height as filter elements */
.header-controls #game-search {
  width: 200px;
  padding: 9px 14px;
  font-size: 0.875rem;
  height: 38px;
  box-sizing: border-box;
}
.header-controls .filter-bar {
  margin-top: 0;
  padding: 0;
  flex: 0 0 auto;
  justify-content: flex-start;
  flex-wrap: nowrap;
}
/* Match filter controls height to search */
.header-controls .filter-bar select,
.header-controls .filter-wip-btn,
.header-controls .filter-clear {
  height: 38px;
  box-sizing: border-box;
}

/* Compact mode: hide title row, controls row sticks */
header.compact {
  padding: 8px 24px 0;
  box-shadow: 0 3px 18px rgba(0,0,0,0.65);
  border-bottom-color: #1e2535;
}
header.compact .header-top,
header.compact .filter-hint {
  display: none;
}
header.compact .header-controls {
  padding-bottom: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
header.compact .header-controls::-webkit-scrollbar { display: none; }
header.compact #game-search {
  width: min(180px, 26vw);
  padding: 7px 13px;
  font-size: 0.85rem;
}
header.compact #search-hint { display: none; }
header.compact .filter-bar {
  flex-wrap: nowrap;
  overflow-x: visible;
}
header.compact .filter-bar select,
header.compact .filter-wip-btn,
header.compact .filter-clear {
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 0.82rem;
  flex-shrink: 0;
}

/* ── Flip Counter ── */
.flip-counter-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
}

.flip-counter {
  display: flex;
  gap: 10px;
}

.flip-counter-label {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: 'Special Gothic', sans-serif;
}

.expansion-count-label {
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-family: 'Special Gothic Condensed One', sans-serif;
  opacity: 0.75;
}

/* ── Individual digit panel ── */
.flip-digit {
  position: relative;
  width: 72px;
  height: 104px;
  border-radius: 6px;
  box-shadow:
    0 0 0 2px #555,
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 8px 20px rgba(0,0,0,0.9);
}

/* Clip wrappers */
.fd-upper {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  overflow: hidden;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid #000;
}

.fd-lower {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 52px;
  overflow: hidden;
  border-radius: 0 0 6px 6px;
}

.fd-static-u,
.fd-flap-u {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
}

.fd-static-l,
.fd-flap-l {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 52px;
}

/* Flap layers sit on top (z-index 1) and have a solid background so they
   look like real cards covering the static layer behind them. */
.fd-flap-u {
  z-index: 1;
  transform-origin: center bottom;
  background: linear-gradient(180deg, #2a2a2a 0%, #1c1c1c 100%);
}

.fd-flap-l {
  z-index: 1;
  transform-origin: center top;
  background: linear-gradient(180deg, #181818 0%, #141414 100%);
}

/* Static backgrounds (shown behind the flap) */
.fd-static-u { background: linear-gradient(180deg, #2a2a2a 0%, #1c1c1c 100%); }
.fd-static-l { background: linear-gradient(180deg, #181818 0%, #141414 100%); }

/* Numbers — full-digit-height container, clipped to the correct half by the parent. */
.fd-static-u .fd-num,
.fd-flap-u .fd-num {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.2rem;
  line-height: 1;
  font-weight: 900;
  font-family: 'Special Gothic Condensed One', sans-serif;
  color: #f0ece4;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  user-select: none;
  pointer-events: none;
}

.fd-static-l .fd-num,
.fd-flap-l .fd-num {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.2rem;
  line-height: 1;
  font-weight: 900;
  font-family: 'Special Gothic Condensed One', sans-serif;
  color: #f0ece4;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
  user-select: none;
  pointer-events: none;
}

/* scaleY (2D) instead of rotateX (3D): Chrome's GPU compositor gives
   3D-transformed children their own layer that ignores parent overflow:hidden.
   2D transforms clip correctly. The visual result is identical. */
@keyframes fd-upper-flip {
  0%   { transform: scaleY(1); }
  100% { transform: scaleY(0); }
}
@keyframes fd-lower-flip {
  0%   { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

.flip-digit.flipping .fd-flap-u {
  animation: fd-upper-flip 0.13s ease-in forwards;
}
.flip-digit.flipping .fd-flap-l {
  animation: fd-lower-flip 0.13s ease-out 0.11s both;
}

/* ── Search ── */
.search-wrap {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#game-search {
  background: #13161e;
  border: 1px solid var(--wood-dark);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 18px;
  width: min(400px, 88vw);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#game-search::placeholder { color: var(--text-muted); }

#game-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91,155,213,0.22);
}

#search-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.2em;
}

/* ── Floating nav (search pill + back-to-top) ── */
.floating-nav {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  z-index: 500;
}

/* Search nav pill — sits to the left of the top button */
.floating-search-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  background: var(--lb-panel);
  border: 1px solid var(--wood-dark);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
  overflow: hidden;
}
.floating-search-nav.hidden { display: none; }

.fsn-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 10px 13px;
  transition: color 0.15s, background 0.15s;
}
.fsn-btn:hover { color: var(--accent); background: rgba(91,155,213,0.08); }

.fsn-count {
  font-size: 0.78rem;
  color: var(--text);
  min-width: 46px;
  text-align: center;
  font-family: inherit;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.fsn-divider {
  width: 1px;
  height: 24px;
  background: var(--wood-dark);
  flex-shrink: 0;
}

.fsn-clear { color: var(--text-muted); }
.fsn-clear:hover { color: #e87e7e; background: rgba(232,126,126,0.08); }

/* Back-to-top circle */
.floating-top-btn {
  width: 44px;
  height: 44px;
  background: var(--wood-mid);
  border: 2px solid var(--wood-dark);
  border-radius: 50%;
  color: #1a1008;
  font-size: 1.15rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.55);
  transition: background 0.2s, transform 0.18s;
  flex-shrink: 0;
}
.floating-top-btn:hover { background: var(--accent); transform: translateY(-2px); }

/* ── Search active: dim everything, then restore matches ── */
#shelf.searching .game-box {
  filter: grayscale(100%) brightness(0.35);
  transition: filter 0.25s ease, transform 0.18s ease;
}

#shelf.searching .game-box:hover {
  transform: none; /* disable hover lift on dimmed boxes */
}

#shelf.searching .game-box.search-match {
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));
  transition: filter 0.25s ease, transform 0.18s ease;
}

#shelf.searching .game-box.search-match:hover {
  transform: translateY(-10px);
  filter: drop-shadow(2px 14px 12px rgba(0,0,0,0.8));
  z-index: 10;
}

/* ── Highlight pulse on first match ── */
@keyframes highlight-pulse {
  0%   { outline-color: var(--accent); filter: drop-shadow(0 0 0px  rgba(91,155,213,0)); }
  30%  { outline-color: var(--accent); filter: drop-shadow(0 0 16px rgba(91,155,213,1)); }
  100% { outline-color: var(--accent); filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5)); }
}

.game-box.highlighted {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  animation: highlight-pulse 0.9s ease forwards;
  animation-iteration-count: 2;
  z-index: 10;
}

/* ── Kallax outer frame ── */
.kallax-frame {
  margin: 40px auto 60px;
  width: min(1480px, calc(100vw - 32px));
  padding: var(--frame-w);
  background:
    repeating-linear-gradient(
      91deg,
      transparent 0px, transparent 80px,
      rgba(0,0,0,0.04) 80px, rgba(0,0,0,0.04) 82px
    ),
    repeating-linear-gradient(
      180deg,
      transparent 0px, transparent 12px,
      rgba(255,255,255,0.03) 12px, rgba(255,255,255,0.03) 13px
    ),
    linear-gradient(175deg,
      var(--wood-light) 0%,
      var(--wood-mid) 30%,
      #3a4a60 55%,
      var(--wood-mid) 75%,
      var(--wood-light) 100%
    );
  border: 4px solid var(--wood-dark);
  border-radius: 3px;
  overflow: hidden;
  box-shadow:
    inset 6px 0 18px rgba(0,0,0,0.3),
    inset -6px 0 18px rgba(0,0,0,0.3),
    inset 0 6px 14px rgba(0,0,0,0.25),
    inset 0 -6px 14px rgba(0,0,0,0.25),
    0 16px 60px rgba(0,0,0,0.7);
}

/* ── Shelf (flat flex-wrap — no JS row packing) ── */
#shelf {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  align-content: flex-start;
  column-gap: var(--gap);
  row-gap: 0;
  padding: 0 8px;
  width: 100%;
  box-sizing: border-box;
  /* Draw a shelf plank under every row of games */
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent var(--box-h),
    var(--shelf-bg) var(--box-h),
    var(--shelf-bg) calc(var(--shelf-height) - 5px),
    var(--wood-dark) calc(var(--shelf-height) - 5px),
    var(--wood-dark) var(--shelf-height)
  );
  /* Each row of games occupies exactly --shelf-height px */
  background-size: 100% var(--shelf-height);
  background-repeat: repeat-y;
}

/* ── Game box — width is natural (image-driven), height is fixed ── */
.game-box {
  position: relative;
  height: var(--box-h);
  width: max-content;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));
  /* Sit on the shelf plank: margin fills the plank area below each box */
  margin-bottom: var(--shelf-plank);
}

/* Image sits directly in the box — height locked to row height, width follows naturally */
.game-box > img {
  height: var(--box-h);
  width: auto;
  display: block;
  border-radius: 2px;
  flex-shrink: 0;
}

.game-box:hover {
  transform: translateY(-10px);
  filter: drop-shadow(2px 14px 12px rgba(0,0,0,0.8));
  z-index: 10;
}

/* ── Expansion bottom badge ── */
.exp-ribbon-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 5;
}

.exp-ribbon {
  display: block;
  width: 100%;
  background: rgba(13, 17, 23, 0.72);
  border-top: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.58rem;
  font-weight: 600;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 3px 0 4px;
  backdrop-filter: blur(2px);
}

/* ── No image fallback ── */
.game-box-placeholder {
  width: 90px;
  height: 100%;
  background: linear-gradient(160deg, #1e2535, #131824);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

.game-box-placeholder span {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
  word-break: break-word;
}

/* ══════════════════════════════════════════════════════════════
   LIGHTBOX
══════════════════════════════════════════════════════════════ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden { display: none; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

/* ── Scene wrapper: owns perspective + opacity fade-in ──
   Keeping opacity animation HERE (not on .lightbox-box) is critical:
   opacity < 1 on a preserve-3d element flattens all children to 2D. */
.lightbox-scene {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 900px;
  perspective-origin: center center;
  opacity: 0;
  z-index: 1;
}

.lightbox-scene.scene-animating {
  animation: scene-fade 0.18s ease-out forwards;
}

.lightbox-scene.scene-shown {
  opacity: 1;
}

@keyframes scene-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox-scene.scene-closing {
  animation: scene-fade-out 0.35s ease-in forwards;
}

@keyframes scene-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   TRUE 3D BOX  —  translateZ technique
   Each face: rotate to orient, then translateZ(halfExtent) to place it.
   Side faces are centred in the container before rotation so that
   translateZ moves them exactly to the correct edge.

   Box: --_w × --_h face, --_d deep (≈ a mid-weight board game box).
══════════════════════════════════════════════════════════════ */
.lightbox-box {
  --_w: min(940px, 95vw);
  --_h: min(800px, 90vh);
  --_d: 80px;

  position: relative;
  width:  var(--_w);
  height: var(--_h);
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
  /* NO opacity, NO will-change, NO filter here — any of those on a
     preserve-3d element creates a stacking context that flattens the 3D */
}

/* All six faces */
.box-face {
  position: absolute;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ── Front face — box art ── */
.box-face-front {
  width:  var(--_w);
  height: var(--_h);
  top: 0; left: 0;
  transform: translateZ(calc(var(--_d) / 2));
  background: #080c12;
  border: 1px solid #2d3748;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.box-face-front img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Back face — info panel ──
   rotateY(180deg) flips it to face backward; translateZ(d/2) places
   it at the back edge so it lines up with the depth sides. */
.box-face-back {
  width:  var(--_w);
  height: var(--_h);
  top: 0; left: 0;
  transform: rotateY(180deg) translateZ(calc(var(--_d) / 2));
  background: var(--lb-panel);
  border: 1px solid #2d3748;
  border-radius: 6px;
  overflow: hidden;
}

/* Inner scroll wrapper — keeps overflow off the 3D-transformed element */
.lb-back-scroll {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 44px 20px 20px;
  box-sizing: border-box;
}

/* ── 2-column main content area ── */
.lb-main-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Left column: box art image + stat badges stacked below */
.lb-image-col {
  flex: 0 0 180px;
  width: 180px;
}

.lb-box-image {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  border: 1px solid #2d3748;
  margin-bottom: 12px;
}

/* Right column: title, credits, description */
.lb-info-col {
  flex: 1;
  min-width: 0;
}

/* Make stats 1-col in the narrow left column */
.lb-image-col .lb-stats {
  grid-template-columns: 1fr 1fr;
  margin-top: 0;
}

.lb-image-col .lb-stat {
  padding: 8px 5px;
}

.lb-image-col .lb-stat-value {
  font-size: 0.95rem;
}

.lb-image-col .lb-stat-icon {
  font-size: 1rem;
}

/* ── Right face ──
   Centre the panel (width = _d) in the container so its midpoint is
   at _w/2. After rotateY(90°) + translateZ(_w/2) it lands at x = _w.
   Background is overridden dynamically by JS to match the box art. */
.box-face-right {
  width:  var(--_d);
  height: var(--_h);
  top: 0;
  left: calc((var(--_w) - var(--_d)) / 2);
  transform: rotateY(90deg) translateZ(calc(var(--_w) / 2));
  background: #0d1018; /* JS fallback */
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Left face — mirror of right ── */
.box-face-left {
  width:  var(--_d);
  height: var(--_h);
  top: 0;
  left: calc((var(--_w) - var(--_d)) / 2);
  transform: rotateY(-90deg) translateZ(calc(var(--_w) / 2));
  background: #0d1018;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Top face ── */
.box-face-top {
  width:  var(--_w);
  height: var(--_d);
  left: 0;
  top: calc((var(--_h) - var(--_d)) / 2);
  transform: rotateX(-90deg) translateZ(calc(var(--_h) / 2));
  background: #0d1018;
  border: 1px solid rgba(255,255,255,0.05);
}

/* ── Bottom face ── */
.box-face-bottom {
  width:  var(--_w);
  height: var(--_d);
  left: 0;
  top: calc((var(--_h) - var(--_d)) / 2);
  transform: rotateX(90deg) translateZ(calc(var(--_h) / 2));
  background: #0d1018;
  border: 1px solid rgba(255,255,255,0.05);
}

/* ── Spine text (game name along the side faces) ── */
.spine-text {
  position: absolute;
  /* width = face height so the rotated text spans the full length */
  width: calc(var(--_h) - 24px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Special Gothic Condensed One', sans-serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.88);
  text-shadow: 0 1px 5px rgba(0,0,0,0.7);
  pointer-events: none;
  user-select: none;
}

.box-face-right .spine-text { transform: rotate(90deg); }
.box-face-left  .spine-text { transform: rotate(-90deg); }

/* ── Fly-in + 3D flip animation ──
   Phase 1 (0-27%):  box rockets in from the shelf at an angle — depth
                     sides visible as it arrives.
   Phase 2 (27-44%): slight overshoot then starts sweeping around.
   Phase 3 (44-100%): full 180° rotation, right-side face prominent at ~55°. */
/* Box fly+flip is driven entirely by the Web Animations API in main.js so that
   the starting position can be computed from the clicked shelf box at runtime.
   .box-shown is the only CSS state needed — it holds the final resting position. */

.lightbox-box.box-shown {
  transform: rotateY(-180deg);
}

/* ── Close button ── */
.lightbox-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
  padding: 4px 6px;
  z-index: 2;
}
.lightbox-close:hover { color: var(--text); }

/* ── Back face content ── */
.lb-info-col h2 {
  font-size: 1.35rem;
  color: var(--accent);
  line-height: 1.2;
  font-family: 'Special Gothic Condensed One', sans-serif;
  margin-bottom: 6px;
  padding-right: 28px; /* clear the × button */
}

.lb-bgg-link {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid #2d3748;
  border-radius: 5px;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.lb-bgg-link:hover { color: var(--accent); border-color: var(--accent); }
.lb-bgg-link.hidden { display: none; }

/* ── Stat blocks ── */
.lb-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.lb-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-radius: 8px;
  border-top: 3px solid;
  gap: 2px;
  width: 100%;
}

.lb-stat-icon {
  font-size: 1.3rem;
  line-height: 1;
  margin-bottom: 2px;
}

.lb-stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.lb-stat-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

.lb-stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
  margin-top: 3px;
  white-space: nowrap;
}

.lb-stat.rating     { background: #1e3a1e; border-color: #7ecf7e; color: #7ecf7e; }
.lb-stat.players    { background: #172333; border-color: #7eb8e8; color: #7eb8e8; }
.lb-stat.complexity { background: #3a1e1e; border-color: #e87e7e; color: #e87e7e; }
.lb-stat.time       { background: #1e2e1e; border-color: #a8d4a8; color: #a8d4a8; }
.lb-stat.age        { background: #2e2614; border-color: #d4c080; color: #d4c080; }
.lb-stat.rank       { background: #1e1630; border-color: #b090e8; color: #b090e8; }

/* ── Sections ── */
.lb-section {
  border-top: 1px solid #2d3748;
  padding: 18px 0;
}

.lb-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.lb-credits {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-credit-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.lb-credit-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 72px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lb-credit-value {
  font-size: 0.95rem;
  color: var(--text);
}

.lb-desc {
  font-size: 0.9rem;
  line-height: 1.65;
  color: #c8bfb0;
}

/* ── Expansion list ── */
.lb-expansions {
  border-top: 1px solid #2d3748;
  padding: 18px 0 0;
}

.lb-expansions.hidden { display: none; }

.lb-expansions ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.exp-thumb-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  width: 100%;
}

.exp-thumb-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 3px;
  filter: drop-shadow(1px 2px 4px rgba(0,0,0,0.5));
  transition: transform 0.18s ease, filter 0.18s ease;
  background: #1a2030;
}

.exp-thumb-card:hover .exp-thumb-img {
  transform: translateY(-5px);
  filter: drop-shadow(1px 8px 10px rgba(0,0,0,0.8));
}

.exp-thumb-name {
  font-size: 0.63rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.25;
  padding: 0 2px;
}

/* ── Mechanics & Categories tags ── */
.lb-tags-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.lb-tag-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lb-tag-row.hidden { display: none; }

.lb-tag-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.lb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lb-tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: nowrap;
}

.lb-tag--category {
  background: rgba(91,155,213,0.12);
  color: var(--accent);
  border: 1px solid rgba(91,155,213,0.28);
}

.lb-tag--mechanic {
  background: #1e2535;
  color: var(--text-muted);
  border: 1px solid #2d3748;
}

/* ── Similar Games ── */
.lb-similar-section {
  border-top: 1px solid #2d3748;
  padding: 18px 0 4px;
}
.lb-similar-section.hidden { display: none; }

.lb-similar-games {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

/* Games you own — accent pill, opens inline */
.similar-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.similar-chip--owned {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91,155,213,0.25);
}
.similar-chip--owned:hover {
  background: #4a8ac4;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(91,155,213,0.4);
}

/* Games not in collection — muted pill, opens BGG */
.similar-chip--external {
  background: #1e2535;
  color: var(--text-muted);
  border: 1px solid #2d3748;
}
.similar-chip--external:hover {
  color: var(--text);
  border-color: #4a5568;
  background: #252d3f;
}

/* Divider between owned and not-owned chips */
.similar-divider {
  width: 1px;
  height: 24px;
  background: #2d3748;
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Expansion slide-in lightbox ── */
.exp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.exp-lightbox.hidden { display: none; }

.exp-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.exp-lightbox-panel {
  position: relative;
  background: var(--lb-panel);
  border: 1px solid #2d3748;
  border-radius: 14px;
  width: min(940px, 95vw);
  height: min(800px, 90vh);
  overflow-y: auto;
  padding: 60px 36px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.95);
  transform: translateX(110%);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.exp-lightbox-panel.open {
  transform: translateX(0);
}

.exp-lightbox-back {
  position: absolute;
  top: 16px;
  left: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
  padding: 4px 6px;
  letter-spacing: 0.02em;
}
.exp-lightbox-back:hover { color: var(--accent); }

.exp-lightbox-close {
  position: absolute;
  top: 14px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
  padding: 4px 6px;
}
.exp-lightbox-close:hover { color: var(--text); }

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 0 16px;
}

.filter-bar select {
  appearance: none;
  -webkit-appearance: none;
  background: #13161e;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238090a8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid var(--wood-dark);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 9px 30px 9px 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-bar select:hover,
.filter-bar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91,155,213,0.18);
}

.filter-bar select.filter-active {
  border-color: var(--accent);
  color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235b9bd5' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.filter-sep {
  width: 1px;
  height: 28px;
  background: var(--wood-dark);
  flex-shrink: 0;
}

.filter-clear {
  appearance: none;
  background: none;
  border: 1px solid #2d4060;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 9px 14px;
  transition: border-color 0.2s, color 0.2s;
}
.filter-clear:hover { border-color: var(--accent); color: var(--accent); }
.filter-clear.hidden { display: none; }

.filter-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  min-height: 1.1em;
}

/* ── Tutorial buttons (lightbox left column) ── */
.lb-tutorials-wrap {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 14px;
  width: 100%;
}
.lb-tutorial-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: #13161e;
  border: 1px solid #2d3748;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  width: 100%;
  box-sizing: border-box;
}
.lb-tutorial-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: #1a2035;
}
.lb-tutorial-btn img {
  height: 20px;
  width: auto;
  flex-shrink: 0;
  border-radius: 3px;
}

/* ── Has Tutorial filter button ── */
.filter-wip-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  appearance: none;
  background: #13161e;
  border: 1px solid var(--wood-dark);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 8px 13px;
  outline: none;
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.filter-wip-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.filter-wip-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(91,155,213,0.18);
}
.filter-wip-btn.filter-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(91,155,213,0.08);
}
.filter-wip-btn.filter-active svg { opacity: 1; }

/* ── Scrollbar styling ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a4a5a; border-radius: 3px; }

/* ── Loading state ── */
#shelf.loading::after {
  content: 'Loading your collection...';
  display: block;
  text-align: center;
  color: var(--text-muted);
  padding: 60px;
  font-size: 1.1rem;
}

@media (max-width: 700px) {
  :root { --box-h: 120px; --frame-w: 14px; }
  .kallax-frame { margin: 16px auto 40px; }
  .lb-stat { padding: 10px 8px; }
  .lb-stat-value { font-size: 1rem; }
  .exp-lightbox-panel { padding: 52px 18px 24px; }
  .filter-bar { gap: 6px; }
  .filter-bar select { font-size: 0.8rem; padding: 8px 26px 8px 10px; height: auto; }
  .filter-sep { display: none; }

  /* ── Mobile header ── */
  header { padding: 8px 14px 0; }
  .header-top { gap: 10px; }

  /* Title + subtitle */
  header h1 { font-size: 2.2rem; }
  .site-subtitle { font-size: 0.62rem; letter-spacing: 0.06em; }

  /* Flip counter — shrink digits so the title has room */
  .flip-counter { gap: 5px; }
  .flip-counter-wrap { gap: 3px; }
  .flip-counter-label { font-size: 0.55rem; letter-spacing: 0.08em; }
  .expansion-count-label { font-size: 0.7rem; }

  .flip-digit { width: 50px; height: 72px; border-radius: 5px; }
  .fd-upper  { height: 36px; border-radius: 5px 5px 0 0; }
  .fd-lower  { height: 36px; border-radius: 0 0 5px 5px; }
  .fd-static-u, .fd-flap-u { height: 36px; }
  .fd-static-l, .fd-flap-l { height: 36px; }
  .fd-static-u .fd-num, .fd-flap-u .fd-num { height: 72px; font-size: 3rem; }
  .fd-static-l .fd-num, .fd-flap-l .fd-num { height: 72px; font-size: 3rem; }

  /* Game Nights button — compact */
  .game-nights-link { padding: 8px 12px; font-size: 0.82rem; gap: 5px; }

  /* Controls row: search fills its own line, filters scroll horizontally below */
  .header-controls { gap: 6px; padding-bottom: 8px; }
  .header-controls .search-wrap { flex: 1 1 100%; }
  .header-controls #game-search { width: 100%; height: auto; padding: 10px 14px; font-size: 0.9rem; }
  .header-controls .filter-bar {
    flex: 1 1 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; /* room for scroll shadow */
  }
  .header-controls .filter-bar::-webkit-scrollbar { display: none; }
  .header-controls .filter-bar select,
  .header-controls .filter-wip-btn,
  .header-controls .filter-clear { height: auto; flex-shrink: 0; }
}

@media (max-width: 480px) {
  /* Even smaller digits on phones in portrait */
  .flip-digit { width: 40px; height: 58px; }
  .fd-upper  { height: 29px; }
  .fd-lower  { height: 29px; }
  .fd-static-u, .fd-flap-u { height: 29px; }
  .fd-static-l, .fd-flap-l { height: 29px; }
  .fd-static-u .fd-num, .fd-flap-u .fd-num { height: 58px; font-size: 2.4rem; }
  .fd-static-l .fd-num, .fd-flap-l .fd-num { height: 58px; font-size: 2.4rem; }
  .game-nights-link { padding: 7px 10px; font-size: 0.76rem; }
  .expansion-count-label { display: none; } /* save vertical space on small phones */
}

@media (max-width: 520px) {
  :root { --box-h: 90px; --frame-w: 10px; }
  .lightbox-box { --_d: 54px; }
  .lb-main-content { flex-direction: column; }
  .lb-image-col { flex: none; width: 100%; }
  .lb-box-image { max-height: 160px; object-fit: cover; }
}
