tilegrid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0;
  align-items: flex-start;
}

tile {
  display: block;
  position: relative;
  box-sizing: border-box;
  flex: 0 0 auto;
  overflow: hidden;
  transition: transform 0.2s ease;
}

tile:hover {
  transform: scale(1.075);
  z-index: 5;
}

tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

tile img.tileflag {
  position: absolute !important;
  inset: auto !important;
  top: 0px !important;
  right: 0px !important;
  width: 25% !important;
  height: auto !important;
  object-fit: contain !important;
  z-index: auto !important;
}

tile img.tileflag.topright { top: 0px !important; right: 0px !important; }
tile img.tileflag.topleft { top: 0px !important; left: 0px !important; }
tile img.tileflag.bottomright { bottom: 0px !important; right: 0px !important; }
tile img.tileflag.bottomleft { bottom: 0px !important; left: 0px !important; }
tile img.tileflag.topcenter { top: 0px !important; left: 50% !important; transform: translateX(-50%); }
tile img.tileflag.bottomcenter { bottom: 0px !important; left: 50% !important; transform: translateX(-50%); }
tile img.tileflag.middleleft { left: 0px !important; top: 50% !important; transform: translateY(-50%); }
tile img.tileflag.middleright { right: 0px !important; top: 50% !important; transform: translateY(-50%); }
tile img.tileflag.small  { width: 15% !important; }
tile img.tileflag.medium { width: 25% !important; }
tile img.tileflag.large  { width: 40% !important; }

tiletext {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 10;
  font-weight: 600; 
  padding: 0px;
  box-sizing: border-box;
  pointer-events: none;
  text-align: center;
  white-space: normal;      /* allow wrapping */
  line-height: 1;           /* tighter lines */
  word-wrap: break-word;    /* prevent overflow */
}


tilestack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-sizing: border-box;
  flex: 0 0 auto;
  position: relative;
}

tilestack > tile {
  flex: 1 1 0;
  height: auto !important;
}