/* hide source table immediately */
#sourceTable, table { display: none !important; }

/* Basic reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; font-family: 'Dancing Script', cursive; }

/* Grid wrapper centers the grid using flexbox (avoid translate transforms so pinch-zoom works) */
.grid-wrap {
  position: absolute;
  inset: 0;                       /* fill viewport and let flex center */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #f6f7f9;
  overflow: auto;                 /* allow scroll / pinch interactions */
  z-index: 100;                   /* base z-index */
  -webkit-overflow-scrolling: touch;
}

/* The square grid — size is responsive (vmin) and keeps 1:1 aspect ratio */
.grid {
  display: grid;
  background: #fff;
  gap: 0;
  border-radius: 6px;
  overflow: visible;
  box-shadow: 0 6px 28px rgba(0,0,0,0.08);
  transform-origin: center center;

  /* Responsive sizing: uses viewport-relative units so the grid scales naturally */
  width: min(92vmin, calc(100vw - 40px));
  max-width: 1400px;
  aspect-ratio: 1 / 1; /* maintain square */
}

/* Each cell corresponds to a patch */
.cell {
  border: 0.5px solid rgba(0,0,0,0.06);
  position: relative;
  overflow: visible;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  will-change: transform;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* protect link from interference */
.cell > a {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

/* image inside cell */
.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 2px;
}

/* hover scale (still OK on desktop) */
.cell:hover {
  transform: scale(1.06);
  z-index: 50;
  box-shadow: 0 14px 40px rgba(0,0,0,0.22);
}

.patch-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transform-origin: left top;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.cell:hover .patch-badge { opacity: 1; transform: translateY(0); }

@media (hover: none) { .patch-badge { opacity: 0; } }

.patch-placeholder {
  font-weight: 700;
  font-size: calc(10px + 0.8vmin);
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell.disabled {
  pointer-events: none;
  opacity: 0.3;
}

/* Import Dancing Script font */
@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@500;700&display=swap');

/* Category filter wrapper */
#filterContainer {
  position: fixed;
  left: 18px;
  top: 110px;   /* below logo */
  z-index: 9999;
  pointer-events: auto;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Dancing Script', cursive; /* label font */
  font-size: 18px; /* adjust label size */
  font-weight: 500;
  color: #111; /* label color */
}

/* Label styling */
#filterContainer label {
  font-family: 'Dancing Script', cursive;
  font-size: 18px;
  font-weight: 500;
  color: #111;
  cursor: pointer;
}

/* Hide default arrow and style select */
#filterContainer select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  border-bottom: 0.5px solid #333; /* underline */
  background: transparent;
  padding: 4px 24px 4px 0;       /* space for arrow */
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  color: #111;
  outline: none;
  width: 220px;                  /* adjust width for longer underline */
  font-family: 'Dancing Script', cursive; /* custom font */
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Hover effect: soft 4-sided shadow */
/* Hover effect for category dropdown */
#filterContainer select:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 6px;       /* rounded corners on hover */
  border-bottom: 0.5px solid #333; /* keep your updated underline width */
}


/* Down arrow via pseudo-element on container */
#filterContainer::after {
  content: '▼';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 12px;
  color: #555;
}

/* Dropdown options font */
#filterContainer select option {
  font-family: 'Dancing Script', cursive;
  font-size: 15px;
  color: #111;
}


#categoryFilter {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  border-bottom: 1px solid #333; /* underline style */
  background: transparent;
  padding: 4px 20px 4px 0;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  color: #111;
  outline: none;
  position: relative;
}

/* Down arrow using pseudo-element */
#categoryFilter::after {
  content: '▼';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 12px;
  color: #555;
}

/* Hover effect */
#categoryFilter:hover {
  border-color: #555;
}

/* Left Ad - fixed position to the left until the grid starts */
#leftAd {
  position: fixed;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 120px; /* adjust ad width */
  text-align: center;
  z-index: 999;
  background: #f0f0f0;
  padding: 8px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* Top Ad - below dropdown */
#topAd {
  position: fixed;
  left: 260px; /* adjust to align with dropdown */
  top: 150px;  /* slightly below dropdown */
  width: 200px; /* ad width */
  text-align: center;
  background: #f0f0f0;
  padding: 6px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 999;
}


/* Responsive grid sizing handled by CSS using vmin + aspect-ratio */
